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