Line data Source code
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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "undoback.hxx"
22 : #include "sdpage.hxx"
23 : #include "sdresid.hxx"
24 : #include "strings.hrc"
25 : #include <svl/itemset.hxx>
26 :
27 0 : TYPEINIT1( SdBackgroundObjUndoAction, SdUndoAction );
28 :
29 :
30 :
31 0 : SdBackgroundObjUndoAction::SdBackgroundObjUndoAction(
32 : SdDrawDocument& rDoc,
33 : SdPage& rPage,
34 : const SfxItemSet& rItenSet)
35 : : SdUndoAction(&rDoc),
36 : mrPage(rPage),
37 0 : mpItemSet(new SfxItemSet(rItenSet))
38 : {
39 0 : OUString aString( SdResId( STR_UNDO_CHANGE_PAGEFORMAT ) );
40 0 : SetComment( aString );
41 0 : }
42 :
43 :
44 :
45 0 : SdBackgroundObjUndoAction::~SdBackgroundObjUndoAction()
46 : {
47 0 : delete mpItemSet;
48 0 : }
49 :
50 :
51 :
52 0 : void SdBackgroundObjUndoAction::ImplRestoreBackgroundObj()
53 : {
54 0 : SfxItemSet* pNew = new SfxItemSet(mrPage.getSdrPageProperties().GetItemSet());
55 0 : mrPage.getSdrPageProperties().ClearItem();
56 0 : mrPage.getSdrPageProperties().PutItemSet(*mpItemSet);
57 0 : delete mpItemSet;
58 0 : mpItemSet = pNew;
59 :
60 : // tell the page that it's visualization has changed
61 0 : mrPage.ActionChanged();
62 0 : }
63 :
64 :
65 :
66 0 : void SdBackgroundObjUndoAction::Undo()
67 : {
68 0 : ImplRestoreBackgroundObj();
69 0 : }
70 :
71 :
72 :
73 0 : void SdBackgroundObjUndoAction::Redo()
74 : {
75 0 : ImplRestoreBackgroundObj();
76 0 : }
77 :
78 :
79 :
80 0 : SdUndoAction* SdBackgroundObjUndoAction::Clone() const
81 : {
82 0 : return new SdBackgroundObjUndoAction(*mpDoc, mrPage, *mpItemSet);
83 : }
84 :
85 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|