Makefile.fetch | 1 RepositoryExternal.mk | 10 ++++++ download.lst | 5 +++ external/Module_external.mk | 1 external/frozen/Module_frozen.mk | 16 ++++++++++ external/frozen/README.md | 7 ++++ external/frozen/UnpackedTarball_frozen.mk | 18 +++++++++++ external/frozen/defines_h_constexpr_string.patch.0 | 11 +++++++ include/svx/dialog/ThemeDialog.hxx | 7 +--- include/svx/theme/IThemeColorChanger.hxx | 2 - include/svx/theme/ThemeColorChanger.hxx | 2 - sc/source/ui/inc/ThemeColorChanger.hxx | 2 - sc/source/ui/theme/ThemeColorChanger.cxx | 27 +++++++++++++++-- sc/source/ui/view/tabvwsh3.cxx | 7 +--- svx/source/dialog/ThemeDialog.cxx | 11 +++---- svx/source/svdraw/svdpage.cxx | 17 ----------- svx/source/theme/ThemeColorChanger.cxx | 6 +-- sw/qa/core/theme/ThemeTest.cxx | 6 +-- sw/source/core/inc/ThemeColorChanger.hxx | 2 - sw/source/core/model/ThemeColorChanger.cxx | 32 ++++++++++----------- sw/source/uibase/shells/basesh.cxx | 16 +++++++--- sw/source/uibase/sidebar/ThemePanel.cxx | 2 - 22 files changed, 143 insertions(+), 65 deletions(-)
New commits: commit b31e885e987025fba953ce9d6cb713a48a853d6a Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Jul 16 12:17:20 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jun 22 20:59:56 2023 +0200 Add frozen library support - for compile-time dict, set support Change-Id: I8fa02569ba02048cc3ef02b349aafba1c0cbebb4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153173 Reviewed-by: Taichi Haradaguchi <20001...@ymail.ne.jp> Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153442 diff --git a/Makefile.fetch b/Makefile.fetch index c8c5c91941f2..625e781dc36a 100644 --- a/Makefile.fetch +++ b/Makefile.fetch @@ -125,6 +125,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S $(call fetch_Optional,FONTCONFIG,FONTCONFIG_TARBALL) \ $(call fetch_Optional,FREEHAND,FREEHAND_TARBALL) \ $(call fetch_Optional,FREETYPE,FREETYPE_TARBALL) \ + FROZEN_TARBALL \ $(call fetch_Optional,EPOXY,EPOXY_TARBALL) \ $(call fetch_Optional,GLM,GLM_TARBALL) \ $(call fetch_Optional,GPGMEPP,GPGME_TARBALL) \ diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 3ec3cd924395..631466f0001a 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -4297,4 +4297,14 @@ endif # ENABLE_ZXING endif # SYSTEM_ZXING + +define gb_LinkTarget__use_frozen +$(call gb_LinkTarget_use_unpacked,$(1),frozen) +$(call gb_LinkTarget_set_include,$(1),\ + -I$(call gb_UnpackedTarball_get_dir,frozen/include/)\ + $$(INCLUDE) \ +) +endef + + # vim: set noet sw=4 ts=4: diff --git a/download.lst b/download.lst index e8ce2bfc67aa..7111b41795c9 100644 --- a/download.lst +++ b/download.lst @@ -202,6 +202,11 @@ FREETYPE_TARBALL := freetype-2.13.0.tar.xz # three static lines # so that git cherry-pick # will not run into conflicts +FROZEN_SHA256SUM := f7c7075750e8fceeac081e9ef01944f221b36d9725beac8681cbd2838d26be45 +FROZEN_TARBALL := frozen-1.1.1.tar.gz +# three static lines +# so that git cherry-pick +# will not run into conflicts GLM_SHA256SUM := 6bba5f032bed47c73ad9397f2313b9acbfb56253d0d0576b5873d3dcb25e99ad GLM_TARBALL := glm-0.9.9.8.zip # three static lines diff --git a/external/Module_external.mk b/external/Module_external.mk index 73d6530ac10f..cd9c5924d71d 100644 --- a/external/Module_external.mk +++ b/external/Module_external.mk @@ -41,6 +41,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\ $(call gb_Helper_optional,FONTCONFIG,fontconfig) \ $(call gb_Helper_optional,FREEHAND,libfreehand) \ $(call gb_Helper_optional,FREETYPE,freetype) \ + frozen \ $(call gb_Helper_optional,GLM,glm) \ $(call gb_Helper_optional,GPGMEPP,gpgmepp) \ $(call gb_Helper_optional,GRAPHITE,graphite) \ diff --git a/external/frozen/Module_frozen.mk b/external/frozen/Module_frozen.mk new file mode 100644 index 000000000000..10fa0997e0ed --- /dev/null +++ b/external/frozen/Module_frozen.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# 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_Module_Module,frozen)) + +$(eval $(call gb_Module_add_targets,frozen,\ + UnpackedTarball_frozen \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/frozen/README.md b/external/frozen/README.md new file mode 100644 index 000000000000..56b011a771b6 --- /dev/null +++ b/external/frozen/README.md @@ -0,0 +1,7 @@ +External header only library frozen + +Header-only library that provides 0 cost initialization for immutable containers, fixed-size containers, and various algorithms. + +https://github.com/serge-sans-paille/frozen + +Release archives at: https://github.com/serge-sans-paille/frozen/tags diff --git a/external/frozen/UnpackedTarball_frozen.mk b/external/frozen/UnpackedTarball_frozen.mk new file mode 100644 index 000000000000..41ddb0fed85a --- /dev/null +++ b/external/frozen/UnpackedTarball_frozen.mk @@ -0,0 +1,18 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# 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_UnpackedTarball_UnpackedTarball,frozen)) + +$(eval $(call gb_UnpackedTarball_set_tarball,frozen,$(FROZEN_TARBALL))) + +$(eval $(call gb_UnpackedTarball_add_patches,frozen,\ + external/frozen/defines_h_constexpr_string.patch.0 \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/frozen/defines_h_constexpr_string.patch.0 b/external/frozen/defines_h_constexpr_string.patch.0 new file mode 100644 index 000000000000..d911ce3f9fa5 --- /dev/null +++ b/external/frozen/defines_h_constexpr_string.patch.0 @@ -0,0 +1,11 @@ +--- include/frozen/bits/defines.h ++++ include/frozen/bits/defines.h +@@ -59,7 +59,7 @@ + #define FROZEN_LETITGO_HAS_DEDUCTION_GUIDES + #endif + +-#if __cpp_lib_constexpr_string >= 201907L ++#if defined(__cpp_lib_constexpr_string) && __cpp_lib_constexpr_string >= 201907L + #define FROZEN_LETITGO_HAS_CONSTEXPR_STRING + #endif + commit 0ee5c63830f42bd2bb8d3b71b499e7e0cc2a061c Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu May 11 23:02:08 2023 +0900 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jun 22 20:59:49 2023 +0200 sc: change text and background theme colors for direct attributes Change-Id: Ia1ef2d151476bb627a0cb999135f6add827fb341 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151675 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153441 diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx b/sc/source/ui/theme/ThemeColorChanger.cxx index 870ef5b15cb8..2211aa67b554 100644 --- a/sc/source/ui/theme/ThemeColorChanger.cxx +++ b/sc/source/ui/theme/ThemeColorChanger.cxx @@ -21,6 +21,8 @@ #include <stlsheet.hxx> #include <scitems.hxx> #include <document.hxx> +#include <address.hxx> +#include <dociter.hxx> namespace sc { @@ -33,10 +35,9 @@ ThemeColorChanger::~ThemeColorChanger() = default; namespace { -void paragraphStyleChange(ScStyleSheet* pStyle, model::ColorSet const& rColorSet) +void changeCellItems(SfxItemSet& rItemSet, model::ColorSet const& rColorSet) { const SfxPoolItem* pItem = nullptr; - auto& rItemSet = pStyle->GetItemSet(); if (rItemSet.HasItem(ATTR_FONT_COLOR, &pItem)) { @@ -87,9 +88,27 @@ void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet) pStyle = static_cast<ScStyleSheet*>(pPool->First(SfxStyleFamily::Para)); while (pStyle) { - paragraphStyleChange(pStyle, *pColorSet); + auto& rItemSet = pStyle->GetItemSet(); + changeCellItems(rItemSet, *pColorSet); pStyle = static_cast<ScStyleSheet*>(pPool->Next()); } + + // Change Cell / Text attributes + for (SCTAB nTab = 0; nTab < rDocument.GetTableCount(); nTab++) + { + ScDocAttrIterator aAttributeIterator(rDocument, nTab, 0, 0, rDocument.MaxCol(), + rDocument.MaxRow()); + SCCOL nCol = 0; + SCROW nRow1 = 0; + SCROW nRow2 = 0; + + while (const ScPatternAttr* pPattern = aAttributeIterator.GetNext(nCol, nRow1, nRow2)) + { + auto* pNonConstPattern = const_cast<ScPatternAttr*>(pPattern); + auto& rItemSet = pNonConstPattern->GetItemSet(); + changeCellItems(rItemSet, *pColorSet); + } + } } } // end sw namespace commit 2369ae97cfe868262dd521f350fcd82dc8e91cf1 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Jun 6 15:05:18 2023 +0900 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jun 22 20:59:42 2023 +0200 lok: send theme palette after the change in ThemeDialog For some reason the SdrPage is constructed in Online after every change (cursor, selection) so can't use that to send theme change callback. Instead of that send it after the theme is changed with the ThemeDialog. in addition this requires that we transport model::ColorSet in a shared_ptr more, to prevent doing constant copies. This requires that the IThemeColorChanger interface is changed and the signature of apply() method. Change-Id: Iac951fce57a8e9dff467bd27b2f9c64ec65ea30c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152635 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 6c40e4d1796bcb6418dcb5ec17f46f576c171796) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152728 Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153440 diff --git a/include/svx/dialog/ThemeDialog.hxx b/include/svx/dialog/ThemeDialog.hxx index d715894f027a..020240c97ca3 100644 --- a/include/svx/dialog/ThemeDialog.hxx +++ b/include/svx/dialog/ThemeDialog.hxx @@ -36,7 +36,7 @@ private: std::unique_ptr<weld::CustomWeld> mxValueSetThemeColorsWindow; std::unique_ptr<weld::Button> mxAdd; - std::optional<std::reference_wrapper<model::ColorSet>> moCurrentColorSet; + std::shared_ptr<model::ColorSet> mpCurrentColorSet; void runThemeColorEditDialog(); void initColorSets(); @@ -49,10 +49,7 @@ public: DECL_LINK(SelectItem, ValueSet*, void); DECL_LINK(ButtonClicked, weld::Button&, void); - std::optional<std::reference_wrapper<model::ColorSet>> const& getCurrentColorSet() - { - return moCurrentColorSet; - } + std::shared_ptr<model::ColorSet> const& getCurrentColorSet() { return mpCurrentColorSet; } }; } // end svx namespace diff --git a/include/svx/theme/IThemeColorChanger.hxx b/include/svx/theme/IThemeColorChanger.hxx index 4f10ad15120f..d9273238c712 100644 --- a/include/svx/theme/IThemeColorChanger.hxx +++ b/include/svx/theme/IThemeColorChanger.hxx @@ -18,7 +18,7 @@ class SVXCORE_DLLPUBLIC IThemeColorChanger { public: virtual ~IThemeColorChanger() = default; - virtual void apply(model::ColorSet const& rColorSet) = 0; + virtual void apply(std::shared_ptr<model::ColorSet> const& pColorSet) = 0; }; } // end svx namespace diff --git a/include/svx/theme/ThemeColorChanger.hxx b/include/svx/theme/ThemeColorChanger.hxx index 708344fef2b3..8e942ea975ad 100644 --- a/include/svx/theme/ThemeColorChanger.hxx +++ b/include/svx/theme/ThemeColorChanger.hxx @@ -31,7 +31,7 @@ public: ThemeColorChanger(SdrPage* pPage); virtual ~ThemeColorChanger() override; - void apply(model::ColorSet const& rColorSet) override; + void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override; }; } // end svx namespace diff --git a/sc/source/ui/inc/ThemeColorChanger.hxx b/sc/source/ui/inc/ThemeColorChanger.hxx index 89d154aca7d9..888cf34f11ba 100644 --- a/sc/source/ui/inc/ThemeColorChanger.hxx +++ b/sc/source/ui/inc/ThemeColorChanger.hxx @@ -23,7 +23,7 @@ public: ThemeColorChanger(ScDocShell& rDocShell); virtual ~ThemeColorChanger() override; - void apply(model::ColorSet const& rColorSet) override; + void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override; }; } // end sc namespace diff --git a/sc/source/ui/theme/ThemeColorChanger.cxx b/sc/source/ui/theme/ThemeColorChanger.cxx index 1e8641f525a4..870ef5b15cb8 100644 --- a/sc/source/ui/theme/ThemeColorChanger.cxx +++ b/sc/source/ui/theme/ThemeColorChanger.cxx @@ -77,7 +77,7 @@ void paragraphStyleChange(ScStyleSheet* pStyle, model::ColorSet const& rColorSet } } // end anonymous ns -void ThemeColorChanger::apply(model::ColorSet const& rColorSet) +void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet) { auto& rDocument = m_rDocShell.GetDocument(); ScStyleSheetPool* pPool = rDocument.GetStyleSheetPool(); @@ -87,7 +87,7 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) pStyle = static_cast<ScStyleSheet*>(pPool->First(SfxStyleFamily::Para)); while (pStyle) { - paragraphStyleChange(pStyle, rColorSet); + paragraphStyleChange(pStyle, *pColorSet); pStyle = static_cast<ScStyleSheet*>(pPool->Next()); } } diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index bb03be4fd9cc..7395325f775c 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -1356,12 +1356,11 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) if (RET_OK != nResult) return; - auto oColorSet = pDialog->getCurrentColorSet(); - if (oColorSet) + auto pColorSet = pDialog->getCurrentColorSet(); + if (pColorSet) { - auto& rColorSet = (*oColorSet).get(); sc::ThemeColorChanger aChanger(*GetViewData().GetDocShell()); - aChanger.apply(rColorSet); + aChanger.apply(pColorSet); } }); } diff --git a/svx/source/dialog/ThemeDialog.cxx b/svx/source/dialog/ThemeDialog.cxx index ce88b2ef4b79..8af6f5975df2 100644 --- a/svx/source/dialog/ThemeDialog.cxx +++ b/svx/source/dialog/ThemeDialog.cxx @@ -40,7 +40,7 @@ ThemeDialog::ThemeDialog(weld::Window* pParent, model::Theme* pTheme) if (!maColorSets.empty()) { mxValueSetThemeColors->SelectItem(1); // ItemId 1, position 0 - moCurrentColorSet = std::ref(maColorSets[0]); + mpCurrentColorSet = std::make_shared<model::ColorSet>(maColorSets[0]); } } @@ -80,12 +80,12 @@ IMPL_LINK_NOARG(ThemeDialog, SelectItem, ValueSet*, void) if (nIndex >= maColorSets.size()) return; - moCurrentColorSet = std::ref(maColorSets[nIndex]); + mpCurrentColorSet = std::make_shared<model::ColorSet>(maColorSets[nIndex]); } void ThemeDialog::runThemeColorEditDialog() { - auto pDialog = std::make_shared<svx::ThemeColorEditDialog>(mpWindow, *moCurrentColorSet); + auto pDialog = std::make_shared<svx::ThemeColorEditDialog>(mpWindow, *mpCurrentColorSet); weld::DialogController::runAsync(pDialog, [this, pDialog](sal_uInt32 nResult) { if (nResult != RET_OK) return; @@ -99,14 +99,15 @@ void ThemeDialog::runThemeColorEditDialog() initColorSets(); mxValueSetThemeColors->SelectItem(maColorSets.size() - 1); - moCurrentColorSet = std::ref(maColorSets[maColorSets.size() - 1]); + mpCurrentColorSet + = std::make_shared<model::ColorSet>(maColorSets[maColorSets.size() - 1]); } }); } IMPL_LINK(ThemeDialog, ButtonClicked, weld::Button&, rButton, void) { - if (moCurrentColorSet && mxAdd.get() == &rButton) + if (mpCurrentColorSet && mxAdd.get() == &rButton) { runThemeColorEditDialog(); } diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index d165300292f7..2a316a25080f 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -47,7 +47,6 @@ #include <svx/fmdpage.hxx> #include <svx/theme/ThemeColorChanger.hxx> #include <svx/ColorSets.hxx> -#include <svx/theme/ThemeColorPaletteManager.hxx> #include <sdr/contact/viewcontactofsdrpage.hxx> #include <svx/sdr/contact/viewobjectcontact.hxx> @@ -58,8 +57,6 @@ #include <rtl/strbuf.hxx> #include <libxml/xmlwriter.h> #include <docmodel/theme/Theme.hxx> -#include <sfx2/lokhelper.hxx> -#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <com/sun/star/lang/IllegalArgumentException.hpp> @@ -1205,7 +1202,6 @@ SdrPageProperties::SdrPageProperties(SdrPage& rSdrPage) { std::shared_ptr<model::ColorSet> pDefaultColorSet(new model::ColorSet(*pColorSet)); mpTheme->setColorSet(pDefaultColorSet); - sendLOKitThemeChangedCallback(); } } } @@ -1283,8 +1279,6 @@ void SdrPageProperties::SetTheme(std::shared_ptr<model::Theme> const& pTheme) mpTheme = pTheme; - sendLOKitThemeChangedCallback(); - if (mpTheme && mpTheme->getColorSet() && mpSdrPage->IsMasterPage()) { SdrModel& rModel = mpSdrPage->getSdrModelFromSdrPage(); @@ -1298,20 +1292,11 @@ void SdrPageProperties::SetTheme(std::shared_ptr<model::Theme> const& pTheme) } svx::ThemeColorChanger aChanger(pPage); - aChanger.apply(*mpTheme->getColorSet()); + aChanger.apply(mpTheme->getColorSet()); } } } -void SdrPageProperties::sendLOKitThemeChangedCallback() -{ - if (!comphelper::LibreOfficeKit::isActive()) - return; - - svx::ThemeColorPaletteManager aManager(mpTheme->getColorSet()); - SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, aManager.generateJSON()); -} - std::shared_ptr<model::Theme> const& SdrPageProperties::GetTheme() const { return mpTheme; diff --git a/svx/source/theme/ThemeColorChanger.cxx b/svx/source/theme/ThemeColorChanger.cxx index 06d199cc3896..2edc00820381 100644 --- a/svx/source/theme/ThemeColorChanger.cxx +++ b/svx/source/theme/ThemeColorChanger.cxx @@ -135,12 +135,12 @@ ThemeColorChanger::ThemeColorChanger(SdrPage* pPage) ThemeColorChanger::~ThemeColorChanger() = default; -void ThemeColorChanger::apply(model::ColorSet const& rColorSet) +void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet) { for (size_t nObject = 0; nObject < mpPage->GetObjCount(); ++nObject) { SdrObject* pObject = mpPage->GetObj(nObject); - theme::updateSdrObject(rColorSet, pObject); + theme::updateSdrObject(*pColorSet, pObject); // update child objects SdrObjList* pList = pObject->GetSubList(); @@ -149,7 +149,7 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) SdrObjListIter aIter(pList, SdrIterMode::DeepWithGroups); while (aIter.IsMore()) { - theme::updateSdrObject(rColorSet, aIter.Next()); + theme::updateSdrObject(*pColorSet, aIter.Next()); } } } diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx index da41c8bb56a8..5d8480035f77 100644 --- a/sw/qa/core/theme/ThemeTest.cxx +++ b/sw/qa/core/theme/ThemeTest.cxx @@ -430,12 +430,12 @@ CPPUNIT_TEST_FIXTURE(SwCoreThemeTest, testThemeChanging) // Change theme colors { auto const& rColorSets = svx::ColorSets::get(); - model::ColorSet const& rNewColorSet = rColorSets.getColorSet(0); + auto pNewColorSet = std::make_shared<model::ColorSet>(rColorSets.getColorSet(0)); // check that the theme colors are as expected - CPPUNIT_ASSERT_EQUAL(OUString(u"LibreOffice"), rNewColorSet.getName()); + CPPUNIT_ASSERT_EQUAL(OUString(u"LibreOffice"), pNewColorSet->getName()); sw::ThemeColorChanger aChanger(pDoc->GetDocShell()); - aChanger.apply(rNewColorSet); + aChanger.apply(pNewColorSet); } // Check new theme colors diff --git a/sw/source/core/inc/ThemeColorChanger.hxx b/sw/source/core/inc/ThemeColorChanger.hxx index e7e2620a41d0..6c3e9f3cc7f7 100644 --- a/sw/source/core/inc/ThemeColorChanger.hxx +++ b/sw/source/core/inc/ThemeColorChanger.hxx @@ -25,7 +25,7 @@ public: ThemeColorChanger(SwDocShell* pDocSh); virtual ~ThemeColorChanger() override; - void apply(model::ColorSet const& rColorSet) override; + void apply(std::shared_ptr<model::ColorSet> const& pColorSet) override; }; } // end sw namespace diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx index e9ae920362a5..caf4de1787ce 100644 --- a/sw/source/core/model/ThemeColorChanger.cxx +++ b/sw/source/core/model/ThemeColorChanger.cxx @@ -345,7 +345,7 @@ ThemeColorChanger::ThemeColorChanger(SwDocShell* pDocSh) ThemeColorChanger::~ThemeColorChanger() = default; -void ThemeColorChanger::apply(model::ColorSet const& rColorSet) +void ThemeColorChanger::apply(std::shared_ptr<model::ColorSet> const& pColorSet) { SwDoc* pDocument = mpDocSh->GetDoc(); if (!pDocument) @@ -362,8 +362,8 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) pPage->getSdrPageProperties().SetTheme(pTheme); } - auto pNewColorSet = std::make_shared<model::ColorSet>(rColorSet); - auto pOldColorSet = pTheme->getColorSet(); + std::shared_ptr<model::ColorSet> pNewColorSet = pColorSet; + std::shared_ptr<model::ColorSet> pOldColorSet = pTheme->getColorSet(); pTheme->setColorSet(pNewColorSet); auto pUndoThemeChange @@ -379,8 +379,8 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone(); bool bChanged = false; - bChanged = bChanged || changeBackground(rAttrSet, *pNewSet, rColorSet); - bChanged = bChanged || changeBox(rAttrSet, *pNewSet, rColorSet); + bChanged = bChanged || changeBackground(rAttrSet, *pNewSet, *pColorSet); + bChanged = bChanged || changeBox(rAttrSet, *pNewSet, *pColorSet); if (bChanged) { @@ -403,8 +403,8 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone(); bool bChanged = false; - bChanged = changeBackground(rAttrSet, *pNewSet, rColorSet) || bChanged; - bChanged = changeBox(rAttrSet, *pNewSet, rColorSet) || bChanged; + bChanged = changeBackground(rAttrSet, *pNewSet, *pColorSet) || bChanged; + bChanged = changeBox(rAttrSet, *pNewSet, *pColorSet) || bChanged; if (bChanged) pDocument->ChgFormat(*pFrameFormat, *pNewSet); @@ -423,11 +423,11 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone(); bool bChanged = false; - bChanged = changeColor(rAttrSet, *pNewSet, rColorSet) || bChanged; - bChanged = changeOverlineColor(rAttrSet, *pNewSet, rColorSet) || bChanged; - bChanged = changeUnderlineColor(rAttrSet, *pNewSet, rColorSet) || bChanged; - bChanged = changeBox(rAttrSet, *pNewSet, rColorSet) || bChanged; - bChanged = changeBackground(rAttrSet, *pNewSet, rColorSet) || bChanged; + bChanged = changeColor(rAttrSet, *pNewSet, *pColorSet) || bChanged; + bChanged = changeOverlineColor(rAttrSet, *pNewSet, *pColorSet) || bChanged; + bChanged = changeUnderlineColor(rAttrSet, *pNewSet, *pColorSet) || bChanged; + bChanged = changeBox(rAttrSet, *pNewSet, *pColorSet) || bChanged; + bChanged = changeBackground(rAttrSet, *pNewSet, *pColorSet) || bChanged; if (bChanged) pDocument->ChgFormat(*pTextFormatCollection, *pNewSet); @@ -446,9 +446,9 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) std::unique_ptr<SfxItemSet> pNewSet = rAttrSet.Clone(); bool bChanged = false; - bChanged = changeColor(rAttrSet, *pNewSet, rColorSet) || bChanged; - bChanged = changeOverlineColor(rAttrSet, *pNewSet, rColorSet) || bChanged; - bChanged = changeUnderlineColor(rAttrSet, *pNewSet, rColorSet) || bChanged; + bChanged = changeColor(rAttrSet, *pNewSet, *pColorSet) || bChanged; + bChanged = changeOverlineColor(rAttrSet, *pNewSet, *pColorSet) || bChanged; + bChanged = changeUnderlineColor(rAttrSet, *pNewSet, *pColorSet) || bChanged; if (bChanged) pDocument->ChgFormat(*pCharFormat, *pNewSet); } @@ -456,7 +456,7 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) } // Direct format change - auto pHandler = std::make_shared<ThemeColorHandler>(*pDocument, rColorSet); + auto pHandler = std::make_shared<ThemeColorHandler>(*pDocument, *pColorSet); sw::ModelTraverser aModelTraverser(pDocument); aModelTraverser.addNodeHandler(pHandler); aModelTraverser.traverse(); diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 118df74e23a1..504c9fefa89d 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -91,15 +91,19 @@ #include <SwRewriter.hxx> #include <GraphicSizeCheck.hxx> #include <svx/galleryitem.hxx> +#include <svx/theme/ThemeColorPaletteManager.hxx> #include <sfx2/devtools/DevelopmentToolChildWindow.hxx> #include <com/sun/star/gallery/GalleryItemType.hpp> #include <com/sun/star/beans/PropertyValues.hpp> #include <memory> + #include <svx/unobrushitemhelper.hxx> #include <svx/dialog/ThemeDialog.hxx> #include <comphelper/scopeguard.hxx> #include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <osl/diagnose.h> #include <svx/svxdlg.hxx> @@ -2976,11 +2980,15 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) if (RET_OK != nResult) return; - auto oColorSet = pDialog->getCurrentColorSet(); - if (oColorSet) + auto pColorSet = pDialog->getCurrentColorSet(); + if (pColorSet) { - auto& rColorSet = (*oColorSet).get(); - pChanger->apply(rColorSet); + pChanger->apply(pColorSet); + if (comphelper::LibreOfficeKit::isActive()) + { + svx::ThemeColorPaletteManager aManager(pColorSet); + SfxLokHelper::notifyAllViews(LOK_CALLBACK_COLOR_PALETTES, aManager.generateJSON()); + } } }); } diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index 2dabadbba545..55853a544f8e 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -97,7 +97,7 @@ void ThemePanel::DoubleClickHdl() model::ColorSet const& rColorSet = rColorSets.getColorSet(nIndex); ThemeColorChanger aChanger(pDocSh); - aChanger.apply(rColorSet); + aChanger.apply(std::make_shared<model::ColorSet>(rColorSet)); } void ThemePanel::NotifyItemUpdate(const sal_uInt16 /*nSId*/,