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