This adds ComplexColor to many of the color properties that are available in charts. It also handles some import code in oox, so the complex colors are set correctly to the chart elements if an OOXML document is loaded. This doesn't yet handle export and if a theme is changed, as well if a color is changed manually in the chart. Change the tests so they now assert the scheme color like it is defined in the source document and not the calculated derived color. In addition change the WriteRunProperties to have a struct as an input instead a number of parameters, which in most cases don't need to be filled out and are using the default value. This was needed for the new parameter bUseTextSchemeColors, which is used for charts, so the text colors use tx1 and tx2 elements instead dk1 and dk2, which are usually used in Impress. Change-Id: Iaebbaea983c5232c51233c1a02bd8fe1da24d551 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194939 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
206 lines
9.4 KiB
C++
206 lines
9.4 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
|
|
#include <FillProperties.hxx>
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
|
#include <com/sun/star/drawing/BitmapMode.hpp>
|
|
#include <com/sun/star/drawing/FillStyle.hpp>
|
|
#include <com/sun/star/drawing/RectanglePoint.hpp>
|
|
#include <com/sun/star/util/XComplexColor.hpp>
|
|
|
|
#include <tools/color.hxx>
|
|
|
|
using namespace css;
|
|
namespace chart
|
|
{
|
|
|
|
namespace
|
|
{
|
|
|
|
void lcl_AddPropertiesToVector_without_BitmapProperties( std::vector<beans::Property> & rOutProperties )
|
|
{
|
|
rOutProperties.emplace_back( "FillStyle",
|
|
FillProperties::PROP_FILL_STYLE,
|
|
cppu::UnoType<drawing::FillStyle>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillColor",
|
|
FillProperties::PROP_FILL_COLOR,
|
|
cppu::UnoType<sal_Int32>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEVOID // "maybe auto"
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back("FillComplexColor",
|
|
FillProperties::PROP_FILL_COMPLEX_COLOR,
|
|
cppu::UnoType<util::XComplexColor>::get(),
|
|
beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillTransparence",
|
|
FillProperties::PROP_FILL_TRANSPARENCE,
|
|
cppu::UnoType<sal_Int16>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillTransparenceGradientName",
|
|
FillProperties::PROP_FILL_TRANSPARENCE_GRADIENT_NAME,
|
|
cppu::UnoType<OUString>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEVOID
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillGradientName",
|
|
FillProperties::PROP_FILL_GRADIENT_NAME,
|
|
cppu::UnoType<OUString>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEVOID
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillGradientStepCount",
|
|
FillProperties::PROP_FILL_GRADIENT_STEPCOUNT,
|
|
cppu::UnoType<sal_Int16>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEVOID );
|
|
|
|
rOutProperties.emplace_back( "FillHatchName",
|
|
FillProperties::PROP_FILL_HATCH_NAME,
|
|
cppu::UnoType<OUString>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEVOID
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
//bitmap properties see lcl_AddPropertiesToVector_only_BitmapProperties()
|
|
|
|
rOutProperties.emplace_back( "FillBackground",
|
|
FillProperties::PROP_FILL_BACKGROUND,
|
|
cppu::UnoType<sal_Bool>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
}
|
|
|
|
void lcl_AddPropertiesToVector_only_BitmapProperties(std::vector<beans::Property> & rOutProperties)
|
|
{
|
|
rOutProperties.emplace_back( "FillBitmapName",
|
|
FillProperties::PROP_FILL_BITMAP_NAME,
|
|
cppu::UnoType<OUString>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEVOID
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapOffsetX",
|
|
FillProperties::PROP_FILL_BITMAP_OFFSETX,
|
|
cppu::UnoType<sal_Int16>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapOffsetY",
|
|
FillProperties::PROP_FILL_BITMAP_OFFSETY,
|
|
cppu::UnoType<sal_Int16>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapPositionOffsetX",
|
|
FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX,
|
|
cppu::UnoType<sal_Int16>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapPositionOffsetY",
|
|
FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY,
|
|
cppu::UnoType<sal_Int16>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapRectanglePoint",
|
|
FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT,
|
|
cppu::UnoType<drawing::RectanglePoint>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapLogicalSize",
|
|
FillProperties::PROP_FILL_BITMAP_LOGICALSIZE,
|
|
cppu::UnoType<sal_Bool>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapSizeX",
|
|
FillProperties::PROP_FILL_BITMAP_SIZEX,
|
|
cppu::UnoType<sal_Int32>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapSizeY",
|
|
FillProperties::PROP_FILL_BITMAP_SIZEY,
|
|
cppu::UnoType<sal_Int32>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
|
|
rOutProperties.emplace_back( "FillBitmapMode",
|
|
FillProperties::PROP_FILL_BITMAP_MODE,
|
|
cppu::UnoType<drawing::BitmapMode>::get(),
|
|
beans::PropertyAttribute::BOUND
|
|
| beans::PropertyAttribute::MAYBEDEFAULT );
|
|
}
|
|
|
|
void lcl_AddDefaultsToMap_without_BitmapProperties(
|
|
::chart::tPropertyValueMap & rOutMap )
|
|
{
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_STYLE, drawing::FillStyle_SOLID );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_COLOR, Color(0xd9, 0xd9, 0xd9) ); // gray85
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_TRANSPARENCE, sal_Int16(0) );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BACKGROUND, false );
|
|
}
|
|
|
|
void lcl_AddDefaultsToMap_only_BitmapProperties(
|
|
::chart::tPropertyValueMap & rOutMap )
|
|
{
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETX, sal_Int16(0) );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_OFFSETY, sal_Int16(0) );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETX, sal_Int16(0) );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_POSITION_OFFSETY, sal_Int16(0) );
|
|
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_RECTANGLEPOINT, drawing::RectanglePoint_MIDDLE_MIDDLE );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_LOGICALSIZE, true );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEX, sal_Int32(0) );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_SIZEY, sal_Int32(0) );
|
|
::chart::PropertyHelper::setPropertyValueDefault( rOutMap, FillProperties::PROP_FILL_BITMAP_MODE, drawing::BitmapMode_REPEAT );
|
|
}
|
|
|
|
}//end anonymous namespace
|
|
|
|
void FillProperties::AddPropertiesToVector(
|
|
std::vector<beans::Property> & rOutProperties )
|
|
{
|
|
// Fill Properties see service drawing::FillProperties
|
|
lcl_AddPropertiesToVector_without_BitmapProperties( rOutProperties );
|
|
lcl_AddPropertiesToVector_only_BitmapProperties( rOutProperties );
|
|
}
|
|
|
|
void FillProperties::AddDefaultsToMap(
|
|
::chart::tPropertyValueMap & rOutMap )
|
|
{
|
|
lcl_AddDefaultsToMap_without_BitmapProperties( rOutMap );
|
|
lcl_AddDefaultsToMap_only_BitmapProperties( rOutMap );
|
|
}
|
|
|
|
} // namespace chart
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|