summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-06-06 15:05:18 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-06-07 08:42:12 +0200
commit6c40e4d1796bcb6418dcb5ec17f46f576c171796 (patch)
treeac7d7162d5c4e940d130d0927358ed4f73a82976 /sw
parent30d3ad42d6b5a7e5ca636ec530f5f26262a78608 (diff)
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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/core/theme/ThemeTest.cxx6
-rw-r--r--sw/source/core/inc/ThemeColorChanger.hxx2
-rw-r--r--sw/source/core/model/ThemeColorChanger.cxx32
-rw-r--r--sw/source/uibase/shells/basesh.cxx16
-rw-r--r--sw/source/uibase/sidebar/ThemePanel.cxx2
5 files changed, 33 insertions, 25 deletions
diff --git a/sw/qa/core/theme/ThemeTest.cxx b/sw/qa/core/theme/ThemeTest.cxx
index a7c937d9c923..abd368f47fa9 100644
--- a/sw/qa/core/theme/ThemeTest.cxx
+++ b/sw/qa/core/theme/ThemeTest.cxx
@@ -418,12 +418,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 fb3175e929cf..171f8e67fffb 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 5055bbd33b9f..6932ed068fd7 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>
@@ -3088,11 +3092,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*/,