LibreOffice Module sc (master) 1
UndoThemeChange.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
12#include <svx/svdpage.hxx>
13#include <scresid.hxx>
14#include <globstr.hrc>
15
16namespace sc
17{
19 std::shared_ptr<model::ColorSet> const& pOldColorSet,
20 std::shared_ptr<model::ColorSet> const& pNewColorSet)
21 : ScSimpleUndo(&rDocShell)
22 , mpOldColorSet(pOldColorSet)
23 , mpNewColorSet(pNewColorSet)
24{
25}
26
28
30{
31 BeginUndo();
32
33 ScDocument& rDocument = pDocShell->GetDocument();
34 ScDrawLayer* pModel = rDocument.GetDrawLayer();
35 SdrPage* pPage = pModel->GetPage(0);
36
37 auto pTheme = pPage->getSdrPageProperties().GetTheme();
38 if (!pTheme)
39 {
40 pTheme = std::make_shared<model::Theme>("Office");
41 pPage->getSdrPageProperties().SetTheme(pTheme);
42 }
43 pTheme->setColorSet(mpOldColorSet);
44
45 EndUndo();
46}
47
49{
50 BeginRedo();
51
52 ScDocument& rDocument = pDocShell->GetDocument();
53 ScDrawLayer* pModel = rDocument.GetDrawLayer();
54 SdrPage* pPage = pModel->GetPage(0);
55
56 auto pTheme = pPage->getSdrPageProperties().GetTheme();
57 if (!pTheme)
58 {
59 pTheme = std::make_shared<model::Theme>("Office");
60 pPage->getSdrPageProperties().SetTheme(pTheme);
61 }
62 pTheme->setColorSet(mpNewColorSet);
63
64 EndRedo();
65}
66
67void UndoThemeChange::Repeat(SfxRepeatTarget& /*rTarget*/) {}
68
69bool UndoThemeChange::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; }
70
71OUString UndoThemeChange::GetComment() const { return ScResId(STR_UNDO_THEME_CHANGE); }
72
73} // end sc namespace
74
75/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1084
void BeginRedo()
Definition: undobase.cxx:145
void EndRedo()
Definition: undobase.cxx:154
void EndUndo()
Definition: undobase.cxx:125
ScDocShell * pDocShell
Definition: undobase.hxx:50
void BeginUndo()
Definition: undobase.cxx:90
const SdrPage * GetPage(sal_uInt16 nPgNum) const
std::shared_ptr< model::Theme > const & GetTheme() const
void SetTheme(std::shared_ptr< model::Theme > const &pTheme)
SdrPageProperties & getSdrPageProperties()
void Undo() override
std::shared_ptr< model::ColorSet > mpOldColorSet
void Repeat(SfxRepeatTarget &rTarget) override
void Redo() override
virtual ~UndoThemeChange() override
UndoThemeChange(ScDocShell &rDocShell, std::shared_ptr< model::ColorSet > const &pOldColorSet, std::shared_ptr< model::ColorSet > const &pNewColorSet)
std::shared_ptr< model::ColorSet > mpNewColorSet
bool CanRepeat(SfxRepeatTarget &rTarget) const override
OUString GetComment() const override
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90