sw: support for reading back theme color from OOXML

OOXML supports theme colors and tint/shade value that additionally
changed the theme color. Read back which theme color + tint/shade
value was applied in the resulting color and add this attributes
as properties to be used by writer.
In sidebar theme panel the changing the theme colors now doesn't
takes this into account and changes the colors correctly.

Change-Id: I3a2d49d485fd37a1611483ee0bb5e6034ac5f88e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143697
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Tomaž Vajngerl
2022-12-25 02:06:58 +00:00
committed by Tomaž Vajngerl
parent 376152fbd1
commit df9f3f3fd8
19 changed files with 254 additions and 30 deletions
+2
View File
@@ -21,6 +21,8 @@
#include <rtl/ustring.hxx>
inline constexpr OUStringLiteral UNO_NAME_CHAR_COLOR = u"CharColor";
inline constexpr OUStringLiteral UNO_NAME_CHAR_COLOR_THEME = u"CharColorTheme";
inline constexpr OUStringLiteral UNO_NAME_CHAR_COLOR_TINT_OR_SHADE = u"CharColorTintOrShade";
inline constexpr OUStringLiteral UNO_NAME_CHAR_HEIGHT = u"CharHeight";
inline constexpr OUStringLiteral UNO_NAME_CHAR_POSTURE = u"CharPosture";
inline constexpr OUStringLiteral UNO_NAME_CHAR_SHADOWED = u"CharShadowed";
+62
View File
@@ -0,0 +1,62 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#*************************************************************************
#
# 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/.
#
#*************************************************************************
$(eval $(call gb_CppunitTest_CppunitTest,sw_core_theme))
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_theme))
$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_theme, \
sw/qa/core/theme/ThemeTest \
))
$(eval $(call gb_CppunitTest_use_libraries,sw_core_theme, \
comphelper \
cppu \
cppuhelper \
sal \
sfx \
subsequenttest \
sw \
swqahelper \
test \
unotest \
utl \
vcl \
svt \
tl \
svl \
svxcore \
))
$(eval $(call gb_CppunitTest_use_externals,sw_core_theme,\
boost_headers \
libxml2 \
))
$(eval $(call gb_CppunitTest_set_include,sw_core_theme,\
-I$(SRCDIR)/sw/inc \
-I$(SRCDIR)/sw/source/core/inc \
-I$(SRCDIR)/sw/source/uibase/inc \
-I$(SRCDIR)/sw/qa/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_api,sw_core_theme,\
udkapi \
offapi \
))
$(eval $(call gb_CppunitTest_use_ure,sw_core_theme))
$(eval $(call gb_CppunitTest_use_vcl,sw_core_theme))
$(eval $(call gb_CppunitTest_use_rdb,sw_core_theme,services))
$(eval $(call gb_CppunitTest_use_configuration,sw_core_theme))
# vim: set noet sw=4 ts=4:
+1
View File
@@ -154,6 +154,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_filter_ww8 \
CppunitTest_sw_filter_html \
CppunitTest_sw_a11y \
CppunitTest_sw_core_theme \
))
ifneq ($(DISABLE_GUI),TRUE)
+35
View File
@@ -0,0 +1,35 @@
/* -*- 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/.
*/
#include <swmodeltestbase.hxx>
#include <memory>
#include <docsh.hxx>
class SwCoreThemeTest : public SwModelTestBase
{
public:
SwCoreThemeTest()
: SwModelTestBase("/sw/qa/core/theme/data/")
{
}
};
CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testThemeColorInHeading)
{
createSwDoc("ThemeColorInHeading.docx");
SwDoc* pDoc = getSwDoc();
CPPUNIT_ASSERT(pDoc);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4), getProperty<sal_Int16>(getParagraph(1), "CharColorTheme"));
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Binary file not shown.
+3 -1
View File
@@ -1437,7 +1437,9 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetPropertyM
// SvxAdjustItem
{ UNO_NAME_PARA_ADJUST, RES_PARATR_ADJUST, cppu::UnoType<sal_Int16>::get(),PropertyAttribute::MAYBEVOID, MID_PARA_ADJUST },
// SvxColorItem
{ UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0 },
{ UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0 },
{ UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX },
{ UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE },
// SvxShadowedItem
{ UNO_NAME_CHAR_SHADOWED, RES_CHRATR_SHADOWED, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0 },
// SvxContouredItem
+5 -1
View File
@@ -178,7 +178,9 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetCharStyle
{ UNO_NAME_CHAR_BACK_COLOR, RES_CHRATR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE ,MID_BACK_COLOR },
{ UNO_NAME_CHAR_HIGHLIGHT, RES_CHRATR_HIGHLIGHT, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, MID_BACK_COLOR },
{ UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0},
{ UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
{ UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0 },
{ UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX },
{ UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE },
{ UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA},
{ UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT},
{ UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
@@ -241,6 +243,8 @@ o3tl::span<const SfxItemPropertyMapEntry> SwUnoPropertyMapProvider::GetAutoChar
{ UNO_NAME_CHAR_HIGHLIGHT, RES_CHRATR_HIGHLIGHT, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, MID_BACK_COLOR },
{ UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0},
{ UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},
{ UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX },
{ UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE },
{ UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA},
{ UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT},
{ UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},
@@ -125,6 +125,8 @@
{ UNO_NAME_PARA_BACK_COLOR, RES_BACKGROUND, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::MAYBEVOID, MID_BACK_COLOR }, \
{ UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, 0 }, \
{ UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::MAYBEVOID, 0 }, \
{ UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_COLOR_THEME_INDEX }, \
{ UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_COLOR_TINT_OR_SHADE }, \
{ UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_COLOR_ALPHA }, \
{ UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT }, \
{ UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<bool>::get(), PropertyAttribute::MAYBEVOID, MID_CROSSED_OUT }, \
@@ -369,6 +371,8 @@
{ UNO_NAME_PARA_GRAPHIC_LOCATION, RES_BACKGROUND, cppu::UnoType<css::style::GraphicLocation>::get(), PROPERTY_NONE ,MID_GRAPHIC_POSITION}, \
{ UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0},\
{ UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},\
{ UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX }, \
{ UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE }, \
{ UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA},\
{ UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT},\
{ UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},\
@@ -479,6 +483,8 @@
#define COMMON_ACCESSIBILITY_TEXT_ATTRIBUTE \
{ UNO_NAME_CHAR_BACK_COLOR, RES_CHRATR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE ,MID_BACK_COLOR }, \
{ UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, \
{ UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX }, \
{ UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE }, \
{ UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA }, \
{ UNO_NAME_CHAR_CONTOURED, RES_CHRATR_CONTOUR, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, \
{ UNO_NAME_CHAR_EMPHASIS, RES_CHRATR_EMPHASIS_MARK, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_EMPHASIS}, \
+9 -20
View File
@@ -75,21 +75,6 @@ public:
{
maVariable = aVariable;
}
Color getColor(svx::ColorSet const & rColorSet)
{
Color aColor;
if (maVariable.mnIndex > -1)
{
aColor = rColorSet.getColor(maVariable.mnIndex);
aColor.ApplyTintOrShade(maVariable.mnTintShade);
}
else
{
aColor = COL_BLACK;
}
return aColor;
}
};
class StyleSet
@@ -229,13 +214,17 @@ void changeFont(SwFormat* pFormat, SwDocStyleSheet const * pStyle, FontSet const
}
}*/
void changeColor(SwTextFormatColl* pCollection, svx::ColorSet const & rColorSet, StyleRedefinition* pRedefinition)
void changeColor(SwTextFormatColl* pCollection, svx::ColorSet const& rColorSet, StyleRedefinition* /*pRedefinition*/)
{
Color aColor = pRedefinition->getColor(rColorSet);
SvxColorItem aColorItem(pCollection->GetColor());
aColorItem.SetValue(aColor);
pCollection->SetFormatAttr(aColorItem);
auto nThemeIndex = aColorItem.GetThemeColor().GetThemeIndex();
if (nThemeIndex >= 0)
{
Color aColor = rColorSet.getColor(nThemeIndex);
aColor.ApplyTintOrShade(aColorItem.GetTintOrShade());
aColorItem.SetValue(aColor);
pCollection->SetFormatAttr(aColorItem);
}
}
std::vector<FontSet> initFontSets()
@@ -562,7 +562,12 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& rEditSh,
UNO_NAME_PARA_CONTINUEING_PREVIOUS_SUB_TREE,
UNO_NAME_CHAR_STYLE_NAME,
UNO_NAME_NUMBERING_LEVEL,
UNO_NAME_PARRSID };
UNO_NAME_PARRSID,
UNO_NAME_CHAR_COLOR_THEME,
UNO_NAME_CHAR_COLOR_TINT_OR_SHADE };
const std::vector<OUString> aHiddenCharacterProperties{ UNO_NAME_CHAR_COLOR_THEME,
UNO_NAME_CHAR_COLOR_TINT_OR_SHADE };
InsertValues(xRange, aIsDefined, aCharDFNode, false, aHiddenProperties, aFieldsNode);
@@ -585,7 +590,8 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& rEditSh,
aCurrentChild.sNodeName = sDisplayName;
aCurrentChild.NodeType = svx::sidebar::TreeNode::ComplexProperty;
InsertValues(xPropertiesSet, aIsDefined, aCurrentChild, false, {}, aFieldsNode);
InsertValues(xPropertiesSet, aIsDefined, aCurrentChild, false, aHiddenCharacterProperties,
aFieldsNode);
aCharNode.children.push_back(aCurrentChild);
}
@@ -615,8 +621,8 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& rEditSh,
aCurrentChild.sNodeName = sDisplayName;
aCurrentChild.NodeType = svx::sidebar::TreeNode::ComplexProperty;
InsertValues(xPropertiesSet, aIsDefined, aCurrentChild, aParentParaStyle.isEmpty(), {},
aFieldsNode);
InsertValues(xPropertiesSet, aIsDefined, aCurrentChild, aParentParaStyle.isEmpty(),
aHiddenCharacterProperties, aFieldsNode);
aParaNode.children.push_back(aCurrentChild);
sCurrentParaStyle = aParentParaStyle;
@@ -1031,12 +1031,28 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
// footnote or endnote reference id - not needed
break;
case NS_ooxml::LN_CT_Color_themeColor:
if (m_pImpl->GetTopContext())
{
sal_Int16 nIndex = TDefTableHandler::getThemeColorTypeIndex(nIntValue);
if (nIndex >= 0 && nIndex <= 11)
m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR_THEME_INDEX, uno::Any(nIndex));
}
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeColor", TDefTableHandler::getThemeColorTypeString(nIntValue));
break;
case NS_ooxml::LN_CT_Color_themeTint:
if (m_pImpl->GetTopContext())
{
if (nIntValue != 0)
m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR_TINT_OR_SHADE, uno::Any(sal_Int16((256 - nIntValue) * 10000 / 256)));
}
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeTint", OUString::number(nIntValue, 16));
break;
case NS_ooxml::LN_CT_Color_themeShade:
if (m_pImpl->GetTopContext())
{
if (nIntValue != 0)
m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR_TINT_OR_SHADE, uno::Any(sal_Int16((nIntValue - 256) * 10000 / 256)));
}
m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "themeShade", OUString::number(nIntValue, 16));
break;
case NS_ooxml::LN_CT_DocGrid_linePitch:
@@ -32,6 +32,8 @@ OUString getPropertyName( PropertyIds eId )
case PROP_CHAR_SHADOWED: sName = "CharShadowed"; break;
case PROP_CHAR_CASE_MAP: sName = "CharCaseMap"; break;
case PROP_CHAR_COLOR: sName = "CharColor"; break;
case PROP_CHAR_COLOR_THEME_INDEX: sName = "CharColorTheme"; break;
case PROP_CHAR_COLOR_TINT_OR_SHADE: sName = "CharColorTintOrShade"; break;
case PROP_CHAR_RELIEF: sName = "CharRelief"; break;
case PROP_CHAR_UNDERLINE: sName = "CharUnderline"; break;
case PROP_CHAR_UNDERLINE_COLOR: sName = "CharUnderlineColor"; break;
@@ -54,6 +54,8 @@ enum PropertyIds
,PROP_CHAR_CASE_MAP
,PROP_CHAR_CHAR_KERNING
,PROP_CHAR_COLOR
,PROP_CHAR_COLOR_THEME_INDEX
,PROP_CHAR_COLOR_TINT_OR_SHADE
,PROP_CHAR_COMBINE_IS_ON
,PROP_CHAR_COMBINE_PREFIX
,PROP_CHAR_COMBINE_SUFFIX
@@ -269,6 +269,50 @@ OUString TDefTableHandler::getThemeColorTypeString(sal_Int32 nType)
return OUString();
}
sal_Int16 TDefTableHandler::getThemeColorTypeIndex(sal_Int32 nType)
{
switch (nType)
{
case NS_ooxml::LN_Value_St_ThemeColor_dark1:
return 0;
case NS_ooxml::LN_Value_St_ThemeColor_light1:
return 1;
case NS_ooxml::LN_Value_St_ThemeColor_dark2:
return 2;
case NS_ooxml::LN_Value_St_ThemeColor_light2:
return 3;
case NS_ooxml::LN_Value_St_ThemeColor_accent1:
return 4;
case NS_ooxml::LN_Value_St_ThemeColor_accent2:
return 5;
case NS_ooxml::LN_Value_St_ThemeColor_accent3:
return 6;
case NS_ooxml::LN_Value_St_ThemeColor_accent4:
return 7;
case NS_ooxml::LN_Value_St_ThemeColor_accent5:
return 8;
case NS_ooxml::LN_Value_St_ThemeColor_accent6:
return 9;
case NS_ooxml::LN_Value_St_ThemeColor_hyperlink:
return 10;
case NS_ooxml::LN_Value_St_ThemeColor_followedHyperlink:
return 11;
case NS_ooxml::LN_Value_St_ThemeColor_none:
return -1;
case NS_ooxml::LN_Value_St_ThemeColor_background1:
return 0;
case NS_ooxml::LN_Value_St_ThemeColor_text1:
return 1;
case NS_ooxml::LN_Value_St_ThemeColor_background2:
return 2;
case NS_ooxml::LN_Value_St_ThemeColor_text2:
return 3;
default:
break;
}
return -1;
}
void TDefTableHandler::lcl_attribute(Id rName, Value & rVal)
{
sal_Int32 nIntValue = rVal.getInt();
@@ -66,6 +66,7 @@ public:
css::beans::PropertyValue getInteropGrabBag(const OUString& aName = OUString());
static OUString getBorderTypeString(sal_Int32 nType);
static OUString getThemeColorTypeString(sal_Int32 nType);
static sal_Int16 getThemeColorTypeIndex(sal_Int32 nType);
};
}
+49
View File
@@ -0,0 +1,49 @@
/* -*- 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/.
*/
#pragma once
#include <xmloff/xmlprhdl.hxx>
using namespace ::xmloff::token;
class XMLThemeColorHandler : public XMLPropertyHandler
{
public:
bool importXML(const OUString& rStrImpValue, css::uno::Any& rValue,
const SvXMLUnitConverter&) const override
{
sal_Int16 nValue;
bool bReturn = SvXMLUnitConverter::convertEnum(nValue, rStrImpValue, pXML_ThemeColor_Enum);
if (bReturn)
rValue <<= nValue;
return bReturn;
}
bool exportXML(OUString& rStrExpValue, const css::uno::Any& rValue,
const SvXMLUnitConverter&) const override
{
sal_Int16 nThemeIndex;
rValue >>= nThemeIndex;
if (nThemeIndex == -1) // Default
return false;
OUStringBuffer aOutBuffer;
bool bReturn = SvXMLUnitConverter::convertEnum(aOutBuffer, nThemeIndex,
pXML_ThemeColor_Enum, XML_NONE);
rStrExpValue = aOutBuffer.makeStringAndClear();
return bReturn;
}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+1 -1
View File
@@ -19,6 +19,6 @@ template <typename EnumT> struct SvXMLEnumMapEntry;
extern SvXMLEnumMapEntry<css::drawing::FillStyle> const aXML_FillStyle_EnumMap[];
extern SvXMLEnumMapEntry<css::drawing::RectanglePoint> const aXML_RefPoint_EnumMap[];
extern SvXMLEnumMapEntry<css::drawing::BitmapMode> const aXML_BitmapMode_EnumMap[];
extern SvXMLEnumMapEntry<sal_uInt16> const pXML_ThemeColor_Enum[];
extern SvXMLEnumMapEntry<sal_Int16> const pXML_ThemeColor_Enum[];
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
+2 -1
View File
@@ -60,6 +60,7 @@
#include <XMLIsPercentagePropertyHandler.hxx>
#include <XMLPercentOrMeasurePropertyHandler.hxx>
#include <XMLTextColumnsPropertyHandler.hxx>
#include <XMLThemeColorHandler.hxx>
#include <animations.hxx>
#include <sax/tools/converter.hxx>
#include <xmlsdtypes.hxx>
@@ -1308,7 +1309,7 @@ const XMLPropertyHandler* XMLSdPropHdlFactory::GetPropertyHandler( sal_Int32 nTy
pHdl = new XMLTextColumnsPropertyHandler;
break;
case XML_TYPE_THEME_COLOR:
pHdl = new XMLConstantsPropertyHandler(pXML_ThemeColor_Enum, XML_TOKEN_INVALID);
pHdl = new XMLThemeColorHandler;
break;
}
+4 -2
View File
@@ -56,6 +56,7 @@
#include <XMLFillBitmapSizePropertyHandler.hxx>
#include <XMLBitmapLogicalSizePropertyHandler.hxx>
#include <XMLBitmapRepeatOffsetPropertyHandler.hxx>
#include <XMLThemeColorHandler.hxx>
#include <vcl/graph.hxx>
using namespace ::com::sun::star;
@@ -249,8 +250,9 @@ SvXMLEnumMapEntry<drawing::TextVerticalAdjust> const pXML_VerticalAlign_Enum[] =
{ XML_TOKEN_INVALID, drawing::TextVerticalAdjust(0) }
};
SvXMLEnumMapEntry<sal_uInt16> const pXML_ThemeColor_Enum[] =
SvXMLEnumMapEntry<sal_Int16> const pXML_ThemeColor_Enum[] =
{
{ XML_NONE, -1 },
{ XML_DK1, 0 },
{ XML_LT1, 1 },
{ XML_DK2, 2 },
@@ -1430,7 +1432,7 @@ static const XMLPropertyHandler *GetPropertyHandler
pHdl = new XMLGraphicPropertyHandler;
break;
case XML_TYPE_THEME_COLOR:
pHdl = new XMLConstantsPropertyHandler(pXML_ThemeColor_Enum, XML_TOKEN_INVALID);
pHdl = new XMLThemeColorHandler;
break;
default:
{