Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #ifndef _SVDLAYER
31 : : #include <svx/svdlayer.hxx>
32 : : #endif
33 : : #include <sfx2/dispatch.hxx>
34 : : #include <sfx2/viewfrm.hxx>
35 : :
36 : :
37 : : #include "strings.hrc"
38 : : #include "glob.hxx"
39 : : #include "glob.hrc" // STR_BCKGRND, STR_BCKGRNDOBJ
40 : : #include "app.hrc" // SID_SWITCHPAGE
41 : :
42 : : #include "unmodpg.hxx"
43 : : #include "sdpage.hxx"
44 : : #include "sdresid.hxx"
45 : : #include "drawdoc.hxx"
46 : :
47 : :
48 [ # # ][ # # ]: 0 : TYPEINIT1(ModifyPageUndoAction, SdUndoAction);
49 : :
50 : :
51 : : /*************************************************************************
52 : : |*
53 : : |* Konstruktor
54 : : |*
55 : : \************************************************************************/
56 : :
57 : 0 : ModifyPageUndoAction::ModifyPageUndoAction(
58 : : SdDrawDocument* pTheDoc,
59 : : SdPage* pThePage,
60 : : String aTheNewName,
61 : : AutoLayout eTheNewAutoLayout,
62 : : sal_Bool bTheNewBckgrndVisible,
63 : : sal_Bool bTheNewBckgrndObjsVisible)
64 [ # # ][ # # ]: 0 : : SdUndoAction(pTheDoc)
[ # # ]
65 : : {
66 : : DBG_ASSERT(pThePage, "Undo ohne Seite ???");
67 : :
68 : 0 : mpPage = pThePage;
69 [ # # ]: 0 : maNewName = aTheNewName;
70 : 0 : meNewAutoLayout = eTheNewAutoLayout;
71 : 0 : mbNewBckgrndVisible = bTheNewBckgrndVisible;
72 : 0 : mbNewBckgrndObjsVisible = bTheNewBckgrndObjsVisible;
73 : :
74 : 0 : meOldAutoLayout = mpPage->GetAutoLayout();
75 : :
76 [ # # ]: 0 : if (!mpPage->IsMasterPage())
77 : : {
78 [ # # ][ # # ]: 0 : maOldName = mpPage->GetName();
79 : 0 : SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
80 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
[ # # ][ # # ]
81 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
[ # # ][ # # ]
82 [ # # ]: 0 : SetOfByte aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers();
83 : :
84 : 0 : mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd);
85 : 0 : mbOldBckgrndObjsVisible = aVisibleLayers.IsSet(aBckgrndObj);
86 : : }
87 : :
88 [ # # ][ # # ]: 0 : maComment = String(SdResId(STR_UNDO_MODIFY_PAGE));
[ # # ][ # # ]
89 : 0 : }
90 : :
91 : : /*************************************************************************
92 : : |*
93 : : |* Undo()
94 : : |*
95 : : \************************************************************************/
96 : : #include <svx/svdviter.hxx>
97 : : #include <svx/svdview.hxx>
98 : 0 : void ModifyPageUndoAction::Undo()
99 : : {
100 : : // invalidate Selection, there could be objects deleted in tis UNDO
101 : : // which are no longer allowed to be selected then.
102 [ # # ]: 0 : SdrViewIter aIter(mpPage);
103 [ # # ]: 0 : SdrView* pView = aIter.FirstView();
104 : :
105 [ # # ]: 0 : while(pView)
106 : : {
107 [ # # ]: 0 : if(pView->AreObjectsMarked())
108 [ # # ]: 0 : pView->UnmarkAll();
109 [ # # ]: 0 : pView = aIter.NextView();
110 : : }
111 : :
112 [ # # ]: 0 : mpPage->SetAutoLayout( meOldAutoLayout );
113 : :
114 [ # # ]: 0 : if (!mpPage->IsMasterPage())
115 : : {
116 [ # # ][ # # ]: 0 : if (mpPage->GetName() != maOldName)
[ # # ]
117 : : {
118 [ # # ]: 0 : mpPage->SetName(maOldName);
119 : :
120 [ # # ]: 0 : if (mpPage->GetPageKind() == PK_STANDARD)
121 : : {
122 [ # # ][ # # ]: 0 : SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
123 [ # # ]: 0 : pNotesPage->SetName(maOldName);
124 : : }
125 : : }
126 : :
127 : 0 : SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
128 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
[ # # ][ # # ]
129 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
[ # # ][ # # ]
130 : 0 : SetOfByte aVisibleLayers;
131 : 0 : aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible);
132 : 0 : aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible);
133 [ # # ]: 0 : mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
134 : : }
135 : :
136 : : // Redisplay
137 : : SfxViewFrame::Current()->GetDispatcher()->Execute(
138 [ # # ][ # # ]: 0 : SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
139 : 0 : }
140 : :
141 : : /*************************************************************************
142 : : |*
143 : : |* Redo()
144 : : |*
145 : : \************************************************************************/
146 : :
147 : 0 : void ModifyPageUndoAction::Redo()
148 : : {
149 : : // invalidate Selection, there could be objects deleted in tis UNDO
150 : : // which are no longer allowed to be selected then.
151 [ # # ]: 0 : SdrViewIter aIter(mpPage);
152 [ # # ]: 0 : SdrView* pView = aIter.FirstView();
153 : :
154 [ # # ]: 0 : while(pView)
155 : : {
156 [ # # ]: 0 : if(pView->AreObjectsMarked())
157 [ # # ]: 0 : pView->UnmarkAll();
158 [ # # ]: 0 : pView = aIter.NextView();
159 : : }
160 : :
161 : 0 : mpPage->meAutoLayout = meNewAutoLayout;
162 : :
163 [ # # ]: 0 : if (!mpPage->IsMasterPage())
164 : : {
165 [ # # ][ # # ]: 0 : if (mpPage->GetName() != maNewName)
[ # # ]
166 : : {
167 [ # # ]: 0 : mpPage->SetName(maNewName);
168 : :
169 [ # # ]: 0 : if (mpPage->GetPageKind() == PK_STANDARD)
170 : : {
171 [ # # ][ # # ]: 0 : SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
172 [ # # ]: 0 : pNotesPage->SetName(maNewName);
173 : : }
174 : : }
175 : :
176 : 0 : SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
177 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
[ # # ][ # # ]
178 [ # # ][ # # ]: 0 : sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
[ # # ][ # # ]
179 : 0 : SetOfByte aVisibleLayers;
180 : 0 : aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible);
181 : 0 : aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible);
182 [ # # ]: 0 : mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
183 : : }
184 : :
185 : : // Redisplay
186 : : SfxViewFrame::Current()->GetDispatcher()->Execute(
187 [ # # ][ # # ]: 0 : SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
188 : 0 : }
189 : :
190 : : /*************************************************************************
191 : : |*
192 : : |* Destruktor
193 : : |*
194 : : \************************************************************************/
195 : :
196 [ # # ][ # # ]: 0 : ModifyPageUndoAction::~ModifyPageUndoAction()
[ # # ]
197 : : {
198 [ # # ]: 0 : }
199 : :
200 : : /*************************************************************************
201 : : |*
202 : : |* Kommentar liefern
203 : : |*
204 : : \************************************************************************/
205 : :
206 : 0 : rtl::OUString ModifyPageUndoAction::GetComment() const
207 : : {
208 : 0 : return maComment;
209 : : }
210 : :
211 : : // --------------------------------------------------------------------
212 : :
213 : 0 : RenameLayoutTemplateUndoAction::RenameLayoutTemplateUndoAction( SdDrawDocument* pDocument, const String& rOldLayoutName, const String& rNewLayoutName )
214 : : : SdUndoAction(pDocument)
215 : : , maOldName( rOldLayoutName )
216 : : , maNewName( rNewLayoutName )
217 [ # # ][ # # ]: 0 : , maComment(SdResId(STR_TITLE_RENAMESLIDE))
[ # # ][ # # ]
218 : : {
219 [ # # ]: 0 : sal_uInt16 nPos = maOldName.SearchAscii( SD_LT_SEPARATOR );
220 [ # # ]: 0 : if( nPos != (sal_uInt16)-1 )
221 [ # # ]: 0 : maOldName.Erase(nPos);
222 : 0 : }
223 : :
224 : 0 : void RenameLayoutTemplateUndoAction::Undo()
225 : : {
226 [ # # ]: 0 : String aLayoutName( maNewName );
227 [ # # ]: 0 : aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
228 [ # # ][ # # ]: 0 : aLayoutName.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
[ # # ][ # # ]
229 : :
230 [ # # ][ # # ]: 0 : mpDoc->RenameLayoutTemplate( aLayoutName, maOldName );
231 : 0 : }
232 : :
233 : 0 : void RenameLayoutTemplateUndoAction::Redo()
234 : : {
235 [ # # ]: 0 : String aLayoutName( maOldName );
236 [ # # ]: 0 : aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
237 [ # # ][ # # ]: 0 : aLayoutName.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
[ # # ][ # # ]
238 : :
239 [ # # ][ # # ]: 0 : mpDoc->RenameLayoutTemplate( aLayoutName, maNewName );
240 : 0 : }
241 : :
242 : 0 : rtl::OUString RenameLayoutTemplateUndoAction::GetComment() const
243 : : {
244 : 0 : return maComment;
245 : : }
246 : :
247 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|