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