1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10*5b190011SAndrew Rist *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19*5b190011SAndrew Rist *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #ifndef _SVDLAYER
28cdf0e10cSrcweir #include <svx/svdlayer.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
31cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include "strings.hrc"
35cdf0e10cSrcweir #include "glob.hxx"
36cdf0e10cSrcweir #include "glob.hrc" // STR_BCKGRND, STR_BCKGRNDOBJ
37cdf0e10cSrcweir #include "app.hrc" // SID_SWITCHPAGE
38cdf0e10cSrcweir
39cdf0e10cSrcweir #include "unmodpg.hxx"
40cdf0e10cSrcweir #include "sdpage.hxx"
41cdf0e10cSrcweir #include "sdresid.hxx"
42cdf0e10cSrcweir #include "drawdoc.hxx"
43cdf0e10cSrcweir
44cdf0e10cSrcweir
45cdf0e10cSrcweir TYPEINIT1(ModifyPageUndoAction, SdUndoAction);
46cdf0e10cSrcweir
47cdf0e10cSrcweir
48cdf0e10cSrcweir /*************************************************************************
49cdf0e10cSrcweir |*
50cdf0e10cSrcweir |* Konstruktor
51cdf0e10cSrcweir |*
52cdf0e10cSrcweir \************************************************************************/
53cdf0e10cSrcweir
ModifyPageUndoAction(SdDrawDocument * pTheDoc,SdPage * pThePage,String aTheNewName,AutoLayout eTheNewAutoLayout,sal_Bool bTheNewBckgrndVisible,sal_Bool bTheNewBckgrndObjsVisible)54cdf0e10cSrcweir ModifyPageUndoAction::ModifyPageUndoAction(
55cdf0e10cSrcweir SdDrawDocument* pTheDoc,
56cdf0e10cSrcweir SdPage* pThePage,
57cdf0e10cSrcweir String aTheNewName,
58cdf0e10cSrcweir AutoLayout eTheNewAutoLayout,
59cdf0e10cSrcweir sal_Bool bTheNewBckgrndVisible,
60cdf0e10cSrcweir sal_Bool bTheNewBckgrndObjsVisible)
61cdf0e10cSrcweir : SdUndoAction(pTheDoc)
62cdf0e10cSrcweir {
63cdf0e10cSrcweir DBG_ASSERT(pThePage, "Undo ohne Seite ???");
64cdf0e10cSrcweir
65cdf0e10cSrcweir mpPage = pThePage;
66cdf0e10cSrcweir maNewName = aTheNewName;
67cdf0e10cSrcweir meNewAutoLayout = eTheNewAutoLayout;
68cdf0e10cSrcweir mbNewBckgrndVisible = bTheNewBckgrndVisible;
69cdf0e10cSrcweir mbNewBckgrndObjsVisible = bTheNewBckgrndObjsVisible;
70cdf0e10cSrcweir
71cdf0e10cSrcweir meOldAutoLayout = mpPage->GetAutoLayout();
72cdf0e10cSrcweir
73cdf0e10cSrcweir if (!mpPage->IsMasterPage())
74cdf0e10cSrcweir {
75cdf0e10cSrcweir maOldName = mpPage->GetName();
76cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
77cdf0e10cSrcweir sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
78cdf0e10cSrcweir sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
79cdf0e10cSrcweir SetOfByte aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers();
80cdf0e10cSrcweir
81cdf0e10cSrcweir mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd);
82cdf0e10cSrcweir mbOldBckgrndObjsVisible = aVisibleLayers.IsSet(aBckgrndObj);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
85cdf0e10cSrcweir maComment = String(SdResId(STR_UNDO_MODIFY_PAGE));
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir /*************************************************************************
89cdf0e10cSrcweir |*
90cdf0e10cSrcweir |* Undo()
91cdf0e10cSrcweir |*
92cdf0e10cSrcweir \************************************************************************/
93cdf0e10cSrcweir #include <svx/svdviter.hxx>
94cdf0e10cSrcweir #include <svx/svdview.hxx>
Undo()95cdf0e10cSrcweir void ModifyPageUndoAction::Undo()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir // #94637# invalidate Selection, there could be objects deleted in tis UNDO
98cdf0e10cSrcweir // which are no longer allowed to be selected then.
99cdf0e10cSrcweir SdrViewIter aIter(mpPage);
100cdf0e10cSrcweir SdrView* pView = aIter.FirstView();
101cdf0e10cSrcweir
102cdf0e10cSrcweir while(pView)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir if(pView->AreObjectsMarked())
105cdf0e10cSrcweir pView->UnmarkAll();
106cdf0e10cSrcweir pView = aIter.NextView();
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
109cdf0e10cSrcweir mpPage->SetAutoLayout( meOldAutoLayout );
110cdf0e10cSrcweir
111cdf0e10cSrcweir if (!mpPage->IsMasterPage())
112cdf0e10cSrcweir {
113cdf0e10cSrcweir if (mpPage->GetName() != maOldName)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir mpPage->SetName(maOldName);
116cdf0e10cSrcweir
117cdf0e10cSrcweir if (mpPage->GetPageKind() == PK_STANDARD)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
120cdf0e10cSrcweir pNotesPage->SetName(maOldName);
121cdf0e10cSrcweir }
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
125cdf0e10cSrcweir sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
126cdf0e10cSrcweir sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
127cdf0e10cSrcweir SetOfByte aVisibleLayers;
128cdf0e10cSrcweir aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible);
129cdf0e10cSrcweir aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible);
130cdf0e10cSrcweir mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir // Redisplay
134cdf0e10cSrcweir SfxViewFrame::Current()->GetDispatcher()->Execute(
135cdf0e10cSrcweir SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir /*************************************************************************
139cdf0e10cSrcweir |*
140cdf0e10cSrcweir |* Redo()
141cdf0e10cSrcweir |*
142cdf0e10cSrcweir \************************************************************************/
143cdf0e10cSrcweir
Redo()144cdf0e10cSrcweir void ModifyPageUndoAction::Redo()
145cdf0e10cSrcweir {
146cdf0e10cSrcweir // #94637# invalidate Selection, there could be objects deleted in tis UNDO
147cdf0e10cSrcweir // which are no longer allowed to be selected then.
148cdf0e10cSrcweir SdrViewIter aIter(mpPage);
149cdf0e10cSrcweir SdrView* pView = aIter.FirstView();
150cdf0e10cSrcweir
151cdf0e10cSrcweir while(pView)
152cdf0e10cSrcweir {
153cdf0e10cSrcweir if(pView->AreObjectsMarked())
154cdf0e10cSrcweir pView->UnmarkAll();
155cdf0e10cSrcweir pView = aIter.NextView();
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir mpPage->meAutoLayout = meNewAutoLayout;
159cdf0e10cSrcweir
160cdf0e10cSrcweir if (!mpPage->IsMasterPage())
161cdf0e10cSrcweir {
162cdf0e10cSrcweir if (mpPage->GetName() != maNewName)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir mpPage->SetName(maNewName);
165cdf0e10cSrcweir
166cdf0e10cSrcweir if (mpPage->GetPageKind() == PK_STANDARD)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
169cdf0e10cSrcweir pNotesPage->SetName(maNewName);
170cdf0e10cSrcweir }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
174cdf0e10cSrcweir sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
175cdf0e10cSrcweir sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
176cdf0e10cSrcweir SetOfByte aVisibleLayers;
177cdf0e10cSrcweir aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible);
178cdf0e10cSrcweir aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible);
179cdf0e10cSrcweir mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir // Redisplay
183cdf0e10cSrcweir SfxViewFrame::Current()->GetDispatcher()->Execute(
184cdf0e10cSrcweir SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
185cdf0e10cSrcweir }
186cdf0e10cSrcweir
187cdf0e10cSrcweir /*************************************************************************
188cdf0e10cSrcweir |*
189cdf0e10cSrcweir |* Destruktor
190cdf0e10cSrcweir |*
191cdf0e10cSrcweir \************************************************************************/
192cdf0e10cSrcweir
~ModifyPageUndoAction()193cdf0e10cSrcweir ModifyPageUndoAction::~ModifyPageUndoAction()
194cdf0e10cSrcweir {
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir /*************************************************************************
198cdf0e10cSrcweir |*
199cdf0e10cSrcweir |* Kommentar liefern
200cdf0e10cSrcweir |*
201cdf0e10cSrcweir \************************************************************************/
202cdf0e10cSrcweir
GetComment() const203cdf0e10cSrcweir String ModifyPageUndoAction::GetComment() const
204cdf0e10cSrcweir {
205cdf0e10cSrcweir return maComment;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir
208cdf0e10cSrcweir // --------------------------------------------------------------------
209cdf0e10cSrcweir
RenameLayoutTemplateUndoAction(SdDrawDocument * pDocument,const String & rOldLayoutName,const String & rNewLayoutName)210cdf0e10cSrcweir RenameLayoutTemplateUndoAction::RenameLayoutTemplateUndoAction( SdDrawDocument* pDocument, const String& rOldLayoutName, const String& rNewLayoutName )
211cdf0e10cSrcweir : SdUndoAction(pDocument)
212cdf0e10cSrcweir , maOldName( rOldLayoutName )
213cdf0e10cSrcweir , maNewName( rNewLayoutName )
214cdf0e10cSrcweir , maComment(SdResId(STR_TITLE_RENAMESLIDE))
215cdf0e10cSrcweir {
216cdf0e10cSrcweir sal_uInt16 nPos = maOldName.SearchAscii( SD_LT_SEPARATOR );
217cdf0e10cSrcweir if( nPos != (sal_uInt16)-1 )
218cdf0e10cSrcweir maOldName.Erase(nPos);
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
Undo()221cdf0e10cSrcweir void RenameLayoutTemplateUndoAction::Undo()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir String aLayoutName( maNewName );
224cdf0e10cSrcweir aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
225cdf0e10cSrcweir aLayoutName.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
226cdf0e10cSrcweir
227cdf0e10cSrcweir mpDoc->RenameLayoutTemplate( aLayoutName, maOldName );
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
Redo()230cdf0e10cSrcweir void RenameLayoutTemplateUndoAction::Redo()
231cdf0e10cSrcweir {
232cdf0e10cSrcweir String aLayoutName( maOldName );
233cdf0e10cSrcweir aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
234cdf0e10cSrcweir aLayoutName.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
235cdf0e10cSrcweir
236cdf0e10cSrcweir mpDoc->RenameLayoutTemplate( aLayoutName, maNewName );
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
GetComment() const239cdf0e10cSrcweir String RenameLayoutTemplateUndoAction::GetComment() const
240cdf0e10cSrcweir {
241cdf0e10cSrcweir return maComment;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir
244