sw/source/core/model/ThemeColorChanger.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
New commits: commit 784ee6e9fad22560add4a0767828ef07b8567bc2 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Jan 25 18:09:15 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Jan 25 14:56:41 2023 +0000 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 <qui...@gmail.com> 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;