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 <com/sun/star/embed/ElementModes.hpp> 29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include "comphelper/anytostring.hxx" 32cdf0e10cSrcweir #include "cppuhelper/exc_hlp.hxx" 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <utility> 35cdf0e10cSrcweir #include <algorithm> 36cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 37cdf0e10cSrcweir #include <sfx2/docfile.hxx> 38cdf0e10cSrcweir #include <sot/storage.hxx> 39cdf0e10cSrcweir #include <sfx2/app.hxx> 40cdf0e10cSrcweir #include <svl/itemset.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx> 43cdf0e10cSrcweir #include <sfx2/fcontnr.hxx> 44cdf0e10cSrcweir #include <svx/svdopath.hxx> 45cdf0e10cSrcweir #include <svx/svditer.hxx> 46cdf0e10cSrcweir #include <svl/style.hxx> 47cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> 48cdf0e10cSrcweir #include <svx/svdpagv.hxx> 49cdf0e10cSrcweir #include <svx/svdogrp.hxx> 50cdf0e10cSrcweir #include <svx/svdundo.hxx> 51cdf0e10cSrcweir #include <vcl/msgbox.hxx> 52cdf0e10cSrcweir #include <sot/storage.hxx> 53cdf0e10cSrcweir #include <sot/formats.hxx> 54cdf0e10cSrcweir 55cdf0e10cSrcweir #include <set> 56cdf0e10cSrcweir #include <boost/bind.hpp> 57cdf0e10cSrcweir 58cdf0e10cSrcweir #include "glob.hrc" 59cdf0e10cSrcweir #include "drawdoc.hxx" 60cdf0e10cSrcweir #include "sdpage.hxx" 61cdf0e10cSrcweir #include "stlpool.hxx" 62cdf0e10cSrcweir #include "sdresid.hxx" 63cdf0e10cSrcweir #include "sdiocmpt.hxx" 64cdf0e10cSrcweir #include "strmname.h" 65cdf0e10cSrcweir #include "anminfo.hxx" 66cdf0e10cSrcweir 67cdf0e10cSrcweir #include "../ui/inc/unmovss.hxx" 68cdf0e10cSrcweir #include "../ui/inc/unchss.hxx" 69cdf0e10cSrcweir #include "../ui/inc/unprlout.hxx" 70cdf0e10cSrcweir #include "../ui/inc/DrawDocShell.hxx" 71cdf0e10cSrcweir #include "../ui/inc/GraphicDocShell.hxx" 72cdf0e10cSrcweir #include "../ui/inc/ViewShell.hxx" 73cdf0e10cSrcweir #include "../ui/inc/View.hxx" 74cdf0e10cSrcweir #include "../ui/inc/cfgids.hxx" 75cdf0e10cSrcweir #include "../ui/inc/strings.hrc" 76cdf0e10cSrcweir 77cdf0e10cSrcweir using namespace ::com::sun::star; 78cdf0e10cSrcweir 79cdf0e10cSrcweir #define POOL_BUFFER_SIZE (sal_uInt16)32768 80cdf0e10cSrcweir #define BASIC_BUFFER_SIZE (sal_uInt16)8192 81cdf0e10cSrcweir #define DOCUMENT_BUFFER_SIZE (sal_uInt16)32768 82cdf0e10cSrcweir 83cdf0e10cSrcweir /************************************************************************* 84cdf0e10cSrcweir |* 85cdf0e10cSrcweir |* Oeffnet ein Bookmark-Dokument 86cdf0e10cSrcweir |* 87cdf0e10cSrcweir \************************************************************************/ 88cdf0e10cSrcweir /* 89cdf0e10cSrcweir SdStorageListener : public BaseImplHelper1 < lang::XEventListener > 90cdf0e10cSrcweir { 91cdf0e10cSrcweir uno::Reference < embed::XStorage >& xStor; 92cdf0e10cSrcweir public: 93cdf0e10cSrcweir SdStorageListener ( uno::Reference < embed::XStorage >& rStor ) 94cdf0e10cSrcweir : xStor( rStor ) 95cdf0e10cSrcweir {} 96cdf0e10cSrcweir 97cdf0e10cSrcweir void disposing ( const lang::EventObject& aEvent ) throw ( uno::RuntimeException ); 98cdf0e10cSrcweir }; 99cdf0e10cSrcweir 100cdf0e10cSrcweir void SdStorageListener::disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir xStor = NULL; 103cdf0e10cSrcweir }*/ 104cdf0e10cSrcweir 105cdf0e10cSrcweir SdDrawDocument* SdDrawDocument::OpenBookmarkDoc(SfxMedium& rMedium) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir sal_Bool bOK = sal_True; 108cdf0e10cSrcweir SdDrawDocument* pBookmarkDoc = NULL; 109cdf0e10cSrcweir String aBookmarkName = rMedium.GetName(); 110cdf0e10cSrcweir const SfxFilter* pFilter = rMedium.GetFilter(); 111cdf0e10cSrcweir if ( !pFilter ) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir rMedium.UseInteractionHandler( sal_True ); 114cdf0e10cSrcweir SFX_APP()->GetFilterMatcher().GuessFilter( rMedium, &pFilter ); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir if ( !pFilter ) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir bOK = sal_False; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir else if ( maBookmarkFile != aBookmarkName && aBookmarkName.Len() ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir sal_Bool bCreateGraphicShell = pFilter->GetServiceName().EqualsAscii( "com.sun.star.drawing.DrawingDocument" ); 124cdf0e10cSrcweir sal_Bool bCreateImpressShell = pFilter->GetServiceName().EqualsAscii( "com.sun.star.presentation.PresentationDocument" ); 125cdf0e10cSrcweir if ( bCreateGraphicShell || bCreateImpressShell ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir CloseBookmarkDoc(); 128cdf0e10cSrcweir 129cdf0e10cSrcweir // Es wird eine DocShell erzeugt, da in dem Dokument OLE-Objekte 130cdf0e10cSrcweir // enthalten sein koennten (Persist) 131cdf0e10cSrcweir // Wenn dem nicht so waere, so koennte man auch das Model 132cdf0e10cSrcweir // direkt laden 133cdf0e10cSrcweir if ( bCreateGraphicShell ) 134cdf0e10cSrcweir // Draw 135cdf0e10cSrcweir mxBookmarkDocShRef = new ::sd::GraphicDocShell(SFX_CREATE_MODE_STANDARD, sal_True); 136cdf0e10cSrcweir else 137cdf0e10cSrcweir // Impress 138cdf0e10cSrcweir mxBookmarkDocShRef = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_True); 139cdf0e10cSrcweir 140cdf0e10cSrcweir bOK = mxBookmarkDocShRef->DoLoad(&rMedium); 141cdf0e10cSrcweir if( bOK ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir maBookmarkFile = aBookmarkName; 144cdf0e10cSrcweir pBookmarkDoc = mxBookmarkDocShRef->GetDoc(); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir DBG_ASSERT(aBookmarkName.Len(), "Empty document name!"); 150cdf0e10cSrcweir 151cdf0e10cSrcweir if (!bOK) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir ErrorBox aErrorBox( NULL, (WinBits)WB_OK, String(SdResId(STR_READ_DATA_ERROR))); 154cdf0e10cSrcweir aErrorBox.Execute(); 155cdf0e10cSrcweir 156cdf0e10cSrcweir CloseBookmarkDoc(); 157cdf0e10cSrcweir pBookmarkDoc = NULL; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir else if (mxBookmarkDocShRef.Is()) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir pBookmarkDoc = mxBookmarkDocShRef->GetDoc(); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir return(pBookmarkDoc); 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir /************************************************************************* 168cdf0e10cSrcweir |* 169cdf0e10cSrcweir |* Oeffnet ein Bookmark-Dokument 170cdf0e10cSrcweir |* 171cdf0e10cSrcweir \************************************************************************/ 172cdf0e10cSrcweir 173cdf0e10cSrcweir SdDrawDocument* SdDrawDocument::OpenBookmarkDoc(const String& rBookmarkFile) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir SdDrawDocument* pBookmarkDoc = NULL; 176cdf0e10cSrcweir 177cdf0e10cSrcweir if (maBookmarkFile != rBookmarkFile && rBookmarkFile.Len()) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir SfxMedium* pMedium = new SfxMedium( rBookmarkFile, STREAM_READ, sal_False ); 180cdf0e10cSrcweir pBookmarkDoc = OpenBookmarkDoc(*pMedium); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir else if (mxBookmarkDocShRef.Is()) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir pBookmarkDoc = mxBookmarkDocShRef->GetDoc(); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir return(pBookmarkDoc); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir /************************************************************************* 191cdf0e10cSrcweir |* 192cdf0e10cSrcweir |* Fuegt ein Bookmark (Seite oder Objekt) ein 193cdf0e10cSrcweir |* 194cdf0e10cSrcweir \************************************************************************/ 195cdf0e10cSrcweir 196cdf0e10cSrcweir sal_Bool SdDrawDocument::InsertBookmark( 197cdf0e10cSrcweir List* pBookmarkList, // Liste der Namen der einzufuegenden Bookmarks 198cdf0e10cSrcweir List* pExchangeList, // Liste der zu verwendenen Namen 199cdf0e10cSrcweir sal_Bool bLink, // Bookmarks sollen als Verknuepfung eingefuegt werden 200cdf0e10cSrcweir sal_Bool bReplace, // Aktuellen Seiten (Standard&Notiz) werden ersetzt 201cdf0e10cSrcweir sal_uInt16 nInsertPos, // Einfuegeposition fuer Seiten 202cdf0e10cSrcweir sal_Bool bNoDialogs, // Keine Dialoge anzeigen 203cdf0e10cSrcweir ::sd::DrawDocShell* pBookmarkDocSh, // Wenn gesetzt, so ist dieses das Source-Dokument 204cdf0e10cSrcweir sal_Bool bCopy, // Seiten werden kopiert 205cdf0e10cSrcweir Point* pObjPos) // Einfuegeposition fuer Objekte 206cdf0e10cSrcweir { 207cdf0e10cSrcweir sal_Bool bOK = sal_True; 208cdf0e10cSrcweir sal_Bool bInsertPages = sal_False; 209cdf0e10cSrcweir 210cdf0e10cSrcweir if (!pBookmarkList) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir /********************************************************************** 213cdf0e10cSrcweir * Alle Seiten werden eingefuegt 214cdf0e10cSrcweir **********************************************************************/ 215cdf0e10cSrcweir bInsertPages = sal_True; 216cdf0e10cSrcweir } 217cdf0e10cSrcweir else 218cdf0e10cSrcweir { 219cdf0e10cSrcweir SdDrawDocument* pBookmarkDoc = NULL; 220cdf0e10cSrcweir String aBookmarkName; 221cdf0e10cSrcweir 222cdf0e10cSrcweir if (pBookmarkDocSh) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir pBookmarkDoc = pBookmarkDocSh->GetDoc(); 225cdf0e10cSrcweir aBookmarkName = pBookmarkDocSh->GetMedium()->GetName(); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir else if ( mxBookmarkDocShRef.Is() ) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir pBookmarkDoc = mxBookmarkDocShRef->GetDoc(); 230cdf0e10cSrcweir aBookmarkName = maBookmarkFile; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir else 233cdf0e10cSrcweir bOK = sal_False; 234cdf0e10cSrcweir 235cdf0e10cSrcweir for (sal_uInt16 nPos = 0; bOK && ( nPos < pBookmarkList->Count() ) && !bInsertPages; nPos++) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir /****************************************************************** 238cdf0e10cSrcweir * Gibt es in der Bookmark-Liste einen Seitennamen? 239cdf0e10cSrcweir ******************************************************************/ 240cdf0e10cSrcweir String aBMPgName (*(String*) pBookmarkList->GetObject(nPos)); 241cdf0e10cSrcweir sal_Bool bIsMasterPage; 242cdf0e10cSrcweir 243cdf0e10cSrcweir if( pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage ) != SDRPAGE_NOTFOUND ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir // Seite gefunden 246cdf0e10cSrcweir bInsertPages = sal_True; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir } 249cdf0e10cSrcweir } 250cdf0e10cSrcweir 251cdf0e10cSrcweir if ( bOK && bInsertPages ) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir // Zuerst werden alle Seiten-Bookmarks eingefuegt 254cdf0e10cSrcweir bOK = InsertBookmarkAsPage(pBookmarkList, pExchangeList, bLink, bReplace, 255cdf0e10cSrcweir nInsertPos, bNoDialogs, pBookmarkDocSh, bCopy, sal_True, sal_False); 256cdf0e10cSrcweir } 257cdf0e10cSrcweir 258cdf0e10cSrcweir if ( bOK && pBookmarkList ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir // Es werden alle Objekt-Bookmarks eingefuegt 261cdf0e10cSrcweir bOK = InsertBookmarkAsObject(pBookmarkList, pExchangeList, bLink, 262cdf0e10cSrcweir pBookmarkDocSh, pObjPos); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir 265cdf0e10cSrcweir return bOK; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir /************************************************************************* 269cdf0e10cSrcweir |* 270cdf0e10cSrcweir |* Fuegt ein Bookmark als Seite ein 271cdf0e10cSrcweir |* 272cdf0e10cSrcweir \************************************************************************/ 273cdf0e10cSrcweir 274cdf0e10cSrcweir /** Concrete incarnations get called by IterateBookmarkPages, for 275cdf0e10cSrcweir every page in the bookmark document/list 276cdf0e10cSrcweir */ 277cdf0e10cSrcweir class SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase 278cdf0e10cSrcweir { 279cdf0e10cSrcweir public: 280cdf0e10cSrcweir virtual ~InsertBookmarkAsPage_PageFunctorBase() = 0; 281cdf0e10cSrcweir virtual void operator()( SdDrawDocument&, SdPage* ) = 0; 282cdf0e10cSrcweir }; 283cdf0e10cSrcweir 284cdf0e10cSrcweir SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase::~InsertBookmarkAsPage_PageFunctorBase() 285cdf0e10cSrcweir { 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir void SdDrawDocument::IterateBookmarkPages( SdDrawDocument* pBookmarkDoc, List* pBookmarkList, sal_uInt16 nBMSdPageCount, 289cdf0e10cSrcweir SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase& rPageIterator ) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir // 292cdf0e10cSrcweir // #96029# Refactored copy'n'pasted layout name collection from InsertBookmarkAsPage 293cdf0e10cSrcweir // 294cdf0e10cSrcweir int nPos, nEndPos; 295cdf0e10cSrcweir 296cdf0e10cSrcweir if( !pBookmarkList ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir // no list? whole source document 299cdf0e10cSrcweir nEndPos = nBMSdPageCount; 300cdf0e10cSrcweir } 301cdf0e10cSrcweir else 302cdf0e10cSrcweir { 303cdf0e10cSrcweir // bookmark list? number of entries 304cdf0e10cSrcweir nEndPos = pBookmarkList->Count(); 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir SdPage* pBMPage; 308cdf0e10cSrcweir 309cdf0e10cSrcweir // iterate over number of pages to insert 310cdf0e10cSrcweir for (nPos = 0; nPos < nEndPos; ++nPos) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir // the master page associated to the nPos'th page to insert 313cdf0e10cSrcweir SdPage* pBMMPage = NULL; 314cdf0e10cSrcweir 315cdf0e10cSrcweir if( !pBookmarkList ) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir // simply take master page of nPos'th page in source document 318cdf0e10cSrcweir pBMMPage = (SdPage*)(&(pBookmarkDoc->GetSdPage((sal_uInt16)nPos, PK_STANDARD)->TRG_GetMasterPage())); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir else 321cdf0e10cSrcweir { 322cdf0e10cSrcweir // fetch nPos'th entry from bookmark list, and determine master page 323cdf0e10cSrcweir String aBMPgName (*(String*) pBookmarkList->GetObject(nPos)); 324cdf0e10cSrcweir sal_Bool bIsMasterPage; 325cdf0e10cSrcweir 326cdf0e10cSrcweir sal_uInt16 nBMPage = pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage ); 327cdf0e10cSrcweir 328cdf0e10cSrcweir if (nBMPage != SDRPAGE_NOTFOUND) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir pBMPage = (SdPage*) pBookmarkDoc->GetPage(nBMPage); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir else 333cdf0e10cSrcweir { 334cdf0e10cSrcweir pBMPage = NULL; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir // enforce that bookmarked page is a standard page and not already a master page 338cdf0e10cSrcweir if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage()) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir const sal_uInt16 nBMSdPage = (nBMPage - 1) / 2; 341cdf0e10cSrcweir pBMMPage = (SdPage*) (&(pBookmarkDoc->GetSdPage(nBMSdPage, PK_STANDARD)->TRG_GetMasterPage())); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir // successfully determined valid (bookmarked) page? 346cdf0e10cSrcweir if( pBMMPage ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir // yes, call functor 349cdf0e10cSrcweir rPageIterator( *this, pBMMPage ); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir } 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir class InsertBookmarkAsPage_FindDuplicateLayouts : public SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase 355cdf0e10cSrcweir { 356cdf0e10cSrcweir public: 357cdf0e10cSrcweir InsertBookmarkAsPage_FindDuplicateLayouts( List* pLayoutsToTransfer, SdDrawDocument* pBookmarkDoc, 358cdf0e10cSrcweir List* pBookmarkList, sal_uInt16 nBMSdPageCount ) : 359cdf0e10cSrcweir mpLayoutsToTransfer(pLayoutsToTransfer), mpBookmarkDoc(pBookmarkDoc), 360cdf0e10cSrcweir mpBookmarkList(pBookmarkList), mnBMSdPageCount(nBMSdPageCount) {} 361cdf0e10cSrcweir virtual ~InsertBookmarkAsPage_FindDuplicateLayouts() {}; 362cdf0e10cSrcweir virtual void operator()( SdDrawDocument&, SdPage* ); 363cdf0e10cSrcweir private: 364cdf0e10cSrcweir List* mpLayoutsToTransfer; 365cdf0e10cSrcweir SdDrawDocument* mpBookmarkDoc; 366cdf0e10cSrcweir List* mpBookmarkList; 367cdf0e10cSrcweir sal_uInt16 mnBMSdPageCount; 368cdf0e10cSrcweir }; 369cdf0e10cSrcweir 370cdf0e10cSrcweir void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc, SdPage* pBMMPage ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir // now check for duplicate masterpage and layout names 373cdf0e10cSrcweir // =================================================== 374cdf0e10cSrcweir 375cdf0e10cSrcweir String sFullLayoutName( pBMMPage->GetLayoutName() ); 376cdf0e10cSrcweir String* pLayout = new String(sFullLayoutName); 377cdf0e10cSrcweir pLayout->Erase( pLayout->SearchAscii( SD_LT_SEPARATOR )); 378cdf0e10cSrcweir 379cdf0e10cSrcweir String* pTest = (String*) mpLayoutsToTransfer->First(); 380cdf0e10cSrcweir sal_Bool bFound = sal_False; 381cdf0e10cSrcweir 382cdf0e10cSrcweir while (pTest && !bFound) // found yet? 383cdf0e10cSrcweir { 384cdf0e10cSrcweir if (*pLayout == *pTest) 385cdf0e10cSrcweir bFound = sal_True; 386cdf0e10cSrcweir else 387cdf0e10cSrcweir pTest = (String*)mpLayoutsToTransfer->Next(); 388cdf0e10cSrcweir } 389cdf0e10cSrcweir 390cdf0e10cSrcweir const sal_uInt16 nMPageCount = rDoc.GetMasterPageCount(); 391cdf0e10cSrcweir for (sal_uInt16 nMPage = 0; nMPage < nMPageCount && !bFound; nMPage++) 392cdf0e10cSrcweir { 393cdf0e10cSrcweir /************************************************************** 394cdf0e10cSrcweir * Gibt es die Layouts schon im Dokument? 395cdf0e10cSrcweir **************************************************************/ 396cdf0e10cSrcweir SdPage* pTestPage = (SdPage*) rDoc.GetMasterPage(nMPage); 397cdf0e10cSrcweir String aTest(pTestPage->GetLayoutName()); 398cdf0e10cSrcweir aTest.Erase( aTest.SearchAscii( SD_LT_SEPARATOR )); 399cdf0e10cSrcweir 400cdf0e10cSrcweir if (aTest == *pLayout) 401cdf0e10cSrcweir bFound = sal_True; 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir if (!bFound) 405cdf0e10cSrcweir mpLayoutsToTransfer->Insert(pLayout, LIST_APPEND); 406cdf0e10cSrcweir else 407cdf0e10cSrcweir delete pLayout; 408cdf0e10cSrcweir } 409cdf0e10cSrcweir 410cdf0e10cSrcweir /** Just add one page to the container given to the constructor. 411cdf0e10cSrcweir */ 412cdf0e10cSrcweir class InsertBookmarkAsPage_AddBookmarkedPages 413cdf0e10cSrcweir : public SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase 414cdf0e10cSrcweir { 415cdf0e10cSrcweir public: 416cdf0e10cSrcweir InsertBookmarkAsPage_AddBookmarkedPages(::std::vector<SdPage*>& rContainer) 417cdf0e10cSrcweir : mrContainer(rContainer) {} 418cdf0e10cSrcweir ~InsertBookmarkAsPage_AddBookmarkedPages(void) {} 419cdf0e10cSrcweir void operator() (SdDrawDocument&, SdPage* pPage) { mrContainer.push_back(pPage); } 420cdf0e10cSrcweir private: 421cdf0e10cSrcweir ::std::vector<SdPage*>& mrContainer; 422cdf0e10cSrcweir }; 423cdf0e10cSrcweir 424cdf0e10cSrcweir 425cdf0e10cSrcweir sal_Bool SdDrawDocument::InsertBookmarkAsPage( 426cdf0e10cSrcweir List* pBookmarkList, 427cdf0e10cSrcweir List* pExchangeList, // Liste der zu verwendenen Namen 428cdf0e10cSrcweir sal_Bool bLink, 429cdf0e10cSrcweir sal_Bool bReplace, 430cdf0e10cSrcweir sal_uInt16 nInsertPos, 431cdf0e10cSrcweir sal_Bool bNoDialogs, 432cdf0e10cSrcweir ::sd::DrawDocShell* pBookmarkDocSh, 433cdf0e10cSrcweir sal_Bool bCopy, 434cdf0e10cSrcweir sal_Bool bMergeMasterPages, 435cdf0e10cSrcweir sal_Bool bPreservePageNames) 436cdf0e10cSrcweir { 437cdf0e10cSrcweir sal_Bool bOK = sal_True; 438cdf0e10cSrcweir sal_Bool bContinue = sal_True; 439cdf0e10cSrcweir sal_Bool bScaleObjects = sal_False; 440cdf0e10cSrcweir sal_uInt16 nReplacedStandardPages = 0; 441cdf0e10cSrcweir 442cdf0e10cSrcweir SdDrawDocument* pBookmarkDoc = NULL; 443cdf0e10cSrcweir String aBookmarkName; 444cdf0e10cSrcweir 445cdf0e10cSrcweir if (pBookmarkDocSh) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir pBookmarkDoc = pBookmarkDocSh->GetDoc(); 448cdf0e10cSrcweir 449cdf0e10cSrcweir if (pBookmarkDocSh->GetMedium()) 450cdf0e10cSrcweir { 451cdf0e10cSrcweir aBookmarkName = pBookmarkDocSh->GetMedium()->GetName(); 452cdf0e10cSrcweir } 453cdf0e10cSrcweir } 454cdf0e10cSrcweir else if ( mxBookmarkDocShRef.Is() ) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir pBookmarkDoc = mxBookmarkDocShRef->GetDoc(); 457cdf0e10cSrcweir aBookmarkName = maBookmarkFile; 458cdf0e10cSrcweir } 459cdf0e10cSrcweir else 460cdf0e10cSrcweir { 461cdf0e10cSrcweir return sal_False; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir 464cdf0e10cSrcweir const sal_uInt16 nSdPageCount = GetSdPageCount(PK_STANDARD); 465cdf0e10cSrcweir const sal_uInt16 nBMSdPageCount = pBookmarkDoc->GetSdPageCount(PK_STANDARD); 466cdf0e10cSrcweir const sal_uInt16 nMPageCount = GetMasterPageCount(); 467cdf0e10cSrcweir 468cdf0e10cSrcweir if (nSdPageCount==0 || nBMSdPageCount==0 || nMPageCount==0) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir bContinue = bOK = sal_False; 471cdf0e10cSrcweir return(bContinue); 472cdf0e10cSrcweir } 473cdf0e10cSrcweir 474cdf0e10cSrcweir // Store the size and some other properties of the first page and notes 475cdf0e10cSrcweir // page so that inserted pages can be properly scaled even when inserted 476cdf0e10cSrcweir // before the first page. 477cdf0e10cSrcweir // Note that the pointers are used later on as general page pointers. 478cdf0e10cSrcweir SdPage* pRefPage = GetSdPage(0, PK_STANDARD); 479cdf0e10cSrcweir Size aSize(pRefPage->GetSize()); 480cdf0e10cSrcweir sal_Int32 nLeft = pRefPage->GetLftBorder(); 481cdf0e10cSrcweir sal_Int32 nRight = pRefPage->GetRgtBorder(); 482cdf0e10cSrcweir sal_Int32 nUpper = pRefPage->GetUppBorder(); 483cdf0e10cSrcweir sal_Int32 nLower = pRefPage->GetLwrBorder(); 484cdf0e10cSrcweir Orientation eOrient = pRefPage->GetOrientation(); 485cdf0e10cSrcweir 486cdf0e10cSrcweir SdPage* pNPage = GetSdPage(0, PK_NOTES); 487cdf0e10cSrcweir Size aNSize(GetSdPage(0, PK_NOTES)->GetSize()); 488cdf0e10cSrcweir sal_Int32 nNLeft = pNPage->GetLftBorder(); 489cdf0e10cSrcweir sal_Int32 nNRight = pNPage->GetRgtBorder(); 490cdf0e10cSrcweir sal_Int32 nNUpper = pNPage->GetUppBorder(); 491cdf0e10cSrcweir sal_Int32 nNLower = pNPage->GetLwrBorder(); 492cdf0e10cSrcweir Orientation eNOrient = pRefPage->GetOrientation(); 493cdf0e10cSrcweir 494cdf0e10cSrcweir // Seitengroesse und -raender an die Werte der letzten 495cdf0e10cSrcweir // Seiten anpassen? 496cdf0e10cSrcweir pRefPage = GetSdPage(nSdPageCount - 1, PK_STANDARD); 497cdf0e10cSrcweir 498cdf0e10cSrcweir if( bNoDialogs ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir if( !pBookmarkList ) 501cdf0e10cSrcweir bScaleObjects = pRefPage->IsScaleObjects(); 502cdf0e10cSrcweir else 503cdf0e10cSrcweir bScaleObjects = sal_True; 504cdf0e10cSrcweir } 505cdf0e10cSrcweir else 506cdf0e10cSrcweir { 507cdf0e10cSrcweir SdPage* pBMPage = pBookmarkDoc->GetSdPage(0,PK_STANDARD); 508cdf0e10cSrcweir 509cdf0e10cSrcweir if (pBMPage->GetSize() != pRefPage->GetSize() || 510cdf0e10cSrcweir pBMPage->GetLftBorder() != pRefPage->GetLftBorder() || 511cdf0e10cSrcweir pBMPage->GetRgtBorder() != pRefPage->GetRgtBorder() || 512cdf0e10cSrcweir pBMPage->GetUppBorder() != pRefPage->GetUppBorder() || 513cdf0e10cSrcweir pBMPage->GetLwrBorder() != pRefPage->GetLwrBorder()) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir String aStr(SdResId(STR_SCALE_OBJECTS)); 516cdf0e10cSrcweir sal_uInt16 nBut = QueryBox( NULL, WB_YES_NO_CANCEL, aStr).Execute(); 517cdf0e10cSrcweir 518cdf0e10cSrcweir bScaleObjects = nBut == RET_YES; 519cdf0e10cSrcweir bContinue = nBut != RET_CANCEL; 520cdf0e10cSrcweir 521cdf0e10cSrcweir if (!bContinue) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir return(bContinue); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir } 526cdf0e10cSrcweir } 527cdf0e10cSrcweir 528cdf0e10cSrcweir 529cdf0e10cSrcweir /************************************************************************** 530cdf0e10cSrcweir |* Die benoetigten Praesentations-StyleSheets ermitteln und vor 531cdf0e10cSrcweir |* den Seiten transferieren, sonst verlieren die Textobjekte 532cdf0e10cSrcweir |* beim Transfer den Bezug zur Vorlage 533cdf0e10cSrcweir \*************************************************************************/ 534cdf0e10cSrcweir ::svl::IUndoManager* pUndoMgr = NULL; 535cdf0e10cSrcweir if( mpDocSh ) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir pUndoMgr = mpDocSh->GetUndoManager(); 538cdf0e10cSrcweir pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_INSERTPAGES)), String()); 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir List* pLayoutsToTransfer = new List; 542cdf0e10cSrcweir 543cdf0e10cSrcweir // 544cdf0e10cSrcweir // #96029# Refactored copy'n'pasted layout name collection into IterateBookmarkPages 545cdf0e10cSrcweir // 546cdf0e10cSrcweir InsertBookmarkAsPage_FindDuplicateLayouts aSearchFunctor( pLayoutsToTransfer, pBookmarkDoc, 547cdf0e10cSrcweir pBookmarkList, nBMSdPageCount ); 548cdf0e10cSrcweir IterateBookmarkPages( pBookmarkDoc, pBookmarkList, nBMSdPageCount, aSearchFunctor ); 549cdf0e10cSrcweir 550cdf0e10cSrcweir 551cdf0e10cSrcweir /************************************************************************** 552cdf0e10cSrcweir * Die tatsaechlich benoetigten Vorlagen kopieren 553cdf0e10cSrcweir **************************************************************************/ 554cdf0e10cSrcweir SdStyleSheetPool* pBookmarkStyleSheetPool = 555cdf0e10cSrcweir (SdStyleSheetPool*) pBookmarkDoc->GetStyleSheetPool(); 556cdf0e10cSrcweir String* pLayout = (String*) pLayoutsToTransfer->First(); 557cdf0e10cSrcweir 558cdf0e10cSrcweir // Wenn Vorlagen kopiert werden muessen, dann muessen auch die 559cdf0e10cSrcweir // MasterPages kopiert werden! 560cdf0e10cSrcweir if( pLayout ) 561cdf0e10cSrcweir bMergeMasterPages = sal_True; 562cdf0e10cSrcweir 563cdf0e10cSrcweir while (pLayout) 564cdf0e10cSrcweir { 565cdf0e10cSrcweir SdStyleSheetVector aCreatedStyles; 566cdf0e10cSrcweir 567cdf0e10cSrcweir ((SdStyleSheetPool*)GetStyleSheetPool())->CopyLayoutSheets(*pLayout, *pBookmarkStyleSheetPool,aCreatedStyles); 568cdf0e10cSrcweir 569cdf0e10cSrcweir if(!aCreatedStyles.empty()) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir if( pUndoMgr ) 572cdf0e10cSrcweir { 573cdf0e10cSrcweir SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aCreatedStyles, sal_True); 574cdf0e10cSrcweir pUndoMgr->AddUndoAction(pMovStyles); 575cdf0e10cSrcweir } 576cdf0e10cSrcweir } 577cdf0e10cSrcweir 578cdf0e10cSrcweir delete pLayout; 579cdf0e10cSrcweir 580cdf0e10cSrcweir pLayout = (String*)pLayoutsToTransfer->Next(); 581cdf0e10cSrcweir } 582cdf0e10cSrcweir 583cdf0e10cSrcweir delete pLayoutsToTransfer; 584cdf0e10cSrcweir 585cdf0e10cSrcweir /************************************************************************** 586cdf0e10cSrcweir * Dokument einfuegen 587cdf0e10cSrcweir **************************************************************************/ 588cdf0e10cSrcweir 589cdf0e10cSrcweir const bool bUndo = IsUndoEnabled(); 590cdf0e10cSrcweir 591cdf0e10cSrcweir if( bUndo ) 592cdf0e10cSrcweir BegUndo(String(SdResId(STR_UNDO_INSERTPAGES))); 593cdf0e10cSrcweir 594cdf0e10cSrcweir if (!pBookmarkList) 595cdf0e10cSrcweir { 596cdf0e10cSrcweir if (nInsertPos >= GetPageCount()) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir // Seiten werden hinten angefuegt 599cdf0e10cSrcweir nInsertPos = GetPageCount(); 600cdf0e10cSrcweir } 601cdf0e10cSrcweir 602cdf0e10cSrcweir sal_uInt16 nActualInsertPos = nInsertPos; 603cdf0e10cSrcweir 604cdf0e10cSrcweir List aNameList; 605cdf0e10cSrcweir std::set<sal_uInt16> aRenameSet; 606cdf0e10cSrcweir sal_uInt16 nBMSdPage; 607cdf0e10cSrcweir 608cdf0e10cSrcweir for (nBMSdPage=0; nBMSdPage < nBMSdPageCount; nBMSdPage++) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir SdPage* pBMPage = pBookmarkDoc->GetSdPage(nBMSdPage, PK_STANDARD); 611cdf0e10cSrcweir String pName( pBMPage->GetName() ); 612cdf0e10cSrcweir sal_Bool bIsMasterPage; 613cdf0e10cSrcweir 614cdf0e10cSrcweir if (bLink) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir // Es werden sich die Namen aller Seiten gemerkt 617cdf0e10cSrcweir aNameList.Insert(new String(pName), nBMSdPage); 618cdf0e10cSrcweir } 619cdf0e10cSrcweir 620cdf0e10cSrcweir // #95677# Have to check for duplicate names here, too 621cdf0e10cSrcweir // #67905# don't change name if source and dest model are the same! 622cdf0e10cSrcweir if( pBookmarkDoc != this && 623cdf0e10cSrcweir GetPageByName(pName, bIsMasterPage ) != SDRPAGE_NOTFOUND ) 624cdf0e10cSrcweir { 625cdf0e10cSrcweir // #95991# delay renaming *after* pages are copied (might destroy source otherwise) 626cdf0e10cSrcweir aRenameSet.insert(nBMSdPage); 627cdf0e10cSrcweir } 628cdf0e10cSrcweir } 629cdf0e10cSrcweir 630cdf0e10cSrcweir Merge(*pBookmarkDoc, 631cdf0e10cSrcweir 1, // Nicht die Handzettelseite 632cdf0e10cSrcweir 0xFFFF, // Aber alle anderen 633cdf0e10cSrcweir nActualInsertPos, // An Position einfuegen 634cdf0e10cSrcweir bMergeMasterPages, // MasterPages mitnehmen 635cdf0e10cSrcweir sal_False, // Aber nur die benoetigten MasterPages 636cdf0e10cSrcweir sal_True, // Undo-Aktion erzeugen 637cdf0e10cSrcweir bCopy); // Seiten kopieren (oder mergen) 638cdf0e10cSrcweir 639cdf0e10cSrcweir for (nBMSdPage=0; nBMSdPage < nBMSdPageCount; nBMSdPage++) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir SdPage* pPage = (SdPage*) GetPage(nActualInsertPos); 642cdf0e10cSrcweir SdPage* pNotesPage = (SdPage*) GetPage(nActualInsertPos+1); 643cdf0e10cSrcweir String* pName = (String*) aNameList.GetObject(nBMSdPage); 644cdf0e10cSrcweir 645cdf0e10cSrcweir // #95991# delay renaming *after* pages are copied (might destroy source otherwise) 646cdf0e10cSrcweir if( aRenameSet.find(nBMSdPage) != aRenameSet.end() ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir // Seitenname schon vorhanden -> Defaultname 649cdf0e10cSrcweir // fuer Standard & Notizseite 650cdf0e10cSrcweir pPage->SetName(String()); 651cdf0e10cSrcweir pNotesPage->SetName(String()); 652cdf0e10cSrcweir } 653cdf0e10cSrcweir 654cdf0e10cSrcweir if (bLink) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir // Nun werden die Link-Namen zusammengestellt 657cdf0e10cSrcweir pPage->SetFileName(aBookmarkName); 658cdf0e10cSrcweir pPage->SetBookmarkName(*(pName)); 659cdf0e10cSrcweir delete pName; 660cdf0e10cSrcweir pPage->SetModel(this); 661cdf0e10cSrcweir } 662cdf0e10cSrcweir 663cdf0e10cSrcweir nActualInsertPos += 2; 664cdf0e10cSrcweir } 665cdf0e10cSrcweir } 666cdf0e10cSrcweir else 667cdf0e10cSrcweir { 668cdf0e10cSrcweir /********************************************************************** 669cdf0e10cSrcweir * Ausgewaehlte Seiten einfuegen 670cdf0e10cSrcweir **********************************************************************/ 671cdf0e10cSrcweir SdPage* pBMPage; 672cdf0e10cSrcweir 673cdf0e10cSrcweir if (nInsertPos >= GetPageCount()) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir // Seiten werden hinten angefuegt 676cdf0e10cSrcweir bReplace = sal_False; 677cdf0e10cSrcweir nInsertPos = GetPageCount(); 678cdf0e10cSrcweir } 679cdf0e10cSrcweir 680cdf0e10cSrcweir sal_uInt16 nActualInsertPos = nInsertPos; 681cdf0e10cSrcweir 682cdf0e10cSrcweir // Collect the bookmarked pages. 683cdf0e10cSrcweir ::std::vector<SdPage*> aBookmarkedPages (pBookmarkList->Count(), NULL); 684cdf0e10cSrcweir for (sal_uInt16 nPos = 0; nPos < pBookmarkList->Count(); nPos++) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir String aPgName(*(String*) pBookmarkList->GetObject(nPos)); 687cdf0e10cSrcweir sal_Bool bIsMasterPage; 688cdf0e10cSrcweir sal_uInt16 nBMPage = pBookmarkDoc->GetPageByName( aPgName, bIsMasterPage ); 689cdf0e10cSrcweir 690cdf0e10cSrcweir if (nBMPage != SDRPAGE_NOTFOUND) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir aBookmarkedPages[nPos] = dynamic_cast<SdPage*>(pBookmarkDoc->GetPage(nBMPage)); 693cdf0e10cSrcweir } 694cdf0e10cSrcweir } 695cdf0e10cSrcweir 696cdf0e10cSrcweir for (sal_uInt16 nPos = 0; nPos < pBookmarkList->Count(); nPos++) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir pBMPage = aBookmarkedPages[nPos]; 699cdf0e10cSrcweir sal_uInt16 nBMPage = pBMPage!=NULL ? pBMPage->GetPageNum() : SDRPAGE_NOTFOUND; 700cdf0e10cSrcweir 701cdf0e10cSrcweir if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage()) 702cdf0e10cSrcweir { 703cdf0e10cSrcweir /************************************************************** 704cdf0e10cSrcweir * Es muss eine StandardSeite sein 705cdf0e10cSrcweir **************************************************************/ 706cdf0e10cSrcweir sal_Bool bMustRename = sal_False; 707cdf0e10cSrcweir 708cdf0e10cSrcweir // #95991# delay renaming *after* pages are copied (might destroy source otherwise) 709cdf0e10cSrcweir // #67905# don't change name if source and dest model are the same! 710cdf0e10cSrcweir // #96029# avoid renaming if replacing the same page 711cdf0e10cSrcweir String aPgName(*(String*) pBookmarkList->GetObject(nPos)); 712cdf0e10cSrcweir sal_Bool bIsMasterPage; 713cdf0e10cSrcweir sal_uInt16 nPageSameName = GetPageByName(aPgName, bIsMasterPage); 714cdf0e10cSrcweir if( pBookmarkDoc != this && 715cdf0e10cSrcweir nPageSameName != SDRPAGE_NOTFOUND && 716cdf0e10cSrcweir ( !bReplace || 717cdf0e10cSrcweir nPageSameName != nActualInsertPos ) ) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir bMustRename = sal_True; 720cdf0e10cSrcweir } 721cdf0e10cSrcweir 722cdf0e10cSrcweir SdPage* pBookmarkPage = pBMPage; 723cdf0e10cSrcweir if (bReplace ) 724cdf0e10cSrcweir { 725cdf0e10cSrcweir ReplacePageInCustomShows( dynamic_cast< SdPage* >( GetPage( nActualInsertPos ) ), pBookmarkPage ); 726cdf0e10cSrcweir } 727cdf0e10cSrcweir 728cdf0e10cSrcweir Merge(*pBookmarkDoc, 729cdf0e10cSrcweir nBMPage, // Von Seite (Standard) 730cdf0e10cSrcweir nBMPage+1, // Bis Seite (Notizen) 731cdf0e10cSrcweir nActualInsertPos, // An Position einfuegen 732cdf0e10cSrcweir bMergeMasterPages, // MasterPages mitnehmen 733cdf0e10cSrcweir sal_False, // Aber nur die benoetigten MasterPages 734cdf0e10cSrcweir sal_True, // Undo-Aktion erzeugen 735cdf0e10cSrcweir bCopy); // Seiten kopieren (oder mergen) 736cdf0e10cSrcweir 737cdf0e10cSrcweir if( bReplace ) 738cdf0e10cSrcweir { 739cdf0e10cSrcweir if( GetPage( nActualInsertPos ) != pBookmarkPage ) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir // bookmark page was not moved but cloned, so update custom shows again 742cdf0e10cSrcweir ReplacePageInCustomShows( pBookmarkPage, dynamic_cast< SdPage* >( GetPage( nActualInsertPos ) ) ); 743cdf0e10cSrcweir } 744cdf0e10cSrcweir } 745cdf0e10cSrcweir 746cdf0e10cSrcweir if( bMustRename ) 747cdf0e10cSrcweir { 748cdf0e10cSrcweir // Seitenname schon vorhanden -> Defaultname 749cdf0e10cSrcweir // fuer Standard & Notizseite 750cdf0e10cSrcweir SdPage* pPage = (SdPage*) GetPage(nActualInsertPos); 751cdf0e10cSrcweir pPage->SetName(String()); 752cdf0e10cSrcweir SdPage* pNotesPage = (SdPage*) GetPage(nActualInsertPos+1); 753cdf0e10cSrcweir pNotesPage->SetName(String()); 754cdf0e10cSrcweir } 755cdf0e10cSrcweir 756cdf0e10cSrcweir if (bLink) 757cdf0e10cSrcweir { 758cdf0e10cSrcweir SdPage* pPage = (SdPage*) GetPage(nActualInsertPos); 759cdf0e10cSrcweir pPage->SetFileName(aBookmarkName); 760cdf0e10cSrcweir pPage->SetBookmarkName(aPgName); 761cdf0e10cSrcweir pPage->SetModel(this); 762cdf0e10cSrcweir } 763cdf0e10cSrcweir 764cdf0e10cSrcweir if (bReplace) 765cdf0e10cSrcweir { 766cdf0e10cSrcweir // Seite & Notizseite ausfuegen 767cdf0e10cSrcweir const sal_uInt16 nDestPageNum(nActualInsertPos + 2); 768cdf0e10cSrcweir SdPage* pStandardPage = 0L; 769cdf0e10cSrcweir 770cdf0e10cSrcweir if(nDestPageNum < GetPageCount()) 771cdf0e10cSrcweir { 772cdf0e10cSrcweir pStandardPage = (SdPage*)GetPage(nDestPageNum); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir if (pStandardPage) 776cdf0e10cSrcweir { 777cdf0e10cSrcweir if( bPreservePageNames ) 778cdf0e10cSrcweir { 779cdf0e10cSrcweir // #96029# Take old slide names for inserted pages 780cdf0e10cSrcweir SdPage* pPage = (SdPage*) GetPage(nActualInsertPos); 781cdf0e10cSrcweir pPage->SetName( pStandardPage->GetRealName() ); 782cdf0e10cSrcweir } 783cdf0e10cSrcweir 784cdf0e10cSrcweir if( bUndo ) 785cdf0e10cSrcweir AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pStandardPage)); 786cdf0e10cSrcweir 787cdf0e10cSrcweir RemovePage(nDestPageNum); 788cdf0e10cSrcweir 789cdf0e10cSrcweir if( !bUndo ) 790cdf0e10cSrcweir delete pStandardPage; 791cdf0e10cSrcweir } 792cdf0e10cSrcweir 793cdf0e10cSrcweir SdPage* pNotesPage = 0L; 794cdf0e10cSrcweir 795cdf0e10cSrcweir if(nDestPageNum < GetPageCount()) 796cdf0e10cSrcweir { 797cdf0e10cSrcweir pNotesPage = (SdPage*)GetPage(nDestPageNum); 798cdf0e10cSrcweir } 799cdf0e10cSrcweir 800cdf0e10cSrcweir if (pNotesPage) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir if( bPreservePageNames ) 803cdf0e10cSrcweir { 804cdf0e10cSrcweir // #96029# Take old slide names for inserted pages 805cdf0e10cSrcweir SdPage* pNewNotesPage = (SdPage*) GetPage(nActualInsertPos+1); 806cdf0e10cSrcweir if( pNewNotesPage ) 807cdf0e10cSrcweir pNewNotesPage->SetName( pStandardPage->GetRealName() ); 808cdf0e10cSrcweir } 809cdf0e10cSrcweir 810cdf0e10cSrcweir if( bUndo ) 811cdf0e10cSrcweir AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage)); 812cdf0e10cSrcweir 813cdf0e10cSrcweir RemovePage(nDestPageNum); 814cdf0e10cSrcweir 815cdf0e10cSrcweir if( !bUndo ) 816cdf0e10cSrcweir delete pNotesPage; 817cdf0e10cSrcweir } 818cdf0e10cSrcweir 819cdf0e10cSrcweir nReplacedStandardPages++; 820cdf0e10cSrcweir } 821cdf0e10cSrcweir 822cdf0e10cSrcweir nActualInsertPos += 2; 823cdf0e10cSrcweir } 824cdf0e10cSrcweir } 825cdf0e10cSrcweir } 826cdf0e10cSrcweir 827cdf0e10cSrcweir 828cdf0e10cSrcweir /************************************************************************** 829cdf0e10cSrcweir |* Dabei sind evtl. zu viele Masterpages ruebergekommen, da die 830cdf0e10cSrcweir |* DrawingEngine gleiche Praesentationslayouts nicht erkennen kann. 831cdf0e10cSrcweir |* Ueberzaehlige MasterPages entfernen. 832cdf0e10cSrcweir \*************************************************************************/ 833cdf0e10cSrcweir sal_uInt16 nNewMPageCount = GetMasterPageCount(); 834cdf0e10cSrcweir 835cdf0e10cSrcweir // rueckwaerts, damit Nummern nicht durcheinander geraten 836cdf0e10cSrcweir for (sal_uInt16 nPage = nNewMPageCount - 1; nPage >= nMPageCount; nPage--) 837cdf0e10cSrcweir { 838cdf0e10cSrcweir pRefPage = (SdPage*) GetMasterPage(nPage); 839cdf0e10cSrcweir String aMPLayout(pRefPage->GetLayoutName()); 840cdf0e10cSrcweir PageKind eKind = pRefPage->GetPageKind(); 841cdf0e10cSrcweir 842cdf0e10cSrcweir // gibt's den schon? 843cdf0e10cSrcweir for (sal_uInt16 nTest = 0; nTest < nMPageCount; nTest++) 844cdf0e10cSrcweir { 845cdf0e10cSrcweir SdPage* pTest = (SdPage*) GetMasterPage(nTest); 846cdf0e10cSrcweir String aTest(pTest->GetLayoutName()); 847cdf0e10cSrcweir 848cdf0e10cSrcweir // #96029# nInsertPos > 2 is always true when inserting into non-empty models 849cdf0e10cSrcweir if ( nInsertPos > 2 && 850cdf0e10cSrcweir aTest == aMPLayout && 851cdf0e10cSrcweir eKind == pTest->GetPageKind() ) 852cdf0e10cSrcweir { 853cdf0e10cSrcweir if( bUndo ) 854cdf0e10cSrcweir AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pRefPage)); 855cdf0e10cSrcweir 856cdf0e10cSrcweir RemoveMasterPage(nPage); 857cdf0e10cSrcweir 858cdf0e10cSrcweir if( !bUndo ) 859cdf0e10cSrcweir delete pRefPage; 860cdf0e10cSrcweir nNewMPageCount--; 861cdf0e10cSrcweir break; 862cdf0e10cSrcweir } 863cdf0e10cSrcweir } 864cdf0e10cSrcweir } 865cdf0e10cSrcweir 866cdf0e10cSrcweir // #96029# nInsertPos > 2 is always true when inserting into non-empty models 867cdf0e10cSrcweir if (nInsertPos > 0) 868cdf0e10cSrcweir { 869cdf0e10cSrcweir sal_uInt16 nSdPageStart = (nInsertPos - 1) / 2; 870cdf0e10cSrcweir sal_uInt16 nSdPageEnd = GetSdPageCount(PK_STANDARD) - nSdPageCount + 871cdf0e10cSrcweir nSdPageStart - 1; 872cdf0e10cSrcweir const bool bRemoveEmptyPresObj = pBookmarkDoc && 873cdf0e10cSrcweir (pBookmarkDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) && 874cdf0e10cSrcweir (GetDocumentType() == DOCUMENT_TYPE_DRAW); 875cdf0e10cSrcweir 876cdf0e10cSrcweir if( bReplace ) 877cdf0e10cSrcweir { 878cdf0e10cSrcweir nSdPageEnd = nSdPageStart + nReplacedStandardPages - 1; 879cdf0e10cSrcweir } 880cdf0e10cSrcweir 881cdf0e10cSrcweir for (sal_uInt16 nSdPage = nSdPageStart; nSdPage <= nSdPageEnd; nSdPage++) 882cdf0e10cSrcweir { 883cdf0e10cSrcweir pRefPage = GetSdPage(nSdPage, PK_STANDARD); 884cdf0e10cSrcweir 885cdf0e10cSrcweir if (pExchangeList) 886cdf0e10cSrcweir { 887cdf0e10cSrcweir // Zuverwendener Name aus Exchange-Liste holen 888cdf0e10cSrcweir if (pExchangeList->GetCurObject()) 889cdf0e10cSrcweir { 890cdf0e10cSrcweir String aExchangeName (*(String*) pExchangeList->GetCurObject()); 891cdf0e10cSrcweir pRefPage->SetName(aExchangeName); 892cdf0e10cSrcweir SdrHint aHint(HINT_PAGEORDERCHG); 893cdf0e10cSrcweir aHint.SetPage(pRefPage); 894cdf0e10cSrcweir Broadcast(aHint); 895cdf0e10cSrcweir SdPage* pNewNotesPage = GetSdPage(nSdPage, PK_NOTES); 896cdf0e10cSrcweir pNewNotesPage->SetName(aExchangeName); 897cdf0e10cSrcweir aHint.SetPage(pNewNotesPage); 898cdf0e10cSrcweir Broadcast(aHint); 899cdf0e10cSrcweir } 900cdf0e10cSrcweir 901cdf0e10cSrcweir pExchangeList->Next(); 902cdf0e10cSrcweir } 903cdf0e10cSrcweir 904cdf0e10cSrcweir String aLayout(pRefPage->GetLayoutName()); 905cdf0e10cSrcweir aLayout.Erase(aLayout.SearchAscii( SD_LT_SEPARATOR )); 906cdf0e10cSrcweir 907cdf0e10cSrcweir // update layout and referred master page 908cdf0e10cSrcweir pRefPage->SetPresentationLayout(aLayout); 909cdf0e10cSrcweir if( bUndo ) 910cdf0e10cSrcweir AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) ); 911cdf0e10cSrcweir 912cdf0e10cSrcweir if (bScaleObjects) 913cdf0e10cSrcweir { 914cdf0e10cSrcweir Rectangle aBorderRect(nLeft, nUpper, nRight, nLower); 915cdf0e10cSrcweir pRefPage->ScaleObjects(aSize, aBorderRect, sal_True); 916cdf0e10cSrcweir } 917cdf0e10cSrcweir pRefPage->SetSize(aSize); 918cdf0e10cSrcweir pRefPage->SetBorder(nLeft, nUpper, nRight, nLower); 919cdf0e10cSrcweir pRefPage->SetOrientation( eOrient ); 920cdf0e10cSrcweir 921cdf0e10cSrcweir if( bRemoveEmptyPresObj ) 922cdf0e10cSrcweir pRefPage->RemoveEmptyPresentationObjects(); 923cdf0e10cSrcweir 924cdf0e10cSrcweir pRefPage = GetSdPage(nSdPage, PK_NOTES); 925cdf0e10cSrcweir 926cdf0e10cSrcweir // update layout and referred master page 927cdf0e10cSrcweir pRefPage->SetPresentationLayout(aLayout); 928cdf0e10cSrcweir if( bUndo ) 929cdf0e10cSrcweir AddUndo( GetSdrUndoFactory().CreateUndoPageChangeMasterPage( *pRefPage ) ); 930cdf0e10cSrcweir 931cdf0e10cSrcweir if (bScaleObjects) 932cdf0e10cSrcweir { 933cdf0e10cSrcweir Rectangle aBorderRect(nNLeft, nNUpper, nNRight, nNLower); 934cdf0e10cSrcweir pRefPage->ScaleObjects(aNSize, aBorderRect, sal_True); 935cdf0e10cSrcweir } 936cdf0e10cSrcweir 937cdf0e10cSrcweir pRefPage->SetSize(aNSize); 938cdf0e10cSrcweir pRefPage->SetBorder(nNLeft, nNUpper, nNRight, nNLower); 939cdf0e10cSrcweir pRefPage->SetOrientation( eNOrient ); 940cdf0e10cSrcweir 941cdf0e10cSrcweir if( bRemoveEmptyPresObj ) 942cdf0e10cSrcweir pRefPage->RemoveEmptyPresentationObjects(); 943cdf0e10cSrcweir } 944cdf0e10cSrcweir 945cdf0e10cSrcweir for (sal_uInt16 nPage = nMPageCount; nPage < nNewMPageCount; nPage++) 946cdf0e10cSrcweir { 947cdf0e10cSrcweir pRefPage = (SdPage*) GetMasterPage(nPage); 948cdf0e10cSrcweir if (pRefPage->GetPageKind() == PK_STANDARD) 949cdf0e10cSrcweir { 950cdf0e10cSrcweir if (bScaleObjects) 951cdf0e10cSrcweir { 952cdf0e10cSrcweir Rectangle aBorderRect(nLeft, nUpper, nRight, nLower); 953cdf0e10cSrcweir pRefPage->ScaleObjects(aSize, aBorderRect, sal_True); 954cdf0e10cSrcweir } 955cdf0e10cSrcweir pRefPage->SetSize(aSize); 956cdf0e10cSrcweir pRefPage->SetBorder(nLeft, nUpper, nRight, nLower); 957cdf0e10cSrcweir pRefPage->SetOrientation( eOrient ); 958cdf0e10cSrcweir } 959cdf0e10cSrcweir else // kann nur noch NOTES sein 960cdf0e10cSrcweir { 961cdf0e10cSrcweir if (bScaleObjects) 962cdf0e10cSrcweir { 963cdf0e10cSrcweir Rectangle aBorderRect(nNLeft, nNUpper, nNRight, nNLower); 964cdf0e10cSrcweir pRefPage->ScaleObjects(aNSize, aBorderRect, sal_True); 965cdf0e10cSrcweir } 966cdf0e10cSrcweir pRefPage->SetSize(aNSize); 967cdf0e10cSrcweir pRefPage->SetBorder(nNLeft, nNUpper, nNRight, nNLower); 968cdf0e10cSrcweir pRefPage->SetOrientation( eNOrient ); 969cdf0e10cSrcweir } 970cdf0e10cSrcweir 971cdf0e10cSrcweir if( bRemoveEmptyPresObj ) 972cdf0e10cSrcweir pRefPage->RemoveEmptyPresentationObjects(); 973cdf0e10cSrcweir } 974cdf0e10cSrcweir } 975cdf0e10cSrcweir 976cdf0e10cSrcweir // #91146# Make absolutely sure no double masterpages are there 977cdf0e10cSrcweir RemoveUnnecessaryMasterPages(NULL, sal_True, sal_True); 978cdf0e10cSrcweir 979cdf0e10cSrcweir if( bUndo ) 980cdf0e10cSrcweir EndUndo(); 981cdf0e10cSrcweir pUndoMgr->LeaveListAction(); 982cdf0e10cSrcweir 983cdf0e10cSrcweir return bContinue; 984cdf0e10cSrcweir } 985cdf0e10cSrcweir 986cdf0e10cSrcweir /************************************************************************* 987cdf0e10cSrcweir |* 988cdf0e10cSrcweir |* Fuegt ein Bookmark als Objekt ein 989cdf0e10cSrcweir |* 990cdf0e10cSrcweir \************************************************************************/ 991cdf0e10cSrcweir 992cdf0e10cSrcweir sal_Bool SdDrawDocument::InsertBookmarkAsObject( 993cdf0e10cSrcweir List* pBookmarkList, 994cdf0e10cSrcweir List* pExchangeList, // Liste der zu verwendenen Namen 995cdf0e10cSrcweir sal_Bool /* bLink */, 996cdf0e10cSrcweir ::sd::DrawDocShell* pBookmarkDocSh, 997cdf0e10cSrcweir Point* pObjPos) 998cdf0e10cSrcweir { 999cdf0e10cSrcweir sal_Bool bOK = sal_True; 1000cdf0e10cSrcweir sal_Bool bOLEObjFound = sal_False; 1001cdf0e10cSrcweir ::sd::View* pBMView = NULL; 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir SdDrawDocument* pBookmarkDoc = NULL; 1004cdf0e10cSrcweir String aBookmarkName; 1005cdf0e10cSrcweir 1006cdf0e10cSrcweir if (pBookmarkDocSh) 1007cdf0e10cSrcweir { 1008cdf0e10cSrcweir pBookmarkDoc = pBookmarkDocSh->GetDoc(); 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir if (pBookmarkDocSh->GetMedium()) 1011cdf0e10cSrcweir { 1012cdf0e10cSrcweir aBookmarkName = pBookmarkDocSh->GetMedium()->GetName(); 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir } 1015cdf0e10cSrcweir else if ( mxBookmarkDocShRef.Is() ) 1016cdf0e10cSrcweir { 1017cdf0e10cSrcweir pBookmarkDoc = mxBookmarkDocShRef->GetDoc(); 1018cdf0e10cSrcweir aBookmarkName = maBookmarkFile; 1019cdf0e10cSrcweir } 1020cdf0e10cSrcweir else 1021cdf0e10cSrcweir { 1022cdf0e10cSrcweir return sal_False; 1023cdf0e10cSrcweir } 1024cdf0e10cSrcweir 1025cdf0e10cSrcweir if (!pBookmarkList) 1026cdf0e10cSrcweir { 1027cdf0e10cSrcweir pBMView = new ::sd::View(pBookmarkDoc, (OutputDevice*) NULL); 1028cdf0e10cSrcweir pBMView->EndListening(*pBookmarkDoc); 1029cdf0e10cSrcweir pBMView->MarkAll(); 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir else 1032cdf0e10cSrcweir { 1033cdf0e10cSrcweir SdrPage* pPage; 1034cdf0e10cSrcweir SdrPageView* pPV; 1035cdf0e10cSrcweir 1036cdf0e10cSrcweir for (sal_uInt16 nPos = 0; nPos < pBookmarkList->Count(); nPos++) 1037cdf0e10cSrcweir { 1038cdf0e10cSrcweir /****************************************************************** 1039cdf0e10cSrcweir * Namen der Bookmarks aus Liste holen 1040cdf0e10cSrcweir ******************************************************************/ 1041cdf0e10cSrcweir String aBMName (*(String*) pBookmarkList->GetObject(nPos)); 1042cdf0e10cSrcweir 1043cdf0e10cSrcweir SdrObject* pObj = pBookmarkDoc->GetObj(aBMName); 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir if (pObj) 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir // Objekt gefunden 1048cdf0e10cSrcweir 1049cdf0e10cSrcweir if (pObj->GetObjInventor() == SdrInventor && 1050cdf0e10cSrcweir pObj->GetObjIdentifier() == OBJ_OLE2) 1051cdf0e10cSrcweir { 1052cdf0e10cSrcweir bOLEObjFound = sal_True; 1053cdf0e10cSrcweir } 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir if (!pBMView) 1056cdf0e10cSrcweir { 1057cdf0e10cSrcweir // View erstmalig erzeugen 1058cdf0e10cSrcweir pBMView = new ::sd::View(pBookmarkDoc, (OutputDevice*) NULL); 1059cdf0e10cSrcweir pBMView->EndListening(*pBookmarkDoc); 1060cdf0e10cSrcweir } 1061cdf0e10cSrcweir 1062cdf0e10cSrcweir pPage = pObj->GetPage(); 1063cdf0e10cSrcweir 1064cdf0e10cSrcweir if (pPage->IsMasterPage()) 1065cdf0e10cSrcweir { 1066cdf0e10cSrcweir pPV = pBMView->ShowSdrPage(pBMView->GetModel()->GetMasterPage(pPage->GetPageNum())); 1067cdf0e10cSrcweir } 1068cdf0e10cSrcweir else 1069cdf0e10cSrcweir { 1070cdf0e10cSrcweir pPV = pBMView->GetSdrPageView(); 1071cdf0e10cSrcweir if( !pPV || (pPV->GetPage() != pPage)) 1072cdf0e10cSrcweir pPV = pBMView->ShowSdrPage(pPage); 1073cdf0e10cSrcweir } 1074cdf0e10cSrcweir 1075cdf0e10cSrcweir pBMView->MarkObj(pObj, pPV, sal_False); 1076cdf0e10cSrcweir } 1077cdf0e10cSrcweir } 1078cdf0e10cSrcweir } 1079cdf0e10cSrcweir 1080cdf0e10cSrcweir if (pBMView) 1081cdf0e10cSrcweir { 1082cdf0e10cSrcweir /********************************************************************** 1083cdf0e10cSrcweir * Selektierte Objekte einfuegen 1084cdf0e10cSrcweir **********************************************************************/ 1085cdf0e10cSrcweir ::sd::View* pView = new ::sd::View(this, (OutputDevice*) NULL); 1086cdf0e10cSrcweir pView->EndListening(*this); 1087cdf0e10cSrcweir 1088cdf0e10cSrcweir // Seite bestimmen, auf der die Objekte eingefuegt werden sollen 1089cdf0e10cSrcweir SdrPage* pPage = GetSdPage(0, PK_STANDARD); 1090cdf0e10cSrcweir 1091cdf0e10cSrcweir if (mpDocSh) 1092cdf0e10cSrcweir { 1093cdf0e10cSrcweir ::sd::ViewShell* pViewSh = mpDocSh->GetViewShell(); 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir if (pViewSh) 1096cdf0e10cSrcweir { 1097cdf0e10cSrcweir // Welche Seite wird denn aktuell angezeigt? 1098cdf0e10cSrcweir SdrPageView* pPV = pViewSh->GetView()->GetSdrPageView(); 1099cdf0e10cSrcweir 1100cdf0e10cSrcweir if (pPV) 1101cdf0e10cSrcweir { 1102cdf0e10cSrcweir pPage = pPV->GetPage(); 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir else if (pViewSh->GetActualPage()) 1105cdf0e10cSrcweir { 1106cdf0e10cSrcweir pPage = pViewSh->GetActualPage(); 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir } 1109cdf0e10cSrcweir } 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir Point aObjPos; 1112cdf0e10cSrcweir 1113cdf0e10cSrcweir if (pObjPos) 1114cdf0e10cSrcweir { 1115cdf0e10cSrcweir aObjPos = *pObjPos; 1116cdf0e10cSrcweir } 1117cdf0e10cSrcweir else 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir aObjPos = Rectangle(Point(), pPage->GetSize()).Center(); 1120cdf0e10cSrcweir } 1121cdf0e10cSrcweir 1122cdf0e10cSrcweir sal_uLong nCountBefore = 0; 1123cdf0e10cSrcweir 1124cdf0e10cSrcweir if (pExchangeList) 1125cdf0e10cSrcweir { 1126cdf0e10cSrcweir // OrdNums sortieren und Anzahl Objekte vor dem Einfuegen bestimmen 1127cdf0e10cSrcweir pPage->RecalcObjOrdNums(); 1128cdf0e10cSrcweir nCountBefore = pPage->GetObjCount(); 1129cdf0e10cSrcweir } 1130cdf0e10cSrcweir 1131cdf0e10cSrcweir if (bOLEObjFound) 1132cdf0e10cSrcweir pBMView->GetDoc()->SetAllocDocSh(sal_True); 1133cdf0e10cSrcweir 1134cdf0e10cSrcweir SdDrawDocument* pTmpDoc = (SdDrawDocument*) pBMView->GetAllMarkedModel(); 1135cdf0e10cSrcweir bOK = pView->Paste(*pTmpDoc, aObjPos, pPage); 1136cdf0e10cSrcweir 1137cdf0e10cSrcweir if (bOLEObjFound) 1138cdf0e10cSrcweir pBMView->GetDoc()->SetAllocDocSh(sal_False); 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir if (!bOLEObjFound) 1141cdf0e10cSrcweir delete pTmpDoc; // Wird ansonsten von der DocShell zerstoert 1142cdf0e10cSrcweir 1143cdf0e10cSrcweir delete pView; 1144cdf0e10cSrcweir 1145cdf0e10cSrcweir List* pList = pBookmarkList; 1146cdf0e10cSrcweir 1147cdf0e10cSrcweir if (pExchangeList) 1148cdf0e10cSrcweir { 1149cdf0e10cSrcweir // Anzahl Objekte nach dem Einfuegen bestimmen 1150cdf0e10cSrcweir sal_uLong nCount = pPage->GetObjCount(); 1151cdf0e10cSrcweir 1152cdf0e10cSrcweir for (sal_uLong nObj = nCountBefore; nObj < nCount; nObj++) 1153cdf0e10cSrcweir { 1154cdf0e10cSrcweir // Zuverwendener Name aus Exchange-Liste holen 1155cdf0e10cSrcweir if (pExchangeList->GetCurObject()) 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir String aExchangeName (*(String*) pExchangeList->GetCurObject()); 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir if (pPage->GetObj(nObj)) 1160cdf0e10cSrcweir { 1161cdf0e10cSrcweir pPage->GetObj(nObj)->SetName(aExchangeName); 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir } 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir pExchangeList->Next(); 1166cdf0e10cSrcweir } 1167cdf0e10cSrcweir 1168cdf0e10cSrcweir pList = pExchangeList; 1169cdf0e10cSrcweir } 1170cdf0e10cSrcweir } 1171cdf0e10cSrcweir 1172cdf0e10cSrcweir delete pBMView; 1173cdf0e10cSrcweir 1174cdf0e10cSrcweir return bOK; 1175cdf0e10cSrcweir } 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir /************************************************************************* 1178cdf0e10cSrcweir |* 1179cdf0e10cSrcweir |* Beendet das Einfuegen von Bookmarks 1180cdf0e10cSrcweir |* 1181cdf0e10cSrcweir \************************************************************************/ 1182cdf0e10cSrcweir 1183cdf0e10cSrcweir void SdDrawDocument::CloseBookmarkDoc() 1184cdf0e10cSrcweir { 1185cdf0e10cSrcweir if (mxBookmarkDocShRef.Is()) 1186cdf0e10cSrcweir { 1187cdf0e10cSrcweir mxBookmarkDocShRef->DoClose(); 1188cdf0e10cSrcweir } 1189cdf0e10cSrcweir 1190cdf0e10cSrcweir mxBookmarkDocShRef.Clear(); 1191cdf0e10cSrcweir maBookmarkFile = String(); 1192cdf0e10cSrcweir } 1193cdf0e10cSrcweir 1194cdf0e10cSrcweir /************************************************************************* 1195cdf0e10cSrcweir |* 1196cdf0e10cSrcweir |* Dokument laden (fuer gelinkte Objekte) 1197cdf0e10cSrcweir |* 1198cdf0e10cSrcweir \************************************************************************/ 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir const SdrModel* SdDrawDocument::LoadModel(const String& rFileName) 1201cdf0e10cSrcweir { 1202cdf0e10cSrcweir return ( OpenBookmarkDoc(rFileName) ); 1203cdf0e10cSrcweir } 1204cdf0e10cSrcweir 1205cdf0e10cSrcweir /************************************************************************* 1206cdf0e10cSrcweir |* 1207cdf0e10cSrcweir |* Dokument schliessen (fuer gelinkte Objekte) 1208cdf0e10cSrcweir |* 1209cdf0e10cSrcweir \************************************************************************/ 1210cdf0e10cSrcweir 1211cdf0e10cSrcweir void SdDrawDocument::DisposeLoadedModels() 1212cdf0e10cSrcweir { 1213cdf0e10cSrcweir CloseBookmarkDoc(); 1214cdf0e10cSrcweir } 1215cdf0e10cSrcweir 1216cdf0e10cSrcweir /************************************************************************* 1217cdf0e10cSrcweir |* 1218cdf0e10cSrcweir |* Ist das Dokument read-only? 1219cdf0e10cSrcweir |* 1220cdf0e10cSrcweir \************************************************************************/ 1221cdf0e10cSrcweir 1222cdf0e10cSrcweir FASTBOOL SdDrawDocument::IsReadOnly() const 1223cdf0e10cSrcweir { 1224cdf0e10cSrcweir return sal_False; 1225cdf0e10cSrcweir } 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir 1228cdf0e10cSrcweir /************************************************************************* 1229cdf0e10cSrcweir |* 1230cdf0e10cSrcweir |* In anschliessendem AllocModel() wird eine DocShell erzeugt 1231cdf0e10cSrcweir |* (xAllocedDocShRef). Eine bereits bestehende DocShell wird ggf. geloescht 1232cdf0e10cSrcweir |* 1233cdf0e10cSrcweir \************************************************************************/ 1234cdf0e10cSrcweir 1235cdf0e10cSrcweir void SdDrawDocument::SetAllocDocSh(sal_Bool bAlloc) 1236cdf0e10cSrcweir { 1237cdf0e10cSrcweir mbAllocDocSh = bAlloc; 1238cdf0e10cSrcweir 1239cdf0e10cSrcweir if(mxAllocedDocShRef.Is()) 1240cdf0e10cSrcweir { 1241cdf0e10cSrcweir mxAllocedDocShRef->DoClose(); 1242cdf0e10cSrcweir } 1243cdf0e10cSrcweir 1244cdf0e10cSrcweir mxAllocedDocShRef.Clear(); 1245cdf0e10cSrcweir } 1246cdf0e10cSrcweir 1247cdf0e10cSrcweir /************************************************************************* 1248cdf0e10cSrcweir |* 1249cdf0e10cSrcweir |* Liste der CustomShows zurueckgeben (ggf. zuerst erzeugen) 1250cdf0e10cSrcweir |* 1251cdf0e10cSrcweir \************************************************************************/ 1252cdf0e10cSrcweir 1253cdf0e10cSrcweir List* SdDrawDocument::GetCustomShowList(sal_Bool bCreate) 1254cdf0e10cSrcweir { 1255cdf0e10cSrcweir if (!mpCustomShowList && bCreate) 1256cdf0e10cSrcweir { 1257cdf0e10cSrcweir // Liste erzeugen 1258cdf0e10cSrcweir mpCustomShowList = new List(); 1259cdf0e10cSrcweir } 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir return(mpCustomShowList); 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir 1264cdf0e10cSrcweir /************************************************************************* 1265cdf0e10cSrcweir |* 1266cdf0e10cSrcweir |* Document-Stream herausgeben (fuer load-on-demand Graphiken) 1267cdf0e10cSrcweir |* 1268cdf0e10cSrcweir \************************************************************************/ 1269cdf0e10cSrcweir 1270cdf0e10cSrcweir SvStream* SdDrawDocument::GetDocumentStream(SdrDocumentStreamInfo& rStreamInfo) const 1271cdf0e10cSrcweir { 1272cdf0e10cSrcweir uno::Reference < embed::XStorage > xStor; 1273cdf0e10cSrcweir if (mpDocSh) 1274cdf0e10cSrcweir xStor = mpDocSh->GetStorage(); 1275cdf0e10cSrcweir SvStream* pRet = NULL; 1276cdf0e10cSrcweir 1277cdf0e10cSrcweir if( xStor.is() ) 1278cdf0e10cSrcweir { 1279cdf0e10cSrcweir //TODO/MBA: binary format removed, needs testing 1280cdf0e10cSrcweir if( rStreamInfo.maUserData.Len() && 1281cdf0e10cSrcweir ( rStreamInfo.maUserData.GetToken( 0, ':' ) == 1282cdf0e10cSrcweir String( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package" ) ) ) ) 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir const String aPicturePath( rStreamInfo.maUserData.GetToken( 1, ':' ) ); 1285cdf0e10cSrcweir 1286cdf0e10cSrcweir // graphic from picture stream in picture storage in XML package 1287cdf0e10cSrcweir if( aPicturePath.GetTokenCount( '/' ) == 2 ) try 1288cdf0e10cSrcweir { 1289cdf0e10cSrcweir const String aPictureStreamName( aPicturePath.GetToken( 1, '/' ) ); 1290cdf0e10cSrcweir const String aPictureStorageName( aPicturePath.GetToken( 0, '/' ) ); 1291cdf0e10cSrcweir if( xStor->isStorageElement( aPictureStorageName ) ) 1292cdf0e10cSrcweir { 1293cdf0e10cSrcweir uno::Reference < embed::XStorage > xPictureStorage = 1294cdf0e10cSrcweir xStor->openStorageElement( aPictureStorageName, embed::ElementModes::READ ); 1295cdf0e10cSrcweir try 1296cdf0e10cSrcweir { 1297cdf0e10cSrcweir if( xPictureStorage.is() && xPictureStorage->isStreamElement( aPictureStreamName ) ) 1298cdf0e10cSrcweir { 1299cdf0e10cSrcweir uno::Reference < io::XStream > xStream = xPictureStorage->openStreamElement( aPictureStreamName, embed::ElementModes::READ ); 1300cdf0e10cSrcweir if( xStream.is() ) 1301cdf0e10cSrcweir pRet = ::utl::UcbStreamHelper::CreateStream( xStream ); 1302cdf0e10cSrcweir } 1303cdf0e10cSrcweir } 1304cdf0e10cSrcweir catch( container::NoSuchElementException& ) 1305cdf0e10cSrcweir { 1306cdf0e10cSrcweir } 1307cdf0e10cSrcweir } 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir catch( uno::Exception& e ) 1310cdf0e10cSrcweir { 1311cdf0e10cSrcweir (void)e; 1312cdf0e10cSrcweir DBG_ERROR( 1313cdf0e10cSrcweir (rtl::OString("sd::SdDrawDocument::GetDocumentStream(), " 1314cdf0e10cSrcweir "exception caught: ") + 1315cdf0e10cSrcweir rtl::OUStringToOString( 1316cdf0e10cSrcweir comphelper::anyToString( cppu::getCaughtException() ), 1317cdf0e10cSrcweir RTL_TEXTENCODING_UTF8 ) + 1318cdf0e10cSrcweir rtl::OString("\r\nATTENTION: Graphics may get lost now, please inform CL or KA!") ).getStr() ); 1319cdf0e10cSrcweir } 1320cdf0e10cSrcweir 1321cdf0e10cSrcweir rStreamInfo.mbDeleteAfterUse = ( pRet != NULL ); 1322cdf0e10cSrcweir } 1323cdf0e10cSrcweir } 1324cdf0e10cSrcweir 1325cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 1326cdf0e10cSrcweir if( pRet ) 1327cdf0e10cSrcweir { 1328cdf0e10cSrcweir // try to get some information from stream 1329cdf0e10cSrcweir const sal_uLong nStartPos = pRet->Tell(); 1330cdf0e10cSrcweir const sal_uLong nEndPos = pRet->Seek( STREAM_SEEK_TO_END ); 1331cdf0e10cSrcweir const sal_uLong nStmLen = nEndPos - nStartPos; 1332cdf0e10cSrcweir sal_uChar aTestByte; 1333cdf0e10cSrcweir 1334cdf0e10cSrcweir // try to read one byte 1335cdf0e10cSrcweir if( nStmLen ) 1336cdf0e10cSrcweir *pRet >> aTestByte; 1337cdf0e10cSrcweir 1338cdf0e10cSrcweir pRet->Seek( nStartPos ); 1339cdf0e10cSrcweir } 1340cdf0e10cSrcweir #endif 1341cdf0e10cSrcweir 1342cdf0e10cSrcweir return pRet; 1343cdf0e10cSrcweir } 1344cdf0e10cSrcweir 1345cdf0e10cSrcweir 1346cdf0e10cSrcweir /************************************************************************* 1347cdf0e10cSrcweir |* 1348cdf0e10cSrcweir |* Nicht benutzte MasterPages und Layouts entfernen 1349cdf0e10cSrcweir |* 1350cdf0e10cSrcweir \************************************************************************/ 1351cdf0e10cSrcweir 1352cdf0e10cSrcweir void SdDrawDocument::RemoveUnnecessaryMasterPages(SdPage* pMasterPage, sal_Bool bOnlyDuplicatePages, sal_Bool bUndo) 1353cdf0e10cSrcweir { 1354cdf0e10cSrcweir ::sd::View* pView = NULL; 1355cdf0e10cSrcweir ::svl::IUndoManager* pUndoMgr = NULL; 1356cdf0e10cSrcweir 1357cdf0e10cSrcweir if( bUndo && !IsUndoEnabled() ) 1358cdf0e10cSrcweir bUndo = sal_False; 1359cdf0e10cSrcweir 1360cdf0e10cSrcweir if (mpDocSh) 1361cdf0e10cSrcweir { 1362cdf0e10cSrcweir pUndoMgr = mpDocSh->GetUndoManager(); 1363cdf0e10cSrcweir 1364cdf0e10cSrcweir if (mpDocSh->GetViewShell()) 1365cdf0e10cSrcweir pView = mpDocSh->GetViewShell()->GetView(); 1366cdf0e10cSrcweir } 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir /*********************************************************** 1369cdf0e10cSrcweir * Alle MasterPages pruefen 1370cdf0e10cSrcweir ***********************************************************/ 1371cdf0e10cSrcweir sal_uInt16 nSdMasterPageCount = GetMasterSdPageCount( PK_STANDARD ); 1372cdf0e10cSrcweir for (sal_Int32 nMPage = nSdMasterPageCount - 1; nMPage >= 0; nMPage--) 1373cdf0e10cSrcweir { 1374cdf0e10cSrcweir SdPage* pMaster = pMasterPage; 1375cdf0e10cSrcweir SdPage* pNotesMaster = NULL; 1376cdf0e10cSrcweir 1377cdf0e10cSrcweir if (!pMaster) 1378cdf0e10cSrcweir { 1379cdf0e10cSrcweir pMaster = (SdPage*) GetMasterSdPage( (sal_uInt16) nMPage, PK_STANDARD ); 1380cdf0e10cSrcweir pNotesMaster = (SdPage*) GetMasterSdPage( (sal_uInt16) nMPage, PK_NOTES ); 1381cdf0e10cSrcweir } 1382cdf0e10cSrcweir else 1383cdf0e10cSrcweir { 1384cdf0e10cSrcweir for ( sal_uInt16 nMPg = 0; nMPg < GetMasterPageCount(); nMPg++ ) 1385cdf0e10cSrcweir { 1386cdf0e10cSrcweir if ( pMaster == GetMasterPage( nMPg ) ) 1387cdf0e10cSrcweir { 1388cdf0e10cSrcweir pNotesMaster = (SdPage*) GetMasterPage( ++nMPg ); 1389cdf0e10cSrcweir break; 1390cdf0e10cSrcweir } 1391cdf0e10cSrcweir } 1392cdf0e10cSrcweir } 1393cdf0e10cSrcweir 1394cdf0e10cSrcweir DBG_ASSERT( pMaster->GetPageKind() == PK_STANDARD, "wrong page kind" ); 1395cdf0e10cSrcweir 1396cdf0e10cSrcweir if ( pMaster->GetPageKind() == PK_STANDARD && 1397cdf0e10cSrcweir GetMasterPageUserCount( pMaster ) == 0 && 1398cdf0e10cSrcweir pNotesMaster ) 1399cdf0e10cSrcweir { 1400cdf0e10cSrcweir // Do not delete master pages that have their precious flag set. 1401cdf0e10cSrcweir sal_Bool bDeleteMaster = !pMaster->IsPrecious(); 1402cdf0e10cSrcweir String aLayoutName = pMaster->GetLayoutName(); 1403cdf0e10cSrcweir 1404cdf0e10cSrcweir if(bOnlyDuplicatePages ) 1405cdf0e10cSrcweir { 1406cdf0e10cSrcweir // remove only duplicate pages 1407cdf0e10cSrcweir bDeleteMaster = sal_False; 1408cdf0e10cSrcweir for (sal_uInt16 i = 0; i < GetMasterSdPageCount( PK_STANDARD ); i++) 1409cdf0e10cSrcweir { 1410cdf0e10cSrcweir SdPage* pMPg = (SdPage*) GetMasterSdPage( i, PK_STANDARD ); 1411cdf0e10cSrcweir if( pMPg != pMaster && 1412cdf0e10cSrcweir pMPg->GetLayoutName() == aLayoutName ) 1413cdf0e10cSrcweir { 1414cdf0e10cSrcweir // duplicate page found -> remove it 1415cdf0e10cSrcweir bDeleteMaster = sal_True; 1416cdf0e10cSrcweir } 1417cdf0e10cSrcweir } 1418cdf0e10cSrcweir } 1419cdf0e10cSrcweir 1420cdf0e10cSrcweir if( bDeleteMaster ) 1421cdf0e10cSrcweir { 1422cdf0e10cSrcweir if (pView) 1423cdf0e10cSrcweir { 1424cdf0e10cSrcweir // if MasterPage is visible hide on pageview 1425cdf0e10cSrcweir SdrPageView* pPgView = pView->GetSdrPageView(); 1426cdf0e10cSrcweir if (pPgView) 1427cdf0e10cSrcweir { 1428cdf0e10cSrcweir SdrPage* pShownPage = pPgView->GetPage(); 1429cdf0e10cSrcweir if( (pShownPage == pMaster) || (pShownPage == pNotesMaster) ) 1430cdf0e10cSrcweir { 1431cdf0e10cSrcweir pView->HideSdrPage(); 1432cdf0e10cSrcweir pView->ShowSdrPage( GetSdPage( 0, PK_STANDARD ) ); 1433cdf0e10cSrcweir } 1434cdf0e10cSrcweir } 1435cdf0e10cSrcweir } 1436cdf0e10cSrcweir 1437cdf0e10cSrcweir if( bUndo ) 1438cdf0e10cSrcweir { 1439cdf0e10cSrcweir BegUndo(); 1440cdf0e10cSrcweir AddUndo( GetSdrUndoFactory().CreateUndoDeletePage( *pNotesMaster ) ); 1441cdf0e10cSrcweir } 1442cdf0e10cSrcweir 1443cdf0e10cSrcweir RemoveMasterPage( pNotesMaster->GetPageNum() ); 1444cdf0e10cSrcweir 1445cdf0e10cSrcweir if( !bUndo ) 1446cdf0e10cSrcweir delete pNotesMaster; 1447cdf0e10cSrcweir 1448cdf0e10cSrcweir if( bUndo ) 1449cdf0e10cSrcweir AddUndo(GetSdrUndoFactory().CreateUndoDeletePage(*pMaster)); 1450cdf0e10cSrcweir 1451cdf0e10cSrcweir RemoveMasterPage( pMaster->GetPageNum() ); 1452cdf0e10cSrcweir 1453cdf0e10cSrcweir if( !bUndo ) 1454cdf0e10cSrcweir delete pMaster; 1455cdf0e10cSrcweir 1456cdf0e10cSrcweir if( bUndo ) 1457cdf0e10cSrcweir EndUndo(); // schon hier, damit sich Joes Actions ZWISCHEN unsere eigenen schieben 1458cdf0e10cSrcweir 1459cdf0e10cSrcweir // alte Layoutvorlagen loeschen, wenn sie nicht mehr benoetigt werden 1460cdf0e10cSrcweir sal_Bool bDeleteOldStyleSheets = sal_True; 1461cdf0e10cSrcweir for ( sal_uInt16 nMPg = 0; 1462cdf0e10cSrcweir nMPg < GetMasterPageCount() && bDeleteOldStyleSheets; 1463cdf0e10cSrcweir nMPg++ ) 1464cdf0e10cSrcweir { 1465cdf0e10cSrcweir SdPage* pMPg = (SdPage*) GetMasterPage(nMPg); 1466cdf0e10cSrcweir if (pMPg->GetLayoutName() == aLayoutName) 1467cdf0e10cSrcweir { 1468cdf0e10cSrcweir bDeleteOldStyleSheets = sal_False; 1469cdf0e10cSrcweir } 1470cdf0e10cSrcweir } 1471cdf0e10cSrcweir 1472cdf0e10cSrcweir if (bDeleteOldStyleSheets) 1473cdf0e10cSrcweir { 1474cdf0e10cSrcweir SdStyleSheetVector aRemove; 1475cdf0e10cSrcweir static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->CreateLayoutSheetList( aLayoutName, aRemove ); 1476cdf0e10cSrcweir 1477cdf0e10cSrcweir if( bUndo ) 1478cdf0e10cSrcweir { 1479cdf0e10cSrcweir // die Liste gehoert der UndoAction 1480cdf0e10cSrcweir SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction( this, aRemove, false ); 1481cdf0e10cSrcweir 1482cdf0e10cSrcweir if (pUndoMgr) 1483cdf0e10cSrcweir pUndoMgr->AddUndoAction(pMovStyles); 1484cdf0e10cSrcweir } 1485cdf0e10cSrcweir 1486cdf0e10cSrcweir for( SdStyleSheetVector::iterator iter = aRemove.begin(); iter != aRemove.end(); iter++ ) 1487cdf0e10cSrcweir static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->Remove((*iter).get()); 1488cdf0e10cSrcweir } 1489cdf0e10cSrcweir } 1490cdf0e10cSrcweir } 1491cdf0e10cSrcweir 1492cdf0e10cSrcweir if (pMasterPage) 1493cdf0e10cSrcweir break; // Nur diese eine MasterPage! 1494cdf0e10cSrcweir } 1495cdf0e10cSrcweir } 1496cdf0e10cSrcweir 1497cdf0e10cSrcweir 1498cdf0e10cSrcweir /************************************************************************* 1499cdf0e10cSrcweir |* 1500cdf0e10cSrcweir |* MasterPage austauschen 1501cdf0e10cSrcweir |* 1502cdf0e10cSrcweir |* Entweder erhaelt nSdPageNum eine neue, eigene MasterPage, oder die MasterPage 1503cdf0e10cSrcweir |* wird komplett ausgetauscht (gilt dann fuer alle Seiten). 1504cdf0e10cSrcweir |* 1505cdf0e10cSrcweir |* nSdPageNum : Nummer der Seite, welche die neue MasterPage erhalten soll 1506cdf0e10cSrcweir |* rLayoutName : LayoutName der neuen MasterPage 1507cdf0e10cSrcweir |* pSourceDoc : Dokument (Vorlage) aus dem die MasterPage geholt wird 1508cdf0e10cSrcweir |* bMaster : Die MasterPage von nSdPageNum soll ausgetauscht werden 1509cdf0e10cSrcweir |* bCheckMasters: Nicht benutzte MasterPages sollen entfernt werden 1510cdf0e10cSrcweir |* 1511cdf0e10cSrcweir |* Ist pSourceDoc == NULL, so wird eine leere MasterPage zugewiesen. 1512cdf0e10cSrcweir |* Ist rLayoutName leer, so wird die erste MasterPage genommen 1513cdf0e10cSrcweir \************************************************************************/ 1514cdf0e10cSrcweir 1515cdf0e10cSrcweir void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum, 1516cdf0e10cSrcweir const String& rLayoutName, 1517cdf0e10cSrcweir SdDrawDocument* pSourceDoc, 1518cdf0e10cSrcweir sal_Bool bMaster, 1519cdf0e10cSrcweir sal_Bool bCheckMasters) 1520cdf0e10cSrcweir { 1521cdf0e10cSrcweir if( mpDocSh ) 1522cdf0e10cSrcweir mpDocSh->SetWaitCursor( sal_True ); 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir ::svl::IUndoManager* pUndoMgr = mpDocSh->GetUndoManager(); 1525cdf0e10cSrcweir 1526cdf0e10cSrcweir const bool bUndo = IsUndoEnabled(); 1527cdf0e10cSrcweir 1528cdf0e10cSrcweir if( bUndo ) 1529cdf0e10cSrcweir { 1530cdf0e10cSrcweir pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_SET_PRESLAYOUT)), String()); 1531cdf0e10cSrcweir } 1532cdf0e10cSrcweir 1533cdf0e10cSrcweir SdPage* pSelectedPage = GetSdPage(nSdPageNum, PK_STANDARD); 1534cdf0e10cSrcweir SdPage* pNotes = (SdPage*) GetPage(pSelectedPage->GetPageNum()+1); 1535cdf0e10cSrcweir SdPage& rOldMaster = (SdPage&)pSelectedPage->TRG_GetMasterPage(); 1536cdf0e10cSrcweir SdPage& rOldNotesMaster = (SdPage&)pNotes->TRG_GetMasterPage(); 1537cdf0e10cSrcweir SdPage* pMaster = NULL; 1538cdf0e10cSrcweir SdPage* pNotesMaster = NULL; 1539cdf0e10cSrcweir SdPage* pPage = NULL; 1540cdf0e10cSrcweir String aOldPageLayoutName(pSelectedPage->GetLayoutName()); 1541cdf0e10cSrcweir String aOldLayoutName(aOldPageLayoutName); 1542cdf0e10cSrcweir aOldLayoutName.Erase(aOldLayoutName.SearchAscii( SD_LT_SEPARATOR )); 1543cdf0e10cSrcweir 1544cdf0e10cSrcweir String aNewLayoutName( rLayoutName ); 1545cdf0e10cSrcweir 1546cdf0e10cSrcweir if (pSourceDoc) 1547cdf0e10cSrcweir { 1548cdf0e10cSrcweir List* pReplList = NULL; 1549cdf0e10cSrcweir sal_Bool bLayoutReloaded = sal_False; // Wurde ex. Layout wieder geladen? 1550cdf0e10cSrcweir 1551cdf0e10cSrcweir /********************************************************************* 1552cdf0e10cSrcweir |* LayoutName, Page and Notespage 1553cdf0e10cSrcweir \*********************************************************************/ 1554cdf0e10cSrcweir if (rLayoutName.Len() == 0) 1555cdf0e10cSrcweir { 1556cdf0e10cSrcweir // No LayoutName: take first MasterPage 1557cdf0e10cSrcweir pMaster = (SdPage*) pSourceDoc->GetMasterSdPage(0, PK_STANDARD); 1558cdf0e10cSrcweir pNotesMaster = (SdPage*) pSourceDoc->GetMasterSdPage(0, PK_NOTES); 1559cdf0e10cSrcweir aNewLayoutName = pMaster->GetName(); 1560cdf0e10cSrcweir } 1561cdf0e10cSrcweir else 1562cdf0e10cSrcweir { 1563cdf0e10cSrcweir String aSearchFor(rLayoutName); 1564cdf0e10cSrcweir aSearchFor.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR )); 1565cdf0e10cSrcweir aSearchFor.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ; 1566cdf0e10cSrcweir 1567cdf0e10cSrcweir for (sal_uInt16 nMP = 0; nMP < pSourceDoc->GetMasterPageCount(); nMP++) 1568cdf0e10cSrcweir { 1569cdf0e10cSrcweir SdPage* pMP = (SdPage*) pSourceDoc->GetMasterPage(nMP); 1570cdf0e10cSrcweir 1571cdf0e10cSrcweir if (pMP->GetLayoutName() == aSearchFor) 1572cdf0e10cSrcweir { 1573cdf0e10cSrcweir if (pMP->GetPageKind() == PK_STANDARD) 1574cdf0e10cSrcweir pMaster = pMP; 1575cdf0e10cSrcweir if (pMP->GetPageKind() == PK_NOTES) 1576cdf0e10cSrcweir pNotesMaster = pMP; 1577cdf0e10cSrcweir } 1578cdf0e10cSrcweir if (pMaster && pNotesMaster) 1579cdf0e10cSrcweir break; 1580cdf0e10cSrcweir } 1581cdf0e10cSrcweir DBG_ASSERT(pMaster, "MasterPage (Standard page) not found"); 1582cdf0e10cSrcweir DBG_ASSERT(pNotesMaster, "MasterPage (Notes page) not found"); 1583cdf0e10cSrcweir 1584cdf0e10cSrcweir // this should not happen, but looking at crashreports, it does 1585cdf0e10cSrcweir if( (pMaster == NULL) || (pNotesMaster == NULL) ) 1586cdf0e10cSrcweir { 1587cdf0e10cSrcweir // so take the first MasterPage 1588cdf0e10cSrcweir pMaster = (SdPage*) pSourceDoc->GetMasterSdPage(0, PK_STANDARD); 1589cdf0e10cSrcweir pNotesMaster = (SdPage*) pSourceDoc->GetMasterSdPage(0, PK_NOTES); 1590cdf0e10cSrcweir aNewLayoutName = pMaster->GetName(); 1591cdf0e10cSrcweir } 1592cdf0e10cSrcweir } 1593cdf0e10cSrcweir 1594cdf0e10cSrcweir // we should never reach this, but one never knows.... 1595cdf0e10cSrcweir if( (pMaster == NULL) || (pNotesMaster == NULL) ) 1596cdf0e10cSrcweir { 1597cdf0e10cSrcweir pUndoMgr->LeaveListAction(); 1598cdf0e10cSrcweir 1599cdf0e10cSrcweir if( mpDocSh ) 1600cdf0e10cSrcweir mpDocSh->SetWaitCursor( sal_False ); 1601cdf0e10cSrcweir 1602cdf0e10cSrcweir DBG_ERROR( "SdDrawDocument::SetMasterPage() failed!" ); 1603cdf0e10cSrcweir 1604cdf0e10cSrcweir return; 1605cdf0e10cSrcweir } 1606cdf0e10cSrcweir 1607cdf0e10cSrcweir if (pSourceDoc != this) 1608cdf0e10cSrcweir { 1609cdf0e10cSrcweir const sal_uInt16 nMasterPageCount = GetMasterPageCount(); 1610cdf0e10cSrcweir for ( sal_uInt16 nMPage = 0; nMPage < nMasterPageCount; nMPage++ ) 1611cdf0e10cSrcweir { 1612cdf0e10cSrcweir SdPage* pCheckMaster = (SdPage*)GetMasterPage(nMPage); 1613cdf0e10cSrcweir if( pCheckMaster->GetName() == aNewLayoutName ) 1614cdf0e10cSrcweir { 1615cdf0e10cSrcweir bLayoutReloaded = sal_True; 1616cdf0e10cSrcweir break; 1617cdf0e10cSrcweir } 1618cdf0e10cSrcweir } 1619cdf0e10cSrcweir 1620cdf0e10cSrcweir /***************************************************************** 1621cdf0e10cSrcweir |* Praesentationsvorlagen korrigieren bzw. neu anlegen 1622cdf0e10cSrcweir \****************************************************************/ 1623cdf0e10cSrcweir // nur die Praesentationsvorlagen beachten 1624cdf0e10cSrcweir String aName; 1625cdf0e10cSrcweir SdStyleSheetPool* pSourceStyleSheetPool = (SdStyleSheetPool*) pSourceDoc->GetStyleSheetPool(); 1626cdf0e10cSrcweir pSourceStyleSheetPool->SetSearchMask(SD_STYLE_FAMILY_MASTERPAGE); 1627cdf0e10cSrcweir static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->SetSearchMask(SD_STYLE_FAMILY_MASTERPAGE); 1628cdf0e10cSrcweir 1629cdf0e10cSrcweir pReplList = new List; // Liste fuer ersetzte StyleSheets 1630cdf0e10cSrcweir SdStyleSheetVector aCreatedStyles; // Liste fuer erzeugte StyleSheets 1631cdf0e10cSrcweir 1632cdf0e10cSrcweir SfxStyleSheetBase* pHisSheet = pSourceStyleSheetPool->First(); 1633cdf0e10cSrcweir 1634cdf0e10cSrcweir while (pHisSheet) 1635cdf0e10cSrcweir { 1636cdf0e10cSrcweir aName = pHisSheet->GetName(); 1637cdf0e10cSrcweir 1638cdf0e10cSrcweir if( aName.Search( aNewLayoutName ) == 0 ) 1639cdf0e10cSrcweir { 1640cdf0e10cSrcweir SfxStyleSheet* pMySheet = static_cast<SfxStyleSheet*>( mxStyleSheetPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE) ); 1641cdf0e10cSrcweir 1642cdf0e10cSrcweir if (pMySheet) 1643cdf0e10cSrcweir { 1644cdf0e10cSrcweir // Es ist eine gleichnamige Vorlage vorhanden ist: Inhalte ersetzen 1645cdf0e10cSrcweir #ifdef DBG_UTIL 1646cdf0e10cSrcweir sal_Bool bTest = 1647cdf0e10cSrcweir #endif 1648cdf0e10cSrcweir pMySheet->SetName(pHisSheet->GetName()); 1649cdf0e10cSrcweir DBG_ASSERT(bTest, "StyleSheet-Umbenennung fehlgeschlagen"); 1650cdf0e10cSrcweir pMySheet->GetItemSet().ClearItem(0); // alle loeschen 1651cdf0e10cSrcweir 1652cdf0e10cSrcweir StyleSheetUndoAction* pUndoChStyle = new StyleSheetUndoAction(this, 1653cdf0e10cSrcweir pMySheet, &pHisSheet->GetItemSet()); 1654cdf0e10cSrcweir pUndoMgr->AddUndoAction(pUndoChStyle); 1655cdf0e10cSrcweir pMySheet->GetItemSet().Put(pHisSheet->GetItemSet()); 1656cdf0e10cSrcweir pMySheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED)); 1657cdf0e10cSrcweir } 1658cdf0e10cSrcweir else 1659cdf0e10cSrcweir { 1660cdf0e10cSrcweir // create new style 1661cdf0e10cSrcweir String aHelpFile; 1662cdf0e10cSrcweir pMySheet = static_cast<SfxStyleSheet*>( &mxStyleSheetPool->Make(aName, SD_STYLE_FAMILY_MASTERPAGE, pHisSheet->GetMask()) ); 1663cdf0e10cSrcweir pMySheet->SetHelpId( aHelpFile, pHisSheet->GetHelpId(aHelpFile) ); 1664cdf0e10cSrcweir pMySheet->GetItemSet().ClearItem(0); // alle loeschen 1665cdf0e10cSrcweir pMySheet->GetItemSet().Put(pHisSheet->GetItemSet()); 1666cdf0e10cSrcweir 1667cdf0e10cSrcweir aCreatedStyles.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( pMySheet ) ) ); 1668cdf0e10cSrcweir } 1669cdf0e10cSrcweir 1670cdf0e10cSrcweir StyleReplaceData* pReplData = new StyleReplaceData; 1671cdf0e10cSrcweir pReplData->nNewFamily = pMySheet->GetFamily(); 1672cdf0e10cSrcweir pReplData->nFamily = pMySheet->GetFamily(); 1673cdf0e10cSrcweir pReplData->aNewName = pMySheet->GetName(); 1674cdf0e10cSrcweir 1675cdf0e10cSrcweir String aTemp(pMySheet->GetName()); 1676cdf0e10cSrcweir sal_uInt16 nPos = aTemp.SearchAscii( SD_LT_SEPARATOR ); 1677cdf0e10cSrcweir aTemp.Erase(0, nPos); 1678cdf0e10cSrcweir aTemp.Insert(aOldLayoutName, 0); 1679cdf0e10cSrcweir pReplData->aName = aTemp; 1680cdf0e10cSrcweir pReplList->Insert(pReplData, LIST_APPEND); 1681cdf0e10cSrcweir } 1682cdf0e10cSrcweir 1683cdf0e10cSrcweir pHisSheet = (SfxStyleSheet*) pSourceStyleSheetPool->Next(); 1684cdf0e10cSrcweir } 1685cdf0e10cSrcweir 1686cdf0e10cSrcweir // wenn neue Vorlagen erzeugt wurden: 1687cdf0e10cSrcweir // eventuell bestehende Parent-Verkettung der Itemsets in den 1688cdf0e10cSrcweir // Vorlagen wieder aufbauen 1689cdf0e10cSrcweir if(!aCreatedStyles.empty()) 1690cdf0e10cSrcweir { 1691cdf0e10cSrcweir StyleReplaceData* pRData = (StyleReplaceData*)pReplList->First(); 1692cdf0e10cSrcweir 1693cdf0e10cSrcweir while (pRData) 1694cdf0e10cSrcweir { 1695cdf0e10cSrcweir SfxStyleSheetBase* pSOld = mxStyleSheetPool->Find(pRData->aName); 1696cdf0e10cSrcweir SfxStyleSheetBase* pSNew = mxStyleSheetPool->Find(pRData->aNewName); 1697cdf0e10cSrcweir 1698cdf0e10cSrcweir if (pSOld && pSNew) 1699cdf0e10cSrcweir { 1700cdf0e10cSrcweir const String& rParentOfOld = pSOld->GetParent(); 1701cdf0e10cSrcweir const String& rParentOfNew = pSNew->GetParent(); 1702cdf0e10cSrcweir 1703cdf0e10cSrcweir if (rParentOfOld.Len() > 0 && rParentOfNew.Len() == 0) 1704cdf0e10cSrcweir { 1705cdf0e10cSrcweir 1706cdf0e10cSrcweir for (sal_uLong i = 0; i < pReplList->Count(); i++) 1707cdf0e10cSrcweir { 1708cdf0e10cSrcweir StyleReplaceData* pRD = (StyleReplaceData*)pReplList-> 1709cdf0e10cSrcweir GetObject(i); 1710cdf0e10cSrcweir if ((pRD->aName == rParentOfOld) && (pRD->aName != pRD->aNewName)) 1711cdf0e10cSrcweir { 1712cdf0e10cSrcweir String aParentOfNew(pRD->aNewName); 1713cdf0e10cSrcweir pSNew->SetParent(aParentOfNew); 1714cdf0e10cSrcweir break; 1715cdf0e10cSrcweir } 1716cdf0e10cSrcweir } 1717cdf0e10cSrcweir } 1718cdf0e10cSrcweir } 1719cdf0e10cSrcweir pRData = (StyleReplaceData*) pReplList->Next(); 1720cdf0e10cSrcweir } 1721cdf0e10cSrcweir 1722cdf0e10cSrcweir // ab jetzt beim Suchen alle beachten 1723cdf0e10cSrcweir pSourceStyleSheetPool->SetSearchMask(SFX_STYLE_FAMILY_ALL); 1724cdf0e10cSrcweir mxStyleSheetPool->SetSearchMask(SFX_STYLE_FAMILY_ALL); 1725cdf0e10cSrcweir } 1726cdf0e10cSrcweir 1727cdf0e10cSrcweir if( !aCreatedStyles.empty() ) 1728cdf0e10cSrcweir { 1729cdf0e10cSrcweir // UndoAction fuer das Erzeugen und Einfuegen vorn StyleSheets 1730cdf0e10cSrcweir // auf den UndoManager legen 1731cdf0e10cSrcweir SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction( this, aCreatedStyles, sal_True); 1732cdf0e10cSrcweir pUndoMgr->AddUndoAction(pMovStyles); 1733cdf0e10cSrcweir } 1734cdf0e10cSrcweir } 1735cdf0e10cSrcweir 1736cdf0e10cSrcweir // Layoutnamen auf Basis des Seitenlayoutnamens der Masterpage bilden 1737cdf0e10cSrcweir String aPageLayoutName(pMaster->GetLayoutName()); 1738cdf0e10cSrcweir String aLayoutName = aPageLayoutName; 1739cdf0e10cSrcweir aLayoutName.Erase( aLayoutName.SearchAscii( SD_LT_SEPARATOR )); 1740cdf0e10cSrcweir 1741cdf0e10cSrcweir if (pSourceDoc != this) 1742cdf0e10cSrcweir { 1743cdf0e10cSrcweir // Aus dem Source-Dokument austragen 1744cdf0e10cSrcweir SdrPage* pTest = NULL; 1745cdf0e10cSrcweir pTest = pSourceDoc->RemoveMasterPage(pNotesMaster->GetPageNum()); 1746cdf0e10cSrcweir pTest = pSourceDoc->RemoveMasterPage(pMaster->GetPageNum()); 1747cdf0e10cSrcweir } 1748cdf0e10cSrcweir 1749cdf0e10cSrcweir /********************************************************************* 1750cdf0e10cSrcweir |* Neue MasterPages ins Dokument eintragen und den Standard- und 1751cdf0e10cSrcweir |* Notizseiten das Praesentationslayout ueberbraten 1752cdf0e10cSrcweir \********************************************************************/ 1753cdf0e10cSrcweir if (pSourceDoc != this) 1754cdf0e10cSrcweir { 1755cdf0e10cSrcweir // Die Masterpages einfuegen: 1756cdf0e10cSrcweir // Masterpages von neuen Layouts hinten anhaengen; wird ein Layout 1757cdf0e10cSrcweir // dagegen ersetzt, so muss vor der Position der alten Masterpage 1758cdf0e10cSrcweir // eingefuegt werden, damit ab jetzt beim Suchen (z. B. SdPage:: 1759cdf0e10cSrcweir // SetPresentationLayout) die neue Masterpage zuerst gefunden wird 1760cdf0e10cSrcweir sal_uInt16 nInsertPos = rOldMaster.GetPageNum(); 1761cdf0e10cSrcweir BegUndo(); 1762cdf0e10cSrcweir 1763cdf0e10cSrcweir if (!bLayoutReloaded) 1764cdf0e10cSrcweir nInsertPos = 0xFFFF; 1765cdf0e10cSrcweir InsertMasterPage(pMaster, nInsertPos); 1766cdf0e10cSrcweir if( bUndo ) 1767cdf0e10cSrcweir AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster)); 1768cdf0e10cSrcweir 1769cdf0e10cSrcweir nInsertPos++; 1770cdf0e10cSrcweir if (!bLayoutReloaded) 1771cdf0e10cSrcweir nInsertPos = 0xFFFF; 1772cdf0e10cSrcweir InsertMasterPage(pNotesMaster, nInsertPos); 1773cdf0e10cSrcweir if( bUndo ) 1774cdf0e10cSrcweir { 1775cdf0e10cSrcweir AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster)); 1776cdf0e10cSrcweir 1777cdf0e10cSrcweir EndUndo(); // schon hier, damit sich Joes Actions ZWISCHEN unsere eigenen schieben 1778cdf0e10cSrcweir } 1779cdf0e10cSrcweir } 1780cdf0e10cSrcweir 1781cdf0e10cSrcweir // Liste mit Seiten fuellen 1782cdf0e10cSrcweir List* pPageList = new List; 1783cdf0e10cSrcweir 1784cdf0e10cSrcweir // #98456, this has to be removed according to CL (KA 07/08/2002) 1785cdf0e10cSrcweir // #109884# but we need them again to restore the styles of the presentation objects while undo 1786cdf0e10cSrcweir pPageList->Insert(pMaster, LIST_APPEND); 1787cdf0e10cSrcweir pPageList->Insert(pNotesMaster, LIST_APPEND); 1788cdf0e10cSrcweir 1789cdf0e10cSrcweir if (bMaster || bLayoutReloaded) 1790cdf0e10cSrcweir { 1791cdf0e10cSrcweir for (sal_uInt16 nPage = 1; nPage < GetPageCount(); nPage++) 1792cdf0e10cSrcweir { 1793cdf0e10cSrcweir pPage = (SdPage*) GetPage(nPage); 1794cdf0e10cSrcweir String aTest = pPage->GetLayoutName(); 1795cdf0e10cSrcweir if (aTest == aOldPageLayoutName) 1796cdf0e10cSrcweir { 1797cdf0e10cSrcweir pPageList->Insert(pPage, LIST_APPEND); 1798cdf0e10cSrcweir } 1799cdf0e10cSrcweir } 1800cdf0e10cSrcweir 1801cdf0e10cSrcweir } 1802cdf0e10cSrcweir else 1803cdf0e10cSrcweir { 1804cdf0e10cSrcweir pPageList->Insert(pSelectedPage, LIST_APPEND); 1805cdf0e10cSrcweir pPageList->Insert(pNotes, LIST_APPEND); 1806cdf0e10cSrcweir } 1807cdf0e10cSrcweir 1808cdf0e10cSrcweir pPage = (SdPage*)pPageList->First(); 1809cdf0e10cSrcweir while (pPage) 1810cdf0e10cSrcweir { 1811cdf0e10cSrcweir AutoLayout eAutoLayout = pPage->GetAutoLayout(); 1812cdf0e10cSrcweir 1813cdf0e10cSrcweir if( bUndo ) 1814cdf0e10cSrcweir { 1815cdf0e10cSrcweir SdPresentationLayoutUndoAction * pPLUndoAction = 1816cdf0e10cSrcweir new SdPresentationLayoutUndoAction 1817cdf0e10cSrcweir (this, 1818cdf0e10cSrcweir pPage->IsMasterPage() ? aLayoutName : aOldLayoutName, 1819cdf0e10cSrcweir aLayoutName, 1820cdf0e10cSrcweir eAutoLayout, eAutoLayout, sal_False, pPage); 1821cdf0e10cSrcweir pUndoMgr->AddUndoAction(pPLUndoAction); 1822cdf0e10cSrcweir } 1823cdf0e10cSrcweir pPage->SetPresentationLayout(aLayoutName); 1824cdf0e10cSrcweir pPage->SetAutoLayout(eAutoLayout); 1825cdf0e10cSrcweir 1826cdf0e10cSrcweir pPage = (SdPage*)pPageList->Next(); 1827cdf0e10cSrcweir } 1828cdf0e10cSrcweir delete pPageList; 1829cdf0e10cSrcweir 1830cdf0e10cSrcweir /********************************************************************* 1831cdf0e10cSrcweir |* Neue Masterpages angleichen 1832cdf0e10cSrcweir \********************************************************************/ 1833cdf0e10cSrcweir if (pSourceDoc != this) 1834cdf0e10cSrcweir { 1835cdf0e10cSrcweir // die Masterpages angleichen 1836cdf0e10cSrcweir Size aSize(rOldMaster.GetSize()); 1837cdf0e10cSrcweir Rectangle aBorderRect(rOldMaster.GetLftBorder(), 1838cdf0e10cSrcweir rOldMaster.GetUppBorder(), 1839cdf0e10cSrcweir rOldMaster.GetRgtBorder(), 1840cdf0e10cSrcweir rOldMaster.GetLwrBorder()); 1841cdf0e10cSrcweir pMaster->ScaleObjects(aSize, aBorderRect, sal_True); 1842cdf0e10cSrcweir pMaster->SetSize(aSize); 1843cdf0e10cSrcweir pMaster->SetBorder(rOldMaster.GetLftBorder(), 1844cdf0e10cSrcweir rOldMaster.GetUppBorder(), 1845cdf0e10cSrcweir rOldMaster.GetRgtBorder(), 1846cdf0e10cSrcweir rOldMaster.GetLwrBorder()); 1847cdf0e10cSrcweir pMaster->SetOrientation( rOldMaster.GetOrientation() ); 1848cdf0e10cSrcweir pMaster->SetAutoLayout(pMaster->GetAutoLayout()); 1849cdf0e10cSrcweir 1850cdf0e10cSrcweir aSize = rOldNotesMaster.GetSize(); 1851cdf0e10cSrcweir Rectangle aNotesBorderRect(rOldNotesMaster.GetLftBorder(), 1852cdf0e10cSrcweir rOldNotesMaster.GetUppBorder(), 1853cdf0e10cSrcweir rOldNotesMaster.GetRgtBorder(), 1854cdf0e10cSrcweir rOldNotesMaster.GetLwrBorder()); 1855cdf0e10cSrcweir pNotesMaster->ScaleObjects(aSize, aNotesBorderRect, sal_True); 1856cdf0e10cSrcweir pNotesMaster->SetSize(aSize); 1857cdf0e10cSrcweir pNotesMaster->SetBorder(rOldNotesMaster.GetLftBorder(), 1858cdf0e10cSrcweir rOldNotesMaster.GetUppBorder(), 1859cdf0e10cSrcweir rOldNotesMaster.GetRgtBorder(), 1860cdf0e10cSrcweir rOldNotesMaster.GetLwrBorder()); 1861cdf0e10cSrcweir pNotesMaster->SetOrientation( rOldNotesMaster.GetOrientation() ); 1862cdf0e10cSrcweir pNotesMaster->SetAutoLayout(pNotesMaster->GetAutoLayout()); 1863cdf0e10cSrcweir 1864cdf0e10cSrcweir // Liste der ersetzten Vorlagen mit Inhalt loeschen 1865cdf0e10cSrcweir StyleReplaceData* pReplData = (StyleReplaceData*)pReplList->First(); 1866cdf0e10cSrcweir while (pReplData) 1867cdf0e10cSrcweir { 1868cdf0e10cSrcweir delete pReplData; 1869cdf0e10cSrcweir pReplData = (StyleReplaceData*)pReplList->Next(); 1870cdf0e10cSrcweir } 1871cdf0e10cSrcweir delete pReplList; 1872cdf0e10cSrcweir 1873cdf0e10cSrcweir 1874cdf0e10cSrcweir if( (pSourceDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS) && 1875cdf0e10cSrcweir (GetDocumentType() == DOCUMENT_TYPE_DRAW) ) 1876cdf0e10cSrcweir { 1877cdf0e10cSrcweir pMaster->RemoveEmptyPresentationObjects(); 1878cdf0e10cSrcweir pNotesMaster->RemoveEmptyPresentationObjects(); 1879cdf0e10cSrcweir } 1880cdf0e10cSrcweir } 1881cdf0e10cSrcweir } 1882cdf0e10cSrcweir else 1883cdf0e10cSrcweir { 1884cdf0e10cSrcweir /********************************************************************* 1885cdf0e10cSrcweir |* Einen neuen Layoutnamen ausdenken 1886cdf0e10cSrcweir \********************************************************************/ 1887cdf0e10cSrcweir String aName = String(SdResId(STR_LAYOUT_DEFAULT_NAME)); 1888cdf0e10cSrcweir String aTest; 1889cdf0e10cSrcweir sal_Bool bNotANewName = sal_True; 1890cdf0e10cSrcweir sal_uInt16 nCount = 0; 1891cdf0e10cSrcweir sal_uInt16 nMPgCount = GetMasterPageCount(); 1892cdf0e10cSrcweir 1893cdf0e10cSrcweir for (nCount = 0; bNotANewName; nCount++) 1894cdf0e10cSrcweir { 1895cdf0e10cSrcweir // Testnamen bilden 1896cdf0e10cSrcweir aTest = aName; // Standard, Standard1, Standard2, ... 1897cdf0e10cSrcweir if (nCount > 0) 1898cdf0e10cSrcweir aTest += String::CreateFromInt32( nCount ); 1899cdf0e10cSrcweir 1900cdf0e10cSrcweir // gibt's schon eine, die so heisst? 1901cdf0e10cSrcweir bNotANewName = sal_False; 1902cdf0e10cSrcweir for (sal_uInt16 nMPg = 1; nMPg < nMPgCount; nMPg++) 1903cdf0e10cSrcweir { 1904cdf0e10cSrcweir const SdrPage* pTest = GetMasterPage(nMPg); 1905cdf0e10cSrcweir String aPageLayoutName(pTest->GetLayoutName()); 1906cdf0e10cSrcweir aPageLayoutName.Erase( aPageLayoutName.SearchAscii( SD_LT_SEPARATOR )); 1907cdf0e10cSrcweir 1908cdf0e10cSrcweir if (aPageLayoutName == aTest) 1909cdf0e10cSrcweir bNotANewName = sal_True; 1910cdf0e10cSrcweir } 1911cdf0e10cSrcweir } 1912cdf0e10cSrcweir aName = aTest; 1913cdf0e10cSrcweir String aPageLayoutName(aName); 1914cdf0e10cSrcweir aPageLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR )); 1915cdf0e10cSrcweir aPageLayoutName += String(SdResId(STR_LAYOUT_OUTLINE)); 1916cdf0e10cSrcweir 1917cdf0e10cSrcweir /********************************************************************* 1918cdf0e10cSrcweir |* Neue StyleSheets erzeugen 1919cdf0e10cSrcweir \********************************************************************/ 1920cdf0e10cSrcweir static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->CreateLayoutStyleSheets(aName); 1921cdf0e10cSrcweir SdStyleSheetVector aCreatedStyles; 1922cdf0e10cSrcweir static_cast<SdStyleSheetPool*>( mxStyleSheetPool.get())->CreateLayoutSheetList(aName, aCreatedStyles); 1923cdf0e10cSrcweir 1924cdf0e10cSrcweir if( bUndo ) 1925cdf0e10cSrcweir { 1926cdf0e10cSrcweir SdMoveStyleSheetsUndoAction* pMovStyles = new SdMoveStyleSheetsUndoAction(this, aCreatedStyles, sal_True); 1927cdf0e10cSrcweir pUndoMgr->AddUndoAction(pMovStyles); 1928cdf0e10cSrcweir } 1929cdf0e10cSrcweir 1930cdf0e10cSrcweir /********************************************************************* 1931cdf0e10cSrcweir |* Neue MasterPages erzeugen und ins Dokument eintragen 1932cdf0e10cSrcweir \********************************************************************/ 1933cdf0e10cSrcweir 1934cdf0e10cSrcweir if( bUndo ) 1935cdf0e10cSrcweir BegUndo(); 1936cdf0e10cSrcweir 1937cdf0e10cSrcweir pMaster = (SdPage*) AllocPage(sal_True); 1938cdf0e10cSrcweir pMaster->SetSize(pSelectedPage->GetSize()); 1939cdf0e10cSrcweir pMaster->SetBorder(pSelectedPage->GetLftBorder(), 1940cdf0e10cSrcweir pSelectedPage->GetUppBorder(), 1941cdf0e10cSrcweir pSelectedPage->GetRgtBorder(), 1942cdf0e10cSrcweir pSelectedPage->GetLwrBorder() ); 1943cdf0e10cSrcweir pMaster->SetName(aName); 1944cdf0e10cSrcweir pMaster->SetLayoutName(aPageLayoutName); 1945cdf0e10cSrcweir InsertMasterPage(pMaster); 1946cdf0e10cSrcweir 1947cdf0e10cSrcweir if( bUndo ) 1948cdf0e10cSrcweir AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pMaster)); 1949cdf0e10cSrcweir 1950cdf0e10cSrcweir pMaster->SetAutoLayout(AUTOLAYOUT_NONE, true, true); 1951cdf0e10cSrcweir 1952cdf0e10cSrcweir pNotesMaster = (SdPage*) AllocPage(sal_True); 1953cdf0e10cSrcweir pNotesMaster->SetPageKind(PK_NOTES); 1954cdf0e10cSrcweir pNotesMaster->SetSize(pNotes->GetSize()); 1955cdf0e10cSrcweir pNotesMaster->SetBorder(pNotes->GetLftBorder(), 1956cdf0e10cSrcweir pNotes->GetUppBorder(), 1957cdf0e10cSrcweir pNotes->GetRgtBorder(), 1958cdf0e10cSrcweir pNotes->GetLwrBorder() ); 1959cdf0e10cSrcweir pNotesMaster->SetName(aName); 1960cdf0e10cSrcweir pNotesMaster->SetLayoutName(aPageLayoutName); 1961cdf0e10cSrcweir InsertMasterPage(pNotesMaster); 1962cdf0e10cSrcweir 1963cdf0e10cSrcweir if( bUndo ) 1964cdf0e10cSrcweir AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pNotesMaster)); 1965cdf0e10cSrcweir 1966cdf0e10cSrcweir pNotesMaster->SetAutoLayout(AUTOLAYOUT_NOTES, true, true); 1967cdf0e10cSrcweir 1968cdf0e10cSrcweir if( bUndo ) 1969cdf0e10cSrcweir EndUndo(); 1970cdf0e10cSrcweir 1971cdf0e10cSrcweir /********************************************************************* 1972cdf0e10cSrcweir |* Liste der betroffenen Standard- und Notizseiten erstellen 1973cdf0e10cSrcweir \********************************************************************/ 1974cdf0e10cSrcweir List* pPageList = new List; 1975cdf0e10cSrcweir if (bMaster) 1976cdf0e10cSrcweir { 1977cdf0e10cSrcweir for (sal_uInt16 nPage = 1; nPage < GetPageCount(); nPage++) 1978cdf0e10cSrcweir { 1979cdf0e10cSrcweir pPage = (SdPage*) GetPage(nPage); 1980cdf0e10cSrcweir const String s(pPage->GetLayoutName()); 1981cdf0e10cSrcweir if(s == aOldPageLayoutName) 1982cdf0e10cSrcweir { 1983cdf0e10cSrcweir pPageList->Insert(pPage, LIST_APPEND); 1984cdf0e10cSrcweir } 1985cdf0e10cSrcweir } 1986cdf0e10cSrcweir } 1987cdf0e10cSrcweir else 1988cdf0e10cSrcweir { 1989cdf0e10cSrcweir pPageList->Insert(pSelectedPage, LIST_APPEND); 1990cdf0e10cSrcweir pPageList->Insert(pNotes, LIST_APPEND); 1991cdf0e10cSrcweir } 1992cdf0e10cSrcweir 1993cdf0e10cSrcweir /********************************************************************* 1994cdf0e10cSrcweir |* An den betroffenen Seiten Praesentations- und Autolayout setzen 1995cdf0e10cSrcweir \********************************************************************/ 1996cdf0e10cSrcweir pPage = (SdPage*)pPageList->First(); 1997cdf0e10cSrcweir while(pPage) 1998cdf0e10cSrcweir { 1999cdf0e10cSrcweir AutoLayout eOldAutoLayout = pPage->GetAutoLayout(); 2000cdf0e10cSrcweir AutoLayout eNewAutoLayout = 2001cdf0e10cSrcweir pPage->GetPageKind() == PK_STANDARD ? AUTOLAYOUT_NONE : AUTOLAYOUT_NOTES; 2002cdf0e10cSrcweir 2003cdf0e10cSrcweir if( bUndo ) 2004cdf0e10cSrcweir { 2005cdf0e10cSrcweir SdPresentationLayoutUndoAction * pPLUndoAction = 2006cdf0e10cSrcweir new SdPresentationLayoutUndoAction 2007cdf0e10cSrcweir (this, aOldLayoutName, aName, 2008cdf0e10cSrcweir eOldAutoLayout, eNewAutoLayout, sal_True, 2009cdf0e10cSrcweir pPage); 2010cdf0e10cSrcweir pUndoMgr->AddUndoAction(pPLUndoAction); 2011cdf0e10cSrcweir } 2012cdf0e10cSrcweir 2013cdf0e10cSrcweir pPage->SetPresentationLayout(aName); 2014cdf0e10cSrcweir pPage->SetAutoLayout(eNewAutoLayout); 2015cdf0e10cSrcweir 2016cdf0e10cSrcweir pPage = (SdPage*)pPageList->Next(); 2017cdf0e10cSrcweir } 2018cdf0e10cSrcweir 2019cdf0e10cSrcweir // Seitenliste loeschen 2020cdf0e10cSrcweir delete pPageList; 2021cdf0e10cSrcweir } 2022cdf0e10cSrcweir 2023cdf0e10cSrcweir /********************************************************************* 2024cdf0e10cSrcweir |* falls die alten Masterpages nicht mehr benoetigt werden, 2025cdf0e10cSrcweir |* muessen sie und die entsprechenden Praesentationsvorlagen 2026cdf0e10cSrcweir |* entfernt werden 2027cdf0e10cSrcweir \********************************************************************/ 2028cdf0e10cSrcweir if (bCheckMasters) 2029cdf0e10cSrcweir { 2030cdf0e10cSrcweir // Alle pruefen 2031cdf0e10cSrcweir RemoveUnnecessaryMasterPages(); 2032cdf0e10cSrcweir } 2033cdf0e10cSrcweir else 2034cdf0e10cSrcweir { 2035cdf0e10cSrcweir // Nur die ausgetauschte MasterPage pruefen 2036cdf0e10cSrcweir RemoveUnnecessaryMasterPages(&rOldMaster); 2037cdf0e10cSrcweir } 2038cdf0e10cSrcweir 2039cdf0e10cSrcweir if( bUndo ) 2040cdf0e10cSrcweir pUndoMgr->LeaveListAction(); 2041cdf0e10cSrcweir 2042cdf0e10cSrcweir if( mpDocSh ) 2043cdf0e10cSrcweir mpDocSh->SetWaitCursor( sal_False ); 2044cdf0e10cSrcweir } 2045cdf0e10cSrcweir 2046cdf0e10cSrcweir 2047cdf0e10cSrcweir 2048cdf0e10cSrcweir void SdDrawDocument::Merge(SdrModel& rSourceModel, 2049cdf0e10cSrcweir sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum, 2050cdf0e10cSrcweir sal_uInt16 nDestPos, 2051cdf0e10cSrcweir FASTBOOL bMergeMasterPages, FASTBOOL bAllMasterPages, 2052cdf0e10cSrcweir FASTBOOL bUndo, FASTBOOL bTreadSourceAsConst) 2053cdf0e10cSrcweir { 2054cdf0e10cSrcweir sal_uInt16 nMasterPageCount = GetMasterPageCount(); 2055cdf0e10cSrcweir SdrModel::Merge( rSourceModel, nFirstPageNum, nLastPageNum, nDestPos, bMergeMasterPages, bAllMasterPages, bUndo, bTreadSourceAsConst ); 2056cdf0e10cSrcweir 2057cdf0e10cSrcweir // add style family for each new master page 2058cdf0e10cSrcweir for( sal_uInt16 nMaster = nMasterPageCount; nMaster < GetMasterPageCount(); nMaster++ ) 2059cdf0e10cSrcweir { 2060cdf0e10cSrcweir SdPage* pPage = static_cast< SdPage* >( GetMasterPage( nMaster ) ); 2061cdf0e10cSrcweir if( pPage && pPage->IsMasterPage() && (pPage->GetPageKind() == PK_STANDARD) ) 2062cdf0e10cSrcweir { 2063cdf0e10cSrcweir // new master page created, add its style family 2064cdf0e10cSrcweir SdStyleSheetPool* pStylePool = (SdStyleSheetPool*) GetStyleSheetPool(); 2065cdf0e10cSrcweir if( pStylePool ) 2066cdf0e10cSrcweir pStylePool->AddStyleFamily( pPage ); 2067cdf0e10cSrcweir } 2068cdf0e10cSrcweir } 2069cdf0e10cSrcweir } 2070