summaryrefslogtreecommitdiffstats
path: root/sw/source/core/undo/UndoThemeChange.cxx
blob: 8e26106873e736d88b6cb96f7da03f2021c52a9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* -*- 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/svdpage.hxx>
#include <docmodel/theme/Theme.hxx>
#include <doc.hxx>
#include <drawdoc.hxx>
#include <IDocumentDrawModelAccess.hxx>

#include <memory>

namespace sw
{
UndoThemeChange::UndoThemeChange(SwDoc& rDocument,
                                 std::shared_ptr<model::ColorSet> const& pOldColorSet,
                                 std::shared_ptr<model::ColorSet> const& pNewColorSet)
    : SwUndo(SwUndoId::CHANGE_THEME, &rDocument)
    , mrDocument(rDocument)
    , mpOldColorSet(pOldColorSet)
    , mpNewColorSet(pNewColorSet)
{
}

UndoThemeChange::~UndoThemeChange() {}

void UndoThemeChange::UndoImpl(UndoRedoContext& /*rUndoRedoContext*/)
{
    SdrModel* pModel = mrDocument.getIDocumentDrawModelAccess().GetDrawModel();
    auto pTheme = pModel->getTheme();
    pTheme->setColorSet(mpOldColorSet);
}

void UndoThemeChange::RedoImpl(UndoRedoContext& /*rUndoRedoContext*/)
{
    SdrModel* pModel = mrDocument.getIDocumentDrawModelAccess().GetDrawModel();
    auto pTheme = pModel->getTheme();
    pTheme->setColorSet(mpNewColorSet);
}
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */