1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #define _ANIMATION 32 #include <unotools/streamwrap.hxx> 33 34 #include <sfx2/lnkbase.hxx> 35 #include <math.h> 36 #include <vcl/salbtype.hxx> 37 #include <sot/formats.hxx> 38 #include <sot/storage.hxx> 39 #include <unotools/ucbstreamhelper.hxx> 40 #include <unotools/localfilehelper.hxx> 41 #include <svl/style.hxx> 42 #include <svtools/filter.hxx> 43 #include <svl/urihelper.hxx> 44 #include <svtools/grfmgr.hxx> 45 #include <vcl/svapp.hxx> 46 47 #include <sfx2/linkmgr.hxx> 48 #include <sfx2/docfile.hxx> 49 #include <svx/svdetc.hxx> 50 #include "svx/svdglob.hxx" 51 #include "svx/svdstr.hrc" 52 #include <svx/svdpool.hxx> 53 #include <svx/svdmodel.hxx> 54 #include <svx/svdpage.hxx> 55 #include <svx/svdmrkv.hxx> 56 #include <svx/svdpagv.hxx> 57 #include "svx/svdviter.hxx" 58 #include <svx/svdview.hxx> 59 #include "svtools/filter.hxx" 60 #include <svx/svdograf.hxx> 61 #include <svx/svdogrp.hxx> 62 #include <svx/xbitmap.hxx> 63 #include <svx/xbtmpit.hxx> 64 #include <svx/xflbmtit.hxx> 65 #include <svx/svdundo.hxx> 66 #include "svdfmtf.hxx" 67 #include <svx/sdgcpitm.hxx> 68 #include <editeng/eeitem.hxx> 69 #include <svx/sdr/properties/graphicproperties.hxx> 70 #include <svx/sdr/contact/viewcontactofgraphic.hxx> 71 #include <basegfx/polygon/b2dpolygon.hxx> 72 #include <basegfx/polygon/b2dpolygontools.hxx> 73 #include <osl/thread.hxx> 74 #include <vos/mutex.hxx> 75 76 using namespace ::com::sun::star::uno; 77 using namespace ::com::sun::star::io; 78 79 // ----------- 80 // - Defines - 81 // ----------- 82 83 #define GRAFSTREAMPOS_INVALID 0xffffffff 84 #define SWAPGRAPHIC_TIMEOUT 5000 85 86 87 // ------------------ 88 // - SdrGraphicLink - 89 // ------------------ 90 91 92 const Graphic ImpLoadLinkedGraphic( const String& rFileName, const String& rFilterName ) 93 { 94 Graphic aGraphic; 95 96 SfxMedium xMed( rFileName, STREAM_STD_READ, sal_True ); 97 xMed.DownLoad(); 98 99 SvStream* pInStrm = xMed.GetInStream(); 100 if ( pInStrm ) 101 { 102 pInStrm->Seek( STREAM_SEEK_TO_BEGIN ); 103 GraphicFilter* pGF = GraphicFilter::GetGraphicFilter(); 104 105 const sal_uInt16 nFilter = rFilterName.Len() && pGF->GetImportFormatCount() 106 ? pGF->GetImportFormatNumber( rFilterName ) 107 : GRFILTER_FORMAT_DONTKNOW; 108 109 String aEmptyStr; 110 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aFilterData( 1 ); 111 112 // Room for improvment: 113 // As this is a linked graphic the GfxLink is not needed if saving/loading our own format. 114 // But this link is required by some filters to access the native graphic (pdf export/ms export), 115 // there we should create a new service to provide this data if needed 116 aFilterData[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CreateNativeLink" ) ); 117 aFilterData[ 0 ].Value = Any( sal_True ); 118 pGF->ImportGraphic( aGraphic, aEmptyStr, *pInStrm, nFilter, NULL, 0, &aFilterData ); 119 } 120 return aGraphic; 121 } 122 123 class SdrGraphicUpdater; 124 class SdrGraphicLink : public sfx2::SvBaseLink 125 { 126 SdrGrafObj* pGrafObj; 127 SdrGraphicUpdater* pGraphicUpdater; 128 129 public: 130 SdrGraphicLink(SdrGrafObj* pObj); 131 virtual ~SdrGraphicLink(); 132 133 virtual void Closed(); 134 virtual void DataChanged( const String& rMimeType, 135 const ::com::sun::star::uno::Any & rValue ); 136 void DataChanged( const Graphic& rGraphic ); 137 138 sal_Bool Connect() { return 0 != GetRealObject(); } 139 void UpdateAsynchron(); 140 void RemoveGraphicUpdater(); 141 }; 142 143 class SdrGraphicUpdater : public ::osl::Thread 144 { 145 public: 146 SdrGraphicUpdater( const String& rFileName, const String& rFilterName, SdrGraphicLink& ); 147 virtual ~SdrGraphicUpdater( void ); 148 149 void SAL_CALL Terminate( void ); 150 151 sal_Bool GraphicLinkChanged( const String& rFileName ){ return mrFileName != rFileName; }; 152 153 protected: 154 155 /** is called from the inherited create method and acts as the 156 main function of this thread. 157 */ 158 virtual void SAL_CALL run(void); 159 160 /** Called after the thread is terminated via the terminate 161 method. Used to kill the thread by calling delete on this. 162 */ 163 virtual void SAL_CALL onTerminated(void); 164 165 private: 166 167 ::osl::Mutex maMutex; 168 const String& mrFileName; 169 const String& mrFilterName; 170 SdrGraphicLink& mrGraphicLink; 171 172 volatile bool mbIsTerminated; 173 }; 174 175 SdrGraphicUpdater::SdrGraphicUpdater( const String& rFileName, const String& rFilterName, SdrGraphicLink& rGraphicLink ) 176 : mrFileName( rFileName ) 177 , mrFilterName( rFilterName ) 178 , mrGraphicLink( rGraphicLink ) 179 , mbIsTerminated( sal_False ) 180 { 181 create(); 182 } 183 184 SdrGraphicUpdater::~SdrGraphicUpdater( void ) 185 { 186 } 187 188 void SdrGraphicUpdater::Terminate() 189 { 190 ::osl::MutexGuard aGuard( maMutex ); 191 mbIsTerminated = sal_True; 192 } 193 194 void SAL_CALL SdrGraphicUpdater::onTerminated(void) 195 { 196 delete this; 197 } 198 199 void SAL_CALL SdrGraphicUpdater::run(void) 200 { 201 Graphic aGraphic( ImpLoadLinkedGraphic( mrFileName, mrFilterName ) ); 202 ::osl::MutexGuard aGuard(maMutex); 203 vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 204 if ( !mbIsTerminated ) 205 { 206 mrGraphicLink.DataChanged( aGraphic ); 207 mrGraphicLink.RemoveGraphicUpdater(); 208 } 209 } 210 211 // ----------------------------------------------------------------------------- 212 213 SdrGraphicLink::SdrGraphicLink(SdrGrafObj* pObj) 214 : ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB ) 215 , pGrafObj( pObj ) 216 , pGraphicUpdater( NULL ) 217 { 218 SetSynchron( sal_False ); 219 } 220 221 // ----------------------------------------------------------------------------- 222 223 SdrGraphicLink::~SdrGraphicLink() 224 { 225 if ( pGraphicUpdater ) 226 pGraphicUpdater->Terminate(); 227 } 228 229 // ----------------------------------------------------------------------------- 230 231 void SdrGraphicLink::DataChanged( const Graphic& rGraphic ) 232 { 233 pGrafObj->ImpSetLinkedGraphic( rGraphic ); 234 } 235 236 // ----------------------------------------------------------------------------- 237 238 void SdrGraphicLink::RemoveGraphicUpdater() 239 { 240 pGraphicUpdater = NULL; 241 } 242 243 // ----------------------------------------------------------------------------- 244 245 void SdrGraphicLink::DataChanged( const String& rMimeType, 246 const ::com::sun::star::uno::Any & rValue ) 247 { 248 SdrModel* pModel = pGrafObj ? pGrafObj->GetModel() : 0; 249 sfx2::LinkManager* pLinkManager= pModel ? pModel->GetLinkManager() : 0; 250 251 if( pLinkManager && rValue.hasValue() ) 252 { 253 pLinkManager->GetDisplayNames( this, 0, &pGrafObj->aFileName, 0, &pGrafObj->aFilterName ); 254 255 Graphic aGraphic; 256 if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGraphic )) 257 { 258 pGrafObj->NbcSetGraphic( aGraphic ); 259 pGrafObj->ActionChanged(); 260 } 261 else if( SotExchange::GetFormatIdFromMimeType( rMimeType ) != sfx2::LinkManager::RegisterStatusInfoId() ) 262 { 263 // broadcasting, to update slidesorter 264 pGrafObj->BroadcastObjectChange(); 265 } 266 } 267 } 268 269 // ----------------------------------------------------------------------------- 270 271 void SdrGraphicLink::Closed() 272 { 273 // Die Verbindung wird aufgehoben; pLink des Objekts auf NULL setzen, da die Link-Instanz ja gerade destruiert wird. 274 pGrafObj->ForceSwapIn(); 275 pGrafObj->pGraphicLink=NULL; 276 pGrafObj->ReleaseGraphicLink(); 277 SvBaseLink::Closed(); 278 } 279 280 // ----------------------------------------------------------------------------- 281 282 void SdrGraphicLink::UpdateAsynchron() 283 { 284 if( GetObj() ) 285 { 286 if ( pGraphicUpdater ) 287 { 288 if ( pGraphicUpdater->GraphicLinkChanged( pGrafObj->GetFileName() ) ) 289 { 290 pGraphicUpdater->Terminate(); 291 pGraphicUpdater = new SdrGraphicUpdater( pGrafObj->GetFileName(), pGrafObj->GetFilterName(), *this ); 292 } 293 } 294 else 295 pGraphicUpdater = new SdrGraphicUpdater( pGrafObj->GetFileName(), pGrafObj->GetFilterName(), *this ); 296 } 297 } 298 299 // -------------- 300 // - SdrGrafObj - 301 // -------------- 302 303 ////////////////////////////////////////////////////////////////////////////// 304 // BaseProperties section 305 306 sdr::properties::BaseProperties* SdrGrafObj::CreateObjectSpecificProperties() 307 { 308 return new sdr::properties::GraphicProperties(*this); 309 } 310 311 ////////////////////////////////////////////////////////////////////////////// 312 // DrawContact section 313 314 sdr::contact::ViewContact* SdrGrafObj::CreateObjectSpecificViewContact() 315 { 316 return new sdr::contact::ViewContactOfGraphic(*this); 317 } 318 319 ////////////////////////////////////////////////////////////////////////////// 320 321 TYPEINIT1(SdrGrafObj,SdrRectObj); 322 323 // ----------------------------------------------------------------------------- 324 325 SdrGrafObj::SdrGrafObj() 326 : SdrRectObj(), 327 pGraphicLink ( NULL ), 328 bMirrored ( sal_False ) 329 { 330 pGraphic = new GraphicObject; 331 pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); 332 bNoShear = sal_True; 333 334 // #111096# 335 mbGrafAnimationAllowed = sal_True; 336 337 // #i25616# 338 mbLineIsOutsideGeometry = sal_True; 339 mbInsidePaint = sal_False; 340 mbIsPreview = sal_False; 341 342 // #i25616# 343 mbSupportTextIndentingOnLineWidthChange = sal_False; 344 } 345 346 // ----------------------------------------------------------------------------- 347 348 SdrGrafObj::SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect) 349 : SdrRectObj ( rRect ), 350 pGraphicLink ( NULL ), 351 bMirrored ( sal_False ) 352 { 353 pGraphic = new GraphicObject( rGrf ); 354 pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); 355 bNoShear = sal_True; 356 357 // #111096# 358 mbGrafAnimationAllowed = sal_True; 359 360 // #i25616# 361 mbLineIsOutsideGeometry = sal_True; 362 mbInsidePaint = sal_False; 363 mbIsPreview = sal_False; 364 365 // #i25616# 366 mbSupportTextIndentingOnLineWidthChange = sal_False; 367 } 368 369 // ----------------------------------------------------------------------------- 370 371 SdrGrafObj::SdrGrafObj( const Graphic& rGrf ) 372 : SdrRectObj(), 373 pGraphicLink ( NULL ), 374 bMirrored ( sal_False ) 375 { 376 pGraphic = new GraphicObject( rGrf ); 377 pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); 378 bNoShear = sal_True; 379 380 // #111096# 381 mbGrafAnimationAllowed = sal_True; 382 383 // #i25616# 384 mbLineIsOutsideGeometry = sal_True; 385 mbInsidePaint = sal_False; 386 mbIsPreview = sal_False; 387 388 // #i25616# 389 mbSupportTextIndentingOnLineWidthChange = sal_False; 390 } 391 392 // ----------------------------------------------------------------------------- 393 394 SdrGrafObj::~SdrGrafObj() 395 { 396 delete pGraphic; 397 ImpLinkAbmeldung(); 398 } 399 400 // ----------------------------------------------------------------------------- 401 402 void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj ) 403 { 404 *pGraphic = rGrfObj; 405 pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT ); 406 pGraphic->SetUserData(); 407 mbIsPreview = sal_False; 408 SetChanged(); 409 BroadcastObjectChange(); 410 } 411 412 // ----------------------------------------------------------------------------- 413 414 const GraphicObject& SdrGrafObj::GetGraphicObject(bool bForceSwapIn) const 415 { 416 if(bForceSwapIn) 417 { 418 ForceSwapIn(); 419 } 420 421 return *pGraphic; 422 } 423 424 // ----------------------------------------------------------------------------- 425 426 void SdrGrafObj::NbcSetGraphic( const Graphic& rGrf ) 427 { 428 pGraphic->SetGraphic( rGrf ); 429 pGraphic->SetUserData(); 430 mbIsPreview = sal_False; 431 } 432 433 void SdrGrafObj::SetGraphic( const Graphic& rGrf ) 434 { 435 NbcSetGraphic(rGrf); 436 SetChanged(); 437 BroadcastObjectChange(); 438 } 439 440 // ----------------------------------------------------------------------------- 441 442 const Graphic& SdrGrafObj::GetGraphic() const 443 { 444 ForceSwapIn(); 445 return pGraphic->GetGraphic(); 446 } 447 448 // ----------------------------------------------------------------------------- 449 450 Graphic SdrGrafObj::GetTransformedGraphic( sal_uIntPtr nTransformFlags ) const 451 { 452 // #107947# Refactored most of the code to GraphicObject, where 453 // everybody can use e.g. the cropping functionality 454 455 GraphicType eType = GetGraphicType(); 456 MapMode aDestMap( pModel->GetScaleUnit(), Point(), pModel->GetScaleFraction(), pModel->GetScaleFraction() ); 457 const Size aDestSize( GetLogicRect().GetSize() ); 458 const sal_Bool bMirror = ( nTransformFlags & SDRGRAFOBJ_TRANSFORMATTR_MIRROR ) != 0; 459 const sal_Bool bRotate = ( ( nTransformFlags & SDRGRAFOBJ_TRANSFORMATTR_ROTATE ) != 0 ) && 460 ( aGeo.nDrehWink && aGeo.nDrehWink != 18000 ) && ( GRAPHIC_NONE != eType ); 461 462 // #104115# Need cropping info earlier 463 ( (SdrGrafObj*) this )->ImpSetAttrToGrafInfo(); 464 GraphicAttr aActAttr; 465 466 if( SDRGRAFOBJ_TRANSFORMATTR_NONE != nTransformFlags && 467 GRAPHIC_NONE != eType ) 468 { 469 // actually transform the graphic only in this case. On the 470 // other hand, cropping will always happen 471 aActAttr = aGrafInfo; 472 473 if( bMirror ) 474 { 475 sal_uInt16 nMirrorCase = ( aGeo.nDrehWink == 18000 ) ? ( bMirrored ? 3 : 4 ) : ( bMirrored ? 2 : 1 ); 476 FASTBOOL bHMirr = nMirrorCase == 2 || nMirrorCase == 4; 477 FASTBOOL bVMirr = nMirrorCase == 3 || nMirrorCase == 4; 478 479 aActAttr.SetMirrorFlags( ( bHMirr ? BMP_MIRROR_HORZ : 0 ) | ( bVMirr ? BMP_MIRROR_VERT : 0 ) ); 480 } 481 482 if( bRotate ) 483 aActAttr.SetRotation( sal_uInt16(aGeo.nDrehWink / 10) ); 484 } 485 486 // #107947# Delegate to moved code in GraphicObject 487 return GetGraphicObject().GetTransformedGraphic( aDestSize, aDestMap, aActAttr ); 488 } 489 490 // ----------------------------------------------------------------------------- 491 492 GraphicType SdrGrafObj::GetGraphicType() const 493 { 494 return pGraphic->GetType(); 495 } 496 497 sal_Bool SdrGrafObj::IsAnimated() const 498 { 499 return pGraphic->IsAnimated(); 500 } 501 502 sal_Bool SdrGrafObj::IsEPS() const 503 { 504 return pGraphic->IsEPS(); 505 } 506 507 sal_Bool SdrGrafObj::IsRenderGraphic() const 508 { 509 return pGraphic->IsRenderGraphic(); 510 } 511 512 sal_Bool SdrGrafObj::HasRenderGraphic() const 513 { 514 return pGraphic->HasRenderGraphic(); 515 } 516 517 sal_Bool SdrGrafObj::IsSwappedOut() const 518 { 519 return mbIsPreview ? sal_True : pGraphic->IsSwappedOut(); 520 } 521 522 const MapMode& SdrGrafObj::GetGrafPrefMapMode() const 523 { 524 return pGraphic->GetPrefMapMode(); 525 } 526 527 const Size& SdrGrafObj::GetGrafPrefSize() const 528 { 529 return pGraphic->GetPrefSize(); 530 } 531 532 // ----------------------------------------------------------------------------- 533 534 void SdrGrafObj::SetGrafStreamURL( const String& rGraphicStreamURL ) 535 { 536 mbIsPreview = sal_False; 537 if( !rGraphicStreamURL.Len() ) 538 { 539 pGraphic->SetUserData(); 540 } 541 else if( pModel->IsSwapGraphics() ) 542 { 543 pGraphic->SetUserData( rGraphicStreamURL ); 544 545 // set state of graphic object to 'swapped out' 546 if( pGraphic->GetType() == GRAPHIC_NONE ) 547 pGraphic->SetSwapState(); 548 } 549 } 550 551 // ----------------------------------------------------------------------------- 552 553 String SdrGrafObj::GetGrafStreamURL() const 554 { 555 return pGraphic->GetUserData(); 556 } 557 558 // ----------------------------------------------------------------------------- 559 560 void SdrGrafObj::SetFileName(const String& rFileName) 561 { 562 aFileName = rFileName; 563 SetChanged(); 564 } 565 566 // ----------------------------------------------------------------------------- 567 568 void SdrGrafObj::SetFilterName(const String& rFilterName) 569 { 570 aFilterName = rFilterName; 571 SetChanged(); 572 } 573 574 // ----------------------------------------------------------------------------- 575 576 void SdrGrafObj::ForceSwapIn() const 577 { 578 if( mbIsPreview ) 579 { 580 // removing preview graphic 581 const String aUserData( pGraphic->GetUserData() ); 582 583 Graphic aEmpty; 584 pGraphic->SetGraphic( aEmpty ); 585 pGraphic->SetUserData( aUserData ); 586 pGraphic->SetSwapState(); 587 588 const_cast< SdrGrafObj* >( this )->mbIsPreview = sal_False; 589 } 590 if ( pGraphicLink && pGraphic->IsSwappedOut() ) 591 ImpUpdateGraphicLink( sal_False ); 592 else 593 pGraphic->FireSwapInRequest(); 594 595 if( pGraphic->IsSwappedOut() || 596 ( pGraphic->GetType() == GRAPHIC_NONE ) || 597 ( pGraphic->GetType() == GRAPHIC_DEFAULT ) ) 598 { 599 Graphic aDefaultGraphic; 600 aDefaultGraphic.SetDefaultType(); 601 pGraphic->SetGraphic( aDefaultGraphic ); 602 } 603 } 604 605 // ----------------------------------------------------------------------------- 606 607 void SdrGrafObj::ForceSwapOut() const 608 { 609 pGraphic->FireSwapOutRequest(); 610 } 611 612 // ----------------------------------------------------------------------------- 613 614 void SdrGrafObj::ImpLinkAnmeldung() 615 { 616 sfx2::LinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL; 617 618 if( pLinkManager != NULL && pGraphicLink == NULL ) 619 { 620 if( aFileName.Len() ) 621 { 622 pGraphicLink = new SdrGraphicLink( this ); 623 pLinkManager->InsertFileLink( *pGraphicLink, OBJECT_CLIENT_GRF, aFileName, ( aFilterName.Len() ? &aFilterName : NULL ), NULL ); 624 pGraphicLink->Connect(); 625 } 626 } 627 } 628 629 // ----------------------------------------------------------------------------- 630 631 void SdrGrafObj::ImpLinkAbmeldung() 632 { 633 sfx2::LinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL; 634 635 if( pLinkManager != NULL && pGraphicLink!=NULL) 636 { 637 // Bei Remove wird *pGraphicLink implizit deleted 638 pLinkManager->Remove( pGraphicLink ); 639 pGraphicLink=NULL; 640 } 641 } 642 643 // ----------------------------------------------------------------------------- 644 645 void SdrGrafObj::SetGraphicLink( const String& rFileName, const String& rFilterName ) 646 { 647 ImpLinkAbmeldung(); 648 aFileName = rFileName; 649 aFilterName = rFilterName; 650 ImpLinkAnmeldung(); 651 pGraphic->SetUserData(); 652 653 // #92205# A linked graphic is per definition swapped out (has to be loaded) 654 pGraphic->SetSwapState(); 655 } 656 657 // ----------------------------------------------------------------------------- 658 659 void SdrGrafObj::ReleaseGraphicLink() 660 { 661 ImpLinkAbmeldung(); 662 aFileName = String(); 663 aFilterName = String(); 664 } 665 666 // ----------------------------------------------------------------------------- 667 668 void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const 669 { 670 FASTBOOL bAnim = pGraphic->IsAnimated(); 671 FASTBOOL bRenderGraphic = pGraphic->HasRenderGraphic(); 672 FASTBOOL bNoPresGrf = ( pGraphic->GetType() != GRAPHIC_NONE ) && !bEmptyPresObj; 673 674 rInfo.bResizeFreeAllowed = aGeo.nDrehWink % 9000 == 0 || 675 aGeo.nDrehWink % 18000 == 0 || 676 aGeo.nDrehWink % 27000 == 0; 677 678 rInfo.bResizePropAllowed = sal_True; 679 rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; 680 rInfo.bRotate90Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; 681 rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim && !bRenderGraphic; 682 rInfo.bMirror45Allowed = bNoPresGrf && !bAnim && !bRenderGraphic; 683 rInfo.bMirror90Allowed = !bEmptyPresObj && !bRenderGraphic; 684 rInfo.bTransparenceAllowed = sal_False; 685 rInfo.bGradientAllowed = sal_False; 686 rInfo.bShearAllowed = sal_False; 687 rInfo.bEdgeRadiusAllowed=sal_False; 688 rInfo.bCanConvToPath = sal_False; 689 rInfo.bCanConvToPathLineToArea = sal_False; 690 rInfo.bCanConvToPolyLineToArea = sal_False; 691 rInfo.bCanConvToPoly = !IsEPS() && !bRenderGraphic; 692 rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary()); 693 } 694 695 // ----------------------------------------------------------------------------- 696 697 sal_uInt16 SdrGrafObj::GetObjIdentifier() const 698 { 699 return sal_uInt16( OBJ_GRAF ); 700 } 701 702 // ----------------------------------------------------------------------------- 703 704 /* The graphic of the GraphicLink will be loaded. If it is called with 705 bAsynchron = true then the graphic will be set later via DataChanged 706 */ 707 sal_Bool SdrGrafObj::ImpUpdateGraphicLink( sal_Bool bAsynchron ) const 708 { 709 sal_Bool bRet = sal_False; 710 if( pGraphicLink ) 711 { 712 if ( bAsynchron ) 713 pGraphicLink->UpdateAsynchron(); 714 else 715 pGraphicLink->DataChanged( ImpLoadLinkedGraphic( aFileName, aFilterName ) ); 716 bRet = sal_True; 717 } 718 return bRet; 719 } 720 721 // ----------------------------------------------------------------------------- 722 723 void SdrGrafObj::ImpSetLinkedGraphic( const Graphic& rGraphic ) 724 { 725 const sal_Bool bIsChanged = GetModel()->IsChanged(); 726 NbcSetGraphic( rGraphic ); 727 ActionChanged(); 728 BroadcastObjectChange(); 729 GetModel()->SetChanged( bIsChanged ); 730 } 731 732 // ----------------------------------------------------------------------------- 733 734 void SdrGrafObj::TakeObjNameSingul(XubString& rName) const 735 { 736 switch( pGraphic->GetType() ) 737 { 738 case GRAPHIC_BITMAP: 739 { 740 const sal_uInt16 nId = ( ( pGraphic->IsTransparent() || ( (const SdrGrafTransparenceItem&) GetObjectItem( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ) ? 741 ( IsLinkedGraphic() ? STR_ObjNameSingulGRAFBMPTRANSLNK : STR_ObjNameSingulGRAFBMPTRANS ) : 742 ( IsLinkedGraphic() ? STR_ObjNameSingulGRAFBMPLNK : STR_ObjNameSingulGRAFBMP ) ); 743 744 rName=ImpGetResStr( nId ); 745 } 746 break; 747 748 case GRAPHIC_GDIMETAFILE: 749 rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFMTFLNK : STR_ObjNameSingulGRAFMTF ); 750 break; 751 752 case GRAPHIC_NONE: 753 rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFNONELNK : STR_ObjNameSingulGRAFNONE ); 754 break; 755 756 default: 757 rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFLNK : STR_ObjNameSingulGRAF ); 758 break; 759 } 760 761 const String aName(GetName()); 762 763 if( aName.Len() ) 764 { 765 rName.AppendAscii( " '" ); 766 rName += aName; 767 rName += sal_Unicode( '\'' ); 768 } 769 } 770 771 // ----------------------------------------------------------------------------- 772 773 void SdrGrafObj::TakeObjNamePlural( XubString& rName ) const 774 { 775 switch( pGraphic->GetType() ) 776 { 777 case GRAPHIC_BITMAP: 778 { 779 const sal_uInt16 nId = ( ( pGraphic->IsTransparent() || ( (const SdrGrafTransparenceItem&) GetObjectItem( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ) ? 780 ( IsLinkedGraphic() ? STR_ObjNamePluralGRAFBMPTRANSLNK : STR_ObjNamePluralGRAFBMPTRANS ) : 781 ( IsLinkedGraphic() ? STR_ObjNamePluralGRAFBMPLNK : STR_ObjNamePluralGRAFBMP ) ); 782 783 rName=ImpGetResStr( nId ); 784 } 785 break; 786 787 case GRAPHIC_GDIMETAFILE: 788 rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFMTFLNK : STR_ObjNamePluralGRAFMTF ); 789 break; 790 791 case GRAPHIC_NONE: 792 rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFNONELNK : STR_ObjNamePluralGRAFNONE ); 793 break; 794 795 default: 796 rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFLNK : STR_ObjNamePluralGRAF ); 797 break; 798 } 799 800 const String aName(GetName()); 801 802 if( aName.Len() ) 803 { 804 rName.AppendAscii( " '" ); 805 rName += aName; 806 rName += sal_Unicode( '\'' ); 807 } 808 } 809 810 // ----------------------------------------------------------------------------- 811 812 SdrObject* SdrGrafObj::getFullDragClone() const 813 { 814 // call parent 815 SdrGrafObj* pRetval = static_cast< SdrGrafObj* >(SdrRectObj::getFullDragClone()); 816 817 // #i103116# the full drag clone leads to problems 818 // with linked graphics, so reset the link in this 819 // temporary interaction object and load graphic 820 if(pRetval && IsLinkedGraphic()) 821 { 822 pRetval->ForceSwapIn(); 823 pRetval->ReleaseGraphicLink(); 824 } 825 826 return pRetval; 827 } 828 829 void SdrGrafObj::operator=( const SdrObject& rObj ) 830 { 831 SdrRectObj::operator=( rObj ); 832 833 const SdrGrafObj& rGraf = (SdrGrafObj&) rObj; 834 835 pGraphic->SetGraphic( rGraf.GetGraphic(), &rGraf.GetGraphicObject() ); 836 aCropRect = rGraf.aCropRect; 837 aFileName = rGraf.aFileName; 838 aFilterName = rGraf.aFilterName; 839 bMirrored = rGraf.bMirrored; 840 841 if( rGraf.pGraphicLink != NULL) 842 { 843 SetGraphicLink( aFileName, aFilterName ); 844 } 845 846 ImpSetAttrToGrafInfo(); 847 } 848 849 // ----------------------------------------------------------------------------- 850 // #i25616# 851 852 basegfx::B2DPolyPolygon SdrGrafObj::TakeXorPoly() const 853 { 854 if(mbInsidePaint) 855 { 856 basegfx::B2DPolyPolygon aRetval; 857 858 // take grown rectangle 859 const sal_Int32 nHalfLineWidth(ImpGetLineWdt() / 2); 860 const Rectangle aGrownRect( 861 aRect.Left() - nHalfLineWidth, 862 aRect.Top() - nHalfLineWidth, 863 aRect.Right() + nHalfLineWidth, 864 aRect.Bottom() + nHalfLineWidth); 865 866 XPolygon aXPoly(ImpCalcXPoly(aGrownRect, GetEckenradius())); 867 aRetval.append(aXPoly.getB2DPolygon()); 868 869 return aRetval; 870 } 871 else 872 { 873 // call parent 874 return SdrRectObj::TakeXorPoly(); 875 } 876 } 877 878 // ----------------------------------------------------------------------------- 879 880 sal_uInt32 SdrGrafObj::GetHdlCount() const 881 { 882 return 8L; 883 } 884 885 // ----------------------------------------------------------------------------- 886 887 SdrHdl* SdrGrafObj::GetHdl(sal_uInt32 nHdlNum) const 888 { 889 return SdrRectObj::GetHdl( nHdlNum + 1L ); 890 } 891 892 // ----------------------------------------------------------------------------- 893 894 void SdrGrafObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) 895 { 896 SdrRectObj::NbcResize( rRef, xFact, yFact ); 897 898 FASTBOOL bMirrX = xFact.GetNumerator() < 0; 899 FASTBOOL bMirrY = yFact.GetNumerator() < 0; 900 901 if( bMirrX != bMirrY ) 902 bMirrored = !bMirrored; 903 } 904 905 // ----------------------------------------------------------------------------- 906 907 void SdrGrafObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs) 908 { 909 SdrRectObj::NbcRotate(rRef,nWink,sn,cs); 910 } 911 912 // ----------------------------------------------------------------------------- 913 914 void SdrGrafObj::NbcMirror(const Point& rRef1, const Point& rRef2) 915 { 916 SdrRectObj::NbcMirror(rRef1,rRef2); 917 bMirrored = !bMirrored; 918 } 919 920 // ----------------------------------------------------------------------------- 921 922 void SdrGrafObj::NbcShear(const Point& rRef, long nWink, double tn, FASTBOOL bVShear) 923 { 924 SdrRectObj::NbcRotate( rRef, nWink, tn, bVShear ); 925 } 926 927 // ----------------------------------------------------------------------------- 928 929 void SdrGrafObj::NbcSetSnapRect(const Rectangle& rRect) 930 { 931 SdrRectObj::NbcSetSnapRect(rRect); 932 } 933 934 // ----------------------------------------------------------------------------- 935 936 void SdrGrafObj::NbcSetLogicRect( const Rectangle& rRect) 937 { 938 //int bChg=rRect.GetSize()!=aRect.GetSize(); 939 SdrRectObj::NbcSetLogicRect(rRect); 940 } 941 942 // ----------------------------------------------------------------------------- 943 944 SdrObjGeoData* SdrGrafObj::NewGeoData() const 945 { 946 return new SdrGrafObjGeoData; 947 } 948 949 // ----------------------------------------------------------------------------- 950 951 void SdrGrafObj::SaveGeoData(SdrObjGeoData& rGeo) const 952 { 953 SdrRectObj::SaveGeoData(rGeo); 954 SdrGrafObjGeoData& rGGeo=(SdrGrafObjGeoData&)rGeo; 955 rGGeo.bMirrored=bMirrored; 956 } 957 958 // ----------------------------------------------------------------------------- 959 960 void SdrGrafObj::RestGeoData(const SdrObjGeoData& rGeo) 961 { 962 //long nDrehMerk = aGeo.nDrehWink; 963 //long nShearMerk = aGeo.nShearWink; 964 //int bMirrMerk = bMirrored; 965 Size aSizMerk( aRect.GetSize() ); 966 967 SdrRectObj::RestGeoData(rGeo); 968 SdrGrafObjGeoData& rGGeo=(SdrGrafObjGeoData&)rGeo; 969 bMirrored=rGGeo.bMirrored; 970 } 971 972 // ----------------------------------------------------------------------------- 973 974 void SdrGrafObj::SetPage( SdrPage* pNewPage ) 975 { 976 FASTBOOL bRemove = pNewPage == NULL && pPage != NULL; 977 FASTBOOL bInsert = pNewPage != NULL && pPage == NULL; 978 979 if( bRemove ) 980 { 981 // hier kein SwapIn noetig, weil wenn nicht geladen, dann auch nicht animiert. 982 if( pGraphic->IsAnimated()) 983 pGraphic->StopAnimation(); 984 985 if( pGraphicLink != NULL ) 986 ImpLinkAbmeldung(); 987 } 988 989 SdrRectObj::SetPage( pNewPage ); 990 991 if(aFileName.Len() && bInsert) 992 ImpLinkAnmeldung(); 993 } 994 995 // ----------------------------------------------------------------------------- 996 997 void SdrGrafObj::SetModel( SdrModel* pNewModel ) 998 { 999 FASTBOOL bChg = pNewModel != pModel; 1000 1001 if( bChg ) 1002 { 1003 if( pGraphic->HasUserData() ) 1004 { 1005 ForceSwapIn(); 1006 pGraphic->SetUserData(); 1007 } 1008 1009 if( pGraphicLink != NULL ) 1010 ImpLinkAbmeldung(); 1011 } 1012 1013 // Model umsetzen 1014 SdrRectObj::SetModel(pNewModel); 1015 1016 if( bChg && aFileName.Len() ) 1017 ImpLinkAnmeldung(); 1018 } 1019 1020 // ----------------------------------------------------------------------------- 1021 1022 void SdrGrafObj::StartAnimation( OutputDevice* /*pOutDev*/, const Point& /*rPoint*/, const Size& /*rSize*/, long /*nExtraData*/) 1023 { 1024 // #111096# 1025 // use new graf animation 1026 SetGrafAnimationAllowed(sal_True); 1027 } 1028 1029 // ----------------------------------------------------------------------------- 1030 1031 void SdrGrafObj::StopAnimation(OutputDevice* /*pOutDev*/, long /*nExtraData*/) 1032 { 1033 // #111096# 1034 // use new graf animation 1035 SetGrafAnimationAllowed(sal_False); 1036 } 1037 1038 // ----------------------------------------------------------------------------- 1039 1040 FASTBOOL SdrGrafObj::HasGDIMetaFile() const 1041 { 1042 return( pGraphic->GetType() == GRAPHIC_GDIMETAFILE ); 1043 } 1044 1045 // ----------------------------------------------------------------------------- 1046 1047 const GDIMetaFile* SdrGrafObj::GetGDIMetaFile() const 1048 { 1049 DBG_ERROR( "Invalid return value! Don't use it! (KA)" ); 1050 return &GetGraphic().GetGDIMetaFile(); 1051 } 1052 1053 // ----------------------------------------------------------------------------- 1054 1055 SdrObject* SdrGrafObj::DoConvertToPolyObj(sal_Bool bBezier) const 1056 { 1057 SdrObject* pRetval = NULL; 1058 1059 switch( GetGraphicType() ) 1060 { 1061 case GRAPHIC_GDIMETAFILE: 1062 { 1063 // NUR die aus dem MetaFile erzeugbaren Objekte in eine Gruppe packen und zurueckliefern 1064 SdrObjGroup* pGrp = new SdrObjGroup(); 1065 ImpSdrGDIMetaFileImport aFilter(*GetModel()); 1066 Point aOutPos( aRect.TopLeft() ); 1067 const Size aOutSiz( aRect.GetSize() ); 1068 1069 aFilter.SetScaleRect(GetSnapRect()); 1070 aFilter.SetLayer(GetLayer()); 1071 1072 sal_uInt32 nInsAnz = aFilter.DoImport(GetTransformedGraphic().GetGDIMetaFile(), *pGrp->GetSubList(), 0); 1073 if(nInsAnz) 1074 { 1075 pRetval = pGrp; 1076 pGrp->NbcSetLayer(GetLayer()); 1077 pGrp->SetModel(GetModel()); 1078 pRetval = ImpConvertAddText(pRetval, bBezier); 1079 1080 // convert all children 1081 if( pRetval ) 1082 { 1083 SdrObject* pHalfDone = pRetval; 1084 pRetval = pHalfDone->DoConvertToPolyObj(bBezier); 1085 SdrObject::Free( pHalfDone ); // resulting object is newly created 1086 1087 if( pRetval ) 1088 { 1089 // flatten subgroups. As we call 1090 // DoConvertToPolyObj() on the resulting group 1091 // objects, subgroups can exist (e.g. text is 1092 // a group object for every line). 1093 SdrObjList* pList = pRetval->GetSubList(); 1094 if( pList ) 1095 pList->FlattenGroups(); 1096 } 1097 } 1098 } 1099 else 1100 delete pGrp; 1101 break; 1102 } 1103 case GRAPHIC_BITMAP: 1104 { 1105 // Grundobjekt kreieren und Fuellung ergaenzen 1106 pRetval = SdrRectObj::DoConvertToPolyObj(bBezier); 1107 1108 // Bitmap als Attribut retten 1109 if(pRetval) 1110 { 1111 // Bitmap als Fuellung holen 1112 SfxItemSet aSet(GetObjectItemSet()); 1113 1114 aSet.Put(XFillStyleItem(XFILL_BITMAP)); 1115 Bitmap aBitmap( GetTransformedGraphic().GetBitmap() ); 1116 XOBitmap aXBmp(aBitmap, XBITMAP_STRETCH); 1117 aSet.Put(XFillBitmapItem(String(), aXBmp)); 1118 aSet.Put(XFillBmpTileItem(sal_False)); 1119 1120 pRetval->SetMergedItemSet(aSet); 1121 } 1122 break; 1123 } 1124 case GRAPHIC_NONE: 1125 case GRAPHIC_DEFAULT: 1126 { 1127 pRetval = SdrRectObj::DoConvertToPolyObj(bBezier); 1128 break; 1129 } 1130 } 1131 1132 return pRetval; 1133 } 1134 1135 // ----------------------------------------------------------------------------- 1136 1137 void SdrGrafObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 1138 { 1139 SetXPolyDirty(); 1140 SdrRectObj::Notify( rBC, rHint ); 1141 ImpSetAttrToGrafInfo(); 1142 } 1143 1144 void SdrGrafObj::ImpSetAttrToGrafInfo() 1145 { 1146 const SfxItemSet& rSet = GetObjectItemSet(); 1147 const sal_uInt16 nTrans = ( (SdrGrafTransparenceItem&) rSet.Get( SDRATTR_GRAFTRANSPARENCE ) ).GetValue(); 1148 const SdrGrafCropItem& rCrop = (const SdrGrafCropItem&) rSet.Get( SDRATTR_GRAFCROP ); 1149 1150 aGrafInfo.SetLuminance( ( (SdrGrafLuminanceItem&) rSet.Get( SDRATTR_GRAFLUMINANCE ) ).GetValue() ); 1151 aGrafInfo.SetContrast( ( (SdrGrafContrastItem&) rSet.Get( SDRATTR_GRAFCONTRAST ) ).GetValue() ); 1152 aGrafInfo.SetChannelR( ( (SdrGrafRedItem&) rSet.Get( SDRATTR_GRAFRED ) ).GetValue() ); 1153 aGrafInfo.SetChannelG( ( (SdrGrafGreenItem&) rSet.Get( SDRATTR_GRAFGREEN ) ).GetValue() ); 1154 aGrafInfo.SetChannelB( ( (SdrGrafBlueItem&) rSet.Get( SDRATTR_GRAFBLUE ) ).GetValue() ); 1155 aGrafInfo.SetGamma( ( (SdrGrafGamma100Item&) rSet.Get( SDRATTR_GRAFGAMMA ) ).GetValue() * 0.01 ); 1156 aGrafInfo.SetTransparency( (sal_uInt8) FRound( Min( nTrans, (sal_uInt16) 100 ) * 2.55 ) ); 1157 aGrafInfo.SetInvert( ( (SdrGrafInvertItem&) rSet.Get( SDRATTR_GRAFINVERT ) ).GetValue() ); 1158 aGrafInfo.SetDrawMode( ( (SdrGrafModeItem&) rSet.Get( SDRATTR_GRAFMODE ) ).GetValue() ); 1159 aGrafInfo.SetCrop( rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom() ); 1160 1161 SetXPolyDirty(); 1162 SetRectsDirty(); 1163 } 1164 1165 // ----------------------------------------------------------------------------- 1166 1167 void SdrGrafObj::ImpSetGrafInfoToAttr() 1168 { 1169 SetObjectItem( SdrGrafLuminanceItem( aGrafInfo.GetLuminance() ) ); 1170 SetObjectItem( SdrGrafContrastItem( aGrafInfo.GetContrast() ) ); 1171 SetObjectItem( SdrGrafRedItem( aGrafInfo.GetChannelR() ) ); 1172 SetObjectItem( SdrGrafGreenItem( aGrafInfo.GetChannelG() ) ); 1173 SetObjectItem( SdrGrafBlueItem( aGrafInfo.GetChannelB() ) ); 1174 SetObjectItem( SdrGrafGamma100Item( FRound( aGrafInfo.GetGamma() * 100.0 ) ) ); 1175 SetObjectItem( SdrGrafTransparenceItem( (sal_uInt16) FRound( aGrafInfo.GetTransparency() / 2.55 ) ) ); 1176 SetObjectItem( SdrGrafInvertItem( aGrafInfo.IsInvert() ) ); 1177 SetObjectItem( SdrGrafModeItem( aGrafInfo.GetDrawMode() ) ); 1178 SetObjectItem( SdrGrafCropItem( aGrafInfo.GetLeftCrop(), aGrafInfo.GetTopCrop(), aGrafInfo.GetRightCrop(), aGrafInfo.GetBottomCrop() ) ); 1179 } 1180 1181 // ----------------------------------------------------------------------------- 1182 1183 void SdrGrafObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly ) 1184 { 1185 Size aSize; 1186 Size aMaxSize( rMaxRect.GetSize() ); 1187 if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL ) 1188 aSize = Application::GetDefaultDevice()->PixelToLogic( pGraphic->GetPrefSize(), MAP_100TH_MM ); 1189 else 1190 aSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(), 1191 pGraphic->GetPrefMapMode(), 1192 MapMode( MAP_100TH_MM ) ); 1193 1194 if( aSize.Height() != 0 && aSize.Width() != 0 ) 1195 { 1196 Point aPos( rMaxRect.TopLeft() ); 1197 1198 // Falls Grafik zu gross, wird die Grafik 1199 // in die Seite eingepasst 1200 if ( (!bShrinkOnly || 1201 ( aSize.Height() > aMaxSize.Height() ) || 1202 ( aSize.Width() > aMaxSize.Width() ) )&& 1203 aSize.Height() && aMaxSize.Height() ) 1204 { 1205 float fGrfWH = (float)aSize.Width() / 1206 (float)aSize.Height(); 1207 float fWinWH = (float)aMaxSize.Width() / 1208 (float)aMaxSize.Height(); 1209 1210 // Grafik an Pagesize anpassen (skaliert) 1211 if ( fGrfWH < fWinWH ) 1212 { 1213 aSize.Width() = (long)(aMaxSize.Height() * fGrfWH); 1214 aSize.Height()= aMaxSize.Height(); 1215 } 1216 else if ( fGrfWH > 0.F ) 1217 { 1218 aSize.Width() = aMaxSize.Width(); 1219 aSize.Height()= (long)(aMaxSize.Width() / fGrfWH); 1220 } 1221 1222 aPos = rMaxRect.Center(); 1223 } 1224 1225 if( bShrinkOnly ) 1226 aPos = aRect.TopLeft(); 1227 1228 aPos.X() -= aSize.Width() / 2; 1229 aPos.Y() -= aSize.Height() / 2; 1230 SetLogicRect( Rectangle( aPos, aSize ) ); 1231 } 1232 } 1233 1234 // ----------------------------------------------------------------------------- 1235 1236 IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO ) 1237 { 1238 SvStream* pRet = GRFMGR_AUTOSWAPSTREAM_NONE; 1239 1240 if( pO->IsInSwapOut() ) 1241 { 1242 if( pModel && !mbIsPreview && pModel->IsSwapGraphics() && pGraphic->GetSizeBytes() > 20480 ) 1243 { 1244 // test if this object is visualized from someone 1245 // ## test only if there are VOCs other than the preview renderer 1246 if(!GetViewContact().HasViewObjectContacts(true)) 1247 { 1248 const sal_uIntPtr nSwapMode = pModel->GetSwapGraphicsMode(); 1249 1250 if( ( pGraphic->HasUserData() || pGraphicLink ) && 1251 ( nSwapMode & SDR_SWAPGRAPHICSMODE_PURGE ) ) 1252 { 1253 pRet = GRFMGR_AUTOSWAPSTREAM_LINK; 1254 } 1255 else if( nSwapMode & SDR_SWAPGRAPHICSMODE_TEMP ) 1256 { 1257 pRet = GRFMGR_AUTOSWAPSTREAM_TEMP; 1258 pGraphic->SetUserData(); 1259 } 1260 1261 // #i102380# 1262 sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&GetViewContact()); 1263 1264 if(pVC) 1265 { 1266 pVC->flushGraphicObjects(); 1267 } 1268 } 1269 } 1270 } 1271 else if( pO->IsInSwapIn() ) 1272 { 1273 // kann aus dem original Doc-Stream nachgeladen werden... 1274 if( pModel != NULL ) 1275 { 1276 if( pGraphic->HasUserData() ) 1277 { 1278 SdrDocumentStreamInfo aStreamInfo; 1279 1280 aStreamInfo.mbDeleteAfterUse = sal_False; 1281 aStreamInfo.maUserData = pGraphic->GetUserData(); 1282 1283 SvStream* pStream = pModel->GetDocumentStream( aStreamInfo ); 1284 1285 if( pStream != NULL ) 1286 { 1287 Graphic aGraphic; 1288 1289 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData = NULL; 1290 1291 if(mbInsidePaint && !GetViewContact().HasViewObjectContacts(true)) 1292 { 1293 // Rectangle aSnapRect(GetSnapRect()); 1294 // const Rectangle aSnapRectPixel(pOutDev->LogicToPixel(aSnapRect)); 1295 1296 pFilterData = new com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >( 3 ); 1297 1298 com::sun::star::awt::Size aPreviewSizeHint( 64, 64 ); 1299 sal_Bool bAllowPartialStreamRead = sal_True; 1300 sal_Bool bCreateNativeLink = sal_False; 1301 (*pFilterData)[ 0 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "PreviewSizeHint" ) ); 1302 (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint; 1303 (*pFilterData)[ 1 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "AllowPartialStreamRead" ) ); 1304 (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead; 1305 (*pFilterData)[ 2 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "CreateNativeLink" ) ); 1306 (*pFilterData)[ 2 ].Value <<= bCreateNativeLink; 1307 1308 mbIsPreview = sal_True; 1309 } 1310 1311 if( !GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *pStream, 1312 GRFILTER_FORMAT_DONTKNOW, NULL, 0, pFilterData ) ) 1313 { 1314 const String aUserData( pGraphic->GetUserData() ); 1315 1316 pGraphic->SetGraphic( aGraphic ); 1317 pGraphic->SetUserData( aUserData ); 1318 1319 // #142146# Graphic successfully swapped in. 1320 pRet = GRFMGR_AUTOSWAPSTREAM_LOADED; 1321 } 1322 delete pFilterData; 1323 1324 pStream->ResetError(); 1325 1326 if( aStreamInfo.mbDeleteAfterUse || aStreamInfo.mxStorageRef.is() ) 1327 { 1328 if ( aStreamInfo.mxStorageRef.is() ) 1329 { 1330 aStreamInfo.mxStorageRef->dispose(); 1331 aStreamInfo.mxStorageRef = 0; 1332 } 1333 1334 delete pStream; 1335 } 1336 } 1337 } 1338 else if( !ImpUpdateGraphicLink( sal_False ) ) 1339 { 1340 pRet = GRFMGR_AUTOSWAPSTREAM_TEMP; 1341 } 1342 else 1343 { 1344 pRet = GRFMGR_AUTOSWAPSTREAM_LOADED; 1345 } 1346 } 1347 else 1348 pRet = GRFMGR_AUTOSWAPSTREAM_TEMP; 1349 } 1350 1351 return (long)(void*) pRet; 1352 } 1353 1354 // ----------------------------------------------------------------------------- 1355 1356 // #111096# 1357 // Access to GrafAnimationAllowed flag 1358 sal_Bool SdrGrafObj::IsGrafAnimationAllowed() const 1359 { 1360 return mbGrafAnimationAllowed; 1361 } 1362 1363 void SdrGrafObj::SetGrafAnimationAllowed(sal_Bool bNew) 1364 { 1365 if(mbGrafAnimationAllowed != bNew) 1366 { 1367 mbGrafAnimationAllowed = bNew; 1368 ActionChanged(); 1369 } 1370 } 1371 1372 // #i25616# 1373 sal_Bool SdrGrafObj::IsObjectTransparent() const 1374 { 1375 if(((const SdrGrafTransparenceItem&)GetObjectItem(SDRATTR_GRAFTRANSPARENCE)).GetValue() 1376 || pGraphic->IsTransparent()) 1377 { 1378 return sal_True; 1379 } 1380 1381 return sal_False; 1382 } 1383 1384 Reference< XInputStream > SdrGrafObj::getInputStream() 1385 { 1386 Reference< XInputStream > xStream; 1387 1388 if( pModel ) 1389 { 1390 // if( !pGraphic->HasUserData() ) 1391 // pGraphic->SwapOut(); 1392 1393 // kann aus dem original Doc-Stream nachgeladen werden... 1394 if( pGraphic->HasUserData() ) 1395 { 1396 SdrDocumentStreamInfo aStreamInfo; 1397 1398 aStreamInfo.mbDeleteAfterUse = sal_False; 1399 aStreamInfo.maUserData = pGraphic->GetUserData(); 1400 1401 SvStream* pStream = pModel->GetDocumentStream( aStreamInfo ); 1402 1403 if( pStream ) 1404 xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) ); 1405 } 1406 else if( pGraphic && GetGraphic().IsLink() ) 1407 { 1408 Graphic aGraphic( GetGraphic() ); 1409 GfxLink aLink( aGraphic.GetLink() ); 1410 sal_uInt32 nSize = aLink.GetDataSize(); 1411 const void* pSourceData = (const void*)aLink.GetData(); 1412 if( nSize && pSourceData ) 1413 { 1414 sal_uInt8 * pBuffer = new sal_uInt8[ nSize ]; 1415 if( pBuffer ) 1416 { 1417 memcpy( pBuffer, pSourceData, nSize ); 1418 1419 SvMemoryStream* pStream = new SvMemoryStream( (void*)pBuffer, (sal_Size)nSize, STREAM_READ ); 1420 pStream->ObjectOwnsMemory( sal_True ); 1421 xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) ); 1422 } 1423 } 1424 } 1425 1426 if( !xStream.is() && aFileName.Len() ) 1427 { 1428 SvFileStream* pStream = new SvFileStream( aFileName, STREAM_READ ); 1429 if( pStream ) 1430 xStream.set( new utl::OInputStreamWrapper( pStream ) ); 1431 } 1432 } 1433 1434 return xStream; 1435 } 1436 1437 // eof 1438