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