editeng/source/items/textitem.cxx | 25 +++---- include/editeng/colritem.hxx | 26 ++++--- sw/CppunitTest_sw_core_theme.mk | 62 ++++++++++++++++++ sw/Module_sw.mk | 1 sw/qa/core/theme/ThemeTest.cxx | 31 +++++++++ sw/qa/core/theme/data/ThemeColorInHeading.docx |binary sw/source/core/unocore/unomap.cxx | 2 sw/source/core/unocore/unomap1.cxx | 4 + 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 + 20 files changed, 273 insertions(+), 52 deletions(-)
New commits: commit 0ba2265645f884d9a3df89fb95e8695998e2a832 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Dec 5 13:59:22 2022 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu Jan 12 03:28:16 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/+/145368 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 72b982b73ff9..329af5edb076 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -1353,9 +1353,10 @@ bool SvxContourItem::GetPresentation } SvxThemeColor::SvxThemeColor() - : maThemeIndex(-1), - mnLumMod(10000), - mnLumOff(0) + : maThemeIndex(-1) + , mnLumMod(10000) + , mnLumOff(0) + , mnTintOrShade(0) { } @@ -1363,7 +1364,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 @@ -1376,6 +1378,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); } @@ -1383,15 +1387,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 ) { } @@ -1405,8 +1407,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 @@ -1432,7 +1433,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: @@ -1488,7 +1489,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 dc34abe85bdd..c71ee46fc78a 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -220,7 +220,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 dd70469e4f7288102df8a2c223c19865c6a1bed2 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun Sep 20 19:27:09 2015 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu Jan 12 03:28:07 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/+/145350 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> 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 c874154c6a43..6dfdede6caf8 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -146,6 +146,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_uibase_fldui \ CppunitTest_sw_core_attr \ CppunitTest_sw_filter_ww8 \ + 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..356fafdb9aa4 --- /dev/null +++ b/sw/qa/core/theme/ThemeTest.cxx @@ -0,0 +1,31 @@ +/* -*- 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> + +constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/theme/data/"; + +class SwCoreThemeTest : public SwModelTestBase +{ +}; + +CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testThemeColorInHeading) +{ + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "ThemeColorInHeading.docx"); + 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 bfbd1711e68d..858057dd7129 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -1507,6 +1507,8 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s { u"" UNO_NAME_PARA_ADJUST, RES_PARATR_ADJUST, cppu::UnoType<sal_Int16>::get(),PropertyAttribute::MAYBEVOID, MID_PARA_ADJUST }, // SvxColorItem { u"" UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0 }, + { u"" UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX }, + { u"" UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE }, // SvxShadowedItem { u"" 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 0fe6db437118..c53f2507a4f6 100644 --- a/sw/source/core/unocore/unomap1.cxx +++ b/sw/source/core/unocore/unomap1.cxx @@ -188,6 +188,8 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetCharStylePropertyMa { u"" UNO_NAME_CHAR_HIGHLIGHT, RES_CHRATR_HIGHLIGHT, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, MID_BACK_COLOR }, { u"" UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, { u"" UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, + { u"" UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX }, + { u"" UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE }, { u"" UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA}, { u"" UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT}, { u"" UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, @@ -251,6 +253,8 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetAutoCharStyleProper { u"" UNO_NAME_CHAR_HIGHLIGHT, RES_CHRATR_HIGHLIGHT, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, MID_BACK_COLOR }, { u"" UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, { u"" UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, + { u"" UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX }, + { u"" UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE }, { u"" UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA}, { u"" UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT}, { u"" 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 c30572f7a92b..dba8bba4f9a0 100644 --- a/sw/source/core/unocore/unomapproperties.hxx +++ b/sw/source/core/unocore/unomapproperties.hxx @@ -122,6 +122,8 @@ { u"" UNO_NAME_PARA_BACK_COLOR, RES_BACKGROUND, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::MAYBEVOID, MID_BACK_COLOR }, \ { u"" UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, 0 }, \ { u"" UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::MAYBEVOID, 0 }, \ + { u"" UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_COLOR_THEME_INDEX }, \ + { u"" UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_COLOR_TINT_OR_SHADE }, \ { u"" UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_COLOR_ALPHA }, \ { u"" UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT }, \ { u"" UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<bool>::get(), PropertyAttribute::MAYBEVOID, MID_CROSSED_OUT }, \ @@ -364,6 +366,8 @@ { u"" UNO_NAME_PARA_GRAPHIC_LOCATION, RES_BACKGROUND, cppu::UnoType<css::style::GraphicLocation>::get(), PROPERTY_NONE ,MID_GRAPHIC_POSITION}, \ { u"" UNO_NAME_CHAR_CASE_MAP, RES_CHRATR_CASEMAP, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0},\ { u"" UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0},\ + { u"" UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX },\ + { u"" UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE },\ { u"" UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA},\ { u"" UNO_NAME_CHAR_STRIKEOUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<sal_Int16>::get(), PropertyAttribute::MAYBEVOID, MID_CROSS_OUT},\ { u"" UNO_NAME_CHAR_CROSSED_OUT, RES_CHRATR_CROSSEDOUT, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0},\ @@ -471,6 +475,8 @@ #define COMMON_ACCESSIBILITY_TEXT_ATTRIBUTE \ { u"" UNO_NAME_CHAR_BACK_COLOR, RES_CHRATR_BACKGROUND, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE ,MID_BACK_COLOR }, \ { u"" UNO_NAME_CHAR_COLOR, RES_CHRATR_COLOR, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, \ + { u"" UNO_NAME_CHAR_COLOR_THEME, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_THEME_INDEX }, \ + { u"" UNO_NAME_CHAR_COLOR_TINT_OR_SHADE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_TINT_OR_SHADE}, \ { u"" UNO_NAME_CHAR_TRANSPARENCE, RES_CHRATR_COLOR, cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, MID_COLOR_ALPHA }, \ { u"" UNO_NAME_CHAR_CONTOURED, RES_CHRATR_CONTOUR, cppu::UnoType<bool>::get() , PROPERTY_NONE, 0}, \ { u"" 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 974f32cb0fa6..dc34abe85bdd 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -74,21 +74,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 @@ -228,13 +213,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 09c773a1d28a..6c13581bc183 100644 --- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx +++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx @@ -557,7 +557,12 @@ static void UpdateTree(SwDocShell* pDocSh, std::vector<svx::sidebar::TreeNode>& 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); @@ -580,7 +585,8 @@ static void UpdateTree(SwDocShell* pDocSh, std::vector<svx::sidebar::TreeNode>& 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); } @@ -610,8 +616,8 @@ static void UpdateTree(SwDocShell* pDocSh, std::vector<svx::sidebar::TreeNode>& 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 034e27079c7c..938fec5fe76c 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1015,12 +1015,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 1189bc0b1410..73726d2c75c3 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 7b6fe9a05275..1fa2a2408dc8 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 53e10529274f..b1adebde48a5 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 343436f71960..59262f1fc576 100644 --- a/xmloff/source/draw/sdpropls.cxx +++ b/xmloff/source/draw/sdpropls.cxx @@ -59,6 +59,7 @@ #include <XMLIsPercentagePropertyHandler.hxx> #include <XMLPercentOrMeasurePropertyHandler.hxx> #include <XMLTextColumnsPropertyHandler.hxx> +#include <XMLThemeColorHandler.hxx> #include <animations.hxx> #include <sax/tools/converter.hxx> #include <xmlsdtypes.hxx> @@ -1285,7 +1286,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: {