editeng/source/items/textitem.cxx | 25 +++---- include/editeng/colritem.hxx | 26 ++++--- include/editeng/unoprnms.hxx | 2 sw/CppunitTest_sw_core_theme.mk | 62 ++++++++++++++++++ sw/Module_sw.mk | 1 sw/qa/core/theme/ThemeTest.cxx | 35 ++++++++++ sw/qa/core/theme/data/ThemeColorInHeading.docx |binary sw/source/core/unocore/unomap.cxx | 4 - sw/source/core/unocore/unomap1.cxx | 6 + sw/source/core/unocore/unomapproperties.hxx | 6 + sw/source/uibase/sidebar/ThemePanel.cxx | 29 ++------ sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx | 14 ++-- writerfilter/source/dmapper/DomainMapper.cxx | 16 ++++ writerfilter/source/dmapper/PropertyIds.cxx | 2 writerfilter/source/dmapper/PropertyIds.hxx | 2 writerfilter/source/dmapper/TDefTableHandler.cxx | 44 ++++++++++++ writerfilter/source/dmapper/TDefTableHandler.hxx | 1 xmloff/inc/XMLThemeColorHandler.hxx | 49 ++++++++++++++ xmloff/inc/enummaps.hxx | 2 xmloff/source/draw/sdpropls.cxx | 3 xmloff/source/text/txtprhdl.cxx | 6 + 21 files changed, 281 insertions(+), 54 deletions(-)
New commits: commit f627192b6055479a2ac2fecd6a8349c0fdc131fc Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Dec 5 13:59:22 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Jan 20 07:11:05 2023 +0000 editeng: move "tint or shade" variable into SvxThemeColor Change-Id: Ia2094854a8275082cf7444307e17fe5449c43b3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143698 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 6fb682487e355933d79a8ef74560ecf318b4f705) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145834 Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 147fa301d548..30b780f1b855 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -1354,9 +1354,10 @@ bool SvxContourItem::GetPresentation } SvxThemeColor::SvxThemeColor() - : maThemeIndex(-1), - mnLumMod(10000), - mnLumOff(0) + : maThemeIndex(-1) + , mnLumMod(10000) + , mnLumOff(0) + , mnTintOrShade(0) { } @@ -1364,7 +1365,8 @@ bool SvxThemeColor::operator==(const SvxThemeColor& rThemeColor) const { return maThemeIndex == rThemeColor.maThemeIndex && mnLumMod == rThemeColor.mnLumMod && - mnLumOff == rThemeColor.mnLumOff; + mnLumOff == rThemeColor.mnLumOff && + mnTintOrShade == rThemeColor.mnTintOrShade; } void SvxThemeColor::dumpAsXml(xmlTextWriterPtr pWriter) const @@ -1377,6 +1379,8 @@ void SvxThemeColor::dumpAsXml(xmlTextWriterPtr pWriter) const BAD_CAST(OString::number(mnLumMod).getStr())); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("lum-off"), BAD_CAST(OString::number(mnLumOff).getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("tint-or-shade"), + BAD_CAST(OString::number(mnTintOrShade).getStr())); (void)xmlTextWriterEndElement(pWriter); } @@ -1384,15 +1388,13 @@ void SvxThemeColor::dumpAsXml(xmlTextWriterPtr pWriter) const // class SvxColorItem ---------------------------------------------------- SvxColorItem::SvxColorItem( const sal_uInt16 nId ) : SfxPoolItem(nId), - mColor( COL_BLACK ), - maTintShade(0) + mColor( COL_BLACK ) { } SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) : SfxPoolItem( nId ), - mColor( rCol ), - maTintShade(0) + mColor( rCol ) { } @@ -1406,8 +1408,7 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const const SvxColorItem& rColorItem = static_cast<const SvxColorItem&>(rAttr); return mColor == rColorItem.mColor && - maThemeColor == rColorItem.maThemeColor && - maTintShade == rColorItem.maTintShade; + maThemeColor == rColorItem.maThemeColor; } bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const @@ -1433,7 +1434,7 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const } case MID_COLOR_TINT_OR_SHADE: { - rVal <<= maTintShade; + rVal <<= maThemeColor.GetTintOrShade(); break; } case MID_COLOR_LUM_MOD: @@ -1489,7 +1490,7 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int16 nTintShade = -1; if (!(rVal >>= nTintShade)) return false; - maTintShade = nTintShade; + maThemeColor.SetTintOrShade(nTintShade); } break; case MID_COLOR_LUM_MOD: diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx index cbd52844b059..05a7183c8582 100644 --- a/include/editeng/colritem.hxx +++ b/include/editeng/colritem.hxx @@ -34,6 +34,8 @@ class EDITENG_DLLPUBLIC SvxThemeColor /// Luminance Offset: 100th percentage, defaults to 0%. sal_Int16 mnLumOff; + sal_Int16 mnTintOrShade; + public: explicit SvxThemeColor(); bool operator==(const SvxThemeColor& rThemeColor) const; @@ -46,8 +48,8 @@ public: void SetThemeIndex(sal_Int16 nIndex) { maThemeIndex = nIndex; - } + } void SetLumMod(sal_Int16 nLumMod) { mnLumMod = nLumMod; } sal_Int16 GetLumMod() const { return mnLumMod; } @@ -56,6 +58,16 @@ public: sal_Int16 GetLumOff() const { return mnLumOff; } + sal_Int16 GetTintOrShade() const + { + return mnTintOrShade; + } + + void SetTintOrShade(sal_Int16 nTintOrShade) + { + mnTintOrShade = nTintOrShade; + } + void dumpAsXml(xmlTextWriterPtr pWriter) const; }; @@ -66,7 +78,7 @@ class EDITENG_DLLPUBLIC SvxColorItem final : public SfxPoolItem private: Color mColor; SvxThemeColor maThemeColor; - sal_Int16 maTintShade; + public: static SfxPoolItem* CreateDefault(); @@ -93,16 +105,6 @@ public: } void SetValue(const Color& rNewColor); - sal_Int16 GetTintOrShade() const - { - return maTintShade; - } - - void SetTintOrShade(sal_Int16 nTintOrShade) - { - maTintShade = nTintOrShade; - } - SvxThemeColor& GetThemeColor() { return maThemeColor; } const SvxThemeColor& GetThemeColor() const { return maThemeColor; } diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index aabe27bb8bb0..d392382e1e31 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -221,7 +221,7 @@ void changeColor(SwTextFormatColl* pCollection, svx::ColorSet const& rColorSet, if (nThemeIndex >= 0) { Color aColor = rColorSet.getColor(nThemeIndex); - aColor.ApplyTintOrShade(aColorItem.GetTintOrShade()); + aColor.ApplyTintOrShade(aColorItem.GetThemeColor().GetTintOrShade()); aColorItem.SetValue(aColor); pCollection->SetFormatAttr(aColorItem); } commit 93388cd7dcdf93f543274b153572dad94fc5165a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Sep 20 19:27:09 2015 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Jan 20 07:10:52 2023 +0000 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 <qui...@gmail.com> (cherry picked from commit df9f3f3fd81d4f81ee2ff984d1e19999abea2963) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145833 Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx index 0df739ee5285..8569a3370464 100644 --- a/include/editeng/unoprnms.hxx +++ b/include/editeng/unoprnms.hxx @@ -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"; diff --git a/sw/CppunitTest_sw_core_theme.mk b/sw/CppunitTest_sw_core_theme.mk new file mode 100644 index 000000000000..84b462ea8245 --- /dev/null +++ b/sw/CppunitTest_sw_core_theme.mk @@ -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: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 8a217a85fbf6..a15763330763 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -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) diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx new file mode 100644 index 000000000000..b20088460234 --- /dev/null +++ b/sw/qa/core/theme/ThemeTest.cxx @@ -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: */ diff --git a/sw/qa/core/theme/data/ThemeColorInHeading.docx b/sw/qa/core/theme/data/ThemeColorInHeading.docx new file mode 100644 index 000000000000..e350c2676d41 Binary files /dev/null and b/sw/qa/core/theme/data/ThemeColorInHeading.docx differ diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 46d40d6b4a9a..ffff63747b61 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -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 diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx index a37843b1538a..1ecf798715e6 100644 --- a/sw/source/core/unocore/unomap1.cxx +++ b/sw/source/core/unocore/unomap1.cxx @@ -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}, diff --git a/sw/source/core/unocore/unomapproperties.hxx b/sw/source/core/unocore/unomapproperties.hxx index 11a326d185c5..de1a6aa1a2d6 100644 --- a/sw/source/core/unocore/unomapproperties.hxx +++ b/sw/source/core/unocore/unomapproperties.hxx @@ -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}, \ diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index 5b17955dd77d..aabe27bb8bb0 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -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() diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx index 5f861000296a..b0fc9b82ce1d 100644 --- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx +++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx @@ -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; diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index e5582d097d55..40a9e9f13d3d 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -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: diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index 1c9bc314862b..3f966d41f18e 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -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; diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index 6e45ca3f05eb..bddcbe56447a 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -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 diff --git a/writerfilter/source/dmapper/TDefTableHandler.cxx b/writerfilter/source/dmapper/TDefTableHandler.cxx index c47ac7db8111..2dea73e65020 100644 --- a/writerfilter/source/dmapper/TDefTableHandler.cxx +++ b/writerfilter/source/dmapper/TDefTableHandler.cxx @@ -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(); diff --git a/writerfilter/source/dmapper/TDefTableHandler.hxx b/writerfilter/source/dmapper/TDefTableHandler.hxx index 17e6f2ed4fab..f9ae47eb5390 100644 --- a/writerfilter/source/dmapper/TDefTableHandler.hxx +++ b/writerfilter/source/dmapper/TDefTableHandler.hxx @@ -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); }; } diff --git a/xmloff/inc/XMLThemeColorHandler.hxx b/xmloff/inc/XMLThemeColorHandler.hxx new file mode 100644 index 000000000000..e98ef725682c --- /dev/null +++ b/xmloff/inc/XMLThemeColorHandler.hxx @@ -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: */ diff --git a/xmloff/inc/enummaps.hxx b/xmloff/inc/enummaps.hxx index a170559af996..4d061a736967 100644 --- a/xmloff/inc/enummaps.hxx +++ b/xmloff/inc/enummaps.hxx @@ -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: */ diff --git a/xmloff/source/draw/sdpropls.cxx b/xmloff/source/draw/sdpropls.cxx index e7223409b6f0..6c8731942782 100644 --- a/xmloff/source/draw/sdpropls.cxx +++ b/xmloff/source/draw/sdpropls.cxx @@ -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; } diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx index 22fbe4174dd6..a4450ce230f4 100644 --- a/xmloff/source/text/txtprhdl.cxx +++ b/xmloff/source/text/txtprhdl.cxx @@ -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: {