1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 #include <com/sun/star/presentation/XPresentation2.hpp> 32 33 #include <com/sun/star/lang/DisposedException.hpp> 34 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> 35 #include <com/sun/star/lang/Locale.hpp> 36 #include <com/sun/star/style/XStyle.hpp> 37 #include <com/sun/star/awt/XDevice.hpp> 38 39 #include <com/sun/star/embed/Aspects.hpp> 40 #include <com/sun/star/presentation/XPresentation2.hpp> 41 42 #include <osl/mutex.hxx> 43 #include <comphelper/serviceinfohelper.hxx> 44 45 #include <comphelper/sequence.hxx> 46 47 #include <rtl/uuid.h> 48 #include <rtl/memory.h> 49 #include <editeng/unofield.hxx> 50 #include <unomodel.hxx> 51 #include <sfx2/dispatch.hxx> 52 #include <sfx2/bindings.hxx> 53 #include <vcl/svapp.hxx> 54 #include <editeng/UnoForbiddenCharsTable.hxx> 55 #include <svx/svdoutl.hxx> 56 #include <editeng/forbiddencharacterstable.hxx> 57 #include <svx/UnoNamespaceMap.hxx> 58 #include <svx/svdlayer.hxx> 59 #include <svx/svdsob.hxx> 60 #include <svx/unoapi.hxx> 61 #include <svx/unofill.hxx> 62 #include <svx/unopool.hxx> 63 #include <svx/svdorect.hxx> 64 #include <editeng/flditem.hxx> 65 #include <vos/mutex.hxx> 66 #include <toolkit/awt/vclxdevice.hxx> 67 #include <svx/svdpool.hxx> 68 #include <editeng/unolingu.hxx> 69 #include <svx/svdpagv.hxx> 70 #include <svtools/unoimap.hxx> 71 #include <svx/unoshape.hxx> 72 #include <editeng/unonrule.hxx> 73 #include <editeng/eeitem.hxx> 74 75 // #99870# Support creation of GraphicObjectResolver and EmbeddedObjectResolver 76 #include <svx/xmleohlp.hxx> 77 #include <svx/xmlgrhlp.hxx> 78 #include "DrawDocShell.hxx" 79 #include "ViewShellBase.hxx" 80 #include <UnoDocumentSettings.hxx> 81 82 #include <drawdoc.hxx> 83 #include <glob.hrc> 84 #include <sdresid.hxx> 85 #include <sdpage.hxx> 86 87 #include <strings.hrc> 88 #include "unohelp.hxx" 89 #include <unolayer.hxx> 90 #include <unoprnms.hxx> 91 #include <unopage.hxx> 92 #include <unocpres.hxx> 93 #include <unoobj.hxx> 94 #include <stlpool.hxx> 95 #include <unopback.hxx> 96 #include <unokywds.hxx> 97 #include "FrameView.hxx" 98 #include "ClientView.hxx" 99 #include "ViewShell.hxx" 100 #include "app.hrc" 101 #include <vcl/pdfextoutdevdata.hxx> 102 #include <com/sun/star/presentation/AnimationEffect.hpp> 103 #include <com/sun/star/presentation/AnimationSpeed.hpp> 104 #include <com/sun/star/presentation/ClickAction.hpp> 105 #include <tools/urlobj.hxx> 106 #include <svx/sdr/contact/viewobjectcontact.hxx> 107 #include <svx/sdr/contact/viewcontact.hxx> 108 #include <svx/sdr/contact/displayinfo.hxx> 109 110 #include <com/sun/star/office/XAnnotation.hpp> 111 #include <com/sun/star/office/XAnnotationAccess.hpp> 112 #include <com/sun/star/office/XAnnotationEnumeration.hpp> 113 #include <com/sun/star/geometry/RealPoint2D.hpp> 114 #include <com/sun/star/util/DateTime.hpp> 115 116 using ::rtl::OUString; 117 118 #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx> 119 120 using namespace ::osl; 121 using namespace ::vos; 122 using namespace ::cppu; 123 using namespace ::com::sun::star; 124 125 extern uno::Reference< uno::XInterface > SdUnoCreatePool( SdDrawDocument* pDrawModel ); 126 127 class SdUnoForbiddenCharsTable : public SvxUnoForbiddenCharsTable, 128 public SfxListener 129 { 130 public: 131 SdUnoForbiddenCharsTable( SdrModel* pModel ); 132 ~SdUnoForbiddenCharsTable(); 133 134 // SfxListener 135 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw (); 136 protected: 137 virtual void onChange(); 138 139 private: 140 SdrModel* mpModel; 141 }; 142 143 SdUnoForbiddenCharsTable::SdUnoForbiddenCharsTable( SdrModel* pModel ) 144 : SvxUnoForbiddenCharsTable( pModel->GetForbiddenCharsTable() ), mpModel( pModel ) 145 { 146 StartListening( *pModel ); 147 } 148 149 void SdUnoForbiddenCharsTable::onChange() 150 { 151 if( mpModel ) 152 { 153 mpModel->ReformatAllTextObjects(); 154 } 155 } 156 157 SdUnoForbiddenCharsTable::~SdUnoForbiddenCharsTable() 158 { 159 if( mpModel ) 160 EndListening( *mpModel ); 161 } 162 163 void SdUnoForbiddenCharsTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() 164 { 165 const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); 166 167 if( pSdrHint ) 168 { 169 if( HINT_MODELCLEARED == pSdrHint->GetKind() ) 170 { 171 mpModel = NULL; 172 } 173 } 174 } 175 176 /////////////////////////////////////////////////////////////////////// 177 178 const sal_Int32 WID_MODEL_LANGUAGE = 1; 179 const sal_Int32 WID_MODEL_TABSTOP = 2; 180 const sal_Int32 WID_MODEL_VISAREA = 3; 181 const sal_Int32 WID_MODEL_MAPUNIT = 4; 182 const sal_Int32 WID_MODEL_FORBCHARS= 5; 183 const sal_Int32 WID_MODEL_CONTFOCUS = 6; 184 const sal_Int32 WID_MODEL_DSGNMODE = 7; 185 const sal_Int32 WID_MODEL_BASICLIBS = 8; 186 const sal_Int32 WID_MODEL_RUNTIMEUID = 9; 187 const sal_Int32 WID_MODEL_BUILDID = 10; 188 const sal_Int32 WID_MODEL_HASVALIDSIGNATURES = 11; 189 const sal_Int32 WID_MODEL_DIALOGLIBS = 12; 190 191 const SvxItemPropertySet* ImplGetDrawModelPropertySet() 192 { 193 // Achtung: Der erste Parameter MUSS sortiert vorliegen !!! 194 const static SfxItemPropertyMapEntry aDrawModelPropertyMap_Impl[] = 195 { 196 { MAP_CHAR_LEN("BuildId"), WID_MODEL_BUILDID, &::getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0}, 197 { MAP_CHAR_LEN(sUNO_Prop_CharLocale), WID_MODEL_LANGUAGE, &::getCppuType((const lang::Locale*)0), 0, 0}, 198 { MAP_CHAR_LEN(sUNO_Prop_TabStop), WID_MODEL_TABSTOP, &::getCppuType((const sal_Int32*)0), 0, 0}, 199 { MAP_CHAR_LEN(sUNO_Prop_VisibleArea), WID_MODEL_VISAREA, &::getCppuType((const awt::Rectangle*)0), 0, 0}, 200 { MAP_CHAR_LEN(sUNO_Prop_MapUnit), WID_MODEL_MAPUNIT, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, 201 { MAP_CHAR_LEN(sUNO_Prop_ForbiddenCharacters), WID_MODEL_FORBCHARS,&::getCppuType((const uno::Reference< i18n::XForbiddenCharacters > *)0), beans::PropertyAttribute::READONLY, 0 }, 202 { MAP_CHAR_LEN(sUNO_Prop_AutomContFocus ), WID_MODEL_CONTFOCUS, &::getBooleanCppuType(), 0, 0}, 203 { MAP_CHAR_LEN(sUNO_Prop_ApplyFrmDsgnMode), WID_MODEL_DSGNMODE, &::getBooleanCppuType(), 0, 0}, 204 { MAP_CHAR_LEN("BasicLibraries"), WID_MODEL_BASICLIBS,&::getCppuType((const uno::Reference< script::XLibraryContainer > *)0), beans::PropertyAttribute::READONLY, 0 }, 205 { MAP_CHAR_LEN("DialogLibraries"), WID_MODEL_DIALOGLIBS, &::getCppuType((const uno::Reference< script::XLibraryContainer > *)0), beans::PropertyAttribute::READONLY, 0 }, 206 { MAP_CHAR_LEN(sUNO_Prop_RuntimeUID), WID_MODEL_RUNTIMEUID, &::getCppuType(static_cast< const rtl::OUString * >(0)), beans::PropertyAttribute::READONLY, 0 }, 207 { MAP_CHAR_LEN(sUNO_Prop_HasValidSignatures), WID_MODEL_HASVALIDSIGNATURES, &::getCppuType(static_cast< const sal_Bool * >(0)), beans::PropertyAttribute::READONLY, 0 }, 208 { 0,0,0,0,0,0 } 209 }; 210 static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 211 return &aDrawModelPropertySet_Impl; 212 } 213 214 // this ctor is used from the DocShell 215 SdXImpressDocument::SdXImpressDocument (::sd::DrawDocShell* pShell, bool bClipBoard ) throw() 216 : SfxBaseModel( pShell ), 217 mpDocShell( pShell ), 218 mpDoc( pShell ? pShell->GetDoc() : NULL ), 219 mbDisposed(false), 220 mbImpressDoc( pShell && pShell->GetDoc() && pShell->GetDoc()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ), 221 mbClipBoard( bClipBoard ), 222 mpPropSet( ImplGetDrawModelPropertySet() ) 223 { 224 if( mpDoc ) 225 { 226 StartListening( *mpDoc ); 227 } 228 else 229 { 230 DBG_ERROR("DocShell is invalid"); 231 } 232 } 233 234 SdXImpressDocument::SdXImpressDocument( SdDrawDocument* pDoc, bool bClipBoard ) throw() 235 : SfxBaseModel( NULL ), 236 mpDocShell( NULL ), 237 mpDoc( pDoc ), 238 mbDisposed(false), 239 mbImpressDoc( pDoc && pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ), 240 mbClipBoard( bClipBoard ), 241 mpPropSet( ImplGetDrawModelPropertySet() ) 242 { 243 if( mpDoc ) 244 { 245 StartListening( *mpDoc ); 246 } 247 else 248 { 249 DBG_ERROR("SdDrawDocument is invalid"); 250 } 251 } 252 253 /*********************************************************************** 254 * * 255 ***********************************************************************/ 256 SdXImpressDocument::~SdXImpressDocument() throw() 257 { 258 } 259 260 // uno helper 261 262 263 /****************************************************************************** 264 * Erzeugt anhand der uebergebennen SdPage eine SdDrawPage. Wurde fuer diese * 265 * SdPage bereits eine SdDrawPage erzeugt, wird keine neue SdDrawPage erzeug. * 266 ******************************************************************************/ 267 /* 268 uno::Reference< drawing::XDrawPage > SdXImpressDocument::CreateXDrawPage( SdPage* pPage ) throw() 269 { 270 DBG_ASSERT(pPage,"SdXImpressDocument::CreateXDrawPage( NULL? )"); 271 272 uno::Reference< drawing::XDrawPage > xDrawPage; 273 274 if(pPage) 275 { 276 xDrawPage = SvxDrawPage::GetPageForSdrPage(pPage); 277 278 if(!xDrawPage.is()) 279 { 280 if(pPage->IsMasterPage()) 281 { 282 xDrawPage = (presentation::XPresentationPage*)new SdMasterPage( this, pPage ); 283 } 284 else 285 { 286 xDrawPage = (SvxDrawPage*)new SdDrawPage( this, pPage ); 287 } 288 } 289 } 290 291 return xDrawPage; 292 } 293 */ 294 295 // XInterface 296 uno::Any SAL_CALL SdXImpressDocument::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException) 297 { 298 uno::Any aAny; 299 300 QUERYINT(lang::XServiceInfo); 301 else QUERYINT(beans::XPropertySet); 302 else QUERYINT(lang::XMultiServiceFactory); 303 else QUERYINT(drawing::XDrawPageDuplicator); 304 else QUERYINT(drawing::XLayerSupplier); 305 else QUERYINT(drawing::XMasterPagesSupplier); 306 else QUERYINT(drawing::XDrawPagesSupplier); 307 else QUERYINT(presentation::XHandoutMasterSupplier); 308 else QUERYINT(document::XLinkTargetSupplier); 309 else QUERYINT(style::XStyleFamiliesSupplier); 310 else QUERYINT(com::sun::star::ucb::XAnyCompareFactory); 311 else QUERYINT(view::XRenderable); 312 else if( mbImpressDoc && rType == ITYPE(presentation::XPresentationSupplier) ) 313 aAny <<= uno::Reference< presentation::XPresentationSupplier >(this); 314 else if( mbImpressDoc && rType == ITYPE(presentation::XCustomPresentationSupplier) ) 315 aAny <<= uno::Reference< presentation::XCustomPresentationSupplier >(this); 316 else 317 return SfxBaseModel::queryInterface( rType ); 318 319 return aAny; 320 } 321 322 void SAL_CALL SdXImpressDocument::acquire() throw ( ) 323 { 324 SfxBaseModel::acquire(); 325 } 326 327 void SAL_CALL SdXImpressDocument::release() throw ( ) 328 { 329 if (osl_decrementInterlockedCount( &m_refCount ) == 0) 330 { 331 // restore reference count: 332 osl_incrementInterlockedCount( &m_refCount ); 333 if(!mbDisposed) 334 { 335 try 336 { 337 dispose(); 338 } 339 catch (uno::RuntimeException const& exc) 340 { // don't break throw () 341 OSL_ENSURE( 342 false, OUStringToOString( 343 exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); 344 static_cast<void>(exc); 345 } 346 } 347 SfxBaseModel::release(); 348 } 349 } 350 351 // XUnoTunnel 352 const ::com::sun::star::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() throw() 353 { 354 static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; 355 if( !pSeq ) 356 { 357 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); 358 if( !pSeq ) 359 { 360 static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 ); 361 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 362 pSeq = &aSeq; 363 } 364 } 365 return *pSeq; 366 } 367 368 SdXImpressDocument* SdXImpressDocument::getImplementation( const uno::Reference< uno::XInterface >& xInt ) 369 { 370 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY ); 371 if( xUT.is() ) 372 return reinterpret_cast<SdXImpressDocument*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething( SdXImpressDocument::getUnoTunnelId() ))); 373 else 374 return NULL; 375 } 376 377 sal_Int64 SAL_CALL SdXImpressDocument::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException) 378 { 379 if( rIdentifier.getLength() == 16 ) 380 { 381 if( (0 == rtl_compareMemory( SdXImpressDocument::getUnoTunnelId().getConstArray(), rIdentifier.getConstArray(), 16 )) ) 382 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 383 384 if( (0 == rtl_compareMemory( SdrModel::getUnoTunnelImplementationId().getConstArray(), rIdentifier.getConstArray(), 16 )) ) 385 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(mpDoc)); 386 } 387 388 return SfxBaseModel::getSomething( rIdentifier ); 389 } 390 391 // XTypeProvider 392 uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes( ) throw(uno::RuntimeException) 393 { 394 OGuard aGuard( Application::GetSolarMutex() ); 395 396 if( maTypeSequence.getLength() == 0 ) 397 { 398 const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() ); 399 const sal_Int32 nBaseTypes = aBaseTypes.getLength(); 400 const uno::Type* pBaseTypes = aBaseTypes.getConstArray(); 401 402 const sal_Int32 nOwnTypes = mbImpressDoc ? 14 : 11; // !DANGER! Keep this updated! 403 404 maTypeSequence.realloc( nBaseTypes + nOwnTypes ); 405 uno::Type* pTypes = maTypeSequence.getArray(); 406 407 *pTypes++ = ITYPE(beans::XPropertySet); 408 *pTypes++ = ITYPE(lang::XServiceInfo); 409 *pTypes++ = ITYPE(lang::XMultiServiceFactory); 410 *pTypes++ = ITYPE(drawing::XDrawPageDuplicator); 411 *pTypes++ = ITYPE(drawing::XLayerSupplier); 412 *pTypes++ = ITYPE(drawing::XMasterPagesSupplier); 413 *pTypes++ = ITYPE(drawing::XDrawPagesSupplier); 414 *pTypes++ = ITYPE(document::XLinkTargetSupplier); 415 *pTypes++ = ITYPE(style::XStyleFamiliesSupplier); 416 *pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory); 417 *pTypes++ = ITYPE(view::XRenderable); 418 if( mbImpressDoc ) 419 { 420 *pTypes++ = ITYPE(presentation::XPresentationSupplier); 421 *pTypes++ = ITYPE(presentation::XCustomPresentationSupplier); 422 *pTypes++ = ITYPE(presentation::XHandoutMasterSupplier); 423 } 424 425 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) 426 *pTypes++ = *pBaseTypes++; 427 } 428 429 return maTypeSequence; 430 } 431 432 uno::Sequence< sal_Int8 > SAL_CALL SdXImpressDocument::getImplementationId( ) throw(uno::RuntimeException) 433 { 434 OGuard aGuard( Application::GetSolarMutex() ); 435 436 static uno::Sequence< sal_Int8 > aId; 437 if( aId.getLength() == 0 ) 438 { 439 aId.realloc( 16 ); 440 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 441 } 442 return aId; 443 } 444 445 /*********************************************************************** 446 * * 447 ***********************************************************************/ 448 void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 449 { 450 if( mpDoc ) 451 { 452 const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); 453 454 if( pSdrHint ) 455 { 456 if( hasEventListeners() ) 457 { 458 document::EventObject aEvent; 459 if( SvxUnoDrawMSFactory::createEvent( mpDoc, pSdrHint, aEvent ) ) 460 notifyEvent( aEvent ); 461 } 462 463 if( pSdrHint->GetKind() == HINT_MODELCLEARED ) 464 { 465 if( mpDoc ) 466 EndListening( *mpDoc ); 467 mpDoc = NULL; 468 mpDocShell = NULL; 469 } 470 } 471 else 472 { 473 const SfxSimpleHint* pSfxHint = PTR_CAST(SfxSimpleHint, &rHint ); 474 475 // ist unser SdDrawDocument gerade gestorben? 476 if(pSfxHint && pSfxHint->GetId() == SFX_HINT_DYING) 477 { 478 // yup, also schnell ein neues erfragen 479 if( mpDocShell ) 480 { 481 SdDrawDocument *pNewDoc = mpDocShell->GetDoc(); 482 483 // ist ueberhaupt ein neues da? 484 if( pNewDoc != mpDoc ) 485 { 486 mpDoc = pNewDoc; 487 if(mpDoc) 488 StartListening( *mpDoc ); 489 } 490 } 491 } 492 } 493 } 494 SfxBaseModel::Notify( rBC, rHint ); 495 } 496 497 /****************************************************************************** 498 * * 499 ******************************************************************************/ 500 SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, sal_Bool bDuplicate ) throw() 501 { 502 sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PK_STANDARD ); 503 SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin(); 504 sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); 505 sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); 506 507 SdPage* pStandardPage = NULL; 508 509 if( 0 == nPageCount ) 510 { 511 // this is only used for clipboard where we only have one page 512 pStandardPage = (SdPage*) mpDoc->AllocPage(sal_False); 513 514 Size aDefSize(21000, 29700); // A4-Hochformat 515 pStandardPage->SetSize( aDefSize ); 516 mpDoc->InsertPage(pStandardPage, 0); 517 } 518 else 519 { 520 // Hier wird die Seite ermittelt, hinter der eingefuegt werden soll 521 SdPage* pPreviousStandardPage = mpDoc->GetSdPage( Min( (sal_uInt16)(nPageCount - 1), nPage ), PK_STANDARD ); 522 SetOfByte aVisibleLayers = pPreviousStandardPage->TRG_GetMasterPageVisibleLayers(); 523 sal_Bool bIsPageBack = aVisibleLayers.IsSet( aBckgrnd ); 524 sal_Bool bIsPageObj = aVisibleLayers.IsSet( aBckgrndObj ); 525 526 // AutoLayouts muessen fertig sein 527 mpDoc->StopWorkStartupDelay(); 528 529 /************************************************************** 530 * Es wird stets zuerst eine Standardseite und dann eine 531 * Notizseite erzeugt. Es ist sichergestellt, dass auf eine 532 * Standardseite stets die zugehoerige Notizseite folgt. 533 **************************************************************/ 534 535 sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2; 536 SdPage* pPreviousNotesPage = (SdPage*) mpDoc->GetPage( nStandardPageNum - 1 ); 537 sal_uInt16 nNotesPageNum = nStandardPageNum + 1; 538 String aStandardPageName; 539 String aNotesPageName; 540 541 /************************************************************** 542 * Standardseite 543 **************************************************************/ 544 if( bDuplicate ) 545 pStandardPage = (SdPage*) pPreviousStandardPage->Clone(); 546 else 547 pStandardPage = (SdPage*) mpDoc->AllocPage(sal_False); 548 549 pStandardPage->SetSize( pPreviousStandardPage->GetSize() ); 550 pStandardPage->SetBorder( pPreviousStandardPage->GetLftBorder(), 551 pPreviousStandardPage->GetUppBorder(), 552 pPreviousStandardPage->GetRgtBorder(), 553 pPreviousStandardPage->GetLwrBorder() ); 554 pStandardPage->SetOrientation( pPreviousStandardPage->GetOrientation() ); 555 pStandardPage->SetName(aStandardPageName); 556 557 // Seite hinter aktueller Seite einfuegen 558 mpDoc->InsertPage(pStandardPage, nStandardPageNum); 559 560 if( !bDuplicate ) 561 { 562 // MasterPage der aktuellen Seite verwenden 563 pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage()); 564 pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() ); 565 pStandardPage->SetAutoLayout(AUTOLAYOUT_NONE, sal_True ); 566 } 567 568 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False); 569 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False); 570 aVisibleLayers.Set(aBckgrnd, bIsPageBack); 571 aVisibleLayers.Set(aBckgrndObj, bIsPageObj); 572 pStandardPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); 573 574 /************************************************************** 575 * Notizseite 576 **************************************************************/ 577 SdPage* pNotesPage = NULL; 578 579 if( bDuplicate ) 580 pNotesPage = (SdPage*) pPreviousNotesPage->Clone(); 581 else 582 pNotesPage = (SdPage*) mpDoc->AllocPage(sal_False); 583 584 pNotesPage->SetSize( pPreviousNotesPage->GetSize() ); 585 pNotesPage->SetBorder( pPreviousNotesPage->GetLftBorder(), 586 pPreviousNotesPage->GetUppBorder(), 587 pPreviousNotesPage->GetRgtBorder(), 588 pPreviousNotesPage->GetLwrBorder() ); 589 pNotesPage->SetOrientation( pPreviousNotesPage->GetOrientation() ); 590 pNotesPage->SetName(aNotesPageName); 591 pNotesPage->SetPageKind(PK_NOTES); 592 593 // Seite hinter aktueller Seite einfuegen 594 mpDoc->InsertPage(pNotesPage, nNotesPageNum); 595 596 if( !bDuplicate ) 597 { 598 // MasterPage der aktuellen Seite verwenden 599 pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage()); 600 pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() ); 601 pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True ); 602 } 603 } 604 605 SetModified(); 606 607 return( pStandardPage ); 608 } 609 610 void SdXImpressDocument::SetModified( sal_Bool bModified /* = sal_True */ ) throw() 611 { 612 if( mpDoc ) 613 mpDoc->SetChanged( bModified ); 614 } 615 616 // XModel 617 void SAL_CALL SdXImpressDocument ::lockControllers( ) 618 throw(uno::RuntimeException) 619 { 620 OGuard aGuard( Application::GetSolarMutex() ); 621 622 if( NULL == mpDoc ) 623 throw lang::DisposedException(); 624 625 mpDoc->setLock( sal_True ); 626 } 627 628 void SAL_CALL SdXImpressDocument::unlockControllers( ) 629 throw(uno::RuntimeException) 630 { 631 OGuard aGuard( Application::GetSolarMutex() ); 632 633 if( NULL == mpDoc ) 634 throw lang::DisposedException(); 635 636 if( mpDoc->isLocked() ) 637 { 638 mpDoc->setLock( sal_False ); 639 } 640 } 641 642 sal_Bool SAL_CALL SdXImpressDocument::hasControllersLocked( ) 643 throw(uno::RuntimeException) 644 { 645 OGuard aGuard( Application::GetSolarMutex() ); 646 647 if( NULL == mpDoc ) 648 throw lang::DisposedException(); 649 650 return mpDoc && mpDoc->isLocked(); 651 } 652 653 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX 654 #include <comphelper/processfactory.hxx> 655 #endif 656 657 uno::Reference < container::XIndexAccess > SAL_CALL SdXImpressDocument::getViewData() throw( uno::RuntimeException ) 658 { 659 OGuard aGuard( Application::GetSolarMutex() ); 660 661 if( NULL == mpDoc ) 662 throw lang::DisposedException(); 663 664 uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() ); 665 666 if( !xRet.is() ) 667 { 668 List* pFrameViewList = mpDoc->GetFrameViewList(); 669 670 if( pFrameViewList && pFrameViewList->Count() ) 671 { 672 xRet = uno::Reference < container::XIndexAccess >::query(::comphelper::getProcessServiceFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")))); 673 674 675 uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY ); 676 DBG_ASSERT( xCont.is(), "SdXImpressDocument::getViewData() failed for OLE object" ); 677 if( xCont.is() ) 678 { 679 sal_uInt32 i; 680 for( i = 0; i < pFrameViewList->Count(); i++ ) 681 { 682 ::sd::FrameView* pFrameView = 683 static_cast< ::sd::FrameView*>( 684 pFrameViewList->GetObject(i)); 685 686 if(pFrameView) 687 { 688 uno::Sequence< beans::PropertyValue > aSeq; 689 pFrameView->WriteUserDataSequence( aSeq ); 690 xCont->insertByIndex( i, uno::makeAny( aSeq ) ); 691 } 692 } 693 } 694 } 695 } 696 697 return xRet; 698 } 699 700 void SAL_CALL SdXImpressDocument::setViewData( const uno::Reference < container::XIndexAccess >& xData ) throw(::com::sun::star::uno::RuntimeException) 701 { 702 OGuard aGuard( Application::GetSolarMutex() ); 703 704 if( NULL == mpDoc ) 705 throw lang::DisposedException(); 706 707 SfxBaseModel::setViewData( xData ); 708 if( mpDocShell && (mpDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED) && xData.is() ) 709 { 710 const sal_Int32 nCount = xData->getCount(); 711 712 List* pFrameViewList = mpDoc->GetFrameViewList(); 713 714 DBG_ASSERT( pFrameViewList, "No FrameViewList?" ); 715 if( pFrameViewList ) 716 { 717 ::sd::FrameView* pFrameView; 718 719 sal_uInt32 i; 720 for ( i = 0; i < pFrameViewList->Count(); i++) 721 { 722 // Ggf. FrameViews loeschen 723 pFrameView = static_cast< ::sd::FrameView*>( 724 pFrameViewList->GetObject(i)); 725 726 if (pFrameView) 727 delete pFrameView; 728 } 729 730 pFrameViewList->Clear(); 731 732 uno::Sequence< beans::PropertyValue > aSeq; 733 sal_Int32 nIndex; 734 for( nIndex = 0; nIndex < nCount; nIndex++ ) 735 { 736 if( xData->getByIndex( nIndex ) >>= aSeq ) 737 { 738 pFrameView = new ::sd::FrameView( mpDoc ); 739 pFrameView->ReadUserDataSequence( aSeq ); 740 pFrameViewList->Insert( pFrameView ); 741 } 742 } 743 } 744 } 745 } 746 747 // XDrawPageDuplicator 748 uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::duplicate( const uno::Reference< drawing::XDrawPage >& xPage ) 749 throw(uno::RuntimeException) 750 { 751 OGuard aGuard( Application::GetSolarMutex() ); 752 753 if( NULL == mpDoc ) 754 throw lang::DisposedException(); 755 756 // pPage von xPage besorgen und dann die Id (nPos )ermitteln 757 SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage ); 758 if( pSvxPage ) 759 { 760 SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage(); 761 sal_uInt16 nPos = pPage->GetPageNum(); 762 nPos = ( nPos - 1 ) / 2; 763 pPage = InsertSdPage( nPos, sal_True ); 764 if( pPage ) 765 { 766 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); 767 return xDrawPage; 768 } 769 } 770 771 uno::Reference< drawing::XDrawPage > xDrawPage; 772 return xDrawPage; 773 } 774 775 776 // XDrawPagesSupplier 777 uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages() 778 throw(uno::RuntimeException) 779 { 780 OGuard aGuard( Application::GetSolarMutex() ); 781 782 if( NULL == mpDoc ) 783 throw lang::DisposedException(); 784 785 uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess ); 786 787 if( !xDrawPages.is() ) 788 { 789 initializeDocument(); 790 mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SdDrawPagesAccess(*this); 791 } 792 793 return xDrawPages; 794 } 795 796 // XMasterPagesSupplier 797 uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getMasterPages() 798 throw(uno::RuntimeException) 799 { 800 OGuard aGuard( Application::GetSolarMutex() ); 801 802 if( NULL == mpDoc ) 803 throw lang::DisposedException(); 804 805 uno::Reference< drawing::XDrawPages > xMasterPages( mxMasterPagesAccess ); 806 807 if( !xMasterPages.is() ) 808 { 809 initializeDocument(); 810 mxMasterPagesAccess = xMasterPages = new SdMasterPagesAccess(*this); 811 } 812 813 return xMasterPages; 814 } 815 816 // XLayerManagerSupplier 817 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLayerManager( ) 818 throw(uno::RuntimeException) 819 { 820 OGuard aGuard( Application::GetSolarMutex() ); 821 822 if( NULL == mpDoc ) 823 throw lang::DisposedException(); 824 825 uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager ); 826 827 if( !xLayerManager.is() ) 828 mxLayerManager = xLayerManager = new SdLayerManager(*this); 829 830 return xLayerManager; 831 } 832 833 // XCustomPresentationSupplier 834 uno::Reference< container::XNameContainer > SAL_CALL SdXImpressDocument::getCustomPresentations() 835 throw(uno::RuntimeException) 836 { 837 OGuard aGuard( Application::GetSolarMutex() ); 838 839 if( NULL == mpDoc ) 840 throw lang::DisposedException(); 841 842 uno::Reference< container::XNameContainer > xCustomPres( mxCustomPresentationAccess ); 843 844 if( !xCustomPres.is() ) 845 mxCustomPresentationAccess = xCustomPres = new SdXCustomPresentationAccess(*this); 846 847 return xCustomPres; 848 } 849 850 extern uno::Reference< presentation::XPresentation > createPresentation( SdXImpressDocument& rModel ); 851 852 // XPresentationSupplier 853 uno::Reference< presentation::XPresentation > SAL_CALL SdXImpressDocument::getPresentation() 854 throw(uno::RuntimeException) 855 { 856 OGuard aGuard( Application::GetSolarMutex() ); 857 858 if( NULL == mpDoc ) 859 throw lang::DisposedException(); 860 861 return uno::Reference< presentation::XPresentation >( mpDoc->getPresentation().get() ); 862 } 863 864 // XHandoutMasterSupplier 865 uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::getHandoutMasterPage() 866 throw (uno::RuntimeException) 867 { 868 OGuard aGuard( Application::GetSolarMutex() ); 869 870 if( NULL == mpDoc ) 871 throw lang::DisposedException(); 872 873 uno::Reference< drawing::XDrawPage > xPage; 874 875 if( mpDoc ) 876 { 877 initializeDocument(); 878 SdPage* pPage = mpDoc->GetMasterSdPage( 0, PK_HANDOUT ); 879 if( pPage ) 880 xPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ); 881 } 882 return xPage; 883 } 884 885 // XMultiServiceFactory ( SvxFmMSFactory ) 886 uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier ) 887 throw(uno::Exception, uno::RuntimeException) 888 { 889 OGuard aGuard( Application::GetSolarMutex() ); 890 891 if( NULL == mpDoc ) 892 throw lang::DisposedException(); 893 894 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) ) 895 { 896 if( !mxDashTable.is() ) 897 mxDashTable = SvxUnoDashTable_createInstance( mpDoc ); 898 899 return mxDashTable; 900 } 901 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) ) 902 { 903 if( !mxGradientTable.is() ) 904 mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc ); 905 906 return mxGradientTable; 907 } 908 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) ) 909 { 910 if( !mxHatchTable.is() ) 911 mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc ); 912 913 return mxHatchTable; 914 } 915 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) ) 916 { 917 if( !mxBitmapTable.is() ) 918 mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc ); 919 920 return mxBitmapTable; 921 } 922 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) ) 923 { 924 if( !mxTransGradientTable.is() ) 925 mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc ); 926 927 return mxTransGradientTable; 928 } 929 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) ) 930 { 931 if( !mxMarkerTable.is() ) 932 mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc ); 933 934 return mxMarkerTable; 935 } 936 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) ) 937 { 938 return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY ); 939 } 940 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Background" ) ) ) 941 { 942 return uno::Reference< uno::XInterface >( 943 static_cast<uno::XWeak*>(new SdUnoPageBackground( mpDoc ))); 944 } 945 946 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) ) 947 { 948 if( !mxDrawingPool.is() ) 949 mxDrawingPool = SdUnoCreatePool( mpDoc ); 950 951 return mxDrawingPool; 952 953 } 954 955 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_Service_ImageMapRectangleObject) ) ) 956 { 957 return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() ); 958 } 959 960 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_Service_ImageMapCircleObject) ) ) 961 { 962 return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() ); 963 } 964 965 if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(sUNO_Service_ImageMapPolygonObject) ) ) 966 { 967 return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() ); 968 } 969 970 if( ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) ) || 971 ( !mbImpressDoc && ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DocumentSettings") ) ) ) || 972 ( mbImpressDoc && ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.DocumentSettings") ) ) ) ) 973 { 974 return sd::DocumentSettings_createInstance( this ); 975 } 976 977 if( ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime") ) ) || 978 ( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.textfield.DateTime") ) ) ) 979 { 980 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_EXT_DATEFIELD ); 981 } 982 983 if( (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TextField.Header"))) || 984 (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.textfield.Header"))) ) 985 { 986 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_HEADERFIELD ); 987 } 988 989 if( (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TextField.Footer"))) || 990 (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.textfield.Footer"))) ) 991 { 992 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_FOOTERFIELD ); 993 } 994 995 if( (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TextField.DateTime"))) || 996 (0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.textfield.DateTime"))) ) 997 { 998 return (::cppu::OWeakObject * )new SvxUnoTextField( ID_DATETIMEFIELD ); 999 } 1000 1001 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.xml.NamespaceMap") ) ) 1002 { 1003 static sal_uInt16 aWhichIds[] = { SDRATTR_XMLATTRIBUTES, EE_CHAR_XMLATTRIBS, EE_PARA_XMLATTRIBS, 0 }; 1004 1005 return svx::NamespaceMap_createInstance( aWhichIds, &mpDoc->GetItemPool() ); 1006 } 1007 1008 // #99870# Support creation of GraphicObjectResolver and EmbeddedObjectResolver 1009 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver") ) ) 1010 { 1011 return (::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE ); 1012 } 1013 1014 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver") ) ) 1015 { 1016 return (::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ ); 1017 } 1018 1019 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver") ) ) 1020 { 1021 ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : NULL; 1022 if( NULL == pPersist ) 1023 throw lang::DisposedException(); 1024 1025 return (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pPersist, EMBEDDEDOBJECTHELPER_MODE_WRITE ); 1026 } 1027 1028 if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver") ) ) 1029 { 1030 ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : NULL; 1031 if( NULL == pPersist ) 1032 throw lang::DisposedException(); 1033 1034 return (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pPersist, EMBEDDEDOBJECTHELPER_MODE_READ ); 1035 } 1036 1037 uno::Reference< uno::XInterface > xRet; 1038 1039 const String aType( aServiceSpecifier ); 1040 if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) ) 1041 { 1042 SvxShape* pShape = NULL; 1043 1044 sal_uInt16 nType = OBJ_TEXT; 1045 // create a shape wrapper 1046 if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) ) 1047 { 1048 nType = OBJ_TEXT; 1049 } 1050 else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) ) 1051 { 1052 nType = OBJ_TEXT; 1053 } 1054 else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) ) 1055 { 1056 nType = OBJ_TEXT; 1057 } 1058 else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) ) 1059 { 1060 nType = OBJ_GRAF; 1061 } 1062 else if( aType.EqualsAscii( "PageShape", 26, 9 ) ) 1063 { 1064 nType = OBJ_PAGE; 1065 } 1066 else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) ) 1067 { 1068 nType = OBJ_OLE2; 1069 } 1070 else if( aType.EqualsAscii( "ChartShape", 26, 10 ) ) 1071 { 1072 nType = OBJ_OLE2; 1073 } 1074 else if( aType.EqualsAscii( "CalcShape", 26, 9 ) ) 1075 { 1076 nType = OBJ_OLE2; 1077 } 1078 else if( aType.EqualsAscii( "TableShape", 26, 10 ) ) 1079 { 1080 nType = OBJ_TABLE; 1081 } 1082 else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) ) 1083 { 1084 nType = OBJ_OLE2; 1085 } 1086 else if( aType.EqualsAscii( "NotesShape", 26, 13 ) ) 1087 { 1088 nType = OBJ_TEXT; 1089 } 1090 else if( aType.EqualsAscii( "HandoutShape", 26, 13 ) ) 1091 { 1092 nType = OBJ_PAGE; 1093 } 1094 else if( aType.EqualsAscii( "FooterShape", 26, 12 ) ) 1095 { 1096 nType = OBJ_TEXT; 1097 } 1098 else if( aType.EqualsAscii( "HeaderShape", 26, 12 ) ) 1099 { 1100 nType = OBJ_TEXT; 1101 } 1102 else if( aType.EqualsAscii( "SlideNumberShape", 26, 17 ) ) 1103 { 1104 nType = OBJ_TEXT; 1105 } 1106 else if( aType.EqualsAscii( "DateTimeShape", 26, 17 ) ) 1107 { 1108 nType = OBJ_TEXT; 1109 } 1110 else if( aType.EqualsAscii( "MediaShape", 26, 10 ) ) 1111 { 1112 nType = OBJ_MEDIA; 1113 } 1114 else 1115 { 1116 throw lang::ServiceNotRegisteredException(); 1117 } 1118 1119 // create the API wrapper 1120 pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor ); 1121 1122 // set shape type 1123 if( pShape && !mbClipBoard ) 1124 pShape->SetShapeType(aServiceSpecifier); 1125 1126 xRet = (uno::XWeak*)pShape; 1127 } 1128 else if( aServiceSpecifier.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape") ) ) 1129 { 1130 SvxShape* pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor ); 1131 if( pShape && !mbClipBoard ) 1132 pShape->SetShapeType(aServiceSpecifier); 1133 1134 xRet = (uno::XWeak*)pShape; 1135 } 1136 else 1137 { 1138 xRet = SvxFmMSFactory::createInstance( aServiceSpecifier ); 1139 } 1140 1141 uno::Reference< drawing::XShape > xShape( xRet, uno::UNO_QUERY ); 1142 if( xShape.is() ) 1143 { 1144 xRet.clear(); 1145 new SdXShape( SvxShape::getImplementation( xShape ), (SdXImpressDocument*)this ); 1146 xRet = xShape; 1147 xShape.clear(); 1148 } 1149 1150 return xRet; 1151 } 1152 1153 uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames() 1154 throw(uno::RuntimeException) 1155 { 1156 OGuard aGuard( Application::GetSolarMutex() ); 1157 1158 if( NULL == mpDoc ) 1159 throw lang::DisposedException(); 1160 1161 const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() ); 1162 1163 uno::Sequence< OUString > aSNS( mbImpressDoc ? (36) : (19) ); 1164 1165 sal_uInt16 i(0); 1166 1167 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable")); 1168 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable")); 1169 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable")); 1170 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable")); 1171 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable")); 1172 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable")); 1173 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules")); 1174 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Background")); 1175 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.Settings")); 1176 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_Service_ImageMapRectangleObject)); 1177 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_Service_ImageMapCircleObject)); 1178 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM(sUNO_Service_ImageMapPolygonObject)); 1179 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.NamespaceMap")); 1180 1181 // #99870# Support creation of GraphicObjectResolver and EmbeddedObjectResolver 1182 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportGraphicObjectResolver")); 1183 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportGraphicObjectResolver")); 1184 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ExportEmbeddedObjectResolver")); 1185 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver")); 1186 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TableShape")); 1187 1188 if(mbImpressDoc) 1189 { 1190 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape")); 1191 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape")); 1192 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape")); 1193 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape")); 1194 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape")); 1195 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape")); 1196 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape")); 1197 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape")); 1198 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape")); 1199 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape")); 1200 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape")); 1201 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.DocumentSettings")); 1202 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.FooterShape")); 1203 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HeaderShape")); 1204 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideNumberShape")); 1205 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.DateTimeShape")); 1206 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.CalcShape")); 1207 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.MediaShape")); 1208 } 1209 else 1210 { 1211 aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DocumentSettings")); 1212 } 1213 1214 DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" ); 1215 1216 return comphelper::concatSequences( aSNS_ORG, aSNS ); 1217 } 1218 1219 // lang::XServiceInfo 1220 OUString SAL_CALL SdXImpressDocument::getImplementationName() 1221 throw(uno::RuntimeException) 1222 { 1223 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdXImpressDocument")); 1224 } 1225 1226 sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName ) 1227 throw(uno::RuntimeException) 1228 { 1229 OGuard aGuard( Application::GetSolarMutex() ); 1230 1231 if ( 1232 (ServiceName.equalsAscii("com.sun.star.document.OfficeDocument" )) || 1233 (ServiceName.equalsAscii("com.sun.star.drawing.GenericDrawingDocument")) || 1234 (ServiceName.equalsAscii("com.sun.star.drawing.DrawingDocumentFactory")) 1235 ) 1236 { 1237 return sal_True; 1238 } 1239 1240 return ( 1241 ( mbImpressDoc && ServiceName.equalsAscii("com.sun.star.presentation.PresentationDocument")) || 1242 (!mbImpressDoc && ServiceName.equalsAscii("com.sun.star.drawing.DrawingDocument" )) 1243 ); 1244 } 1245 1246 uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames() throw(uno::RuntimeException) 1247 { 1248 OGuard aGuard( Application::GetSolarMutex() ); 1249 1250 uno::Sequence< OUString > aSeq( 4 ); 1251 OUString* pServices = aSeq.getArray(); 1252 1253 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.OfficeDocument")); 1254 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GenericDrawingDocument")); 1255 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentFactory")); 1256 1257 if( mbImpressDoc ) 1258 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument")); 1259 else 1260 *pServices++ = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument")); 1261 1262 return aSeq; 1263 } 1264 1265 // XPropertySet 1266 uno::Reference< beans::XPropertySetInfo > SAL_CALL SdXImpressDocument::getPropertySetInfo( ) 1267 throw(uno::RuntimeException) 1268 { 1269 OGuard aGuard( Application::GetSolarMutex() ); 1270 return mpPropSet->getPropertySetInfo(); 1271 } 1272 1273 void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) 1274 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 1275 { 1276 OGuard aGuard( Application::GetSolarMutex() ); 1277 1278 if( NULL == mpDoc ) 1279 throw lang::DisposedException(); 1280 1281 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName); 1282 1283 switch( pEntry ? pEntry->nWID : -1 ) 1284 { 1285 case WID_MODEL_LANGUAGE: 1286 { 1287 lang::Locale aLocale; 1288 if(!(aValue >>= aLocale)) 1289 throw lang::IllegalArgumentException(); 1290 1291 mpDoc->SetLanguage( SvxLocaleToLanguage(aLocale), EE_CHAR_LANGUAGE ); 1292 break; 1293 } 1294 case WID_MODEL_TABSTOP: 1295 { 1296 sal_Int32 nValue = 0; 1297 if(!(aValue >>= nValue) || nValue < 0 ) 1298 throw lang::IllegalArgumentException(); 1299 1300 mpDoc->SetDefaultTabulator((sal_uInt16)nValue); 1301 break; 1302 } 1303 case WID_MODEL_VISAREA: 1304 { 1305 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh(); 1306 if( !pEmbeddedObj ) 1307 break; 1308 1309 awt::Rectangle aVisArea; 1310 if( !(aValue >>= aVisArea) || (aVisArea.Width < 0) || (aVisArea.Height < 0) ) 1311 throw lang::IllegalArgumentException(); 1312 1313 pEmbeddedObj->SetVisArea( Rectangle( aVisArea.X, aVisArea.Y, aVisArea.X + aVisArea.Width - 1, aVisArea.Y + aVisArea.Height - 1 ) ); 1314 } 1315 break; 1316 case WID_MODEL_CONTFOCUS: 1317 { 1318 sal_Bool bFocus = sal_False; 1319 if( !(aValue >>= bFocus ) ) 1320 throw lang::IllegalArgumentException(); 1321 mpDoc->SetAutoControlFocus( bFocus ); 1322 } 1323 break; 1324 case WID_MODEL_DSGNMODE: 1325 { 1326 sal_Bool bMode = sal_False; 1327 if( !(aValue >>= bMode ) ) 1328 throw lang::IllegalArgumentException(); 1329 mpDoc->SetOpenInDesignMode( bMode ); 1330 } 1331 break; 1332 case WID_MODEL_BUILDID: 1333 aValue >>= maBuildId; 1334 return; 1335 case WID_MODEL_MAPUNIT: 1336 case WID_MODEL_BASICLIBS: 1337 case WID_MODEL_RUNTIMEUID: // is read-only 1338 case WID_MODEL_DIALOGLIBS: 1339 throw beans::PropertyVetoException(); 1340 default: 1341 throw beans::UnknownPropertyException(); 1342 } 1343 1344 SetModified(); 1345 } 1346 1347 uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& PropertyName ) 1348 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1349 { 1350 OGuard aGuard( Application::GetSolarMutex() ); 1351 1352 uno::Any aAny; 1353 if( NULL == mpDoc ) 1354 throw lang::DisposedException(); 1355 1356 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName); 1357 1358 switch( pEntry ? pEntry->nWID : -1 ) 1359 { 1360 case WID_MODEL_LANGUAGE: 1361 { 1362 LanguageType eLang = mpDoc->GetLanguage( EE_CHAR_LANGUAGE ); 1363 lang::Locale aLocale; 1364 SvxLanguageToLocale( aLocale, eLang ); 1365 aAny <<= aLocale; 1366 break; 1367 } 1368 case WID_MODEL_TABSTOP: 1369 aAny <<= (sal_Int32)mpDoc->GetDefaultTabulator(); 1370 break; 1371 case WID_MODEL_VISAREA: 1372 { 1373 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh(); 1374 if( !pEmbeddedObj ) 1375 break; 1376 1377 const Rectangle& aRect = pEmbeddedObj->GetVisArea(); 1378 awt::Rectangle aVisArea( aRect.nLeft, aRect.nTop, aRect.getWidth(), aRect.getHeight() ); 1379 aAny <<= aVisArea; 1380 } 1381 break; 1382 case WID_MODEL_MAPUNIT: 1383 { 1384 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh(); 1385 if( !pEmbeddedObj ) 1386 break; 1387 1388 sal_Int16 nMeasureUnit = 0; 1389 SvxMapUnitToMeasureUnit( (const short)pEmbeddedObj->GetMapUnit(), nMeasureUnit ); 1390 aAny <<= (sal_Int16)nMeasureUnit; 1391 } 1392 break; 1393 case WID_MODEL_FORBCHARS: 1394 { 1395 aAny <<= getForbiddenCharsTable(); 1396 } 1397 break; 1398 case WID_MODEL_CONTFOCUS: 1399 aAny <<= (sal_Bool)mpDoc->GetAutoControlFocus(); 1400 break; 1401 case WID_MODEL_DSGNMODE: 1402 aAny <<= mpDoc->GetOpenInDesignMode(); 1403 break; 1404 case WID_MODEL_BASICLIBS: 1405 aAny <<= mpDocShell->GetBasicContainer(); 1406 break; 1407 case WID_MODEL_DIALOGLIBS: 1408 aAny <<= mpDocShell->GetDialogContainer(); 1409 break; 1410 case WID_MODEL_RUNTIMEUID: 1411 aAny <<= getRuntimeUID(); 1412 break; 1413 case WID_MODEL_BUILDID: 1414 return uno::Any( maBuildId ); 1415 case WID_MODEL_HASVALIDSIGNATURES: 1416 aAny <<= hasValidSignatures(); 1417 break; 1418 default: 1419 throw beans::UnknownPropertyException(); 1420 } 1421 1422 return aAny; 1423 } 1424 1425 void SAL_CALL SdXImpressDocument::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 1426 void SAL_CALL SdXImpressDocument::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 1427 void SAL_CALL SdXImpressDocument::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 1428 void SAL_CALL SdXImpressDocument::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 1429 1430 // XLinkTargetSupplier 1431 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks() 1432 throw(uno::RuntimeException) 1433 { 1434 OGuard aGuard( Application::GetSolarMutex() ); 1435 1436 if( NULL == mpDoc ) 1437 throw lang::DisposedException(); 1438 1439 uno::Reference< container::XNameAccess > xLinks( mxLinks ); 1440 if( !xLinks.is() ) 1441 mxLinks = xLinks = new SdDocLinkTargets( *this ); 1442 return xLinks; 1443 } 1444 1445 // XStyleFamiliesSupplier 1446 uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getStyleFamilies( ) 1447 throw(uno::RuntimeException) 1448 { 1449 OGuard aGuard( Application::GetSolarMutex() ); 1450 1451 if( NULL == mpDoc ) 1452 throw lang::DisposedException(); 1453 1454 uno::Reference< container::XNameAccess > xStyles( dynamic_cast< container::XNameAccess* >( mpDoc->GetStyleSheetPool()) ); 1455 return xStyles; 1456 } 1457 1458 // XAnyCompareFactory 1459 uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SdXImpressDocument::createAnyCompareByName( const OUString& ) 1460 throw (uno::RuntimeException) 1461 { 1462 return SvxCreateNumRuleCompare(); 1463 } 1464 1465 // XRenderable 1466 sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelection, 1467 const uno::Sequence< beans::PropertyValue >& ) 1468 throw (lang::IllegalArgumentException, uno::RuntimeException) 1469 { 1470 OGuard aGuard( Application::GetSolarMutex() ); 1471 sal_Int32 nRet = 0; 1472 1473 if( NULL == mpDoc ) 1474 throw lang::DisposedException(); 1475 1476 uno::Sequence< beans::PropertyValue > aRenderer; 1477 1478 if( mpDocShell && mpDoc ) 1479 { 1480 uno::Reference< frame::XModel > xModel; 1481 1482 rSelection >>= xModel; 1483 1484 if( xModel == mpDocShell->GetModel() ) 1485 nRet = mpDoc->GetSdPageCount( PK_STANDARD ); 1486 else 1487 { 1488 uno::Reference< drawing::XShapes > xShapes; 1489 1490 rSelection >>= xShapes; 1491 1492 if( xShapes.is() && xShapes->getCount() ) 1493 nRet = 1; 1494 } 1495 } 1496 return nRet; 1497 } 1498 1499 uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer( sal_Int32 , const uno::Any& , 1500 const uno::Sequence< beans::PropertyValue >& rxOptions ) 1501 throw (lang::IllegalArgumentException, uno::RuntimeException) 1502 { 1503 OGuard aGuard( Application::GetSolarMutex() ); 1504 1505 if( NULL == mpDoc ) 1506 throw lang::DisposedException(); 1507 1508 sal_Bool bExportNotesPages = sal_False; 1509 for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) 1510 { 1511 if( rxOptions[ nProperty ].Name.equalsAscii( "ExportNotesPages" ) ) 1512 rxOptions[ nProperty].Value >>= bExportNotesPages; 1513 } 1514 uno::Sequence< beans::PropertyValue > aRenderer; 1515 if( mpDocShell && mpDoc ) 1516 { 1517 awt::Size aPageSize; 1518 if ( bExportNotesPages ) 1519 { 1520 Size aNotesPageSize = mpDoc->GetSdPage( 0, PK_NOTES )->GetSize(); 1521 aPageSize = awt::Size( aNotesPageSize.Width(), aNotesPageSize.Height() ); 1522 } 1523 else 1524 { 1525 const Rectangle aVisArea( mpDocShell->GetVisArea( embed::Aspects::MSOLE_DOCPRINT ) ); 1526 aPageSize = awt::Size( aVisArea.GetWidth(), aVisArea.GetHeight() ); 1527 } 1528 aRenderer.realloc( 1 ); 1529 1530 aRenderer[ 0 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); 1531 aRenderer[ 0 ].Value <<= aPageSize; 1532 } 1533 return aRenderer; 1534 } 1535 1536 class ImplRenderPaintProc : public ::sdr::contact::ViewObjectContactRedirector 1537 { 1538 const SdrLayerAdmin& rLayerAdmin; 1539 SdrPageView* pSdrPageView; 1540 vcl::PDFExtOutDevData* pPDFExtOutDevData; 1541 1542 vcl::PDFWriter::StructElement ImplBegStructureTag( SdrObject& rObject ); 1543 1544 public: 1545 sal_Bool IsVisible ( const SdrObject* pObj ) const; 1546 sal_Bool IsPrintable( const SdrObject* pObj ) const; 1547 1548 ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData ); 1549 virtual ~ImplRenderPaintProc(); 1550 1551 // all default implementations just call the same methods at the original. To do something 1552 // different, overload the method and at least do what the method does. 1553 virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence( 1554 const sdr::contact::ViewObjectContact& rOriginal, 1555 const sdr::contact::DisplayInfo& rDisplayInfo); 1556 }; 1557 1558 ImplRenderPaintProc::ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData ) 1559 : ViewObjectContactRedirector(), 1560 rLayerAdmin ( rLA ), 1561 pSdrPageView ( pView ), 1562 pPDFExtOutDevData ( pData ) 1563 { 1564 } 1565 1566 ImplRenderPaintProc::~ImplRenderPaintProc() 1567 { 1568 } 1569 1570 sal_Int32 ImplPDFGetBookmarkPage( const String& rBookmark, SdDrawDocument& rDoc ) 1571 { 1572 sal_Int32 nPage = -1; 1573 1574 OSL_TRACE("GotoBookmark %s", 1575 ::rtl::OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr()); 1576 1577 String aBookmark( rBookmark ); 1578 1579 if( rBookmark.Len() && rBookmark.GetChar( 0 ) == sal_Unicode('#') ) 1580 aBookmark = rBookmark.Copy( 1 ); 1581 1582 // is the bookmark a page ? 1583 sal_Bool bIsMasterPage; 1584 sal_uInt16 nPgNum = rDoc.GetPageByName( aBookmark, bIsMasterPage ); 1585 SdrObject* pObj = NULL; 1586 1587 if ( nPgNum == SDRPAGE_NOTFOUND ) 1588 { 1589 // is the bookmark a object ? 1590 pObj = rDoc.GetObj( aBookmark ); 1591 if (pObj) 1592 nPgNum = pObj->GetPage()->GetPageNum(); 1593 } 1594 if ( nPgNum != SDRPAGE_NOTFOUND ) 1595 nPage = ( nPgNum - 1 ) / 2; 1596 return nPage; 1597 } 1598 1599 void ImplPDFExportComments( uno::Reference< drawing::XDrawPage > xPage, vcl::PDFExtOutDevData& rPDFExtOutDevData ) 1600 { 1601 try 1602 { 1603 uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW ); 1604 uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() ); 1605 1606 LanguageType eLanguage = Application::GetSettings().GetLanguage(); 1607 while( xAnnotationEnumeration->hasMoreElements() ) 1608 { 1609 uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() ); 1610 1611 geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() ); 1612 uno::Reference< text::XText > xText( xAnnotation->getTextRange() ); 1613 // rtl::OUString sInitials( getInitials( sAuthor ) ); 1614 util::DateTime aDateTime( xAnnotation->getDateTime() ); 1615 1616 Date aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year ); 1617 Time aTime; 1618 String aStr( SvxDateTimeField::GetFormatted( aDate, aTime, SVXDATEFORMAT_B, *(SD_MOD()->GetNumberFormatter()), eLanguage ) ); 1619 1620 vcl::PDFNote aNote; 1621 String sTitle( xAnnotation->getAuthor() ); 1622 sTitle.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) ); 1623 sTitle += aStr; 1624 aNote.Title = sTitle; 1625 aNote.Contents = xText->getString(); 1626 rPDFExtOutDevData.CreateNote( Rectangle( Point( static_cast< long >( aRealPoint2D.X * 100 ), 1627 static_cast< long >( aRealPoint2D.Y * 100 ) ), Size( 1000, 1000 ) ), aNote ); 1628 } 1629 } 1630 catch( uno::Exception& ) 1631 { 1632 } 1633 } 1634 1635 void ImplPDFExportShapeInteraction( uno::Reference< drawing::XShape > xShape, SdDrawDocument& rDoc, vcl::PDFExtOutDevData& rPDFExtOutDevData ) 1636 { 1637 const rtl::OUString sGroup ( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) ); 1638 const rtl::OUString sOnClick ( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ); 1639 const rtl::OUString sBookmark( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) ); 1640 1641 if ( xShape->getShapeType().equals( sGroup ) ) 1642 { 1643 uno::Reference< container::XIndexAccess > xIndexAccess( xShape, uno::UNO_QUERY ); 1644 if ( xIndexAccess.is() ) 1645 { 1646 sal_Int32 i, nCount = xIndexAccess->getCount(); 1647 for ( i = 0; i < nCount; i++ ) 1648 { 1649 uno::Reference< drawing::XShape > xSubShape( xIndexAccess->getByIndex( i ), uno::UNO_QUERY ); 1650 if ( xSubShape.is() ) 1651 ImplPDFExportShapeInteraction( xSubShape, rDoc, rPDFExtOutDevData ); 1652 } 1653 } 1654 } 1655 else 1656 { 1657 uno::Reference< beans::XPropertySet > xShapePropSet( xShape, uno::UNO_QUERY ); 1658 if( xShapePropSet.is() ) 1659 { 1660 Size aPageSize( rDoc.GetSdPage( 0, PK_STANDARD )->GetSize() ); 1661 Point aPoint( 0, 0 ); 1662 Rectangle aPageRect( aPoint, aPageSize ); 1663 1664 awt::Point aShapePos( xShape->getPosition() ); 1665 awt::Size aShapeSize( xShape->getSize() ); 1666 Rectangle aLinkRect( Point( aShapePos.X, aShapePos.Y ), Size( aShapeSize.Width, aShapeSize.Height ) ); 1667 1668 presentation::ClickAction eCa; 1669 uno::Any aAny( xShapePropSet->getPropertyValue( sOnClick ) ); 1670 if ( aAny >>= eCa ) 1671 { 1672 switch ( eCa ) 1673 { 1674 case presentation::ClickAction_LASTPAGE : 1675 { 1676 sal_Int32 nCount = rDoc.GetSdPageCount( PK_STANDARD ); 1677 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nCount - 1, vcl::PDFWriter::FitRectangle ); 1678 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 ); 1679 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); 1680 } 1681 break; 1682 case presentation::ClickAction_FIRSTPAGE : 1683 { 1684 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, 0, vcl::PDFWriter::FitRectangle ); 1685 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 ); 1686 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); 1687 } 1688 break; 1689 case presentation::ClickAction_PREVPAGE : 1690 { 1691 sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber(); 1692 if ( nDestPage ) 1693 nDestPage--; 1694 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle ); 1695 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 ); 1696 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); 1697 } 1698 break; 1699 case presentation::ClickAction_NEXTPAGE : 1700 { 1701 sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber() + 1; 1702 sal_Int32 nLastPage = rDoc.GetSdPageCount( PK_STANDARD ) - 1; 1703 if ( nDestPage > nLastPage ) 1704 nDestPage = nLastPage; 1705 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle ); 1706 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 ); 1707 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); 1708 } 1709 break; 1710 1711 case presentation::ClickAction_PROGRAM : 1712 case presentation::ClickAction_BOOKMARK : 1713 case presentation::ClickAction_DOCUMENT : 1714 { 1715 rtl::OUString aBookmark; 1716 xShapePropSet->getPropertyValue( sBookmark ) >>= aBookmark; 1717 if( aBookmark.getLength() ) 1718 { 1719 switch( eCa ) 1720 { 1721 case presentation::ClickAction_DOCUMENT : 1722 case presentation::ClickAction_PROGRAM : 1723 { 1724 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 ); 1725 rPDFExtOutDevData.SetLinkURL( nLinkId, aBookmark ); 1726 } 1727 break; 1728 case presentation::ClickAction_BOOKMARK : 1729 { 1730 sal_Int32 nPage = ImplPDFGetBookmarkPage( aBookmark, rDoc ); 1731 if ( nPage != -1 ) 1732 { 1733 sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle ); 1734 sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 ); 1735 rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId ); 1736 } 1737 } 1738 break; 1739 default: 1740 break; 1741 } 1742 } 1743 } 1744 break; 1745 1746 case presentation::ClickAction_STOPPRESENTATION : 1747 case presentation::ClickAction_SOUND : 1748 case presentation::ClickAction_INVISIBLE : 1749 case presentation::ClickAction_VERB : 1750 case presentation::ClickAction_VANISH : 1751 case presentation::ClickAction_MACRO : 1752 default : 1753 break; 1754 } 1755 } 1756 } 1757 } 1758 } 1759 1760 vcl::PDFWriter::StructElement ImplRenderPaintProc::ImplBegStructureTag( SdrObject& rObject ) 1761 { 1762 vcl::PDFWriter::StructElement eElement(vcl::PDFWriter::NonStructElement); 1763 1764 if ( pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportTaggedPDF() ) 1765 { 1766 sal_uInt32 nInventor = rObject.GetObjInventor(); 1767 sal_uInt16 nIdentifier = rObject.GetObjIdentifier(); 1768 sal_Bool bIsTextObj = rObject.ISA( SdrTextObj ); 1769 1770 if ( nInventor == SdrInventor ) 1771 { 1772 if ( nIdentifier == OBJ_GRUP ) 1773 eElement = vcl::PDFWriter::Section; 1774 else if ( nIdentifier == OBJ_TITLETEXT ) 1775 eElement = vcl::PDFWriter::Heading; 1776 else if ( nIdentifier == OBJ_OUTLINETEXT ) 1777 eElement = vcl::PDFWriter::Division; 1778 else if ( !bIsTextObj || !((SdrTextObj&)rObject).HasText() ) 1779 eElement = vcl::PDFWriter::Figure; 1780 } 1781 } 1782 1783 return eElement; 1784 } 1785 1786 drawinglayer::primitive2d::Primitive2DSequence ImplRenderPaintProc::createRedirectedPrimitive2DSequence( 1787 const sdr::contact::ViewObjectContact& rOriginal, 1788 const sdr::contact::DisplayInfo& rDisplayInfo) 1789 { 1790 SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject(); 1791 1792 if(pObject) 1793 { 1794 drawinglayer::primitive2d::Primitive2DSequence xRetval; 1795 1796 if(pObject->GetPage()) 1797 { 1798 if(pObject->GetPage()->checkVisibility(rOriginal, rDisplayInfo, false)) 1799 { 1800 if(IsVisible(pObject) && IsPrintable(pObject)) 1801 { 1802 const vcl::PDFWriter::StructElement eElement(ImplBegStructureTag( *pObject )); 1803 const bool bTagUsed(vcl::PDFWriter::NonStructElement != eElement); 1804 1805 xRetval = ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo); 1806 1807 if(xRetval.hasElements() && bTagUsed) 1808 { 1809 // embed Primitive2DSequence in a structure tag element for 1810 // exactly this purpose (StructureTagPrimitive2D) 1811 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::StructureTagPrimitive2D(eElement, xRetval)); 1812 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 1813 } 1814 } 1815 } 1816 } 1817 1818 return xRetval; 1819 } 1820 else 1821 { 1822 // not an object, maybe a page 1823 return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo); 1824 } 1825 } 1826 1827 sal_Bool ImplRenderPaintProc::IsVisible( const SdrObject* pObj ) const 1828 { 1829 sal_Bool bVisible = sal_True; 1830 SdrLayerID nLayerId = pObj->GetLayer(); 1831 if( pSdrPageView ) 1832 { 1833 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId ); 1834 if ( pSdrLayer ) 1835 { 1836 String aLayerName = pSdrLayer->GetName(); 1837 bVisible = pSdrPageView->IsLayerVisible( aLayerName ); 1838 } 1839 } 1840 return bVisible; 1841 } 1842 sal_Bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const 1843 { 1844 sal_Bool bPrintable = sal_True; 1845 SdrLayerID nLayerId = pObj->GetLayer(); 1846 if( pSdrPageView ) 1847 { 1848 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId ); 1849 if ( pSdrLayer ) 1850 { 1851 String aLayerName = pSdrLayer->GetName(); 1852 bPrintable = pSdrPageView->IsLayerPrintable( aLayerName ); 1853 } 1854 } 1855 return bPrintable; 1856 1857 } 1858 void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection, 1859 const uno::Sequence< beans::PropertyValue >& rxOptions ) 1860 throw (lang::IllegalArgumentException, uno::RuntimeException) 1861 { 1862 OGuard aGuard( Application::GetSolarMutex() ); 1863 1864 if( NULL == mpDoc ) 1865 throw lang::DisposedException(); 1866 1867 if( mpDocShell && mpDoc ) 1868 { 1869 uno::Reference< awt::XDevice > xRenderDevice; 1870 const sal_Int32 nPageNumber = nRenderer + 1; 1871 PageKind ePageKind = PK_STANDARD; 1872 sal_Bool bExportNotesPages = sal_False; 1873 1874 for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty ) 1875 { 1876 if( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) 1877 rxOptions[ nProperty ].Value >>= xRenderDevice; 1878 else if ( rxOptions[ nProperty ].Name == OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportNotesPages" ) ) ) 1879 { 1880 rxOptions[ nProperty].Value >>= bExportNotesPages; 1881 if ( bExportNotesPages ) 1882 ePageKind = PK_NOTES; 1883 } 1884 } 1885 1886 if( xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) ) ) 1887 { 1888 VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice ); 1889 OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL; 1890 1891 if( pOut ) 1892 { 1893 vcl::PDFExtOutDevData* pPDFExtOutDevData = PTR_CAST( vcl::PDFExtOutDevData, pOut->GetExtOutDevData() ); 1894 1895 ::sd::ClientView* pView = new ::sd::ClientView( mpDocShell, pOut, NULL ); 1896 Rectangle aVisArea = Rectangle( Point(), mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind )->GetSize() ); 1897 Region aRegion( aVisArea ); 1898 Point aOrigin; 1899 1900 ::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell(); 1901 ::sd::View* pOldSdView = pOldViewSh ? pOldViewSh->GetView() : NULL; 1902 1903 if ( pOldSdView ) 1904 pOldSdView->SdrEndTextEdit(); 1905 1906 pView->SetHlplVisible( sal_False ); 1907 pView->SetGridVisible( sal_False ); 1908 pView->SetBordVisible( sal_False ); 1909 pView->SetPageVisible( sal_False ); 1910 pView->SetGlueVisible( sal_False ); 1911 1912 pOut->SetMapMode( MAP_100TH_MM ); 1913 pOut->IntersectClipRegion( aVisArea ); 1914 1915 1916 1917 uno::Reference< frame::XModel > xModel; 1918 rSelection >>= xModel; 1919 1920 if( xModel == mpDocShell->GetModel() ) 1921 { 1922 pView->ShowSdrPage( mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind )); 1923 SdrPageView* pPV = pView->GetSdrPageView(); 1924 1925 if( pOldSdView ) 1926 { 1927 SdrPageView* pOldPV = pOldSdView->GetSdrPageView(); 1928 if( pPV && pOldPV ) 1929 { 1930 pPV->SetVisibleLayers( pOldPV->GetVisibleLayers() ); 1931 pPV->SetPrintableLayers( pOldPV->GetPrintableLayers() ); 1932 } 1933 } 1934 1935 ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(), 1936 pPV, pPDFExtOutDevData ); 1937 1938 // background color for outliner :o 1939 SdPage* pPage = (SdPage*)pPV->GetPage(); 1940 if( pPage ) 1941 { 1942 SdrOutliner& rOutl = mpDoc->GetDrawOutliner( NULL ); 1943 bool bScreenDisplay(true); 1944 1945 if(bScreenDisplay && pOut && OUTDEV_PRINTER == pOut->GetOutDevType()) 1946 { 1947 // #i75566# printing; suppress AutoColor BackgroundColor generation 1948 // for visibility reasons by giving GetPageBackgroundColor() 1949 // the needed hint 1950 bScreenDisplay = false; 1951 } 1952 1953 if(bScreenDisplay && pOut && pOut->GetPDFWriter()) 1954 { 1955 // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above) 1956 bScreenDisplay = false; 1957 } 1958 1959 // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and 1960 // hint value if screen display. Only then the AutoColor mechanisms shall be applied 1961 rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor( pPV, bScreenDisplay ) ); 1962 } 1963 pView->SdrPaintView::CompleteRedraw( pOut, aRegion, &aImplRenderPaintProc ); 1964 1965 if ( pPDFExtOutDevData ) 1966 { 1967 try 1968 { 1969 uno::Any aAny; 1970 uno::Reference< drawing::XDrawPage > xPage( uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ) ); 1971 if ( xPage.is() ) 1972 { 1973 if ( pPDFExtOutDevData->GetIsExportNotes() ) 1974 ImplPDFExportComments( xPage, *pPDFExtOutDevData ); 1975 uno::Reference< beans::XPropertySet > xPagePropSet( xPage, uno::UNO_QUERY ); 1976 if( xPagePropSet.is() ) 1977 { 1978 // exporting object interactions to pdf 1979 1980 // if necessary, the master page interactions will be exported first 1981 sal_Bool bIsBackgroundObjectsVisible = sal_False; // SJ: #i39428# IsBackgroundObjectsVisible not available for Draw 1982 const rtl::OUString sIsBackgroundObjectsVisible( RTL_CONSTASCII_USTRINGPARAM( "IsBackgroundObjectsVisible" ) ); 1983 if ( mbImpressDoc && ( xPagePropSet->getPropertyValue( sIsBackgroundObjectsVisible ) >>= bIsBackgroundObjectsVisible ) && bIsBackgroundObjectsVisible ) 1984 { 1985 uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( xPage, uno::UNO_QUERY ); 1986 if ( xMasterPageTarget.is() ) 1987 { 1988 uno::Reference< drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage(); 1989 if ( xMasterPage.is() ) 1990 { 1991 uno::Reference< drawing::XShapes> xShapes( xMasterPage, uno::UNO_QUERY ); 1992 sal_Int32 i, nCount = xShapes->getCount(); 1993 for ( i = 0; i < nCount; i++ ) 1994 { 1995 aAny = xShapes->getByIndex( i ); 1996 uno::Reference< drawing::XShape > xShape; 1997 if ( aAny >>= xShape ) 1998 ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData ); 1999 } 2000 } 2001 } 2002 } 2003 2004 // exporting slide page object interactions 2005 uno::Reference< drawing::XShapes> xShapes( xPage, uno::UNO_QUERY ); 2006 sal_Int32 i, nCount = xShapes->getCount(); 2007 for ( i = 0; i < nCount; i++ ) 2008 { 2009 aAny = xShapes->getByIndex( i ); 2010 uno::Reference< drawing::XShape > xShape; 2011 if ( aAny >>= xShape ) 2012 ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData ); 2013 } 2014 2015 // exporting transition effects to pdf 2016 if ( mbImpressDoc && pPDFExtOutDevData->GetIsExportTransitionEffects() ) // SJ: #i39428# TransitionEffects not available for Draw 2017 { 2018 const rtl::OUString sEffect( RTL_CONSTASCII_USTRINGPARAM( "Effect" ) ); 2019 const rtl::OUString sSpeed ( RTL_CONSTASCII_USTRINGPARAM( "Speed" ) ); 2020 sal_Int32 nTime = 800; 2021 presentation::AnimationSpeed aAs; 2022 aAny = xPagePropSet->getPropertyValue( sSpeed ); 2023 if ( aAny >>= aAs ) 2024 { 2025 switch( aAs ) 2026 { 2027 case presentation::AnimationSpeed_SLOW : nTime = 1500; break; 2028 case presentation::AnimationSpeed_FAST : nTime = 300; break; 2029 default: 2030 case presentation::AnimationSpeed_MEDIUM : nTime = 800; 2031 } 2032 } 2033 presentation::FadeEffect eFe; 2034 aAny = xPagePropSet->getPropertyValue( sEffect ); 2035 vcl::PDFWriter::PageTransition eType = vcl::PDFWriter::Regular; 2036 if ( aAny >>= eFe ) 2037 { 2038 switch( eFe ) 2039 { 2040 case presentation::FadeEffect_HORIZONTAL_LINES : 2041 case presentation::FadeEffect_HORIZONTAL_CHECKERBOARD : 2042 case presentation::FadeEffect_HORIZONTAL_STRIPES : eType = vcl::PDFWriter::BlindsHorizontal; break; 2043 2044 case presentation::FadeEffect_VERTICAL_LINES : 2045 case presentation::FadeEffect_VERTICAL_CHECKERBOARD : 2046 case presentation::FadeEffect_VERTICAL_STRIPES : eType = vcl::PDFWriter::BlindsVertical; break; 2047 2048 case presentation::FadeEffect_UNCOVER_TO_RIGHT : 2049 case presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT : 2050 case presentation::FadeEffect_ROLL_FROM_LEFT : 2051 case presentation::FadeEffect_FADE_FROM_UPPERLEFT : 2052 case presentation::FadeEffect_MOVE_FROM_UPPERLEFT : 2053 case presentation::FadeEffect_FADE_FROM_LEFT : 2054 case presentation::FadeEffect_MOVE_FROM_LEFT : eType = vcl::PDFWriter::WipeLeftToRight; break; 2055 2056 case presentation::FadeEffect_UNCOVER_TO_BOTTOM : 2057 case presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT : 2058 case presentation::FadeEffect_ROLL_FROM_TOP : 2059 case presentation::FadeEffect_FADE_FROM_UPPERRIGHT : 2060 case presentation::FadeEffect_MOVE_FROM_UPPERRIGHT : 2061 case presentation::FadeEffect_FADE_FROM_TOP : 2062 case presentation::FadeEffect_MOVE_FROM_TOP : eType = vcl::PDFWriter::WipeTopToBottom; break; 2063 2064 case presentation::FadeEffect_UNCOVER_TO_LEFT : 2065 case presentation::FadeEffect_UNCOVER_TO_LOWERLEFT : 2066 case presentation::FadeEffect_ROLL_FROM_RIGHT : 2067 2068 case presentation::FadeEffect_FADE_FROM_LOWERRIGHT : 2069 case presentation::FadeEffect_MOVE_FROM_LOWERRIGHT : 2070 case presentation::FadeEffect_FADE_FROM_RIGHT : 2071 case presentation::FadeEffect_MOVE_FROM_RIGHT : eType = vcl::PDFWriter::WipeRightToLeft; break; 2072 2073 case presentation::FadeEffect_UNCOVER_TO_TOP : 2074 case presentation::FadeEffect_UNCOVER_TO_UPPERLEFT : 2075 case presentation::FadeEffect_ROLL_FROM_BOTTOM : 2076 case presentation::FadeEffect_FADE_FROM_LOWERLEFT : 2077 case presentation::FadeEffect_MOVE_FROM_LOWERLEFT : 2078 case presentation::FadeEffect_FADE_FROM_BOTTOM : 2079 case presentation::FadeEffect_MOVE_FROM_BOTTOM : eType = vcl::PDFWriter::WipeBottomToTop; break; 2080 2081 case presentation::FadeEffect_OPEN_VERTICAL : eType = vcl::PDFWriter::SplitHorizontalInward; break; 2082 case presentation::FadeEffect_CLOSE_HORIZONTAL : eType = vcl::PDFWriter::SplitHorizontalOutward; break; 2083 2084 case presentation::FadeEffect_OPEN_HORIZONTAL : eType = vcl::PDFWriter::SplitVerticalInward; break; 2085 case presentation::FadeEffect_CLOSE_VERTICAL : eType = vcl::PDFWriter::SplitVerticalOutward; break; 2086 2087 case presentation::FadeEffect_FADE_TO_CENTER : eType = vcl::PDFWriter::BoxInward; break; 2088 case presentation::FadeEffect_FADE_FROM_CENTER : eType = vcl::PDFWriter::BoxOutward; break; 2089 2090 case presentation::FadeEffect_NONE : eType = vcl::PDFWriter::Regular; break; 2091 2092 case presentation::FadeEffect_RANDOM : 2093 case presentation::FadeEffect_DISSOLVE : 2094 default: eType = vcl::PDFWriter::Dissolve; break; 2095 } 2096 } 2097 pPDFExtOutDevData->SetPageTransition( eType, nTime, -1 ); 2098 } 2099 } 2100 } 2101 2102 Size aPageSize( mpDoc->GetSdPage( 0, PK_STANDARD )->GetSize() ); 2103 Point aPoint( 0, 0 ); 2104 Rectangle aPageRect( aPoint, aPageSize ); 2105 2106 // resolving links found in this page by the method ImpEditEngine::Paint 2107 std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks(); 2108 std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIBeg = rBookmarks.begin(); 2109 std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end(); 2110 while ( aIBeg != aIEnd ) 2111 { 2112 sal_Int32 nPage = ImplPDFGetBookmarkPage( aIBeg->aBookmark, *mpDoc ); 2113 if ( nPage != -1 ) 2114 { 2115 if ( aIBeg->nLinkId != -1 ) 2116 pPDFExtOutDevData->SetLinkDest( aIBeg->nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle ) ); 2117 else 2118 pPDFExtOutDevData->DescribeRegisteredDest( aIBeg->nDestId, aPageRect, nPage, vcl::PDFWriter::FitRectangle ); 2119 } 2120 else 2121 pPDFExtOutDevData->SetLinkURL( aIBeg->nLinkId, aIBeg->aBookmark ); 2122 aIBeg++; 2123 } 2124 rBookmarks.clear(); 2125 //---> i56629, i40318 2126 //get the page name, will be used as outline element in PDF bookmark pane 2127 String aPageName = mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1 , PK_STANDARD )->GetName(); 2128 if( aPageName.Len() > 0 ) 2129 { 2130 // insert the bookmark to this page into the NamedDestinations 2131 if( pPDFExtOutDevData->GetIsExportNamedDestinations() ) 2132 pPDFExtOutDevData->CreateNamedDest( aPageName, aPageRect, nPageNumber - 1 ); 2133 // 2134 // add the name to the outline, (almost) same code as in sc/source/ui/unoobj/docuno.cxx 2135 // issue i40318. 2136 // 2137 if( pPDFExtOutDevData->GetIsExportBookmarks() ) 2138 { 2139 // Destination Export 2140 const sal_Int32 nDestId = 2141 pPDFExtOutDevData->CreateDest( aPageRect , nPageNumber - 1 ); 2142 2143 // Create a new outline item: 2144 pPDFExtOutDevData->CreateOutlineItem( -1 , aPageName, nDestId ); 2145 } 2146 } 2147 //<--- i56629, i40318 2148 } 2149 catch( uno::Exception& ) 2150 { 2151 } 2152 2153 } 2154 } 2155 else 2156 { 2157 uno::Reference< drawing::XShapes > xShapes; 2158 rSelection >>= xShapes; 2159 2160 if( xShapes.is() && xShapes->getCount() ) 2161 { 2162 SdrPageView* pPV = NULL; 2163 2164 ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(), 2165 pOldSdView ? pOldSdView->GetSdrPageView() : NULL, pPDFExtOutDevData ); 2166 2167 for( sal_uInt32 i = 0, nCount = xShapes->getCount(); i < nCount; i++ ) 2168 { 2169 uno::Reference< drawing::XShape > xShape; 2170 xShapes->getByIndex( i ) >>= xShape; 2171 2172 if( xShape.is() ) 2173 { 2174 SvxShape* pShape = SvxShape::getImplementation( xShape ); 2175 2176 if( pShape ) 2177 { 2178 SdrObject* pObj = pShape->GetSdrObject(); 2179 if( pObj && pObj->GetPage() 2180 && aImplRenderPaintProc.IsVisible( pObj ) 2181 && aImplRenderPaintProc.IsPrintable( pObj ) ) 2182 { 2183 if( !pPV ) 2184 pPV = pView->ShowSdrPage( pObj->GetPage() ); 2185 2186 if( pPV ) 2187 pView->MarkObj( pObj, pPV ); 2188 } 2189 } 2190 } 2191 } 2192 pView->DrawMarkedObj(*pOut); 2193 } 2194 } 2195 2196 delete pView; 2197 } 2198 } 2199 } 2200 } 2201 2202 uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable() 2203 { 2204 uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters); 2205 2206 if( !xForb.is() ) 2207 mxForbidenCharacters = xForb = new SdUnoForbiddenCharsTable( mpDoc ); 2208 2209 return xForb; 2210 } 2211 2212 void SdXImpressDocument::initializeDocument() 2213 { 2214 if( !mbClipBoard ) 2215 { 2216 switch( mpDoc->GetPageCount() ) 2217 { 2218 case 1: 2219 { 2220 // nasty hack to detect clipboard document 2221 mbClipBoard = true; 2222 break; 2223 } 2224 case 0: 2225 { 2226 mpDoc->CreateFirstPages(); 2227 mpDoc->StopWorkStartupDelay(); 2228 break; 2229 } 2230 } 2231 } 2232 } 2233 2234 void SAL_CALL SdXImpressDocument::dispose() throw (::com::sun::star::uno::RuntimeException) 2235 { 2236 if( !mbDisposed ) 2237 { 2238 { 2239 OGuard aGuard( Application::GetSolarMutex() ); 2240 2241 if( mpDoc ) 2242 { 2243 EndListening( *mpDoc ); 2244 mpDoc = NULL; 2245 } 2246 2247 // Call the base class dispose() before setting the mbDisposed flag 2248 // to true. The reason for this is that if close() has not yet been 2249 // called this is done in SfxBaseModel::dispose(). At the end of 2250 // that dispose() is called again. It is important to forward this 2251 // second dispose() to the base class, too. 2252 // As a consequence the following code has to be able to be run twice. 2253 SfxBaseModel::dispose(); 2254 mbDisposed = true; 2255 2256 uno::Reference< container::XNameAccess > xStyles(mxStyleFamilies); 2257 if( xStyles.is() ) 2258 { 2259 uno::Reference< lang::XComponent > xComp( xStyles, uno::UNO_QUERY ); 2260 if( xComp.is() ) 2261 xComp->dispose(); 2262 2263 xStyles = 0; 2264 } 2265 2266 uno::Reference< presentation::XPresentation > xPresentation( mxPresentation ); 2267 if( xPresentation.is() ) 2268 { 2269 uno::Reference< ::com::sun::star::presentation::XPresentation2 > xPres( mpDoc->getPresentation().get() ); 2270 uno::Reference< lang::XComponent > xPresComp( xPres, uno::UNO_QUERY ); 2271 if( xPresComp.is() ) 2272 xPresComp->dispose(); 2273 } 2274 2275 uno::Reference< container::XNameAccess > xLinks( mxLinks ); 2276 if( xLinks.is() ) 2277 { 2278 uno::Reference< lang::XComponent > xComp( xLinks, uno::UNO_QUERY ); 2279 if( xComp.is() ) 2280 xComp->dispose(); 2281 2282 xLinks = 0; 2283 } 2284 2285 uno::Reference< drawing::XDrawPages > xDrawPagesAccess( mxDrawPagesAccess ); 2286 if( xDrawPagesAccess.is() ) 2287 { 2288 uno::Reference< lang::XComponent > xComp( xDrawPagesAccess, uno::UNO_QUERY ); 2289 if( xComp.is() ) 2290 xComp->dispose(); 2291 2292 xDrawPagesAccess = 0; 2293 } 2294 2295 uno::Reference< drawing::XDrawPages > xMasterPagesAccess( mxMasterPagesAccess ); 2296 if( xDrawPagesAccess.is() ) 2297 { 2298 uno::Reference< lang::XComponent > xComp( xMasterPagesAccess, uno::UNO_QUERY ); 2299 if( xComp.is() ) 2300 xComp->dispose(); 2301 2302 xDrawPagesAccess = 0; 2303 } 2304 2305 uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager ); 2306 if( xLayerManager.is() ) 2307 { 2308 uno::Reference< lang::XComponent > xComp( xLayerManager, uno::UNO_QUERY ); 2309 if( xComp.is() ) 2310 xComp->dispose(); 2311 2312 xLayerManager = 0; 2313 } 2314 2315 uno::Reference< container::XNameContainer > xCustomPresentationAccess( mxCustomPresentationAccess ); 2316 if( xCustomPresentationAccess.is() ) 2317 { 2318 uno::Reference< lang::XComponent > xComp( xCustomPresentationAccess, uno::UNO_QUERY ); 2319 if( xComp.is() ) 2320 xComp->dispose(); 2321 2322 xCustomPresentationAccess = 0; 2323 } 2324 2325 mxDashTable = 0; 2326 mxGradientTable = 0; 2327 mxHatchTable = 0; 2328 mxBitmapTable = 0; 2329 mxTransGradientTable = 0; 2330 mxMarkerTable = 0; 2331 mxDrawingPool = 0; 2332 } 2333 } 2334 } 2335 2336 //============================================================================= 2337 // class SdDrawPagesAccess 2338 //============================================================================= 2339 2340 SdDrawPagesAccess::SdDrawPagesAccess( SdXImpressDocument& rMyModel ) throw() 2341 : mpModel( &rMyModel) 2342 { 2343 } 2344 2345 SdDrawPagesAccess::~SdDrawPagesAccess() throw() 2346 { 2347 } 2348 2349 // XIndexAccess 2350 sal_Int32 SAL_CALL SdDrawPagesAccess::getCount() 2351 throw(uno::RuntimeException) 2352 { 2353 OGuard aGuard( Application::GetSolarMutex() ); 2354 2355 if( NULL == mpModel ) 2356 throw lang::DisposedException(); 2357 2358 return mpModel->mpDoc->GetSdPageCount( PK_STANDARD ); 2359 } 2360 2361 uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index ) 2362 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 2363 { 2364 OGuard aGuard( Application::GetSolarMutex() ); 2365 2366 if( NULL == mpModel ) 2367 throw lang::DisposedException(); 2368 2369 uno::Any aAny; 2370 2371 if( (Index < 0) || (Index >= mpModel->mpDoc->GetSdPageCount( PK_STANDARD ) ) ) 2372 throw lang::IndexOutOfBoundsException(); 2373 2374 SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)Index, PK_STANDARD ); 2375 if( pPage ) 2376 { 2377 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); 2378 aAny <<= xDrawPage; 2379 } 2380 2381 return aAny; 2382 } 2383 2384 // XNameAccess 2385 uno::Any SAL_CALL SdDrawPagesAccess::getByName( const OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 2386 { 2387 OGuard aGuard( Application::GetSolarMutex() ); 2388 2389 if( NULL == mpModel ) 2390 throw lang::DisposedException(); 2391 2392 if( aName.getLength() != 0 ) 2393 { 2394 const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD ); 2395 sal_uInt16 nPage; 2396 for( nPage = 0; nPage < nCount; nPage++ ) 2397 { 2398 SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD ); 2399 if(NULL == pPage) 2400 continue; 2401 2402 if( aName == SdDrawPage::getPageApiName( pPage ) ) 2403 { 2404 uno::Any aAny; 2405 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); 2406 aAny <<= xDrawPage; 2407 return aAny; 2408 } 2409 } 2410 } 2411 2412 throw container::NoSuchElementException(); 2413 } 2414 2415 uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getElementNames() throw(uno::RuntimeException) 2416 { 2417 OGuard aGuard( Application::GetSolarMutex() ); 2418 2419 if( NULL == mpModel ) 2420 throw lang::DisposedException(); 2421 2422 const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD ); 2423 uno::Sequence< OUString > aNames( nCount ); 2424 OUString* pNames = aNames.getArray(); 2425 2426 sal_uInt16 nPage; 2427 for( nPage = 0; nPage < nCount; nPage++ ) 2428 { 2429 SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD ); 2430 *pNames++ = SdDrawPage::getPageApiName( pPage ); 2431 } 2432 2433 return aNames; 2434 } 2435 2436 sal_Bool SAL_CALL SdDrawPagesAccess::hasByName( const OUString& aName ) throw(uno::RuntimeException) 2437 { 2438 OGuard aGuard( Application::GetSolarMutex() ); 2439 2440 if( NULL == mpModel ) 2441 throw lang::DisposedException(); 2442 2443 const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD ); 2444 sal_uInt16 nPage; 2445 for( nPage = 0; nPage < nCount; nPage++ ) 2446 { 2447 SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD ); 2448 if(NULL == pPage) 2449 continue; 2450 2451 if( aName == SdDrawPage::getPageApiName( pPage ) ) 2452 return sal_True; 2453 } 2454 2455 return sal_False; 2456 } 2457 2458 // XElementAccess 2459 uno::Type SAL_CALL SdDrawPagesAccess::getElementType() 2460 throw(uno::RuntimeException) 2461 { 2462 return ITYPE( drawing::XDrawPage ); 2463 } 2464 2465 sal_Bool SAL_CALL SdDrawPagesAccess::hasElements() 2466 throw(uno::RuntimeException) 2467 { 2468 return getCount() > 0; 2469 } 2470 2471 // XDrawPages 2472 2473 /****************************************************************************** 2474 * Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die * 2475 * dazugehoerige SdDrawPage zurueck. * 2476 ******************************************************************************/ 2477 uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex ) 2478 throw(uno::RuntimeException) 2479 { 2480 OGuard aGuard( Application::GetSolarMutex() ); 2481 2482 if( NULL == mpModel ) 2483 throw lang::DisposedException(); 2484 2485 if( mpModel->mpDoc ) 2486 { 2487 SdPage* pPage = mpModel->InsertSdPage( (sal_uInt16)nIndex ); 2488 if( pPage ) 2489 { 2490 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); 2491 return xDrawPage; 2492 } 2493 } 2494 uno::Reference< drawing::XDrawPage > xDrawPage; 2495 return xDrawPage; 2496 } 2497 2498 /****************************************************************************** 2499 * Entfernt die angegebenne SdDrawPage aus dem Model und aus der internen * 2500 * Liste. Dies funktioniert nur, wenn mindestens eine *normale* Seite im Model * 2501 * nach dem entfernen dieser Seite vorhanden ist. * 2502 ******************************************************************************/ 2503 void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage ) 2504 throw(uno::RuntimeException) 2505 { 2506 OGuard aGuard( Application::GetSolarMutex() ); 2507 2508 if( NULL == mpModel || mpModel->mpDoc == NULL ) 2509 throw lang::DisposedException(); 2510 2511 SdDrawDocument& rDoc = *mpModel->mpDoc; 2512 2513 sal_uInt16 nPageCount = rDoc.GetSdPageCount( PK_STANDARD ); 2514 if( nPageCount > 1 ) 2515 { 2516 // pPage von xPage besorgen und dann die Id (nPos )ermitteln 2517 SdDrawPage* pSvxPage = SdDrawPage::getImplementation( xPage ); 2518 if( pSvxPage ) 2519 { 2520 SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage(); 2521 if(pPage && ( pPage->GetPageKind() == PK_STANDARD ) ) 2522 { 2523 sal_uInt16 nPage = pPage->GetPageNum(); 2524 2525 SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetPage( nPage+1 ) ); 2526 2527 bool bUndo = rDoc.IsUndoEnabled(); 2528 if( bUndo ) 2529 { 2530 // Add undo actions and delete the pages. The order of adding 2531 // the undo actions is important. 2532 rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) ); 2533 rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage)); 2534 rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage)); 2535 } 2536 2537 rDoc.RemovePage( nPage ); // the page 2538 rDoc.RemovePage( nPage ); // the notes page 2539 2540 if( bUndo ) 2541 { 2542 rDoc.EndUndo(); 2543 } 2544 else 2545 { 2546 delete pNotesPage; 2547 delete pPage; 2548 } 2549 } 2550 } 2551 } 2552 2553 mpModel->SetModified(); 2554 } 2555 2556 // XServiceInfo 2557 sal_Char pSdDrawPagesAccessService[sizeof("com.sun.star.drawing.DrawPages")] = "com.sun.star.drawing.DrawPages"; 2558 2559 OUString SAL_CALL SdDrawPagesAccess::getImplementationName( ) throw(uno::RuntimeException) 2560 { 2561 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdDrawPagesAccess" ) ); 2562 } 2563 2564 sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) 2565 { 2566 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSdDrawPagesAccessService ) ); 2567 } 2568 2569 uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException) 2570 { 2571 OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSdDrawPagesAccessService ) ); 2572 uno::Sequence< OUString > aSeq( &aService, 1 ); 2573 return aSeq; 2574 } 2575 2576 // XComponent 2577 void SAL_CALL SdDrawPagesAccess::dispose( ) throw (uno::RuntimeException) 2578 { 2579 mpModel = NULL; 2580 } 2581 2582 void SAL_CALL SdDrawPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 2583 { 2584 DBG_ERROR( "not implemented!" ); 2585 } 2586 2587 void SAL_CALL SdDrawPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 2588 { 2589 DBG_ERROR( "not implemented!" ); 2590 } 2591 2592 //============================================================================= 2593 // class SdMasterPagesAccess 2594 //============================================================================= 2595 2596 SdMasterPagesAccess::SdMasterPagesAccess( SdXImpressDocument& rMyModel ) throw() 2597 : mpModel(&rMyModel) 2598 { 2599 } 2600 2601 SdMasterPagesAccess::~SdMasterPagesAccess() throw() 2602 { 2603 } 2604 2605 // XComponent 2606 void SAL_CALL SdMasterPagesAccess::dispose( ) throw (uno::RuntimeException) 2607 { 2608 mpModel = NULL; 2609 } 2610 2611 void SAL_CALL SdMasterPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 2612 { 2613 DBG_ERROR( "not implemented!" ); 2614 } 2615 2616 void SAL_CALL SdMasterPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 2617 { 2618 DBG_ERROR( "not implemented!" ); 2619 } 2620 2621 // XIndexAccess 2622 sal_Int32 SAL_CALL SdMasterPagesAccess::getCount() 2623 throw(uno::RuntimeException) 2624 { 2625 OGuard aGuard( Application::GetSolarMutex() ); 2626 2627 if( NULL == mpModel->mpDoc ) 2628 throw lang::DisposedException(); 2629 2630 return mpModel->mpDoc->GetMasterSdPageCount(PK_STANDARD); 2631 } 2632 2633 /****************************************************************************** 2634 * Liefert ein drawing::XDrawPage Interface fuer den Zugriff auf die Masterpage and der * 2635 * angegebennen Position im Model. * 2636 ******************************************************************************/ 2637 uno::Any SAL_CALL SdMasterPagesAccess::getByIndex( sal_Int32 Index ) 2638 throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 2639 { 2640 OGuard aGuard( Application::GetSolarMutex() ); 2641 2642 if( NULL == mpModel ) 2643 throw lang::DisposedException(); 2644 2645 uno::Any aAny; 2646 2647 if( (Index < 0) || (Index >= mpModel->mpDoc->GetMasterSdPageCount( PK_STANDARD ) ) ) 2648 throw lang::IndexOutOfBoundsException(); 2649 2650 SdPage* pPage = mpModel->mpDoc->GetMasterSdPage( (sal_uInt16)Index, PK_STANDARD ); 2651 if( pPage ) 2652 { 2653 uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY ); 2654 aAny <<= xDrawPage; 2655 } 2656 2657 return aAny; 2658 } 2659 2660 // XElementAccess 2661 uno::Type SAL_CALL SdMasterPagesAccess::getElementType() 2662 throw(uno::RuntimeException) 2663 { 2664 return ITYPE(drawing::XDrawPage); 2665 } 2666 2667 sal_Bool SAL_CALL SdMasterPagesAccess::hasElements() 2668 throw(uno::RuntimeException) 2669 { 2670 return getCount() > 0; 2671 } 2672 2673 // XDrawPages 2674 uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIndex( sal_Int32 nInsertPos ) 2675 throw(uno::RuntimeException) 2676 { 2677 OGuard aGuard( Application::GetSolarMutex() ); 2678 2679 if( NULL == mpModel ) 2680 throw lang::DisposedException(); 2681 2682 uno::Reference< drawing::XDrawPage > xDrawPage; 2683 2684 SdDrawDocument* mpDoc = mpModel->mpDoc; 2685 if( mpDoc ) 2686 { 2687 // calculate internal index and check for range errors 2688 const sal_Int32 nMPageCount = mpDoc->GetMasterPageCount(); 2689 nInsertPos = nInsertPos * 2 + 1; 2690 if( nInsertPos < 0 || nInsertPos > nMPageCount ) 2691 nInsertPos = nMPageCount; 2692 2693 // now generate a unique name for the new masterpage 2694 const String aStdPrefix( SdResId(STR_LAYOUT_DEFAULT_NAME) ); 2695 String aPrefix( aStdPrefix ); 2696 2697 sal_Bool bUnique = sal_True; 2698 sal_Int32 i = 0; 2699 do 2700 { 2701 bUnique = sal_True; 2702 for( sal_Int32 nMaster = 1; nMaster < nMPageCount; nMaster++ ) 2703 { 2704 SdPage* pPage = (SdPage*)mpDoc->GetMasterPage((sal_uInt16)nMaster); 2705 if( pPage && pPage->GetName() == aPrefix ) 2706 { 2707 bUnique = sal_False; 2708 break; 2709 } 2710 } 2711 2712 if( !bUnique ) 2713 { 2714 i++; 2715 aPrefix = aStdPrefix; 2716 aPrefix += sal_Unicode( ' ' ); 2717 aPrefix += String::CreateFromInt32( i ); 2718 } 2719 2720 } while( !bUnique ); 2721 2722 String aLayoutName( aPrefix ); 2723 aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR )); 2724 aLayoutName += String(SdResId(STR_LAYOUT_OUTLINE)); 2725 2726 // create styles 2727 ((SdStyleSheetPool*)mpDoc->GetStyleSheetPool())->CreateLayoutStyleSheets( aPrefix ); 2728 2729 // get the first page for initial size and border settings 2730 SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_STANDARD ); 2731 SdPage* pRefNotesPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_NOTES); 2732 2733 // create and instert new draw masterpage 2734 SdPage* pMPage = (SdPage*)mpModel->mpDoc->AllocPage(sal_True); 2735 pMPage->SetSize( pPage->GetSize() ); 2736 pMPage->SetBorder( pPage->GetLftBorder(), 2737 pPage->GetUppBorder(), 2738 pPage->GetRgtBorder(), 2739 pPage->GetLwrBorder() ); 2740 pMPage->SetLayoutName( aLayoutName ); 2741 mpDoc->InsertMasterPage(pMPage, (sal_uInt16)nInsertPos); 2742 2743 { 2744 // ensure default MasterPage fill 2745 pMPage->EnsureMasterPageDefaultBackground(); 2746 } 2747 2748 xDrawPage = uno::Reference< drawing::XDrawPage >::query( pMPage->getUnoPage() ); 2749 2750 // create and instert new notes masterpage 2751 SdPage* pMNotesPage = (SdPage*)mpModel->mpDoc->AllocPage(sal_True); 2752 pMNotesPage->SetSize( pRefNotesPage->GetSize() ); 2753 pMNotesPage->SetPageKind(PK_NOTES); 2754 pMNotesPage->SetBorder( pRefNotesPage->GetLftBorder(), 2755 pRefNotesPage->GetUppBorder(), 2756 pRefNotesPage->GetRgtBorder(), 2757 pRefNotesPage->GetLwrBorder() ); 2758 pMNotesPage->SetLayoutName( aLayoutName ); 2759 mpDoc->InsertMasterPage(pMNotesPage, (sal_uInt16)nInsertPos + 1); 2760 // pMNotesPage->InsertMasterPage( pMPage->GetPageNum() ); 2761 pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True, sal_True); 2762 mpModel->SetModified(); 2763 } 2764 2765 return( xDrawPage ); 2766 } 2767 2768 /****************************************************************************** 2769 * Entfernt die angegebenne SdMasterPage aus dem Model und aus der internen * 2770 * Liste. Dies funktioniert nur, wenn keine *normale* Seite im Model diese * 2771 * Seite als Masterpage benutzt. * 2772 ******************************************************************************/ 2773 void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage ) 2774 throw(uno::RuntimeException) 2775 { 2776 OGuard aGuard( Application::GetSolarMutex() ); 2777 2778 if( NULL == mpModel || mpModel->mpDoc == NULL ) 2779 throw lang::DisposedException(); 2780 2781 SdDrawDocument& rDoc = *mpModel->mpDoc; 2782 2783 SdMasterPage* pSdPage = SdMasterPage::getImplementation( xPage ); 2784 if(pSdPage == NULL) 2785 return; 2786 2787 SdPage* pPage = dynamic_cast< SdPage* > (pSdPage->GetSdrPage()); 2788 2789 DBG_ASSERT( pPage && pPage->IsMasterPage(), "SdMasterPage is not masterpage?"); 2790 2791 if( !pPage || !pPage->IsMasterPage() || (mpModel->mpDoc->GetMasterPageUserCount(pPage) > 0)) 2792 return; //Todo: this should be excepted 2793 2794 // only standard pages can be removed directly 2795 if( pPage->GetPageKind() == PK_STANDARD ) 2796 { 2797 sal_uInt16 nPage = pPage->GetPageNum(); 2798 2799 SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetMasterPage( nPage+1 ) ); 2800 2801 bool bUndo = rDoc.IsUndoEnabled(); 2802 if( bUndo ) 2803 { 2804 // Add undo actions and delete the pages. The order of adding 2805 // the undo actions is important. 2806 rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) ); 2807 rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage)); 2808 rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage)); 2809 } 2810 2811 rDoc.RemoveMasterPage( nPage ); 2812 rDoc.RemoveMasterPage( nPage ); 2813 2814 if( bUndo ) 2815 { 2816 rDoc.EndUndo(); 2817 } 2818 else 2819 { 2820 delete pNotesPage; 2821 delete pPage; 2822 } 2823 } 2824 } 2825 2826 // XServiceInfo 2827 sal_Char pSdMasterPagesAccessService[sizeof("com.sun.star.drawing.MasterPages")] = "com.sun.star.drawing.MasterPages"; 2828 2829 OUString SAL_CALL SdMasterPagesAccess::getImplementationName( ) throw(uno::RuntimeException) 2830 { 2831 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SdMasterPagesAccess" ) ); 2832 } 2833 2834 sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) 2835 { 2836 return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSdMasterPagesAccessService ) ); 2837 } 2838 2839 uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException) 2840 { 2841 OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSdMasterPagesAccessService ) ); 2842 uno::Sequence< OUString > aSeq( &aService, 1 ); 2843 return aSeq; 2844 } 2845 2846 //============================================================================= 2847 // class SdDocLinkTargets 2848 //============================================================================= 2849 2850 SdDocLinkTargets::SdDocLinkTargets( SdXImpressDocument& rMyModel ) throw() 2851 : mpModel( &rMyModel ) 2852 { 2853 } 2854 2855 SdDocLinkTargets::~SdDocLinkTargets() throw() 2856 { 2857 } 2858 2859 // XComponent 2860 void SAL_CALL SdDocLinkTargets::dispose( ) throw (uno::RuntimeException) 2861 { 2862 mpModel = NULL; 2863 } 2864 2865 void SAL_CALL SdDocLinkTargets::addEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 2866 { 2867 DBG_ERROR( "not implemented!" ); 2868 } 2869 2870 void SAL_CALL SdDocLinkTargets::removeEventListener( const uno::Reference< lang::XEventListener >& ) throw (uno::RuntimeException) 2871 { 2872 DBG_ERROR( "not implemented!" ); 2873 } 2874 2875 // XNameAccess 2876 uno::Any SAL_CALL SdDocLinkTargets::getByName( const OUString& aName ) 2877 throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 2878 { 2879 OGuard aGuard( Application::GetSolarMutex() ); 2880 2881 if( NULL == mpModel ) 2882 throw lang::DisposedException(); 2883 2884 SdPage* pPage = FindPage( aName ); 2885 2886 if( pPage == NULL ) 2887 throw container::NoSuchElementException(); 2888 2889 uno::Any aAny; 2890 2891 uno::Reference< beans::XPropertySet > xProps( pPage->getUnoPage(), uno::UNO_QUERY ); 2892 if( xProps.is() ) 2893 aAny <<= xProps; 2894 2895 return aAny; 2896 } 2897 2898 uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getElementNames() 2899 throw(uno::RuntimeException) 2900 { 2901 OGuard aGuard( Application::GetSolarMutex() ); 2902 2903 if( NULL == mpModel ) 2904 throw lang::DisposedException(); 2905 2906 SdDrawDocument* mpDoc = mpModel->GetDoc(); 2907 if( mpDoc == NULL ) 2908 { 2909 uno::Sequence< OUString > aSeq; 2910 return aSeq; 2911 } 2912 2913 if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW ) 2914 { 2915 const sal_uInt16 nMaxPages = mpDoc->GetSdPageCount( PK_STANDARD ); 2916 const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterSdPageCount( PK_STANDARD ); 2917 2918 uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages ); 2919 OUString* pStr = aSeq.getArray(); 2920 2921 sal_uInt16 nPage; 2922 // standard pages 2923 for( nPage = 0; nPage < nMaxPages; nPage++ ) 2924 *pStr++ = mpDoc->GetSdPage( nPage, PK_STANDARD )->GetName(); 2925 2926 // master pages 2927 for( nPage = 0; nPage < nMaxMasterPages; nPage++ ) 2928 *pStr++ = mpDoc->GetMasterSdPage( nPage, PK_STANDARD )->GetName(); 2929 return aSeq; 2930 } 2931 else 2932 { 2933 const sal_uInt16 nMaxPages = mpDoc->GetPageCount(); 2934 const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount(); 2935 2936 uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages ); 2937 OUString* pStr = aSeq.getArray(); 2938 2939 sal_uInt16 nPage; 2940 // standard pages 2941 for( nPage = 0; nPage < nMaxPages; nPage++ ) 2942 *pStr++ = ((SdPage*)mpDoc->GetPage( nPage ))->GetName(); 2943 2944 // master pages 2945 for( nPage = 0; nPage < nMaxMasterPages; nPage++ ) 2946 *pStr++ = ((SdPage*)mpDoc->GetMasterPage( nPage ))->GetName(); 2947 return aSeq; 2948 } 2949 } 2950 2951 sal_Bool SAL_CALL SdDocLinkTargets::hasByName( const OUString& aName ) 2952 throw(uno::RuntimeException) 2953 { 2954 OGuard aGuard( Application::GetSolarMutex() ); 2955 2956 if( NULL == mpModel ) 2957 throw lang::DisposedException(); 2958 2959 return FindPage( aName ) != NULL; 2960 } 2961 2962 // container::XElementAccess 2963 uno::Type SAL_CALL SdDocLinkTargets::getElementType() 2964 throw(uno::RuntimeException) 2965 { 2966 return ITYPE(beans::XPropertySet); 2967 } 2968 2969 sal_Bool SAL_CALL SdDocLinkTargets::hasElements() 2970 throw(uno::RuntimeException) 2971 { 2972 OGuard aGuard( Application::GetSolarMutex() ); 2973 2974 if( NULL == mpModel ) 2975 throw lang::DisposedException(); 2976 2977 return mpModel->GetDoc() != NULL; 2978 } 2979 2980 SdPage* SdDocLinkTargets::FindPage( const OUString& rName ) const throw() 2981 { 2982 SdDrawDocument* mpDoc = mpModel->GetDoc(); 2983 if( mpDoc == NULL ) 2984 return NULL; 2985 2986 const sal_uInt16 nMaxPages = mpDoc->GetPageCount(); 2987 const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount(); 2988 2989 sal_uInt16 nPage; 2990 SdPage* pPage; 2991 2992 const String aName( rName ); 2993 2994 const bool bDraw = mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW; 2995 2996 // standard pages 2997 for( nPage = 0; nPage < nMaxPages; nPage++ ) 2998 { 2999 pPage = (SdPage*)mpDoc->GetPage( nPage ); 3000 if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) ) 3001 return pPage; 3002 } 3003 3004 // master pages 3005 for( nPage = 0; nPage < nMaxMasterPages; nPage++ ) 3006 { 3007 pPage = (SdPage*)mpDoc->GetMasterPage( nPage ); 3008 if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) ) 3009 return pPage; 3010 } 3011 3012 return NULL; 3013 } 3014 3015 // XServiceInfo 3016 OUString SAL_CALL SdDocLinkTargets::getImplementationName() 3017 throw(uno::RuntimeException) 3018 { 3019 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdDocLinkTargets") ); 3020 } 3021 3022 sal_Bool SAL_CALL SdDocLinkTargets::supportsService( const OUString& ServiceName ) 3023 throw(uno::RuntimeException) 3024 { 3025 return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 3026 } 3027 3028 uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getSupportedServiceNames() 3029 throw(uno::RuntimeException) 3030 { 3031 const OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.LinkTargets") ); 3032 uno::Sequence< OUString > aSeq( &aSN, 1 ); 3033 return aSeq; 3034 } 3035 3036 rtl::Reference< SdXImpressDocument > SdXImpressDocument::GetModel( SdDrawDocument* pDocument ) 3037 { 3038 rtl::Reference< SdXImpressDocument > xRet; 3039 if( pDocument ) 3040 { 3041 ::sd::DrawDocShell* pDocShell = pDocument->GetDocSh(); 3042 if( pDocShell ) 3043 { 3044 uno::Reference<frame::XModel> xModel(pDocShell->GetModel()); 3045 3046 xRet.set( dynamic_cast< SdXImpressDocument* >( xModel.get() ) ); 3047 } 3048 } 3049 3050 return xRet; 3051 } 3052 3053 void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName ) 3054 { 3055 rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) ); 3056 3057 if( xModel.is() ) 3058 { 3059 uno::Reference< uno::XInterface > xSource( static_cast<uno::XWeak*>( xModel.get() ) ); 3060 ::com::sun::star::document::EventObject aEvent( xSource, rEventName ); 3061 xModel->notifyEvent(aEvent ); 3062 } 3063 } 3064 3065 void NotifyDocumentEvent( SdDrawDocument* pDocument, const rtl::OUString& rEventName, const uno::Reference< uno::XInterface >& xSource ) 3066 { 3067 rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) ); 3068 3069 if( xModel.is() ) 3070 { 3071 ::com::sun::star::document::EventObject aEvent( xSource, rEventName ); 3072 xModel->notifyEvent(aEvent ); 3073 } 3074 } 3075