LibreOffice Module sc (master)
1
sc
source
ui
undo
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
10
#include <
undo/UndoThemeChange.hxx
>
11
#include <
docmodel/theme/Theme.hxx
>
12
#include <
svx/svdpage.hxx
>
13
#include <
scresid.hxx
>
14
#include <globstr.hrc>
15
16
namespace
sc
17
{
18
UndoThemeChange::UndoThemeChange
(
ScDocShell
& rDocShell,
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
27
UndoThemeChange::~UndoThemeChange
() =
default
;
28
29
void
UndoThemeChange::Undo
()
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
48
void
UndoThemeChange::Redo
()
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
67
void
UndoThemeChange::Repeat
(SfxRepeatTarget&
/*rTarget*/
) {}
68
69
bool
UndoThemeChange::CanRepeat
(SfxRepeatTarget&
/*rTarget*/
)
const
{
return
false
; }
70
71
OUString
UndoThemeChange::GetComment
()
const
{
return
ScResId
(STR_UNDO_THEME_CHANGE); }
72
73
}
// end sc namespace
74
75
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Theme.hxx
UndoThemeChange.hxx
ScDocShell
Definition:
docsh.hxx:81
ScDocShell::GetDocument
const ScDocument & GetDocument() const
Definition:
docsh.hxx:219
ScDocument
Definition:
document.hxx:323
ScDocument::GetDrawLayer
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition:
document.hxx:1084
ScDrawLayer
Definition:
drwlayer.hxx:98
ScSimpleUndo
Definition:
undobase.hxx:35
ScSimpleUndo::BeginRedo
void BeginRedo()
Definition:
undobase.cxx:145
ScSimpleUndo::EndRedo
void EndRedo()
Definition:
undobase.cxx:154
ScSimpleUndo::EndUndo
void EndUndo()
Definition:
undobase.cxx:125
ScSimpleUndo::pDocShell
ScDocShell * pDocShell
Definition:
undobase.hxx:50
ScSimpleUndo::BeginUndo
void BeginUndo()
Definition:
undobase.cxx:90
SdrModel::GetPage
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrPageProperties::GetTheme
std::shared_ptr< model::Theme > const & GetTheme() const
SdrPageProperties::SetTheme
void SetTheme(std::shared_ptr< model::Theme > const &pTheme)
SdrPage
SdrPage::getSdrPageProperties
SdrPageProperties & getSdrPageProperties()
sc::UndoThemeChange::Undo
void Undo() override
Definition:
UndoThemeChange.cxx:29
sc::UndoThemeChange::mpOldColorSet
std::shared_ptr< model::ColorSet > mpOldColorSet
Definition:
UndoThemeChange.hxx:19
sc::UndoThemeChange::Repeat
void Repeat(SfxRepeatTarget &rTarget) override
Definition:
UndoThemeChange.cxx:67
sc::UndoThemeChange::Redo
void Redo() override
Definition:
UndoThemeChange.cxx:48
sc::UndoThemeChange::~UndoThemeChange
virtual ~UndoThemeChange() override
sc::UndoThemeChange::UndoThemeChange
UndoThemeChange(ScDocShell &rDocShell, std::shared_ptr< model::ColorSet > const &pOldColorSet, std::shared_ptr< model::ColorSet > const &pNewColorSet)
Definition:
UndoThemeChange.cxx:18
sc::UndoThemeChange::mpNewColorSet
std::shared_ptr< model::ColorSet > mpNewColorSet
Definition:
UndoThemeChange.hxx:20
sc::UndoThemeChange::CanRepeat
bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition:
UndoThemeChange.cxx:69
sc::UndoThemeChange::GetComment
OUString GetComment() const override
Definition:
UndoThemeChange.cxx:71
sc
CAUTION! The following defines must be in the same namespace as the respective type.
Definition:
broadcast.cxx:15
ScResId
OUString ScResId(TranslateId aId)
Definition:
scdll.cxx:90
scresid.hxx
svdpage.hxx
Generated on Sun Jul 30 2023 04:29:31 for LibreOffice Module sc (master) by
1.9.3