diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-05-04 00:21:55 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-05-09 12:41:37 +0200 |
commit | 33d35a2181c9cebf77bc1aa9322a2d11892de5fd (patch) | |
tree | eade1df006626ecd0228012bd150db0b7e9fe204 /sw/source/core/model | |
parent | afccbe23cecc04a08281a91e02bb25dd7b0ffdcf (diff) |
sw: support Undo/Redo for theme colors
Change-Id: Ic4166ec4836545467866a70b4160f1adba0bad96
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151448
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/source/core/model')
-rw-r--r-- | sw/source/core/model/ThemeColorChanger.cxx | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx index 6c70e4bb2cd5..9f973d80aaf2 100644 --- a/sw/source/core/model/ThemeColorChanger.cxx +++ b/sw/source/core/model/ThemeColorChanger.cxx @@ -21,6 +21,7 @@ #include <DocumentContentOperationsManager.hxx> #include <IDocumentDrawModelAccess.hxx> #include <IDocumentUndoRedo.hxx> +#include <UndoThemeChange.hxx> #include <sal/config.h> #include <svx/svdpage.hxx> @@ -154,18 +155,22 @@ void ThemeColorChanger::apply(model::ColorSet const& rColorSet) pDocument->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr); SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + auto pTheme = pPage->getSdrPageProperties().GetTheme(); - if (pTheme) - { - pTheme->setColorSet(std::make_shared<model::ColorSet>(rColorSet)); - } - else + if (!pTheme) { pTheme = std::make_shared<model::Theme>("Office"); pPage->getSdrPageProperties().SetTheme(pTheme); - pTheme->setColorSet(std::make_shared<model::ColorSet>(rColorSet)); } + auto pNewColorSet = std::make_shared<model::ColorSet>(rColorSet); + auto pOldColorSet = pTheme->getColorSet(); + pTheme->setColorSet(pNewColorSet); + + auto pUndoThemeChange + = std::make_unique<sw::UndoThemeChange>(*pDocument, pOldColorSet, pNewColorSet); + pDocument->GetIDocumentUndoRedo().AppendUndo(std::move(pUndoThemeChange)); + SfxStyleSheetBasePool* pPool = mpDocSh->GetStyleSheetPool(); SwDocStyleSheet* pStyle; |