1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include <undo/UndoThemeChange.hxx>
11 #include <docmodel/theme/Theme.hxx>
12 #include <scresid.hxx>
13 #include <globstr.hrc>
17 UndoThemeChange::UndoThemeChange(ScDocShell
& rDocShell
,
18 std::shared_ptr
<model::ColorSet
> const& pOldColorSet
,
19 std::shared_ptr
<model::ColorSet
> const& pNewColorSet
)
20 : ScSimpleUndo(&rDocShell
)
21 , mpOldColorSet(pOldColorSet
)
22 , mpNewColorSet(pNewColorSet
)
26 UndoThemeChange::~UndoThemeChange() = default;
30 std::shared_ptr
<model::Theme
> getTheme(ScDocShell
& rDocShell
)
32 ScDrawLayer
* pModel
= rDocShell
.GetDocument().GetDrawLayer();
34 auto pTheme
= pModel
->getTheme();
37 pTheme
= std::make_shared
<model::Theme
>("Office");
38 pModel
->setTheme(pTheme
);
44 void UndoThemeChange::Undo()
48 auto pTheme
= getTheme(*pDocShell
);
49 pTheme
->setColorSet(mpOldColorSet
);
54 void UndoThemeChange::Redo()
58 auto pTheme
= getTheme(*pDocShell
);
59 pTheme
->setColorSet(mpNewColorSet
);
64 void UndoThemeChange::Repeat(SfxRepeatTarget
& /*rTarget*/) {}
66 bool UndoThemeChange::CanRepeat(SfxRepeatTarget
& /*rTarget*/) const { return false; }
68 OUString
UndoThemeChange::GetComment() const { return ScResId(STR_UNDO_THEME_CHANGE
); }
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */