/src/libreoffice/sd/source/ui/dlg/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 <UndoThemeChange.hxx> |
11 | | #include <svx/dialmgr.hxx> |
12 | | #include <svx/strings.hrc> |
13 | | |
14 | | namespace sd |
15 | | { |
16 | | UndoThemeChange::UndoThemeChange(SdDrawDocument& rDocument, SdrPage* pMasterPage, |
17 | | std::shared_ptr<model::ColorSet> const& pOldColorSet, |
18 | | std::shared_ptr<model::ColorSet> const& pNewColorSet) |
19 | 0 | : SdUndoAction(rDocument) |
20 | 0 | , mpMasterPage(pMasterPage) |
21 | 0 | , mpOldColorSet(pOldColorSet) |
22 | 0 | , mpNewColorSet(pNewColorSet) |
23 | 0 | { |
24 | 0 | SetComment(SvxResId(RID_SVXSTR_UNDO_THEME_COLOR_CHANGE)); |
25 | 0 | } |
26 | | |
27 | | namespace |
28 | | { |
29 | | std::shared_ptr<model::Theme> getTheme(SdrPage* pMasterPage) |
30 | 0 | { |
31 | 0 | auto pTheme = pMasterPage->getSdrPageProperties().getTheme(); |
32 | 0 | if (!pTheme) |
33 | 0 | { |
34 | 0 | pTheme = std::make_shared<model::Theme>("Office"); |
35 | 0 | pMasterPage->getSdrPageProperties().setTheme(pTheme); |
36 | 0 | } |
37 | 0 | return pTheme; |
38 | 0 | } |
39 | | } |
40 | | |
41 | | void UndoThemeChange::Undo() |
42 | 0 | { |
43 | 0 | auto pTheme = getTheme(mpMasterPage); |
44 | 0 | pTheme->setColorSet(mpOldColorSet); |
45 | 0 | } |
46 | | |
47 | | void UndoThemeChange::Redo() |
48 | 0 | { |
49 | 0 | auto pTheme = getTheme(mpMasterPage); |
50 | 0 | pTheme->setColorSet(mpNewColorSet); |
51 | 0 | } |
52 | | |
53 | | } // end sd namespace |
54 | | |
55 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |