xref: /aoo41x/main/sd/source/ui/func/undoback.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "undoback.hxx"
28 #include "sdpage.hxx"
29 #include "sdresid.hxx"
30 #include "strings.hrc"
31 #include <svl/itemset.hxx>
32 
33 // ---------------------------
34 // - BackgroundObjUndoAction -
35 // ---------------------------
36 
37 TYPEINIT1( SdBackgroundObjUndoAction, SdUndoAction );
38 
39 // -----------------------------------------------------------------------------
40 
SdBackgroundObjUndoAction(SdDrawDocument & rDoc,SdPage & rPage,const SfxItemSet & rItenSet)41 SdBackgroundObjUndoAction::SdBackgroundObjUndoAction(
42     SdDrawDocument& rDoc,
43     SdPage& rPage,
44     const SfxItemSet& rItenSet)
45 :   SdUndoAction(&rDoc),
46     mrPage(rPage),
47     mpItemSet(new SfxItemSet(rItenSet))
48 {
49 	String aString( SdResId( STR_UNDO_CHANGE_PAGEFORMAT ) );
50 	SetComment( aString );
51 }
52 
53 // -----------------------------------------------------------------------------
54 
~SdBackgroundObjUndoAction()55 SdBackgroundObjUndoAction::~SdBackgroundObjUndoAction()
56 {
57     delete mpItemSet;
58 }
59 
60 // -----------------------------------------------------------------------------
61 
ImplRestoreBackgroundObj()62 void SdBackgroundObjUndoAction::ImplRestoreBackgroundObj()
63 {
64     SfxItemSet* pNew = new SfxItemSet(mrPage.getSdrPageProperties().GetItemSet());
65     mrPage.getSdrPageProperties().ClearItem();
66     mrPage.getSdrPageProperties().PutItemSet(*mpItemSet);
67     delete mpItemSet;
68     mpItemSet = pNew;
69 
70 	// #110094#-15
71 	// tell the page that it's visualization has changed
72 	mrPage.ActionChanged();
73 }
74 
75 // -----------------------------------------------------------------------------
76 
Undo()77 void SdBackgroundObjUndoAction::Undo()
78 {
79     ImplRestoreBackgroundObj();
80 }
81 
82 // -----------------------------------------------------------------------------
83 
Redo()84 void SdBackgroundObjUndoAction::Redo()
85 {
86     ImplRestoreBackgroundObj();
87 }
88 
89 // -----------------------------------------------------------------------------
90 
Clone() const91 SdUndoAction* SdBackgroundObjUndoAction::Clone() const
92 {
93     return new SdBackgroundObjUndoAction(*mpDoc, mrPage, *mpItemSet);
94 }
95