1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "fuprlout.hxx" 33*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 34*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 35*cdf0e10cSrcweir #include <svl/smplhint.hxx> 36*cdf0e10cSrcweir #include <svl/itempool.hxx> 37*cdf0e10cSrcweir #include <sot/storage.hxx> 38*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 39*cdf0e10cSrcweir #include <svx/svdundo.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 42*cdf0e10cSrcweir #include <sfx2/request.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include "drawdoc.hxx" 45*cdf0e10cSrcweir #include "sdpage.hxx" 46*cdf0e10cSrcweir #include "pres.hxx" 47*cdf0e10cSrcweir #include "DrawViewShell.hxx" 48*cdf0e10cSrcweir #ifndef SD_FRAMW_VIEW_HXX 49*cdf0e10cSrcweir #include "FrameView.hxx" 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #include "stlpool.hxx" 52*cdf0e10cSrcweir #include "View.hxx" 53*cdf0e10cSrcweir #include "glob.hrc" 54*cdf0e10cSrcweir #include "glob.hxx" 55*cdf0e10cSrcweir #include "strings.hrc" 56*cdf0e10cSrcweir #include "strmname.h" 57*cdf0e10cSrcweir #include "app.hrc" 58*cdf0e10cSrcweir #include "DrawDocShell.hxx" 59*cdf0e10cSrcweir #include "unprlout.hxx" 60*cdf0e10cSrcweir #include "unchss.hxx" 61*cdf0e10cSrcweir #include "unmovss.hxx" 62*cdf0e10cSrcweir #include "sdattr.hxx" 63*cdf0e10cSrcweir #include "sdresid.hxx" 64*cdf0e10cSrcweir #include "drawview.hxx" 65*cdf0e10cSrcweir #include "eetext.hxx" 66*cdf0e10cSrcweir #include <editeng/editdata.hxx> 67*cdf0e10cSrcweir #include "sdabstdlg.hxx" 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir namespace sd 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir #ifndef SO2_DECL_SVSTORAGE_DEFINED 73*cdf0e10cSrcweir #define SO2_DECL_SVSTORAGE_DEFINED 74*cdf0e10cSrcweir SO2_DECL_REF(SvStorage) 75*cdf0e10cSrcweir #endif 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir TYPEINIT1( FuPresentationLayout, FuPoor ); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir #define POOL_BUFFER_SIZE (sal_uInt16)32768 80*cdf0e10cSrcweir #define DOCUMENT_BUFFER_SIZE (sal_uInt16)32768 81*cdf0e10cSrcweir #define DOCUMENT_TOKEN (sal_Unicode('#')) 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir /************************************************************************* 84*cdf0e10cSrcweir |* 85*cdf0e10cSrcweir |* Konstruktor 86*cdf0e10cSrcweir |* 87*cdf0e10cSrcweir \************************************************************************/ 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir FuPresentationLayout::FuPresentationLayout ( 90*cdf0e10cSrcweir ViewShell* pViewSh, 91*cdf0e10cSrcweir ::sd::Window* pWin, 92*cdf0e10cSrcweir ::sd::View* pView, 93*cdf0e10cSrcweir SdDrawDocument* pDoc, 94*cdf0e10cSrcweir SfxRequest& rReq) 95*cdf0e10cSrcweir : FuPoor(pViewSh, pWin, pView, pDoc, rReq) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir FunctionReference FuPresentationLayout::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir FunctionReference xFunc( new FuPresentationLayout( pViewSh, pWin, pView, pDoc, rReq ) ); 102*cdf0e10cSrcweir xFunc->DoExecute(rReq); 103*cdf0e10cSrcweir return xFunc; 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir void FuPresentationLayout::DoExecute( SfxRequest& rReq ) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir // damit nicht Objekte, die gerade editiert werden oder selektiert 109*cdf0e10cSrcweir // sind , verschwinden 110*cdf0e10cSrcweir mpView->SdrEndTextEdit(); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir if(mpView->GetSdrPageView()) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir mpView->UnmarkAll(); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir sal_Bool bError = sal_False; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir // die aktive Seite ermitteln 120*cdf0e10cSrcweir sal_uInt16 nSelectedPage = SDRPAGE_NOTFOUND; 121*cdf0e10cSrcweir for (sal_uInt16 nPage = 0; nPage < mpDoc->GetSdPageCount(PK_STANDARD); nPage++) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir if (mpDoc->GetSdPage(nPage, PK_STANDARD)->IsSelected()) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir nSelectedPage = nPage; 126*cdf0e10cSrcweir break; 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir DBG_ASSERT(nSelectedPage != SDRPAGE_NOTFOUND, "keine selektierte Seite"); 131*cdf0e10cSrcweir SdPage* pSelectedPage = mpDoc->GetSdPage(nSelectedPage, PK_STANDARD); 132*cdf0e10cSrcweir String aOldPageLayoutName(pSelectedPage->GetLayoutName()); 133*cdf0e10cSrcweir String aOldLayoutName(aOldPageLayoutName); 134*cdf0e10cSrcweir aOldLayoutName.Erase(aOldLayoutName.SearchAscii(SD_LT_SEPARATOR)); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // wenn wir auf einer Masterpage sind, gelten die Aenderungen fuer alle 137*cdf0e10cSrcweir // Seiten und Notizseiten, die das betreffende Layout benutzen 138*cdf0e10cSrcweir sal_Bool bOnMaster = sal_False; 139*cdf0e10cSrcweir if( mpViewShell && mpViewShell->ISA(DrawViewShell)) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir EditMode eEditMode = 142*cdf0e10cSrcweir static_cast<DrawViewShell*>(mpViewShell)->GetEditMode(); 143*cdf0e10cSrcweir if (eEditMode == EM_MASTERPAGE) 144*cdf0e10cSrcweir bOnMaster = sal_True; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir sal_Bool bMasterPage = bOnMaster; 147*cdf0e10cSrcweir sal_Bool bCheckMasters = sal_False; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir // Dialog aufrufen 150*cdf0e10cSrcweir sal_Bool bLoad = sal_False; // tauchen neue Masterpages auf? 151*cdf0e10cSrcweir String aFile; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir SfxItemSet aSet(mpDoc->GetPool(), ATTR_PRESLAYOUT_START, ATTR_PRESLAYOUT_END); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_LOAD, bLoad)); 156*cdf0e10cSrcweir aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_MASTER_PAGE, bMasterPage ) ); 157*cdf0e10cSrcweir aSet.Put( SfxBoolItem( ATTR_PRESLAYOUT_CHECK_MASTERS, bCheckMasters ) ); 158*cdf0e10cSrcweir aSet.Put( SfxStringItem( ATTR_PRESLAYOUT_NAME, aOldLayoutName)); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs (); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir if (pArgs) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir if (pArgs->GetItemState(ATTR_PRESLAYOUT_LOAD) == SFX_ITEM_SET) 167*cdf0e10cSrcweir bLoad = ((SfxBoolItem&)pArgs->Get(ATTR_PRESLAYOUT_LOAD)).GetValue(); 168*cdf0e10cSrcweir if( pArgs->GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE ) == SFX_ITEM_SET ) 169*cdf0e10cSrcweir bMasterPage = ( (SfxBoolItem&) pArgs->Get( ATTR_PRESLAYOUT_MASTER_PAGE ) ).GetValue(); 170*cdf0e10cSrcweir if( pArgs->GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS ) == SFX_ITEM_SET ) 171*cdf0e10cSrcweir bCheckMasters = ( (SfxBoolItem&) pArgs->Get( ATTR_PRESLAYOUT_CHECK_MASTERS ) ).GetValue(); 172*cdf0e10cSrcweir if (pArgs->GetItemState(ATTR_PRESLAYOUT_NAME) == SFX_ITEM_SET) 173*cdf0e10cSrcweir aFile = ((SfxStringItem&)pArgs->Get(ATTR_PRESLAYOUT_NAME)).GetValue(); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir else 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 178*cdf0e10cSrcweir AbstractSdPresLayoutDlg* pDlg = pFact ? pFact->CreateSdPresLayoutDlg(mpDocSh, mpViewShell, NULL, aSet ) : 0; 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir sal_uInt16 nResult = pDlg ? pDlg->Execute() : RET_CANCEL; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir switch (nResult) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir case RET_OK: 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir pDlg->GetAttr(aSet); 187*cdf0e10cSrcweir if (aSet.GetItemState(ATTR_PRESLAYOUT_LOAD) == SFX_ITEM_SET) 188*cdf0e10cSrcweir bLoad = ((SfxBoolItem&)aSet.Get(ATTR_PRESLAYOUT_LOAD)).GetValue(); 189*cdf0e10cSrcweir if( aSet.GetItemState( ATTR_PRESLAYOUT_MASTER_PAGE ) == SFX_ITEM_SET ) 190*cdf0e10cSrcweir bMasterPage = ( (SfxBoolItem&) aSet.Get( ATTR_PRESLAYOUT_MASTER_PAGE ) ).GetValue(); 191*cdf0e10cSrcweir if( aSet.GetItemState( ATTR_PRESLAYOUT_CHECK_MASTERS ) == SFX_ITEM_SET ) 192*cdf0e10cSrcweir bCheckMasters = ( (SfxBoolItem&) aSet.Get( ATTR_PRESLAYOUT_CHECK_MASTERS ) ).GetValue(); 193*cdf0e10cSrcweir if (aSet.GetItemState(ATTR_PRESLAYOUT_NAME) == SFX_ITEM_SET) 194*cdf0e10cSrcweir aFile = ((SfxStringItem&)aSet.Get(ATTR_PRESLAYOUT_NAME)).GetValue(); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir break; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir default: 199*cdf0e10cSrcweir bError = sal_True; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir delete pDlg; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir if (!bError) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir mpDocSh->SetWaitCursor( sal_True ); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir // Hier werden nur Masterpages ausgewechselt, d.h. die aktuelle Seite 209*cdf0e10cSrcweir // bleibt aktuell. Damit beim Ein- und Ausfuegen der Masterpages nicht 210*cdf0e10cSrcweir // dauernd via PageOrderChangedHint die Methode ResetActualPage gerufen 211*cdf0e10cSrcweir // wird, wird jetzt blockiert. 212*cdf0e10cSrcweir // That isn't quitely right. If the masterpageview is active and you are 213*cdf0e10cSrcweir // removing a masterpage, it's possible that you are removing the 214*cdf0e10cSrcweir // current masterpage. So you have to call ResetActualPage ! 215*cdf0e10cSrcweir if( mpViewShell->ISA(DrawViewShell) && !bCheckMasters ) 216*cdf0e10cSrcweir static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(sal_True); 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir if (bLoad) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir String aFileName = aFile.GetToken( 0, DOCUMENT_TOKEN ); 221*cdf0e10cSrcweir SdDrawDocument* pTempDoc = mpDoc->OpenBookmarkDoc( aFileName ); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir // #69581: If I chosed the standard-template I got no filename and so I get no 224*cdf0e10cSrcweir // SdDrawDocument-Pointer. But the method SetMasterPage is able to handle 225*cdf0e10cSrcweir // a NULL-pointer as a Standard-template ( look at SdDrawDocument::SetMasterPage ) 226*cdf0e10cSrcweir String aLayoutName; 227*cdf0e10cSrcweir if( pTempDoc ) 228*cdf0e10cSrcweir aLayoutName = aFile.GetToken( 1, DOCUMENT_TOKEN ); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir mpDoc->SetMasterPage(nSelectedPage, aLayoutName, pTempDoc, bMasterPage, bCheckMasters); 231*cdf0e10cSrcweir mpDoc->CloseBookmarkDoc(); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir else 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir // MasterPage mit dem LayoutNamen aFile aus aktuellem Doc verwenden 236*cdf0e10cSrcweir mpDoc->SetMasterPage(nSelectedPage, aFile, mpDoc, bMasterPage, bCheckMasters); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir // Blockade wieder aufheben 240*cdf0e10cSrcweir if (mpViewShell->ISA(DrawViewShell) && !bCheckMasters ) 241*cdf0e10cSrcweir static_cast<DrawView*>(mpView)->BlockPageOrderChangedHint(sal_False); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir /************************************************************************* 244*cdf0e10cSrcweir |* Falls dargestellte Masterpage sichtbar war, neu darstellen 245*cdf0e10cSrcweir \************************************************************************/ 246*cdf0e10cSrcweir if (!bError && nSelectedPage != SDRPAGE_NOTFOUND) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir if (bOnMaster) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir if (mpViewShell->ISA(DrawViewShell)) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir ::sd::View* pView = 253*cdf0e10cSrcweir static_cast<DrawViewShell*>(mpViewShell)->GetView(); 254*cdf0e10cSrcweir sal_uInt16 nPgNum = pSelectedPage->TRG_GetMasterPage().GetPageNum(); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir if (static_cast<DrawViewShell*>(mpViewShell)->GetPageKind() == PK_NOTES) 257*cdf0e10cSrcweir nPgNum++; 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir pView->HideSdrPage(); 260*cdf0e10cSrcweir pView->ShowSdrPage(pView->GetModel()->GetMasterPage(nPgNum)); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir // damit TabBar aktualisiert wird 264*cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_MASTERPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir else 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir pSelectedPage->SetAutoLayout(pSelectedPage->GetAutoLayout()); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir // fake a mode change to repaint the page tab bar 273*cdf0e10cSrcweir if( mpViewShell && mpViewShell->ISA( DrawViewShell ) ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir DrawViewShell* pDrawViewSh = 276*cdf0e10cSrcweir static_cast<DrawViewShell*>(mpViewShell); 277*cdf0e10cSrcweir EditMode eMode = pDrawViewSh->GetEditMode(); 278*cdf0e10cSrcweir sal_Bool bLayer = pDrawViewSh->IsLayerModeActive(); 279*cdf0e10cSrcweir pDrawViewSh->ChangeEditMode( eMode, !bLayer ); 280*cdf0e10cSrcweir pDrawViewSh->ChangeEditMode( eMode, bLayer ); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir mpDocSh->SetWaitCursor( sal_False ); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir } // end of namespace sd 288