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 #include <sfx2/docfile.hxx> 31*cdf0e10cSrcweir #include <vcl/svapp.hxx> 32*cdf0e10cSrcweir #include <editeng/outliner.hxx> 33*cdf0e10cSrcweir #ifndef _SVXLINK_HXX 34*cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #include <svx/svdotext.hxx> 37*cdf0e10cSrcweir #include <tools/urlobj.hxx> 38*cdf0e10cSrcweir #include <editeng/outlobj.hxx> 39*cdf0e10cSrcweir #include <svl/urihelper.hxx> 40*cdf0e10cSrcweir #include <editeng/xmlcnitm.hxx> 41*cdf0e10cSrcweir #include <svx/svditer.hxx> 42*cdf0e10cSrcweir #include <tools/list.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include "sdresid.hxx" 45*cdf0e10cSrcweir #include "sdpage.hxx" 46*cdf0e10cSrcweir #include "glob.hxx" 47*cdf0e10cSrcweir #include "glob.hrc" 48*cdf0e10cSrcweir #include "drawdoc.hxx" 49*cdf0e10cSrcweir #include "stlpool.hxx" 50*cdf0e10cSrcweir //#include "sdiocmpt.hxx" 51*cdf0e10cSrcweir #include "pglink.hxx" 52*cdf0e10cSrcweir //#include "strmname.h" 53*cdf0e10cSrcweir #include "anminfo.hxx" 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include "../ui/inc/strings.hrc" 56*cdf0e10cSrcweir #include "../ui/inc/DrawDocShell.hxx" 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir // #90477# 59*cdf0e10cSrcweir #include <tools/tenccvt.hxx> 60*cdf0e10cSrcweir #include <svl/itemset.hxx> 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir using namespace ::sd; 63*cdf0e10cSrcweir using namespace ::com::sun::star; 64*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 65*cdf0e10cSrcweir using namespace ::com::sun::star::office; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir extern void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName, const Reference< XInterface >& xSource ); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir /************************************************************************* 70*cdf0e10cSrcweir |* 71*cdf0e10cSrcweir |* SetPresentationLayout, setzt: Layoutnamen, Masterpage-Verkn�pfung und 72*cdf0e10cSrcweir |* Vorlagen fuer Praesentationsobjekte 73*cdf0e10cSrcweir |* 74*cdf0e10cSrcweir |* Vorraussetzungen: - Die Seite muss bereits das richtige Model kennen! 75*cdf0e10cSrcweir |* - Die entsprechende Masterpage muss bereits im Model sein. 76*cdf0e10cSrcweir |* - Die entsprechenden StyleSheets muessen bereits im 77*cdf0e10cSrcweir |* im StyleSheetPool sein. 78*cdf0e10cSrcweir |* 79*cdf0e10cSrcweir |* bReplaceStyleSheets = sal_True : Benannte StyleSheets werden ausgetauscht 80*cdf0e10cSrcweir |* sal_False: Alle StyleSheets werden neu zugewiesen 81*cdf0e10cSrcweir |* 82*cdf0e10cSrcweir |* bSetMasterPage = sal_True : MasterPage suchen und zuweisen 83*cdf0e10cSrcweir |* 84*cdf0e10cSrcweir |* bReverseOrder = sal_False: MasterPages von vorn nach hinten suchen 85*cdf0e10cSrcweir |* sal_True : MasterPages von hinten nach vorn suchen (fuer Undo-Action) 86*cdf0e10cSrcweir |* 87*cdf0e10cSrcweir \************************************************************************/ 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void SdPage::SetPresentationLayout(const String& rLayoutName, 90*cdf0e10cSrcweir sal_Bool bReplaceStyleSheets, 91*cdf0e10cSrcweir sal_Bool bSetMasterPage, 92*cdf0e10cSrcweir sal_Bool bReverseOrder) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir /********************************************************************* 95*cdf0e10cSrcweir |* Layoutname der Seite 96*cdf0e10cSrcweir \********************************************************************/ 97*cdf0e10cSrcweir String aOldLayoutName(maLayoutName); // merken 98*cdf0e10cSrcweir maLayoutName = rLayoutName; 99*cdf0e10cSrcweir maLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR )); 100*cdf0e10cSrcweir maLayoutName += String(SdResId(STR_LAYOUT_OUTLINE)); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir /********************************************************************* 103*cdf0e10cSrcweir |* ggf. Masterpage suchen und setzen 104*cdf0e10cSrcweir \********************************************************************/ 105*cdf0e10cSrcweir if (bSetMasterPage && !IsMasterPage()) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir SdPage* pMaster; 108*cdf0e10cSrcweir SdPage* pFoundMaster = 0; 109*cdf0e10cSrcweir sal_uInt16 nMaster = 0; 110*cdf0e10cSrcweir sal_uInt16 nMasterCount = pModel->GetMasterPageCount(); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir if( !bReverseOrder ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir for ( nMaster = 0; nMaster < nMasterCount; nMaster++ ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster)); 117*cdf0e10cSrcweir if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir pFoundMaster = pMaster; 120*cdf0e10cSrcweir break; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir else 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir for ( nMaster = nMasterCount; nMaster > 0; nMaster-- ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster - 1)); 129*cdf0e10cSrcweir if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir pFoundMaster = pMaster; 132*cdf0e10cSrcweir break; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir DBG_ASSERT(pFoundMaster, "Masterpage for presentation layout not found!"); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir // this should never happen, but we play failsafe here 140*cdf0e10cSrcweir if( pFoundMaster == 0 ) 141*cdf0e10cSrcweir pFoundMaster = static_cast< SdDrawDocument *>(pModel)->GetSdPage( 0, mePageKind ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir if( pFoundMaster ) 144*cdf0e10cSrcweir TRG_SetMasterPage(*pFoundMaster); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir /********************************************************************* 148*cdf0e10cSrcweir |* Vorlagen fuer Praesentationsobjekte 149*cdf0e10cSrcweir \********************************************************************/ 150*cdf0e10cSrcweir // Listen mit: 151*cdf0e10cSrcweir // - Vorlagenzeigern fuer Gliederungstextobjekt (alte und neue Vorlagen) 152*cdf0e10cSrcweir // -Replacedaten fuer OutlinerParaObject 153*cdf0e10cSrcweir List aOutlineStyles; 154*cdf0e10cSrcweir List aOldOutlineStyles; 155*cdf0e10cSrcweir List aReplList; 156*cdf0e10cSrcweir sal_Bool bListsFilled = sal_False; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir sal_uLong nObjCount = GetObjCount(); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir for (sal_uLong nObj = 0; nObj < nObjCount; nObj++) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir SdrTextObj* pObj = (SdrTextObj*) GetObj(nObj); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir if (pObj->GetObjInventor() == SdrInventor && 165*cdf0e10cSrcweir pObj->GetObjIdentifier() == OBJ_OUTLINETEXT) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir if (!bListsFilled || !bReplaceStyleSheets) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir String aFullName; 170*cdf0e10cSrcweir String aOldFullName; 171*cdf0e10cSrcweir SfxStyleSheetBase* pSheet = NULL; 172*cdf0e10cSrcweir SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool(); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir for (sal_Int16 i = -1; i < 9; i++) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir aFullName = maLayoutName; 177*cdf0e10cSrcweir aOldFullName = aOldLayoutName; 178*cdf0e10cSrcweir aFullName += sal_Unicode( ' ' ); 179*cdf0e10cSrcweir aFullName += String::CreateFromInt32( (sal_Int32) (i <= 0 ) ? 1 : i + 1); 180*cdf0e10cSrcweir aOldFullName += sal_Unicode( ' ' ); 181*cdf0e10cSrcweir aOldFullName += String::CreateFromInt32( (sal_Int32) (i <= 0 ) ? 1 : i + 1 ); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir pSheet = pStShPool->Find(aOldFullName, SD_STYLE_FAMILY_MASTERPAGE); 184*cdf0e10cSrcweir DBG_ASSERT(pSheet, "alte Gliederungsvorlage nicht gefunden"); 185*cdf0e10cSrcweir aOldOutlineStyles.Insert(pSheet, LIST_APPEND); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir pSheet = pStShPool->Find(aFullName, SD_STYLE_FAMILY_MASTERPAGE); 188*cdf0e10cSrcweir DBG_ASSERT(pSheet, "neue Gliederungsvorlage nicht gefunden"); 189*cdf0e10cSrcweir aOutlineStyles.Insert(pSheet, LIST_APPEND); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir if (bReplaceStyleSheets && pSheet) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir // Replace anstatt Set 194*cdf0e10cSrcweir StyleReplaceData* pReplData = new StyleReplaceData; 195*cdf0e10cSrcweir pReplData->nNewFamily = pSheet->GetFamily(); 196*cdf0e10cSrcweir pReplData->nFamily = pSheet->GetFamily(); 197*cdf0e10cSrcweir pReplData->aNewName = aFullName; 198*cdf0e10cSrcweir pReplData->aName = aOldFullName; 199*cdf0e10cSrcweir aReplList.Insert(pReplData, LIST_APPEND); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir else 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject(); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir if( pOPO ) 206*cdf0e10cSrcweir pOPO->SetStyleSheets( i, aFullName, SD_STYLE_FAMILY_MASTERPAGE ); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir bListsFilled = sal_True; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir SfxStyleSheet* pSheet = (SfxStyleSheet*)aOutlineStyles.First(); 214*cdf0e10cSrcweir SfxStyleSheet* pOldSheet = (SfxStyleSheet*)aOldOutlineStyles.First(); 215*cdf0e10cSrcweir while (pSheet) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir if (pSheet != pOldSheet) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir pObj->EndListening(*pOldSheet); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir if (!pObj->IsListening(*pSheet)) 222*cdf0e10cSrcweir pObj->StartListening(*pSheet); 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir pSheet = (SfxStyleSheet*)aOutlineStyles.Next(); 226*cdf0e10cSrcweir pOldSheet = (SfxStyleSheet*)aOldOutlineStyles.Next(); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject(); 230*cdf0e10cSrcweir if ( bReplaceStyleSheets && pOPO ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir StyleReplaceData* pReplData = (StyleReplaceData*) aReplList.First(); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir while( pReplData ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir pOPO->ChangeStyleSheets( pReplData->aName, pReplData->nFamily, pReplData->aNewName, pReplData->nNewFamily ); 237*cdf0e10cSrcweir pReplData = (StyleReplaceData*) aReplList.Next(); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir else if (pObj->GetObjInventor() == SdrInventor && 242*cdf0e10cSrcweir pObj->GetObjIdentifier() == OBJ_TITLETEXT) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir // PresObjKind nicht ueber GetPresObjKind() holen, da dort nur 245*cdf0e10cSrcweir // die PresObjListe beruecksichtigt wird. Es sollen aber alle 246*cdf0e10cSrcweir // "Titelobjekte" hier beruecksichtigt werden (Paste aus Clipboard usw.) 247*cdf0e10cSrcweir SfxStyleSheet* pSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE); 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir if (pSheet) 250*cdf0e10cSrcweir pObj->SetStyleSheet(pSheet, sal_True); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir else 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir SfxStyleSheet* pSheet = GetStyleSheetForPresObj(GetPresObjKind(pObj)); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir if (pSheet) 257*cdf0e10cSrcweir pObj->SetStyleSheet(pSheet, sal_True); 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir for (sal_uLong i = 0; i < aReplList.Count(); i++) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir delete (StyleReplaceData*) aReplList.GetObject(i); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir /************************************************************************* 269*cdf0e10cSrcweir |* 270*cdf0e10cSrcweir |* das Gliederungstextobjekt bei den Vorlagen fuer die Gliederungsebenen 271*cdf0e10cSrcweir |* abmelden 272*cdf0e10cSrcweir |* 273*cdf0e10cSrcweir \************************************************************************/ 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir void SdPage::EndListenOutlineText() 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir SdrObject* pOutlineTextObj = GetPresObj(PRESOBJ_OUTLINE); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir if (pOutlineTextObj) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir SdStyleSheetPool* pSPool = (SdStyleSheetPool*)pModel->GetStyleSheetPool(); 282*cdf0e10cSrcweir DBG_ASSERT(pSPool, "StyleSheetPool nicht gefunden"); 283*cdf0e10cSrcweir String aTrueLayoutName(maLayoutName); 284*cdf0e10cSrcweir aTrueLayoutName.Erase( aTrueLayoutName.SearchAscii( SD_LT_SEPARATOR )); 285*cdf0e10cSrcweir List* pOutlineStyles = pSPool->CreateOutlineSheetList(aTrueLayoutName); 286*cdf0e10cSrcweir for (SfxStyleSheet* pSheet = (SfxStyleSheet*)pOutlineStyles->First(); 287*cdf0e10cSrcweir pSheet; 288*cdf0e10cSrcweir pSheet = (SfxStyleSheet*)pOutlineStyles->Next()) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir pOutlineTextObj->EndListening(*pSheet); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir delete pOutlineStyles; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir /************************************************************************* 298*cdf0e10cSrcweir |* 299*cdf0e10cSrcweir |* Neues Model setzen 300*cdf0e10cSrcweir |* 301*cdf0e10cSrcweir \************************************************************************/ 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir void SdPage::SetModel(SdrModel* pNewModel) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir DisconnectLink(); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir // Model umsetzen 308*cdf0e10cSrcweir FmFormPage::SetModel(pNewModel); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir ConnectLink(); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir /************************************************************************* 314*cdf0e10cSrcweir |* 315*cdf0e10cSrcweir |* Ist die Seite read-only? 316*cdf0e10cSrcweir |* 317*cdf0e10cSrcweir \************************************************************************/ 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir FASTBOOL SdPage::IsReadOnly() const 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir return sal_False; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir /************************************************************************* 325*cdf0e10cSrcweir |* 326*cdf0e10cSrcweir |* Beim sfx2::LinkManager anmelden 327*cdf0e10cSrcweir |* 328*cdf0e10cSrcweir \************************************************************************/ 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir void SdPage::ConnectLink() 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir if (pLinkManager && !mpPageLink && maFileName.Len() && maBookmarkName.Len() && 335*cdf0e10cSrcweir mePageKind==PK_STANDARD && !IsMasterPage() && 336*cdf0e10cSrcweir ( (SdDrawDocument*) pModel)->IsNewOrLoadCompleted()) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir /********************************************************************** 339*cdf0e10cSrcweir * Anmelden 340*cdf0e10cSrcweir * Nur Standardseiten duerfen gelinkt sein 341*cdf0e10cSrcweir **********************************************************************/ 342*cdf0e10cSrcweir ::sd::DrawDocShell* pDocSh = ((SdDrawDocument*) pModel)->GetDocSh(); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir if (!pDocSh || pDocSh->GetMedium()->GetOrigURL() != maFileName) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir // Keine Links auf Dokument-eigene Seiten! 347*cdf0e10cSrcweir mpPageLink = new SdPageLink(this, maFileName, maBookmarkName); 348*cdf0e10cSrcweir String aFilterName(SdResId(STR_IMPRESS)); 349*cdf0e10cSrcweir pLinkManager->InsertFileLink(*mpPageLink, OBJECT_CLIENT_FILE, 350*cdf0e10cSrcweir maFileName, &aFilterName, &maBookmarkName); 351*cdf0e10cSrcweir mpPageLink->Connect(); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir /************************************************************************* 358*cdf0e10cSrcweir |* 359*cdf0e10cSrcweir |* Beim sfx2::LinkManager abmelden 360*cdf0e10cSrcweir |* 361*cdf0e10cSrcweir \************************************************************************/ 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir void SdPage::DisconnectLink() 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL; 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir if (pLinkManager && mpPageLink) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir /********************************************************************** 370*cdf0e10cSrcweir * Abmelden 371*cdf0e10cSrcweir * (Bei Remove wird *pGraphicLink implizit deleted) 372*cdf0e10cSrcweir **********************************************************************/ 373*cdf0e10cSrcweir pLinkManager->Remove(mpPageLink); 374*cdf0e10cSrcweir mpPageLink=NULL; 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir /************************************************************************* 379*cdf0e10cSrcweir |* 380*cdf0e10cSrcweir |* Copy-Ctor 381*cdf0e10cSrcweir |* 382*cdf0e10cSrcweir \************************************************************************/ 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir SdPage::SdPage(const SdPage& rSrcPage) 385*cdf0e10cSrcweir : FmFormPage(rSrcPage) 386*cdf0e10cSrcweir , SdrObjUserCall() 387*cdf0e10cSrcweir , mpItems(NULL) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir mePageKind = rSrcPage.mePageKind; 390*cdf0e10cSrcweir meAutoLayout = rSrcPage.meAutoLayout; 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir SdrObject* pObj = 0; 393*cdf0e10cSrcweir while((pObj = rSrcPage.maPresentationShapeList.getNextShape(pObj)) != 0) 394*cdf0e10cSrcweir InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj)); 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir mbSelected = sal_False; 397*cdf0e10cSrcweir mnTransitionType = rSrcPage.mnTransitionType; 398*cdf0e10cSrcweir mnTransitionSubtype = rSrcPage.mnTransitionSubtype; 399*cdf0e10cSrcweir mbTransitionDirection = rSrcPage.mbTransitionDirection; 400*cdf0e10cSrcweir mnTransitionFadeColor = rSrcPage.mnTransitionFadeColor; 401*cdf0e10cSrcweir mfTransitionDuration = rSrcPage.mfTransitionDuration; 402*cdf0e10cSrcweir mePresChange = rSrcPage.mePresChange; 403*cdf0e10cSrcweir mnTime = rSrcPage.mnTime; 404*cdf0e10cSrcweir mbSoundOn = rSrcPage.mbSoundOn; 405*cdf0e10cSrcweir mbExcluded = rSrcPage.mbExcluded; 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir maLayoutName = rSrcPage.maLayoutName; 408*cdf0e10cSrcweir maSoundFile = rSrcPage.maSoundFile; 409*cdf0e10cSrcweir mbLoopSound = rSrcPage.mbLoopSound; 410*cdf0e10cSrcweir mbStopSound = rSrcPage.mbStopSound; 411*cdf0e10cSrcweir maCreatedPageName = String(); 412*cdf0e10cSrcweir maFileName = rSrcPage.maFileName; 413*cdf0e10cSrcweir maBookmarkName = rSrcPage.maBookmarkName; 414*cdf0e10cSrcweir mbScaleObjects = rSrcPage.mbScaleObjects; 415*cdf0e10cSrcweir mbBackgroundFullSize = rSrcPage.mbBackgroundFullSize; 416*cdf0e10cSrcweir meCharSet = rSrcPage.meCharSet; 417*cdf0e10cSrcweir mnPaperBin = rSrcPage.mnPaperBin; 418*cdf0e10cSrcweir meOrientation = rSrcPage.meOrientation; 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir // header footer 421*cdf0e10cSrcweir setHeaderFooterSettings( rSrcPage.getHeaderFooterSettings() ); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir mpPageLink = NULL; // Wird beim Einfuegen ueber ConnectLink() gesetzt 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir /************************************************************************* 429*cdf0e10cSrcweir |* 430*cdf0e10cSrcweir |* Clone 431*cdf0e10cSrcweir |* 432*cdf0e10cSrcweir \************************************************************************/ 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir SdrPage* SdPage::Clone() const 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir return Clone(NULL); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir SdrPage* SdPage::Clone(SdrModel* pNewModel) const 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir DBG_ASSERT( pNewModel == 0, "sd::SdPage::Clone(), new page ignored, please check code! CL" ); 442*cdf0e10cSrcweir (void)pNewModel; 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir SdPage* pNewPage = new SdPage(*this); 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir cloneAnimations( *pNewPage ); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir // fix user calls for duplicated slide 449*cdf0e10cSrcweir SdrObjListIter aSourceIter( *this, IM_DEEPWITHGROUPS ); 450*cdf0e10cSrcweir SdrObjListIter aTargetIter( *pNewPage, IM_DEEPWITHGROUPS ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir while( aSourceIter.IsMore() && aTargetIter.IsMore() ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir SdrObject* pSource = aSourceIter.Next(); 455*cdf0e10cSrcweir SdrObject* pTarget = aTargetIter.Next(); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir if( pSource->GetUserCall() ) 458*cdf0e10cSrcweir pTarget->SetUserCall( pNewPage ); 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir return pNewPage; 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir /************************************************************************* 465*cdf0e10cSrcweir |* 466*cdf0e10cSrcweir |* GetTextStyleSheetForObject 467*cdf0e10cSrcweir |* 468*cdf0e10cSrcweir \************************************************************************/ 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir SfxStyleSheet* SdPage::GetTextStyleSheetForObject( SdrObject* pObj ) const 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir const PresObjKind eKind = ((SdPage*)this)->GetPresObjKind(pObj); 474*cdf0e10cSrcweir if( eKind != PRESOBJ_NONE ) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir return ((SdPage*)this)->GetStyleSheetForPresObj(eKind); 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir return FmFormPage::GetTextStyleSheetForObject( pObj ); 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir SfxItemSet* SdPage::getOrCreateItems() 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir if( mpItems == NULL ) 485*cdf0e10cSrcweir mpItems = new SfxItemSet( pModel->GetItemPool(), SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES ); 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir return mpItems; 488*cdf0e10cSrcweir } 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir sal_Bool SdPage::setAlienAttributes( const com::sun::star::uno::Any& rAttributes ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir SfxItemSet* pSet = getOrCreateItems(); 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir SvXMLAttrContainerItem aAlienAttributes( SDRATTR_XMLATTRIBUTES ); 496*cdf0e10cSrcweir if( aAlienAttributes.PutValue( rAttributes, 0 ) ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir pSet->Put( aAlienAttributes ); 499*cdf0e10cSrcweir return sal_True; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir return sal_False; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir void SdPage::getAlienAttributes( com::sun::star::uno::Any& rAttributes ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir const SfxPoolItem* pItem; 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir if( (mpItems == NULL) || ( SFX_ITEM_SET != mpItems->GetItemState( SDRATTR_XMLATTRIBUTES, sal_False, &pItem ) ) ) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir SvXMLAttrContainerItem aAlienAttributes; 512*cdf0e10cSrcweir aAlienAttributes.QueryValue( rAttributes, 0 ); 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir else 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir ((SvXMLAttrContainerItem*)pItem)->QueryValue( rAttributes, 0 ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir void SdPage::RemoveEmptyPresentationObjects() 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir SdrObjListIter aShapeIter( *this, IM_DEEPWITHGROUPS ); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir SdrObject* pShape; 525*cdf0e10cSrcweir for( pShape = aShapeIter.Next(); pShape; pShape = aShapeIter.Next() ) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir if( pShape && pShape->IsEmptyPresObj() ) 528*cdf0e10cSrcweir { 529*cdf0e10cSrcweir RemoveObject( pShape->GetOrdNum() ); 530*cdf0e10cSrcweir SdrObject::Free( pShape ); 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir sal_Int16 SdPage::getTransitionType (void) const 537*cdf0e10cSrcweir { 538*cdf0e10cSrcweir return mnTransitionType; 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir void SdPage::setTransitionType( sal_Int16 nTransitionType ) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir mnTransitionType = nTransitionType; 544*cdf0e10cSrcweir ActionChanged(); 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir sal_Int16 SdPage::getTransitionSubtype (void) const 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir return mnTransitionSubtype; 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir void SdPage::setTransitionSubtype ( sal_Int16 nTransitionSubtype ) 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir mnTransitionSubtype = nTransitionSubtype; 555*cdf0e10cSrcweir ActionChanged(); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir sal_Bool SdPage::getTransitionDirection (void) const 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir return mbTransitionDirection; 561*cdf0e10cSrcweir } 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir void SdPage::setTransitionDirection ( sal_Bool bTransitionbDirection ) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir mbTransitionDirection = bTransitionbDirection; 566*cdf0e10cSrcweir ActionChanged(); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir sal_Int32 SdPage::getTransitionFadeColor (void) const 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir return mnTransitionFadeColor; 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir void SdPage::setTransitionFadeColor ( sal_Int32 nTransitionFadeColor ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir mnTransitionFadeColor = nTransitionFadeColor; 577*cdf0e10cSrcweir ActionChanged(); 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir double SdPage::getTransitionDuration (void) const 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir return mfTransitionDuration; 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir void SdPage::setTransitionDuration ( double fTranstionDuration ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir mfTransitionDuration = fTranstionDuration; 588*cdf0e10cSrcweir ActionChanged(); 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir namespace sd { 592*cdf0e10cSrcweir extern void createAnnotation( Reference< XAnnotation >& xAnnotation, SdPage* pPage ); 593*cdf0e10cSrcweir extern SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert ); 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir void SdPage::createAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation ) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir sd::createAnnotation( xAnnotation, this ); 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIndex ) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir if( (nIndex == -1) || (nIndex > (int)maAnnotations.size()) ) 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir maAnnotations.push_back( xAnnotation ); 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir else 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir maAnnotations.insert( maAnnotations.begin() + nIndex, xAnnotation ); 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir if( pModel && pModel->IsUndoEnabled() ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true ); 615*cdf0e10cSrcweir if( pAction ) 616*cdf0e10cSrcweir pModel->AddUndo( pAction ); 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir SetChanged(); 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir if( pModel ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir pModel->SetChanged(); 624*cdf0e10cSrcweir Reference< XInterface > xSource( xAnnotation, UNO_QUERY ); 625*cdf0e10cSrcweir NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAnnotationInserted" ) ), xSource ); 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation ) 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir if( pModel && pModel->IsUndoEnabled() ) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false ); 634*cdf0e10cSrcweir if( pAction ) 635*cdf0e10cSrcweir pModel->AddUndo( pAction ); 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir AnnotationVector::iterator iter = std::find( maAnnotations.begin(), maAnnotations.end(), xAnnotation ); 639*cdf0e10cSrcweir if( iter != maAnnotations.end() ) 640*cdf0e10cSrcweir maAnnotations.erase( iter ); 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir if( pModel ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir pModel->SetChanged(); 645*cdf0e10cSrcweir Reference< XInterface > xSource( xAnnotation, UNO_QUERY ); 646*cdf0e10cSrcweir NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnAnnotationRemoved" ) ), xSource ); 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir } 649