diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-01-25 18:09:15 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-01-25 14:56:41 +0000 |
commit | 784ee6e9fad22560add4a0767828ef07b8567bc2 (patch) | |
tree | 5129ebdeead667b1fe355e0257260fabc8f382fe | |
parent | cae93bc7a401cb6ddaf33b7a23e2ff3c3bfada40 (diff) |
sw: change or create the selected theme in SdrPage on theme change
When the theme color changes (from the UI), also the theme that
is set to the SdrPage needs to change. If there is no theme set
yet, a new theme needs to be created (from a set of defaults).
Change-Id: I5e3d6d9f973712ddb875a41adba1aff04395ca7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146129
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | sw/source/core/model/ThemeColorChanger.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx index 4c739547685b..87f1901083c4 100644 --- a/sw/source/core/model/ThemeColorChanger.cxx +++ b/sw/source/core/model/ThemeColorChanger.cxx @@ -19,6 +19,7 @@ #include <format.hxx> #include <charatr.hxx> #include <DocumentContentOperationsManager.hxx> +#include <IDocumentDrawModelAccess.hxx> #include <IDocumentUndoRedo.hxx> #include <sal/config.h> @@ -234,8 +235,24 @@ ThemeColorChanger::~ThemeColorChanger() {} void ThemeColorChanger::apply(svx::ColorSet const& rColorSet) { SwDoc* pDocument = mpDocSh->GetDoc(); + if (!pDocument) + return; + pDocument->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr); + SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + if (pTheme) + { + pTheme->SetColorSet(std::make_unique<svx::ColorSet>(rColorSet)); + } + else + { + pPage->getSdrPageProperties().SetTheme(std::make_unique<svx::Theme>("Office")); + pTheme = pPage->getSdrPageProperties().GetTheme(); + pTheme->SetColorSet(std::make_unique<svx::ColorSet>(rColorSet)); + } + SfxStyleSheetBasePool* pPool = mpDocSh->GetStyleSheetPool(); SwDocStyleSheet* pStyle; |