/src/libreoffice/sc/source/ui/undo/UndoThemeChange.cxx
Line | Count | Source |
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 | | |
10 | | #include <undo/UndoThemeChange.hxx> |
11 | | #include <docmodel/theme/Theme.hxx> |
12 | | #include <scresid.hxx> |
13 | | #include <globstr.hrc> |
14 | | |
15 | | namespace sc |
16 | | { |
17 | | UndoThemeChange::UndoThemeChange(ScDocShell& rShell, |
18 | | std::shared_ptr<model::ColorSet> const& pOldColorSet, |
19 | | std::shared_ptr<model::ColorSet> const& pNewColorSet) |
20 | 0 | : ScSimpleUndo(rShell) |
21 | 0 | , mpOldColorSet(pOldColorSet) |
22 | 0 | , mpNewColorSet(pNewColorSet) |
23 | 0 | { |
24 | 0 | } |
25 | | |
26 | 0 | UndoThemeChange::~UndoThemeChange() = default; |
27 | | |
28 | | namespace |
29 | | { |
30 | | std::shared_ptr<model::Theme> getTheme(ScDocShell& rDocShell) |
31 | 0 | { |
32 | 0 | ScDrawLayer* pModel = rDocShell.GetDocument().GetDrawLayer(); |
33 | |
|
34 | 0 | auto pTheme = pModel->getTheme(); |
35 | 0 | if (!pTheme) |
36 | 0 | { |
37 | 0 | pTheme = std::make_shared<model::Theme>("Office"); |
38 | 0 | pModel->setTheme(pTheme); |
39 | 0 | } |
40 | 0 | return pTheme; |
41 | 0 | } |
42 | | } |
43 | | |
44 | | void UndoThemeChange::Undo() |
45 | 0 | { |
46 | 0 | BeginUndo(); |
47 | |
|
48 | 0 | auto pTheme = getTheme(rDocShell); |
49 | 0 | pTheme->setColorSet(mpOldColorSet); |
50 | |
|
51 | 0 | EndUndo(); |
52 | 0 | } |
53 | | |
54 | | void UndoThemeChange::Redo() |
55 | 0 | { |
56 | 0 | BeginUndo(); |
57 | |
|
58 | 0 | auto pTheme = getTheme(rDocShell); |
59 | 0 | pTheme->setColorSet(mpNewColorSet); |
60 | |
|
61 | 0 | EndRedo(); |
62 | 0 | } |
63 | | |
64 | 0 | void UndoThemeChange::Repeat(SfxRepeatTarget& /*rTarget*/) {} |
65 | | |
66 | 0 | bool UndoThemeChange::CanRepeat(SfxRepeatTarget& /*rTarget*/) const { return false; } |
67 | | |
68 | 0 | OUString UndoThemeChange::GetComment() const { return ScResId(STR_UNDO_THEME_CHANGE); } |
69 | | |
70 | | } // end sc namespace |
71 | | |
72 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |