1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unmodpg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include <svx/svdlayer.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <sfx2/viewfrm.hxx>
41 #include "strings.hrc"
43 #include "glob.hrc" // STR_BCKGRND, STR_BCKGRNDOBJ
44 #include "app.hrc" // SID_SWITCHPAGE
46 #include "unmodpg.hxx"
48 #include "sdresid.hxx"
49 #include "drawdoc.hxx"
52 TYPEINIT1(ModifyPageUndoAction
, SdUndoAction
);
55 /*************************************************************************
59 \************************************************************************/
61 ModifyPageUndoAction::ModifyPageUndoAction(
62 SfxUndoManager
* pTheManager
, // #67720#
63 SdDrawDocument
* pTheDoc
,
66 AutoLayout eTheNewAutoLayout
,
67 BOOL bTheNewBckgrndVisible
,
68 BOOL bTheNewBckgrndObjsVisible
)
69 : SdUndoAction(pTheDoc
),
70 mpManager(pTheManager
)
72 DBG_ASSERT(pThePage
, "Undo ohne Seite ???");
75 maNewName
= aTheNewName
;
76 meNewAutoLayout
= eTheNewAutoLayout
;
77 mbNewBckgrndVisible
= bTheNewBckgrndVisible
;
78 mbNewBckgrndObjsVisible
= bTheNewBckgrndObjsVisible
;
80 meOldAutoLayout
= mpPage
->GetAutoLayout();
82 if (!mpPage
->IsMasterPage())
84 maOldName
= mpPage
->GetName();
85 SdrLayerAdmin
& rLayerAdmin
= mpDoc
->GetLayerAdmin();
86 BYTE aBckgrnd
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRND
)), FALSE
);
87 BYTE aBckgrndObj
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), FALSE
);
88 SetOfByte aVisibleLayers
= mpPage
->TRG_GetMasterPageVisibleLayers();
90 mbOldBckgrndVisible
= aVisibleLayers
.IsSet(aBckgrnd
);
91 mbOldBckgrndObjsVisible
= aVisibleLayers
.IsSet(aBckgrndObj
);
94 maComment
= String(SdResId(STR_UNDO_MODIFY_PAGE
));
97 /*************************************************************************
101 \************************************************************************/
102 #include <svx/svdviter.hxx>
103 #include <svx/svdview.hxx>
104 void ModifyPageUndoAction::Undo()
106 // #94637# invalidate Selection, there could be objects deleted in tis UNDO
107 // which are no longer allowed to be selected then.
108 SdrViewIter
aIter(mpPage
);
109 SdrView
* pView
= aIter
.FirstView();
113 if(pView
->AreObjectsMarked())
115 pView
= aIter
.NextView();
118 mpPage
->SetAutoLayout( meOldAutoLayout
);
120 if (!mpPage
->IsMasterPage())
122 if (mpPage
->GetName() != maOldName
)
124 mpPage
->SetName(maOldName
);
126 if (mpPage
->GetPageKind() == PK_STANDARD
)
128 SdPage
* pNotesPage
= (SdPage
*)mpDoc
->GetPage(mpPage
->GetPageNum() + 1);
129 pNotesPage
->SetName(maOldName
);
133 SdrLayerAdmin
& rLayerAdmin
= mpDoc
->GetLayerAdmin();
134 BYTE aBckgrnd
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRND
)), FALSE
);
135 BYTE aBckgrndObj
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), FALSE
);
136 SetOfByte aVisibleLayers
;
137 aVisibleLayers
.Set(aBckgrnd
, mbOldBckgrndVisible
);
138 aVisibleLayers
.Set(aBckgrndObj
, mbOldBckgrndObjsVisible
);
139 mpPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
143 SfxViewFrame::Current()->GetDispatcher()->Execute(
144 SID_SWITCHPAGE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
147 /*************************************************************************
151 \************************************************************************/
153 void ModifyPageUndoAction::Redo()
155 // #94637# invalidate Selection, there could be objects deleted in tis UNDO
156 // which are no longer allowed to be selected then.
157 SdrViewIter
aIter(mpPage
);
158 SdrView
* pView
= aIter
.FirstView();
162 if(pView
->AreObjectsMarked())
164 pView
= aIter
.NextView();
167 mpPage
->meAutoLayout
= meNewAutoLayout
;
169 if (!mpPage
->IsMasterPage())
171 if (mpPage
->GetName() != maNewName
)
173 mpPage
->SetName(maNewName
);
175 if (mpPage
->GetPageKind() == PK_STANDARD
)
177 SdPage
* pNotesPage
= (SdPage
*)mpDoc
->GetPage(mpPage
->GetPageNum() + 1);
178 pNotesPage
->SetName(maNewName
);
182 SdrLayerAdmin
& rLayerAdmin
= mpDoc
->GetLayerAdmin();
183 BYTE aBckgrnd
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRND
)), FALSE
);
184 BYTE aBckgrndObj
= rLayerAdmin
.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ
)), FALSE
);
185 SetOfByte aVisibleLayers
;
186 aVisibleLayers
.Set(aBckgrnd
, mbNewBckgrndVisible
);
187 aVisibleLayers
.Set(aBckgrndObj
, mbNewBckgrndObjsVisible
);
188 mpPage
->TRG_SetMasterPageVisibleLayers(aVisibleLayers
);
192 SfxViewFrame::Current()->GetDispatcher()->Execute(
193 SID_SWITCHPAGE
, SFX_CALLMODE_ASYNCHRON
| SFX_CALLMODE_RECORD
);
196 /*************************************************************************
200 \************************************************************************/
202 ModifyPageUndoAction::~ModifyPageUndoAction()
206 /*************************************************************************
210 \************************************************************************/
212 String
ModifyPageUndoAction::GetComment() const
217 // --------------------------------------------------------------------
219 RenameLayoutTemplateUndoAction::RenameLayoutTemplateUndoAction( SdDrawDocument
* pDocument
, const String
& rOldLayoutName
, const String
& rNewLayoutName
)
220 : SdUndoAction(pDocument
)
221 , maOldName( rOldLayoutName
)
222 , maNewName( rNewLayoutName
)
223 , maComment(SdResId(STR_TITLE_RENAMESLIDE
))
225 USHORT nPos
= maOldName
.SearchAscii( SD_LT_SEPARATOR
);
226 if( nPos
!= (USHORT
)-1 )
227 maOldName
.Erase(nPos
);
230 void RenameLayoutTemplateUndoAction::Undo()
232 String
aLayoutName( maNewName
);
233 aLayoutName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR
));
234 aLayoutName
.Append( String(SdResId(STR_LAYOUT_OUTLINE
))) ;
236 mpDoc
->RenameLayoutTemplate( aLayoutName
, maOldName
);
239 void RenameLayoutTemplateUndoAction::Redo()
241 String
aLayoutName( maOldName
);
242 aLayoutName
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR
));
243 aLayoutName
.Append( String(SdResId(STR_LAYOUT_OUTLINE
))) ;
245 mpDoc
->RenameLayoutTemplate( aLayoutName
, maNewName
);
248 String
RenameLayoutTemplateUndoAction::GetComment() const