summaryrefslogtreecommitdiffstats
path: root/sd/source/ui/dlg/UndoThemeChange.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/dlg/UndoThemeChange.cxx')
-rw-r--r--sd/source/ui/dlg/UndoThemeChange.cxx55
1 files changed, 55 insertions, 0 deletions
diff --git a/sd/source/ui/dlg/UndoThemeChange.cxx b/sd/source/ui/dlg/UndoThemeChange.cxx
new file mode 100644
index 0000000000..1270dc06ca
--- /dev/null
+++ b/sd/source/ui/dlg/UndoThemeChange.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <UndoThemeChange.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/strings.hrc>
+
+namespace sd
+{
+UndoThemeChange::UndoThemeChange(SdDrawDocument* pDocument, SdrPage* pMasterPage,
+ std::shared_ptr<model::ColorSet> const& pOldColorSet,
+ std::shared_ptr<model::ColorSet> const& pNewColorSet)
+ : SdUndoAction(pDocument)
+ , mpMasterPage(pMasterPage)
+ , mpOldColorSet(pOldColorSet)
+ , mpNewColorSet(pNewColorSet)
+{
+ SetComment(SvxResId(RID_SVXSTR_UNDO_THEME_COLOR_CHANGE));
+}
+
+namespace
+{
+std::shared_ptr<model::Theme> getTheme(SdrPage* pMasterPage)
+{
+ auto pTheme = pMasterPage->getSdrPageProperties().getTheme();
+ if (!pTheme)
+ {
+ pTheme = std::make_shared<model::Theme>("Office");
+ pMasterPage->getSdrPageProperties().setTheme(pTheme);
+ }
+ return pTheme;
+}
+}
+
+void UndoThemeChange::Undo()
+{
+ auto pTheme = getTheme(mpMasterPage);
+ pTheme->setColorSet(mpOldColorSet);
+}
+
+void UndoThemeChange::Redo()
+{
+ auto pTheme = getTheme(mpMasterPage);
+ pTheme->setColorSet(mpNewColorSet);
+}
+
+} // end sd namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */