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 10cdf0e10cSrcweir * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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 28cdf0e10cSrcweir #include "ViewShell.hxx" 29cdf0e10cSrcweir #include "GraphicViewShell.hxx" 30cdf0e10cSrcweir #include "GraphicViewShellBase.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 33cdf0e10cSrcweir #include <svtools/svtools.hrc> 34cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp> 35cdf0e10cSrcweir #include <svtools/svtdata.hxx> 36cdf0e10cSrcweir #include <utility> 37cdf0e10cSrcweir #include <vector> 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include "app.hrc" 40cdf0e10cSrcweir #include "strings.hrc" 41cdf0e10cSrcweir #include "res_bmp.hrc" 42cdf0e10cSrcweir #include "glob.hrc" 43cdf0e10cSrcweir #include "sdabstdlg.hxx" 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include "fupoor.hxx" 46cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 47cdf0e10cSrcweir #include <svx/prtqry.hxx> 48cdf0e10cSrcweir #include <svx/svdopage.hxx> 49cdf0e10cSrcweir #include <sfx2/progress.hxx> 50cdf0e10cSrcweir #include <svx/svdobj.hxx> 51cdf0e10cSrcweir #include <vcl/msgbox.hxx> 52cdf0e10cSrcweir #include <sfx2/bindings.hxx> 53cdf0e10cSrcweir #include <svx/svdpagv.hxx> 54cdf0e10cSrcweir #include <svx/svdetc.hxx> 55cdf0e10cSrcweir #include <editeng/outliner.hxx> 56cdf0e10cSrcweir #include <editeng/editstat.hxx> 57cdf0e10cSrcweir #include <tools/multisel.hxx> 58cdf0e10cSrcweir #include <svl/intitem.hxx> 59cdf0e10cSrcweir #include <svl/style.hxx> 60cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx> 61cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 62cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 63cdf0e10cSrcweir #include "stlsheet.hxx" 64cdf0e10cSrcweir #ifndef SD_WINDOW_UPDATER_HXX 65cdf0e10cSrcweir #include "WindowUpdater.hxx" 66cdf0e10cSrcweir #endif 67cdf0e10cSrcweir #include "DrawViewShell.hxx" 68cdf0e10cSrcweir #include "OutlineViewShell.hxx" 69cdf0e10cSrcweir #include "drawview.hxx" 70cdf0e10cSrcweir 71cdf0e10cSrcweir #include "sdattr.hxx" 72cdf0e10cSrcweir #include "drawdoc.hxx" 73cdf0e10cSrcweir #include "sdpage.hxx" 74cdf0e10cSrcweir #include "unoaprms.hxx" // Undo-Action 75cdf0e10cSrcweir #include "sdundogr.hxx" // Undo Gruppe 76cdf0e10cSrcweir #include "Window.hxx" 77cdf0e10cSrcweir #include "DrawDocShell.hxx" 78cdf0e10cSrcweir #include "FrameView.hxx" 79cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx" 80cdf0e10cSrcweir #include "optsitem.hxx" 81cdf0e10cSrcweir #include "sdresid.hxx" 82cdf0e10cSrcweir 83cdf0e10cSrcweir // #96090# 84cdf0e10cSrcweir #ifndef _SVXIDS_HXX 85cdf0e10cSrcweir #include <svx/svxids.hrc> 86cdf0e10cSrcweir #endif 87cdf0e10cSrcweir #include <sfx2/request.hxx> 88cdf0e10cSrcweir #include <svl/aeitem.hxx> 89cdf0e10cSrcweir #include <basic/sbstar.hxx> 90cdf0e10cSrcweir 91cdf0e10cSrcweir using namespace ::com::sun::star; 92cdf0e10cSrcweir using namespace ::rtl; 93cdf0e10cSrcweir 94cdf0e10cSrcweir namespace sd { 95cdf0e10cSrcweir 96cdf0e10cSrcweir /************************************************************************* 97cdf0e10cSrcweir |* 98cdf0e10cSrcweir |* Status (Enabled/Disabled) von Menue-SfxSlots setzen 99cdf0e10cSrcweir |* 100cdf0e10cSrcweir \************************************************************************/ 101cdf0e10cSrcweir 102cdf0e10cSrcweir void ViewShell::GetMenuState( SfxItemSet &rSet ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STYLE_FAMILY ) ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir sal_uInt16 nFamily = (sal_uInt16)GetDocSh()->GetStyleFamily(); 107cdf0e10cSrcweir 108cdf0e10cSrcweir SdrView* pDrView = GetDrawView(); 109cdf0e10cSrcweir 110cdf0e10cSrcweir if( pDrView->AreObjectsMarked() ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir SfxStyleSheet* pStyleSheet = pDrView->GetStyleSheet(); 113cdf0e10cSrcweir if( pStyleSheet ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir if (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE) 116cdf0e10cSrcweir pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir if( pStyleSheet ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir SfxStyleFamily eFamily = pStyleSheet->GetFamily(); 121cdf0e10cSrcweir if(eFamily == SD_STYLE_FAMILY_GRAPHICS) 122cdf0e10cSrcweir nFamily = 2; 123cdf0e10cSrcweir else if(eFamily == SD_STYLE_FAMILY_CELL ) 124cdf0e10cSrcweir nFamily = 3; 125cdf0e10cSrcweir else // SD_STYLE_FAMILY_PSEUDO 126cdf0e10cSrcweir nFamily = 5; 127cdf0e10cSrcweir 128cdf0e10cSrcweir GetDocSh()->SetStyleFamily(nFamily); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir } 131cdf0e10cSrcweir } 132cdf0e10cSrcweir rSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, nFamily )); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir // #96090# 136cdf0e10cSrcweir if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETUNDOSTRINGS)) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir ImpGetUndoStrings(rSet); 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir // #96090# 142cdf0e10cSrcweir if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETREDOSTRINGS)) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir ImpGetRedoStrings(rSet); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir // #96090# 148cdf0e10cSrcweir if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_UNDO)) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir ::svl::IUndoManager* pUndoManager = ImpGetUndoManager(); 151cdf0e10cSrcweir sal_Bool bActivate(sal_False); 152cdf0e10cSrcweir 153cdf0e10cSrcweir if(pUndoManager) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir if(pUndoManager->GetUndoActionCount() != 0) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir bActivate = sal_True; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir if(bActivate) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir // #87229# Set the necessary string like in 164cdf0e10cSrcweir // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1072 ff. 165cdf0e10cSrcweir String aTmp( SvtResId( STR_UNDO ) ); 166cdf0e10cSrcweir aTmp += pUndoManager->GetUndoActionComment(0); 167cdf0e10cSrcweir rSet.Put(SfxStringItem(SID_UNDO, aTmp)); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir else 170cdf0e10cSrcweir { 171cdf0e10cSrcweir rSet.DisableItem(SID_UNDO); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir // #96090# 176cdf0e10cSrcweir if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_REDO)) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir ::svl::IUndoManager* pUndoManager = ImpGetUndoManager(); 179cdf0e10cSrcweir sal_Bool bActivate(sal_False); 180cdf0e10cSrcweir 181cdf0e10cSrcweir if(pUndoManager) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir if(pUndoManager->GetRedoActionCount() != 0) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir bActivate = sal_True; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir if(bActivate) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir // #87229# Set the necessary string like in 192cdf0e10cSrcweir // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1081 ff. 193cdf0e10cSrcweir String aTmp(SvtResId(STR_REDO)); 194cdf0e10cSrcweir aTmp += pUndoManager->GetRedoActionComment(0); 195cdf0e10cSrcweir rSet.Put(SfxStringItem(SID_REDO, aTmp)); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir else 198cdf0e10cSrcweir { 199cdf0e10cSrcweir rSet.DisableItem(SID_REDO); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir 205cdf0e10cSrcweir 206cdf0e10cSrcweir 207cdf0e10cSrcweir /** This method consists basically of three parts: 208cdf0e10cSrcweir 1. Process the arguments of the SFX request. 209cdf0e10cSrcweir 2. Use the model to create a new page or duplicate an existing one. 210cdf0e10cSrcweir 3. Update the tab control and switch to the new page. 211cdf0e10cSrcweir */ 212cdf0e10cSrcweir SdPage* ViewShell::CreateOrDuplicatePage ( 213cdf0e10cSrcweir SfxRequest& rRequest, 214cdf0e10cSrcweir PageKind ePageKind, 215cdf0e10cSrcweir SdPage* pPage, 216cdf0e10cSrcweir const sal_Int32 nInsertPosition) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir sal_uInt16 nSId = rRequest.GetSlot(); 219cdf0e10cSrcweir SdDrawDocument* pDocument = GetDoc(); 220cdf0e10cSrcweir SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin(); 221cdf0e10cSrcweir sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); 222cdf0e10cSrcweir sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); 223cdf0e10cSrcweir SetOfByte aVisibleLayers; 224cdf0e10cSrcweir // Determine the page from which to copy some values, such as layers, 225cdf0e10cSrcweir // size, master page, to the new page. This is usually the given page. 226cdf0e10cSrcweir // When the given page is NULL then use the first page of the document. 227cdf0e10cSrcweir SdPage* pTemplatePage = pPage; 228cdf0e10cSrcweir if (pTemplatePage == NULL) 229cdf0e10cSrcweir if (pDocument->GetSdPage(0, ePageKind) > 0) 230cdf0e10cSrcweir pTemplatePage = pDocument->GetSdPage(0, ePageKind); 231cdf0e10cSrcweir if (pTemplatePage != NULL && pTemplatePage->TRG_HasMasterPage()) 232cdf0e10cSrcweir aVisibleLayers = pTemplatePage->TRG_GetMasterPageVisibleLayers(); 233cdf0e10cSrcweir else 234cdf0e10cSrcweir aVisibleLayers.SetAll(); 235cdf0e10cSrcweir 236cdf0e10cSrcweir String aStandardPageName; 237cdf0e10cSrcweir String aNotesPageName; 238cdf0e10cSrcweir AutoLayout eStandardLayout (AUTOLAYOUT_NONE); 239cdf0e10cSrcweir AutoLayout eNotesLayout (AUTOLAYOUT_NOTES); 240cdf0e10cSrcweir sal_Bool bIsPageBack = aVisibleLayers.IsSet(aBckgrnd); 241cdf0e10cSrcweir sal_Bool bIsPageObj = aVisibleLayers.IsSet(aBckgrndObj); 242cdf0e10cSrcweir 243cdf0e10cSrcweir // 1. Process the arguments. 244cdf0e10cSrcweir const SfxItemSet* pArgs = rRequest.GetArgs(); 245cdf0e10cSrcweir if (! pArgs) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir /* 248cdf0e10cSrcweir // Make the layout menu visible in the tool pane. 249cdf0e10cSrcweir const ViewShellBase& rBase (GetViewShellBase()); 250cdf0e10cSrcweir if (rBase.GetMainViewShell()!=NULL 251cdf0e10cSrcweir && rBase.GetMainViewShell()->GetShellType()!=ViewShell::ST_OUTLINE 252cdf0e10cSrcweir && rBase.GetMainViewShell()->GetShellType()!=ViewShell::ST_DRAW) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir framework::FrameworkHelper::Instance(GetViewShellBase())->RequestTaskPanel( 255cdf0e10cSrcweir framework::FrameworkHelper::msLayoutTaskPanelURL, 256cdf0e10cSrcweir false); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir */ 259cdf0e10cSrcweir 260cdf0e10cSrcweir // AutoLayouts muessen fertig sein 261cdf0e10cSrcweir pDocument->StopWorkStartupDelay(); 262cdf0e10cSrcweir 263cdf0e10cSrcweir // Use the layouts of the previous page and notes page as template. 264cdf0e10cSrcweir if (pTemplatePage != NULL) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir eStandardLayout = pTemplatePage->GetAutoLayout(); 267cdf0e10cSrcweir if( eStandardLayout == AUTOLAYOUT_TITLE ) 268cdf0e10cSrcweir eStandardLayout = AUTOLAYOUT_ENUM; 269cdf0e10cSrcweir 270cdf0e10cSrcweir SdPage* pNotesTemplatePage = static_cast<SdPage*>(pDocument->GetPage(pTemplatePage->GetPageNum()+1)); 271cdf0e10cSrcweir if (pNotesTemplatePage != NULL) 272cdf0e10cSrcweir eNotesLayout = pNotesTemplatePage->GetAutoLayout(); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir } 275cdf0e10cSrcweir else if (pArgs->Count() == 1) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir pDocument->StopWorkStartupDelay(); 278cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); 279cdf0e10cSrcweir if( pLayout ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir if (ePageKind == PK_NOTES) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir eNotesLayout = (AutoLayout) pLayout->GetValue (); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir else 286cdf0e10cSrcweir { 287cdf0e10cSrcweir eStandardLayout = (AutoLayout) pLayout->GetValue (); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir } 290cdf0e10cSrcweir } 291cdf0e10cSrcweir else if (pArgs->Count() == 4) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir // AutoLayouts muessen fertig sein 294cdf0e10cSrcweir pDocument->StopWorkStartupDelay(); 295cdf0e10cSrcweir 296cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pPageName, SfxStringItem, ID_VAL_PAGENAME, sal_False); 297cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False); 298cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pIsPageBack, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False); 299cdf0e10cSrcweir SFX_REQUEST_ARG (rRequest, pIsPageObj, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False); 300cdf0e10cSrcweir 301cdf0e10cSrcweir if (CHECK_RANGE (AUTOLAYOUT__START, (AutoLayout) pLayout->GetValue (), AUTOLAYOUT__END)) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir if (ePageKind == PK_NOTES) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir aNotesPageName = pPageName->GetValue (); 306cdf0e10cSrcweir eNotesLayout = (AutoLayout) pLayout->GetValue (); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir else 309cdf0e10cSrcweir { 310cdf0e10cSrcweir aStandardPageName = pPageName->GetValue (); 311cdf0e10cSrcweir eStandardLayout = (AutoLayout) pLayout->GetValue (); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir bIsPageBack = pIsPageBack->GetValue (); 315cdf0e10cSrcweir bIsPageObj = pIsPageObj->GetValue (); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir else 318cdf0e10cSrcweir { 319cdf0e10cSrcweir Cancel(); 320cdf0e10cSrcweir 321cdf0e10cSrcweir if(HasCurrentFunction( SID_BEZIER_EDIT ) ) 322cdf0e10cSrcweir GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON); 323cdf0e10cSrcweir 324cdf0e10cSrcweir StarBASIC::FatalError (SbERR_BAD_PROP_VALUE); 325cdf0e10cSrcweir rRequest.Ignore (); 326cdf0e10cSrcweir return NULL; 327cdf0e10cSrcweir } 328cdf0e10cSrcweir } 329cdf0e10cSrcweir else 330cdf0e10cSrcweir { 331cdf0e10cSrcweir Cancel(); 332cdf0e10cSrcweir 333cdf0e10cSrcweir if(HasCurrentFunction(SID_BEZIER_EDIT) ) 334cdf0e10cSrcweir GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON); 335cdf0e10cSrcweir 336cdf0e10cSrcweir StarBASIC::FatalError (SbERR_WRONG_ARGS); 337cdf0e10cSrcweir rRequest.Ignore (); 338cdf0e10cSrcweir return NULL; 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir // 2. Create a new page or duplicate an existing one. 342cdf0e10cSrcweir View* pDrView = GetView(); 343cdf0e10cSrcweir const bool bUndo = pDrView && pDrView->IsUndoEnabled(); 344cdf0e10cSrcweir if( bUndo ) 345cdf0e10cSrcweir pDrView->BegUndo( String( SdResId(STR_INSERTPAGE) ) ); 346cdf0e10cSrcweir 347cdf0e10cSrcweir sal_uInt16 nNewPageIndex = 0xffff; 348cdf0e10cSrcweir switch (nSId) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir case SID_INSERTPAGE: 351cdf0e10cSrcweir case SID_INSERTPAGE_QUICK: 352cdf0e10cSrcweir case SID_INSERT_MASTER_PAGE: 353cdf0e10cSrcweir // There are three cases. a) pPage is not NULL: we use it as a 354cdf0e10cSrcweir // template and create a new slide behind it. b) pPage is NULL 355cdf0e10cSrcweir // but the document is not empty: we use the first slide/notes 356cdf0e10cSrcweir // page as template, create a new slide after it and move it 357cdf0e10cSrcweir // then to the head of the document. c) pPage is NULL and the 358cdf0e10cSrcweir // document is empty: We use CreateFirstPages to create the 359cdf0e10cSrcweir // first page of the document. 360cdf0e10cSrcweir if (pPage == NULL) 361cdf0e10cSrcweir if (pTemplatePage == NULL) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir pDocument->CreateFirstPages(); 364cdf0e10cSrcweir nNewPageIndex = 0; 365cdf0e10cSrcweir } 366cdf0e10cSrcweir else 367cdf0e10cSrcweir { 368cdf0e10cSrcweir // Create a new page with the first page as template and 369cdf0e10cSrcweir // insert it after the first page. 370cdf0e10cSrcweir nNewPageIndex = pDocument->CreatePage ( 371cdf0e10cSrcweir pTemplatePage, 372cdf0e10cSrcweir ePageKind, 373cdf0e10cSrcweir aStandardPageName, 374cdf0e10cSrcweir aNotesPageName, 375cdf0e10cSrcweir eStandardLayout, 376cdf0e10cSrcweir eNotesLayout, 377cdf0e10cSrcweir bIsPageBack, 378cdf0e10cSrcweir bIsPageObj, 379cdf0e10cSrcweir nInsertPosition); 380cdf0e10cSrcweir // Select exactly the new page. 381cdf0e10cSrcweir sal_uInt16 nPageCount (pDocument->GetSdPageCount(ePageKind)); 382cdf0e10cSrcweir for (sal_uInt16 i=0; i<nPageCount; i++) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir pDocument->GetSdPage(i, PK_STANDARD)->SetSelected( 385cdf0e10cSrcweir i == nNewPageIndex); 386cdf0e10cSrcweir pDocument->GetSdPage(i, PK_NOTES)->SetSelected( 387cdf0e10cSrcweir i == nNewPageIndex); 388cdf0e10cSrcweir } 389cdf0e10cSrcweir // Move the selected page to the head of the document 390cdf0e10cSrcweir pDocument->MovePages ((sal_uInt16)-1); 391cdf0e10cSrcweir nNewPageIndex = 0; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir else 394cdf0e10cSrcweir nNewPageIndex = pDocument->CreatePage ( 395cdf0e10cSrcweir pPage, 396cdf0e10cSrcweir ePageKind, 397cdf0e10cSrcweir aStandardPageName, 398cdf0e10cSrcweir aNotesPageName, 399cdf0e10cSrcweir eStandardLayout, 400cdf0e10cSrcweir eNotesLayout, 401cdf0e10cSrcweir bIsPageBack, 402cdf0e10cSrcweir bIsPageObj, 403cdf0e10cSrcweir nInsertPosition); 404cdf0e10cSrcweir break; 405cdf0e10cSrcweir 406cdf0e10cSrcweir case SID_DUPLICATE_PAGE: 407cdf0e10cSrcweir // Duplication makes no sense when pPage is NULL. 408cdf0e10cSrcweir if (pPage != NULL) 409cdf0e10cSrcweir nNewPageIndex = pDocument->DuplicatePage ( 410cdf0e10cSrcweir pPage, 411cdf0e10cSrcweir ePageKind, 412cdf0e10cSrcweir aStandardPageName, 413cdf0e10cSrcweir aNotesPageName, 414cdf0e10cSrcweir eStandardLayout, 415cdf0e10cSrcweir eNotesLayout, 416cdf0e10cSrcweir bIsPageBack, 417cdf0e10cSrcweir bIsPageObj, 418cdf0e10cSrcweir nInsertPosition); 419cdf0e10cSrcweir break; 420cdf0e10cSrcweir 421cdf0e10cSrcweir default: 422cdf0e10cSrcweir DBG_WARNING("wrong slot id given to CreateOrDuplicatePage"); 423cdf0e10cSrcweir // Try to handle another slot id gracefully. 424cdf0e10cSrcweir } 425cdf0e10cSrcweir SdPage* pNewPage = 0; 426cdf0e10cSrcweir if(nNewPageIndex != 0xffff) 427cdf0e10cSrcweir pNewPage = pDocument->GetSdPage(nNewPageIndex, PK_STANDARD); 428cdf0e10cSrcweir 429cdf0e10cSrcweir if( bUndo ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir if( pNewPage ) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage)); 434cdf0e10cSrcweir pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES))); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir pDrView->EndUndo(); 438cdf0e10cSrcweir } 439cdf0e10cSrcweir 440cdf0e10cSrcweir return pNewPage; 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir 444cdf0e10cSrcweir } // end of namespace sd 445