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 _SVX_USE_UNOGLOBALS_ 32 #include <cppuhelper/typeprovider.hxx> 33 #include <com/sun/star/awt/XBitmap.hpp> 34 #include <com/sun/star/awt/Rectangle.hpp> 35 #include <com/sun/star/drawing/CircleKind.hpp> 36 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> 37 #include <vcl/svapp.hxx> 38 #include <svl/itemprop.hxx> 39 #include <svtools/fltcall.hxx> 40 #include <vos/mutex.hxx> 41 #include <editeng/unotext.hxx> 42 #include <svx/svdobj.hxx> 43 #include <svx/svdoole2.hxx> 44 #include <osl/mutex.hxx> 45 #include <comphelper/extract.hxx> 46 #include "svx/shapepropertynotifier.hxx" 47 #include <comphelper/serviceinfohelper.hxx> 48 #include <toolkit/unohlp.hxx> 49 #include <comphelper/serviceinfohelper.hxx> 50 #include <rtl/uuid.h> 51 #include <rtl/memory.h> 52 #include <vcl/gfxlink.hxx> 53 #include <vcl/virdev.hxx> 54 #include <sfx2/objsh.hxx> 55 #include <sfx2/viewsh.hxx> 56 #include "svx/svdopage.hxx" 57 #include "svx/xflbstit.hxx" 58 #include "svx/xflbmtit.hxx" 59 #include "svx/xlnstit.hxx" 60 #include "svx/xlnedit.hxx" 61 #include "svx/svdogrp.hxx" 62 #include "svx/scene3d.hxx" 63 #include "svx/svdmodel.hxx" 64 #include "svx/globl3d.hxx" 65 #include "svx/fmglob.hxx" 66 #include "svx/unopage.hxx" 67 #include "svx/view3d.hxx" 68 #include "svx/unoshape.hxx" 69 #include "svx/svxids.hrc" 70 #include "svx/unoshtxt.hxx" 71 #include "svx/svdpage.hxx" 72 #include "svx/unoshprp.hxx" 73 #include "svx/sxciaitm.hxx" // todo: remove 74 #include "svx/svdograf.hxx" 75 #include "svx/unoapi.hxx" 76 #include "svx/svdomeas.hxx" 77 #include "svx/svdpagv.hxx" 78 #include "svx/svdpool.hxx" 79 #include <tools/shl.hxx> // 80 #include "svx/dialmgr.hxx" // not nice, we need our own resources some day 81 #include "svx/dialogs.hrc" // 82 #include "svx/svdocapt.hxx" 83 #include <svx/obj3d.hxx> 84 #include <tools/diagnose_ex.h> 85 #include "svx/xflftrit.hxx" 86 #include "svx/xtable.hxx" 87 #include "svx/xbtmpit.hxx" 88 #include "svx/xflgrit.hxx" 89 #include "svx/xflhtit.hxx" 90 #include "svx/xlnedit.hxx" 91 #include "svx/xlnstit.hxx" 92 #include "svx/xlndsit.hxx" 93 #include "svx/svdglob.hxx" 94 #include "svx/svdstr.hrc" 95 #include "svx/unomaster.hxx" 96 #include <editeng/outlobj.hxx> 97 #include <basegfx/matrix/b2dhommatrix.hxx> 98 #include <basegfx/matrix/b2dhommatrixtools.hxx> 99 100 #include <vector> 101 102 // #i68523# 103 #include "svx/lathe3d.hxx" 104 #include "svx/extrud3d.hxx" 105 #include "unopolyhelper.hxx" 106 107 #include <comphelper/scopeguard.hxx> 108 #include <boost/bind.hpp> 109 110 using ::rtl::OUString; 111 using namespace ::osl; 112 using namespace ::vos; 113 using namespace ::cppu; 114 using namespace ::com::sun::star; 115 using namespace ::com::sun::star::uno; 116 using namespace ::com::sun::star::lang; 117 using namespace ::com::sun::star::container; 118 using ::svx::PropertyValueProvider; 119 using ::svx::IPropertyValueProvider; 120 121 #define QUERYINT( xint ) \ 122 if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \ 123 aAny <<= uno::Reference< xint >(this) 124 125 class GDIMetaFile; 126 class SvStream; 127 sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, 128 FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True ); 129 130 uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject ); 131 132 /*********************************************************************** 133 * class SvxShapeImpl * 134 ***********************************************************************/ 135 136 struct SvxShapeImpl 137 { 138 SvxShape& mrAntiImpl; 139 SfxItemSet* mpItemSet; 140 sal_uInt32 mnObjId; 141 SvxShapeMaster* mpMaster; 142 bool mbHasSdrObjectOwnership; 143 bool mbDisposing; 144 145 /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when 146 * a SvxShape::Create() call is executed. It is then set to the created 147 * SdrObject so a multiple call to SvxShape::Create() with same SdrObject 148 * is prohibited. 149 */ 150 ::tools::WeakReference< SdrObject > mpCreatedObj; 151 152 // for xComponent 153 ::cppu::OInterfaceContainerHelper maDisposeListeners; 154 ::svx::PropertyChangeNotifier maPropertyNotifier; 155 156 SvxShapeImpl( SvxShape& _rAntiImpl, ::osl::Mutex& _rMutex ) 157 :mrAntiImpl( _rAntiImpl ) 158 ,mpItemSet( NULL ) 159 ,mnObjId( 0 ) 160 ,mpMaster( NULL ) 161 ,mbHasSdrObjectOwnership( false ) 162 ,mbDisposing( false ) 163 ,mpCreatedObj() 164 ,maDisposeListeners( _rMutex ) 165 ,maPropertyNotifier( _rAntiImpl, _rMutex ) 166 { 167 } 168 }; 169 170 /**********************************************************************/ 171 class ShapePositionProvider : public PropertyValueProvider 172 { 173 public: 174 ShapePositionProvider( const SvxShapeImpl& _shapeImpl ) 175 :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Position" ) 176 { 177 } 178 179 protected: 180 virtual void getCurrentValue( Any& _out_rCurrentValue ) const 181 { 182 _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getPosition(); 183 } 184 }; 185 186 //---------------------------------------------------------------------- 187 class ShapeSizeProvider : public PropertyValueProvider 188 { 189 public: 190 ShapeSizeProvider( const SvxShapeImpl& _shapeImpl ) 191 :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Size" ) 192 { 193 } 194 195 protected: 196 virtual void getCurrentValue( Any& _out_rCurrentValue ) const 197 { 198 _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getSize(); 199 } 200 }; 201 202 /*********************************************************************** 203 * class SvxShape * 204 ***********************************************************************/ 205 206 DBG_NAME(SvxShape) 207 208 SvxShape::SvxShape( SdrObject* pObject ) throw() 209 : maSize(100,100) 210 , mpImpl( new SvxShapeImpl( *this, maMutex ) ) 211 , mbIsMultiPropertyCall(false) 212 , mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool())) 213 , maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE)) 214 , mpObj(pObject) 215 , mpModel(NULL) 216 , mnLockCount(0) 217 { 218 DBG_CTOR(SvxShape,NULL); 219 impl_construct(); 220 } 221 222 //---------------------------------------------------------------------- 223 SvxShape::SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries, const SvxItemPropertySet* pPropertySet ) throw() 224 : maSize(100,100) 225 , mpImpl( new SvxShapeImpl( *this, maMutex ) ) 226 , mbIsMultiPropertyCall(false) 227 , mpPropSet(pPropertySet) 228 , maPropMapEntries(pEntries) 229 , mpObj(pObject) 230 , mpModel(NULL) 231 , mnLockCount(0) 232 { 233 DBG_CTOR(SvxShape,NULL); 234 impl_construct(); 235 } 236 237 //---------------------------------------------------------------------- 238 SvxShape::SvxShape() throw() 239 : maSize(100,100) 240 , mpImpl( new SvxShapeImpl( *this, maMutex ) ) 241 , mbIsMultiPropertyCall(false) 242 , mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool())) 243 , maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE)) 244 , mpObj(NULL) 245 , mpModel(NULL) 246 , mnLockCount(0) 247 { 248 DBG_CTOR(SvxShape,NULL); 249 impl_construct(); 250 } 251 252 //---------------------------------------------------------------------- 253 SvxShape::~SvxShape() throw() 254 { 255 OGuard aGuard( Application::GetSolarMutex() ); 256 257 DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" ); 258 259 if ( mpModel ) 260 EndListening( *mpModel ); 261 262 if ( mpImpl->mpMaster ) 263 mpImpl->mpMaster->dispose(); 264 265 if ( mpObj.is() ) 266 mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); 267 268 if( HasSdrObjectOwnership() && mpObj.is() ) 269 { 270 mpImpl->mbHasSdrObjectOwnership = false; 271 SdrObject* pObject = mpObj.get(); 272 SdrObject::Free( pObject ); 273 } 274 275 delete mpImpl, mpImpl = NULL; 276 277 DBG_DTOR(SvxShape,NULL); 278 } 279 280 //---------------------------------------------------------------------- 281 282 void SvxShape::TakeSdrObjectOwnership() 283 { 284 mpImpl->mbHasSdrObjectOwnership = true; 285 } 286 287 //---------------------------------------------------------------------- 288 289 bool SvxShape::HasSdrObjectOwnership() const 290 { 291 if ( !mpImpl->mbHasSdrObjectOwnership ) 292 return false; 293 294 OSL_ENSURE( mpObj.is(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" ); 295 return mpObj.is(); 296 } 297 298 //---------------------------------------------------------------------- 299 300 void SvxShape::setShapeKind( sal_uInt32 nKind ) 301 { 302 mpImpl->mnObjId = nKind; 303 } 304 305 //---------------------------------------------------------------------- 306 307 sal_uInt32 SvxShape::getShapeKind() const 308 { 309 return mpImpl->mnObjId; 310 } 311 312 //---------------------------------------------------------------------- 313 314 void SvxShape::setMaster( SvxShapeMaster* pMaster ) 315 { 316 mpImpl->mpMaster = pMaster; 317 } 318 319 SvxShapeMaster* SvxShape::getMaster() 320 { 321 return mpImpl->mpMaster; 322 } 323 324 const SvxShapeMaster* SvxShape::getMaster() const 325 { 326 return mpImpl->mpMaster; 327 } 328 329 //---------------------------------------------------------------------- 330 331 uno::Any SAL_CALL SvxShape::queryAggregation( const uno::Type& rType ) throw (uno::RuntimeException) 332 { 333 if( mpImpl->mpMaster ) 334 { 335 uno::Any aAny; 336 if( mpImpl->mpMaster->queryAggregation( rType, aAny ) ) 337 return aAny; 338 } 339 340 return SvxShape_UnoImplHelper::queryAggregation(rType); 341 } 342 343 //---------------------------------------------------------------------- 344 const ::com::sun::star::uno::Sequence< sal_Int8 > & SvxShape::getUnoTunnelId() throw() 345 { 346 static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; 347 if( !pSeq ) 348 { 349 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); 350 if( !pSeq ) 351 { 352 static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 ); 353 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 354 pSeq = &aSeq; 355 } 356 } 357 return *pSeq; 358 } 359 360 //---------------------------------------------------------------------- 361 SvxShape* SvxShape::getImplementation( const uno::Reference< uno::XInterface >& xInt ) 362 { 363 uno::Reference< lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY ); 364 if( xUT.is() ) 365 return reinterpret_cast<SvxShape*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxShape::getUnoTunnelId()))); 366 else 367 return NULL; 368 } 369 370 //---------------------------------------------------------------------- 371 sal_Int64 SAL_CALL SvxShape::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException) \ 372 { 373 if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) 374 { 375 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this)); 376 } 377 else 378 { 379 return 0; 380 } 381 } 382 383 //---------------------------------------------------------------------- 384 SvxShape* SvxShape::GetShapeForSdrObj( SdrObject* pObj ) throw() 385 { 386 return getImplementation( pObj->getUnoShape() ); 387 } 388 389 //---------------------------------------------------------------------- 390 ::svx::PropertyChangeNotifier& SvxShape::getShapePropertyChangeNotifier() 391 { 392 return mpImpl->maPropertyNotifier; 393 } 394 395 //---------------------------------------------------------------------- 396 void SvxShape::impl_construct() 397 { 398 mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapePosition, 399 ::svx::PPropertyValueProvider( new ShapePositionProvider( *mpImpl ) ) ); 400 mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapeSize, 401 ::svx::PPropertyValueProvider( new ShapeSizeProvider( *mpImpl ) ) ); 402 403 if ( mpObj.is() ) 404 impl_initFromSdrObject(); 405 } 406 407 //---------------------------------------------------------------------- 408 void SvxShape::impl_initFromSdrObject() 409 { 410 DBG_TESTSOLARMUTEX(); 411 OSL_PRECOND( mpObj.is(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" ); 412 if ( !mpObj.is() ) 413 return; 414 415 osl_incrementInterlockedCount( &m_refCount ); 416 { 417 mpObj->setUnoShape( *this, SdrObject::GrantXShapeAccess() ); 418 } 419 osl_decrementInterlockedCount( &m_refCount ); 420 421 mpModel = mpObj->GetModel(); 422 423 // #i40944# 424 // Do not simply return when no model but do the type corrections 425 // following below. 426 if(mpModel) 427 { 428 StartListening( *mpModel ); 429 } 430 431 const sal_uInt32 nInventor = mpObj->GetObjInventor(); 432 433 // is it one of ours (svx) ? 434 if( nInventor == SdrInventor || nInventor == E3dInventor || nInventor == FmFormInventor ) 435 { 436 if(nInventor == FmFormInventor) 437 { 438 mpImpl->mnObjId = OBJ_UNO; 439 } 440 else 441 { 442 mpImpl->mnObjId = mpObj->GetObjIdentifier(); 443 if( nInventor == E3dInventor ) 444 mpImpl->mnObjId |= E3D_INVENTOR_FLAG; 445 } 446 447 switch(mpImpl->mnObjId) 448 { 449 case OBJ_CCUT: // Kreisabschnitt 450 case OBJ_CARC: // Kreisbogen 451 case OBJ_SECT: // Kreissektor 452 mpImpl->mnObjId = OBJ_CIRC; 453 break; 454 455 case E3D_SCENE_ID | E3D_INVENTOR_FLAG: 456 mpImpl->mnObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG; 457 break; 458 } 459 } 460 } 461 462 //---------------------------------------------------------------------- 463 void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) 464 { 465 DBG_TESTSOLARMUTEX(); 466 467 OSL_PRECOND( pNewObj, "SvxShape::Create: invalid new object!" ); 468 if ( !pNewObj ) 469 return; 470 471 SdrObject* pCreatedObj = mpImpl->mpCreatedObj.get(); 472 OSL_ENSURE( ( pCreatedObj == NULL ) || ( pCreatedObj == pNewObj ), 473 "SvxShape::Create: the same shape used for two different objects?! Strange ..." ); 474 475 // --> CL, OD 2005-07-19 #i52126# - correct condition 476 if ( pCreatedObj != pNewObj ) 477 // <-- 478 { 479 DBG_ASSERT( pNewObj->GetModel(), "no model for SdrObject?" ); 480 // --> CL, OD 2005-07-19 #i52126# 481 mpImpl->mpCreatedObj = pNewObj; 482 // <-- 483 484 if( mpObj.is() && mpObj->GetModel() ) 485 { 486 EndListening( *mpObj->GetModel() ); 487 } 488 489 mpObj.reset( pNewObj ); 490 491 OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" ); 492 // this was previously set in impl_initFromSdrObject, but I think it was superfluous 493 // (it definitely was in the other context where it was called, but I strongly suppose 494 // it was also superfluous when called from here) 495 impl_initFromSdrObject(); 496 497 ObtainSettingsFromPropertySet( *mpPropSet ); 498 499 // save user call 500 SdrObjUserCall* pUser = mpObj->GetUserCall(); 501 mpObj->SetUserCall(NULL); 502 503 setPosition( maPosition ); 504 setSize( maSize ); 505 506 // restore user call after we set the initial size 507 mpObj->SetUserCall( pUser ); 508 509 // if this shape was already named, use this name 510 if( maShapeName.getLength() ) 511 { 512 mpObj->SetName( maShapeName ); 513 maShapeName = OUString(); 514 } 515 } 516 } 517 518 //---------------------------------------------------------------------- 519 520 void SvxShape::ChangeModel( SdrModel* pNewModel ) 521 { 522 DBG_TESTSOLARMUTEX(); 523 if( mpObj.is() && mpObj->GetModel() ) 524 { 525 if( mpObj->GetModel() != pNewModel ) 526 { 527 EndListening( *mpObj->GetModel() ); 528 } 529 } 530 531 // --> CL, OD 2005-07-19 #i52126# - always listen to new model 532 if( pNewModel ) 533 { 534 StartListening( *pNewModel ); 535 } 536 // <-- 537 538 // HACK #i53696# ChangeModel should be virtual, but it isn't. can't change that for 2.0.1 539 SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( this ); 540 if( pShapeText ) 541 { 542 SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() ); 543 if( pTextEditSource ) 544 pTextEditSource->ChangeModel( pNewModel ); 545 } 546 547 mpModel = pNewModel; 548 549 if( mpImpl->mpMaster ) 550 mpImpl->mpMaster->modelChanged( pNewModel ); 551 } 552 553 //---------------------------------------------------------------------- 554 555 void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw() 556 { 557 DBG_TESTSOLARMUTEX(); 558 if(mpModel) 559 { 560 SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0); 561 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 562 { 563 switch(eMapUnit) 564 { 565 case SFX_MAPUNIT_TWIP : 566 { 567 rPoint.A() = MM_TO_TWIPS(rPoint.A()); 568 rPoint.B() = MM_TO_TWIPS(rPoint.B()); 569 break; 570 } 571 default: 572 { 573 DBG_ERROR("AW: Missing unit translation to PoolMetric!"); 574 } 575 } 576 } 577 } 578 } 579 580 //---------------------------------------------------------------------- 581 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 582 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw() 583 { 584 DBG_TESTSOLARMUTEX(); 585 if(mpModel) 586 { 587 SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0); 588 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 589 { 590 switch(eMapUnit) 591 { 592 case SFX_MAPUNIT_TWIP : 593 { 594 basegfx::B2DHomMatrix aTransform; 595 const double fMMToTWIPS(72.0 / 127.0); 596 597 aTransform.scale(fMMToTWIPS, fMMToTWIPS); 598 rPolyPolygon.transform(aTransform); 599 break; 600 } 601 default: 602 { 603 DBG_ERROR("Missing unit translation to PoolMetric!"); 604 } 605 } 606 } 607 } 608 } 609 // <-- 610 611 //---------------------------------------------------------------------- 612 void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw() 613 { 614 DBG_TESTSOLARMUTEX(); 615 SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM; 616 if(mpModel) 617 { 618 eMapUnit = mpModel->GetItemPool().GetMetric(0); 619 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 620 { 621 switch(eMapUnit) 622 { 623 case SFX_MAPUNIT_TWIP : 624 { 625 rPoint.A() = TWIPS_TO_MM(rPoint.A()); 626 rPoint.B() = TWIPS_TO_MM(rPoint.B()); 627 break; 628 } 629 default: 630 { 631 DBG_ERROR("AW: Missing unit translation to 100th mm!"); 632 } 633 } 634 } 635 } 636 } 637 638 //---------------------------------------------------------------------- 639 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 640 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const throw() 641 { 642 DBG_TESTSOLARMUTEX(); 643 SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM; 644 if(mpModel) 645 { 646 eMapUnit = mpModel->GetItemPool().GetMetric(0); 647 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 648 { 649 switch(eMapUnit) 650 { 651 case SFX_MAPUNIT_TWIP : 652 { 653 basegfx::B2DHomMatrix aTransform; 654 const double fTWIPSToMM(127.0 / 72.0); 655 aTransform.scale(fTWIPSToMM, fTWIPSToMM); 656 rPolyPolygon.transform(aTransform); 657 break; 658 } 659 default: 660 { 661 DBG_ERROR("Missing unit translation to 100th mm!"); 662 } 663 } 664 } 665 } 666 } 667 // <-- 668 //---------------------------------------------------------------------- 669 670 671 //---------------------------------------------------------------------- 672 void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet, 673 SfxItemSet& rSet, uno::Reference< beans::XPropertySet > xSet, const SfxItemPropertyMap* pMap ) 674 { 675 if(rPropSet.AreThereOwnUsrAnys()) 676 { 677 const SfxItemPropertyMap* pSrc = rPropSet.getPropertyMap(); 678 PropertyEntryVector_t aSrcPropVector = pSrc->getPropertyEntries(); 679 PropertyEntryVector_t::const_iterator aSrcIt = aSrcPropVector.begin(); 680 while(aSrcIt != aSrcPropVector.end()) 681 { 682 if(aSrcIt->nWID) 683 { 684 uno::Any* pUsrAny = rPropSet.GetUsrAnyForID(aSrcIt->nWID); 685 if(pUsrAny) 686 { 687 // Aequivalenten Eintrag in pDst suchen 688 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aSrcIt->sName ); 689 if(pEntry) 690 { 691 // entry found 692 if(pEntry->nWID >= OWN_ATTR_VALUE_START && pEntry->nWID <= OWN_ATTR_VALUE_END) 693 { 694 // Special ID im PropertySet, kann nur direkt am 695 // Objekt gesetzt werden+ 696 xSet->setPropertyValue( aSrcIt->sName, *pUsrAny); 697 } 698 else 699 { 700 if(rSet.GetPool()->IsWhich(pEntry->nWID)) 701 rSet.Put(rSet.GetPool()->GetDefaultItem(pEntry->nWID)); 702 // setzen 703 SvxItemPropertySet_setPropertyValue(rPropSet, pEntry, *pUsrAny, rSet); 704 } 705 } 706 } 707 } 708 709 // next entry 710 ++aSrcIt; 711 } 712 const_cast< SvxItemPropertySet& >(rPropSet).ClearAllUsrAny(); 713 } 714 } 715 716 717 void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet) 718 { 719 DBG_TESTSOLARMUTEX(); 720 if(mpObj.is() && rPropSet.AreThereOwnUsrAnys() && mpModel) 721 { 722 SfxItemSet aSet( mpModel->GetItemPool(), SDRATTR_START, SDRATTR_END, 0); 723 Reference< beans::XPropertySet > xShape( (OWeakObject*)this, UNO_QUERY ); 724 SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet, aSet, xShape, mpPropSet->getPropertyMap() ); 725 726 mpObj->SetMergedItemSetAndBroadcast(aSet); 727 728 mpObj->ApplyNotPersistAttr( aSet ); 729 } 730 } 731 732 //---------------------------------------------------------------------- 733 734 uno::Any SvxShape::GetBitmap( sal_Bool bMetaFile /* = sal_False */ ) const throw() 735 { 736 DBG_TESTSOLARMUTEX(); 737 uno::Any aAny; 738 739 if( !mpObj.is() || mpModel == NULL || !mpObj->IsInserted() || NULL == mpObj->GetPage() ) 740 return aAny; 741 742 VirtualDevice aVDev; 743 aVDev.SetMapMode(MapMode(MAP_100TH_MM)); 744 745 SdrModel* pModel = mpObj->GetModel(); 746 SdrPage* pPage = mpObj->GetPage(); 747 748 E3dView* pView = new E3dView( pModel, &aVDev ); 749 pView->hideMarkHandles(); 750 SdrPageView* pPageView = pView->ShowSdrPage(pPage); 751 752 SdrObject *pTempObj = mpObj.get(); 753 pView->MarkObj(pTempObj,pPageView); 754 755 Rectangle aRect(pTempObj->GetCurrentBoundRect()); 756 aRect.Justify(); 757 Size aSize(aRect.GetSize()); 758 759 GDIMetaFile aMtf( pView->GetAllMarkedMetaFile() ); 760 if( bMetaFile ) 761 { 762 SvMemoryStream aDestStrm( 65535, 65535 ); 763 ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); 764 const uno::Sequence<sal_Int8> aSeq( 765 static_cast< const sal_Int8* >(aDestStrm.GetData()), 766 aDestStrm.GetEndOfData()); 767 aAny.setValue( &aSeq, ::getCppuType((const uno::Sequence< sal_Int8 >*)0) ); 768 } 769 else 770 { 771 Graphic aGraph(aMtf); 772 aGraph.SetPrefSize(aSize); 773 aGraph.SetPrefMapMode(MAP_100TH_MM); 774 775 Reference< awt::XBitmap > xBmp( aGraph.GetXGraphic(), UNO_QUERY ); 776 aAny <<= xBmp; 777 } 778 779 pView->UnmarkAll(); 780 delete pView; 781 782 return aAny; 783 } 784 785 //---------------------------------------------------------------------- 786 787 uno::Sequence< uno::Type > SAL_CALL SvxShape::getTypes() 788 throw (uno::RuntimeException) 789 { 790 if( mpImpl->mpMaster ) 791 { 792 return mpImpl->mpMaster->getTypes(); 793 } 794 else 795 { 796 return _getTypes(); 797 } 798 } 799 800 //---------------------------------------------------------------------- 801 802 uno::Sequence< uno::Type > SAL_CALL SvxShape::_getTypes() 803 throw(uno::RuntimeException) 804 { 805 switch( mpImpl->mnObjId ) 806 { 807 // shapes without text 808 case OBJ_OLE2: 809 case OBJ_PAGE: 810 case OBJ_FRAME: 811 case OBJ_OLE2_PLUGIN: 812 case OBJ_OLE2_APPLET: 813 case E3D_CUBEOBJ_ID|E3D_INVENTOR_FLAG: 814 case E3D_SPHEREOBJ_ID|E3D_INVENTOR_FLAG: 815 case E3D_LATHEOBJ_ID|E3D_INVENTOR_FLAG: 816 case E3D_EXTRUDEOBJ_ID|E3D_INVENTOR_FLAG: 817 case E3D_POLYGONOBJ_ID|E3D_INVENTOR_FLAG: 818 case OBJ_MEDIA: 819 { 820 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; 821 822 if( aTypeSequence.getLength() == 0 ) 823 { 824 // Ready for multithreading; get global mutex for first call of this method only! see before 825 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 826 827 // Control these pointer again ... it can be, that another instance will be faster then these! 828 if( aTypeSequence.getLength() == 0 ) 829 { 830 aTypeSequence.realloc( 12 ); 831 uno::Type* pTypes = aTypeSequence.getArray(); 832 833 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); 834 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); 835 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); 836 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); 837 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); 838 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); 839 *pTypes++ = beans::XMultiPropertyStates::static_type(); 840 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); 841 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); 842 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); 843 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); 844 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); 845 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); 846 } 847 } 848 return aTypeSequence; 849 } 850 // group shape 851 case OBJ_GRUP: 852 { 853 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; 854 855 if( aTypeSequence.getLength() == 0 ) 856 { 857 // Ready for multithreading; get global mutex for first call of this method only! see before 858 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 859 860 // Control these pointer again ... it can be, that another instance will be faster then these! 861 if( aTypeSequence.getLength() == 0 ) 862 { 863 aTypeSequence.realloc( 14 ); 864 uno::Type* pTypes = aTypeSequence.getArray(); 865 866 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); 867 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); 868 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); 869 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); 870 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); 871 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); 872 *pTypes++ = beans::XMultiPropertyStates::static_type(); 873 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); 874 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); 875 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); 876 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); 877 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); 878 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); 879 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapes>*)0); 880 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapeGroup>*)0); 881 } 882 } 883 return aTypeSequence; 884 } 885 // connector shape 886 case OBJ_EDGE: 887 { 888 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; 889 890 if( aTypeSequence.getLength() == 0 ) 891 { 892 // Ready for multithreading; get global mutex for first call of this method only! see before 893 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 894 895 // Control these pointer again ... it can be, that another instance will be faster then these! 896 if( aTypeSequence.getLength() == 0 ) 897 { 898 aTypeSequence.realloc( 17 ); 899 uno::Type* pTypes = aTypeSequence.getArray(); 900 901 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); 902 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); 903 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); 904 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); 905 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); 906 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); 907 *pTypes++ = beans::XMultiPropertyStates::static_type(); 908 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); 909 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); 910 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); 911 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); 912 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); 913 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); 914 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XConnectorShape>*)0); 915 // from SvxUnoTextBase::getTypes() 916 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0); 917 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0); 918 *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); 919 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); 920 } 921 } 922 return aTypeSequence; 923 } 924 // control shape 925 case OBJ_UNO: 926 { 927 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; 928 929 if( aTypeSequence.getLength() == 0 ) 930 { 931 // Ready for multithreading; get global mutex for first call of this method only! see before 932 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 933 934 // Control these pointer again ... it can be, that another instance will be faster then these! 935 if( aTypeSequence.getLength() == 0 ) 936 { 937 aTypeSequence.realloc( 13 ); 938 uno::Type* pTypes = aTypeSequence.getArray(); 939 940 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); 941 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); 942 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); 943 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); 944 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); 945 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); 946 *pTypes++ = beans::XMultiPropertyStates::static_type(); 947 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); 948 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); 949 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); 950 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); 951 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); 952 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); 953 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XControlShape>*)0); 954 } 955 } 956 return aTypeSequence; 957 } 958 // 3d scene shape 959 case E3D_POLYSCENE_ID|E3D_INVENTOR_FLAG: 960 { 961 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; 962 963 if( aTypeSequence.getLength() == 0 ) 964 { 965 // Ready for multithreading; get global mutex for first call of this method only! see before 966 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 967 968 // Control these pointer again ... it can be, that another instance will be faster then these! 969 if( aTypeSequence.getLength() == 0 ) 970 { 971 aTypeSequence.realloc( 13 ); 972 uno::Type* pTypes = aTypeSequence.getArray(); 973 974 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); 975 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); 976 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); 977 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); 978 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); 979 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); 980 *pTypes++ = beans::XMultiPropertyStates::static_type(); 981 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); 982 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); 983 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); 984 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); 985 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); 986 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); 987 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapes>*)0); 988 } 989 } 990 return aTypeSequence; 991 } 992 case OBJ_CUSTOMSHAPE: 993 { 994 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; 995 996 if( aTypeSequence.getLength() == 0 ) 997 { 998 // Ready for multithreading; get global mutex for first call of this method only! see before 999 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 1000 1001 // Control these pointer again ... it can be, that another instance will be faster then these! 1002 if( aTypeSequence.getLength() == 0 ) 1003 { 1004 aTypeSequence.realloc( 16 ); 1005 uno::Type* pTypes = aTypeSequence.getArray(); 1006 1007 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); 1008 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); 1009 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); 1010 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); 1011 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); 1012 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); 1013 *pTypes++ = beans::XMultiPropertyStates::static_type(); 1014 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); 1015 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); 1016 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); 1017 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); 1018 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); 1019 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); 1020 // from SvxUnoTextBase::getTypes() 1021 *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0); 1022 *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); 1023 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); 1024 *pTypes++ = ::getCppuType(( const uno::Reference< drawing::XEnhancedCustomShapeDefaulter >*)0); 1025 } 1026 } 1027 return aTypeSequence; 1028 } 1029 // shapes with text 1030 case OBJ_RECT: 1031 case OBJ_CIRC: 1032 case OBJ_MEASURE: 1033 case OBJ_LINE: 1034 case OBJ_POLY: 1035 case OBJ_PLIN: 1036 case OBJ_PATHLINE: 1037 case OBJ_PATHFILL: 1038 case OBJ_FREELINE: 1039 case OBJ_FREEFILL: 1040 case OBJ_PATHPOLY: 1041 case OBJ_PATHPLIN: 1042 case OBJ_GRAF: 1043 case OBJ_TEXT: 1044 case OBJ_CAPTION: 1045 case OBJ_TABLE: 1046 default: 1047 { 1048 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence; 1049 1050 if( aTypeSequence.getLength() == 0 ) 1051 { 1052 // Ready for multithreading; get global mutex for first call of this method only! see before 1053 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 1054 1055 // Control these pointer again ... it can be, that another instance will be faster then these! 1056 if( aTypeSequence.getLength() == 0 ) 1057 { 1058 aTypeSequence.realloc( 16 ); 1059 uno::Type* pTypes = aTypeSequence.getArray(); 1060 1061 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0); 1062 *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0); 1063 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); 1064 *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0); 1065 // *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0); 1066 *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0); 1067 *pTypes++ = beans::XMultiPropertyStates::static_type(); 1068 *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0); 1069 *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0); 1070 *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0); 1071 *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0); 1072 *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0); 1073 *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0); 1074 // from SvxUnoTextBase::getTypes() 1075 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0); 1076 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0); 1077 *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0); 1078 *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0); 1079 } 1080 } 1081 return aTypeSequence; 1082 } 1083 } 1084 } 1085 1086 //---------------------------------------------------------------------- 1087 1088 uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId() 1089 throw (uno::RuntimeException) 1090 { 1091 static ::cppu::OImplementationId* pID = NULL ; 1092 1093 if ( pID == NULL ) 1094 { 1095 // Ready for multithreading; get global mutex for first call of this method only! see before 1096 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 1097 1098 // Control these pointer again ... it can be, that another instance will be faster then these! 1099 if ( pID == NULL ) 1100 { 1101 // Create a new static ID ... 1102 static ::cppu::OImplementationId aID( sal_False ) ; 1103 // ... and set his address to static pointer! 1104 pID = &aID ; 1105 } 1106 } 1107 1108 return pID->getImplementationId() ; 1109 } 1110 1111 //---------------------------------------------------------------------- 1112 1113 Reference< uno::XInterface > SvxShape_NewInstance() 1114 { 1115 return uno::Reference< uno::XInterface >(static_cast< OWeakObject* >( new SvxShape() ) ); 1116 } 1117 1118 //---------------------------------------------------------------------- 1119 1120 void SvxShape::onUserCall(SdrUserCallType /*_eUserCall*/, const Rectangle& /*_rNewBoundRect*/ ) 1121 { 1122 // obsolete, not called anymore 1123 } 1124 1125 //---------------------------------------------------------------------- 1126 // SfxListener 1127 //---------------------------------------------------------------------- 1128 1129 void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() 1130 { 1131 DBG_TESTSOLARMUTEX(); 1132 if( !mpObj.is() ) 1133 return; 1134 1135 // #i55919# HINT_OBJCHG is only interesting if it's for this object 1136 1137 const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); 1138 if (!pSdrHint || ( /* (pSdrHint->GetKind() != HINT_OBJREMOVED) && */ 1139 (pSdrHint->GetKind() != HINT_MODELCLEARED) && 1140 // #110094#-9 (pSdrHint->GetKind() != HINT_OBJLISTCLEAR) && 1141 ((pSdrHint->GetKind() != HINT_OBJCHG || pSdrHint->GetObject() != mpObj.get() )))) 1142 return; 1143 1144 uno::Reference< uno::XInterface > xSelf( mpObj->getWeakUnoShape() ); 1145 if( !xSelf.is() ) 1146 { 1147 mpObj.reset( NULL ); 1148 return; 1149 } 1150 1151 sal_Bool bClearMe = sal_False; 1152 1153 switch( pSdrHint->GetKind() ) 1154 { 1155 case HINT_OBJCHG: 1156 { 1157 updateShapeKind(); 1158 break; 1159 } 1160 case HINT_MODELCLEARED: 1161 { 1162 bClearMe = sal_True; 1163 mpModel = NULL; 1164 break; 1165 } 1166 default: 1167 break; 1168 }; 1169 1170 if( bClearMe ) 1171 { 1172 if( !HasSdrObjectOwnership() ) 1173 mpObj.reset( NULL ); 1174 if ( !mpImpl->mbDisposing ) 1175 dispose(); 1176 } 1177 } 1178 1179 // XShape 1180 1181 //---------------------------------------------------------------------- 1182 // The "*LogicRectHack" functions also existed in sch, and those 1183 // duplicate symbols cause Bad Things To Happen (TM) #i9462#. 1184 // Prefixing with 'svx' and marking static to make sure name collisions 1185 // do not occur. 1186 1187 static sal_Bool svx_needLogicRectHack( SdrObject* pObj ) 1188 { 1189 if( pObj->GetObjInventor() == SdrInventor) 1190 { 1191 switch(pObj->GetObjIdentifier()) 1192 { 1193 case OBJ_GRUP: 1194 case OBJ_LINE: 1195 case OBJ_POLY: 1196 case OBJ_PLIN: 1197 case OBJ_PATHLINE: 1198 case OBJ_PATHFILL: 1199 case OBJ_FREELINE: 1200 case OBJ_FREEFILL: 1201 case OBJ_SPLNLINE: 1202 case OBJ_SPLNFILL: 1203 case OBJ_EDGE: 1204 case OBJ_PATHPOLY: 1205 case OBJ_PATHPLIN: 1206 case OBJ_MEASURE: 1207 return sal_True; 1208 } 1209 } 1210 return sal_False; 1211 } 1212 1213 //---------------------------------------------------------------------- 1214 1215 static Rectangle svx_getLogicRectHack( SdrObject* pObj ) 1216 { 1217 if(svx_needLogicRectHack(pObj)) 1218 { 1219 return pObj->GetSnapRect(); 1220 } 1221 else 1222 { 1223 return pObj->GetLogicRect(); 1224 } 1225 } 1226 1227 //---------------------------------------------------------------------- 1228 1229 static void svx_setLogicRectHack( SdrObject* pObj, const Rectangle& rRect ) 1230 { 1231 if(svx_needLogicRectHack(pObj)) 1232 { 1233 pObj->SetSnapRect( rRect ); 1234 } 1235 else 1236 { 1237 pObj->SetLogicRect( rRect ); 1238 } 1239 } 1240 1241 //---------------------------------------------------------------------- 1242 1243 awt::Point SAL_CALL SvxShape::getPosition() throw(uno::RuntimeException) 1244 { 1245 OGuard aGuard( Application::GetSolarMutex() ); 1246 1247 if( mpObj.is() && mpModel) 1248 { 1249 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) ); 1250 Point aPt( aRect.Left(), aRect.Top() ); 1251 1252 // Position is relativ to anchor, so recalc to absolut position 1253 if( mpModel->IsWriter() ) 1254 aPt -= mpObj->GetAnchorPos(); 1255 1256 ForceMetricTo100th_mm(aPt); 1257 return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() ); 1258 } 1259 else 1260 { 1261 return maPosition; 1262 } 1263 } 1264 1265 //---------------------------------------------------------------------- 1266 void SAL_CALL SvxShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException) 1267 { 1268 OGuard aGuard( Application::GetSolarMutex() ); 1269 1270 if( mpObj.is() && mpModel ) 1271 { 1272 // do NOT move 3D objects, this would change the homogen 1273 // transformation matrix 1274 if(!mpObj->ISA(E3dCompoundObject)) 1275 { 1276 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) ); 1277 Point aLocalPos( Position.X, Position.Y ); 1278 ForceMetricToItemPoolMetric(aLocalPos); 1279 1280 // Position ist absolut, relativ zum Anker stellen 1281 if( mpModel->IsWriter() ) 1282 aLocalPos += mpObj->GetAnchorPos(); 1283 1284 long nDX = aLocalPos.X() - aRect.Left(); 1285 long nDY = aLocalPos.Y() - aRect.Top(); 1286 1287 mpObj->Move( Size( nDX, nDY ) ); 1288 mpModel->SetChanged(); 1289 } 1290 } 1291 1292 maPosition = Position; 1293 } 1294 1295 //---------------------------------------------------------------------- 1296 awt::Size SAL_CALL SvxShape::getSize() throw(uno::RuntimeException) 1297 { 1298 OGuard aGuard( Application::GetSolarMutex() ); 1299 1300 if( mpObj.is() && mpModel) 1301 { 1302 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) ); 1303 Size aObjSize( aRect.getWidth(), aRect.getHeight() ); 1304 ForceMetricTo100th_mm(aObjSize); 1305 return ::com::sun::star::awt::Size( aObjSize.getWidth(), aObjSize.getHeight() ); 1306 } 1307 else 1308 return maSize; 1309 } 1310 1311 //---------------------------------------------------------------------- 1312 void SAL_CALL SvxShape::setSize( const awt::Size& rSize ) 1313 throw(beans::PropertyVetoException, uno::RuntimeException) 1314 { 1315 OGuard aGuard( Application::GetSolarMutex() ); 1316 1317 if( mpObj.is() && mpModel) 1318 { 1319 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) ); 1320 Size aLocalSize( rSize.Width, rSize.Height ); 1321 ForceMetricToItemPoolMetric(aLocalSize); 1322 1323 if(mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_MEASURE ) 1324 { 1325 Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left()); 1326 Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top()); 1327 Point aPt = mpObj->GetSnapRect().TopLeft(); 1328 mpObj->Resize(aPt,aWdt,aHgt); 1329 } 1330 else 1331 { 1332 //aRect.SetSize(aLocalSize); // this call substract 1 // http://www.openoffice.org/issues/show_bug.cgi?id=83193 1333 if ( !aLocalSize.Width() ) 1334 { 1335 aRect.Right() = RECT_EMPTY; 1336 } 1337 else 1338 aRect.setWidth(aLocalSize.Width()); 1339 if ( !aLocalSize.Height() ) 1340 { 1341 aRect.Bottom() = RECT_EMPTY; 1342 } 1343 else 1344 aRect.setHeight(aLocalSize.Height()); 1345 1346 svx_setLogicRectHack( mpObj.get(), aRect ); 1347 } 1348 1349 mpModel->SetChanged(); 1350 } 1351 maSize = rSize; 1352 } 1353 1354 //---------------------------------------------------------------------- 1355 1356 // XNamed 1357 OUString SAL_CALL SvxShape::getName( ) throw(::com::sun::star::uno::RuntimeException) 1358 { 1359 OGuard aGuard( Application::GetSolarMutex() ); 1360 if( mpObj.is() ) 1361 { 1362 return mpObj->GetName(); 1363 } 1364 else 1365 { 1366 return maShapeName; 1367 } 1368 } 1369 1370 //---------------------------------------------------------------------- 1371 1372 void SAL_CALL SvxShape::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException) 1373 { 1374 OGuard aGuard( Application::GetSolarMutex() ); 1375 if( mpObj.is() ) 1376 { 1377 mpObj->SetName( aName ); 1378 } 1379 else 1380 { 1381 maShapeName = aName; 1382 } 1383 } 1384 1385 // XShapeDescriptor 1386 1387 //---------------------------------------------------------------------- 1388 OUString SAL_CALL SvxShape::getShapeType() throw(uno::RuntimeException) 1389 { 1390 if( 0 == maShapeType.getLength() ) 1391 { 1392 UHashMapEntry* pMap = pSdrShapeIdentifierMap; 1393 while ( ( pMap->nId != mpImpl->mnObjId ) && pMap->aIdentifier.getLength() ) 1394 ++pMap; 1395 1396 if ( pMap->aIdentifier.getLength() ) 1397 { 1398 return pMap->aIdentifier; 1399 } 1400 else 1401 { 1402 DBG_ERROR("[CL] unknown SdrObjekt identifier"); 1403 } 1404 } 1405 1406 return maShapeType; 1407 } 1408 1409 // XComponent 1410 1411 //---------------------------------------------------------------------- 1412 void SAL_CALL SvxShape::dispose() throw(uno::RuntimeException) 1413 { 1414 OGuard aGuard( Application::GetSolarMutex() ); 1415 1416 if( mpImpl->mbDisposing ) 1417 return; // caught a recursion 1418 1419 mpImpl->mbDisposing = true; 1420 1421 lang::EventObject aEvt; 1422 aEvt.Source = *(OWeakAggObject*) this; 1423 mpImpl->maDisposeListeners.disposeAndClear(aEvt); 1424 mpImpl->maPropertyNotifier.disposing(); 1425 1426 if ( mpObj.is() ) 1427 { 1428 bool bFreeSdrObject = false; 1429 1430 if ( mpObj->IsInserted() && mpObj->GetPage() ) 1431 { 1432 OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" ); 1433 // normally, we are allowed to free the SdrObject only if we have its ownership. 1434 // Why isn't this checked here? 1435 1436 SdrPage* pPage = mpObj->GetPage(); 1437 // SdrObject aus der Page loeschen 1438 sal_uInt32 nCount = pPage->GetObjCount(); 1439 for ( sal_uInt32 nNum = 0; nNum < nCount; ++nNum ) 1440 { 1441 if ( pPage->GetObj( nNum ) == mpObj.get() ) 1442 { 1443 OSL_VERIFY( pPage->RemoveObject( nNum ) == mpObj.get() ); 1444 bFreeSdrObject = true; 1445 break; 1446 } 1447 } 1448 } 1449 1450 mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); 1451 1452 if ( bFreeSdrObject ) 1453 { 1454 // in case we have the ownership of the SdrObject, a Free 1455 // would do nothing. So ensure the ownership is reset. 1456 mpImpl->mbHasSdrObjectOwnership = false; 1457 SdrObject* pObject = mpObj.get(); 1458 SdrObject::Free( pObject ); 1459 } 1460 } 1461 1462 if( mpModel ) 1463 { 1464 EndListening( *mpModel ); 1465 mpModel = NULL; 1466 } 1467 } 1468 1469 //---------------------------------------------------------------------- 1470 1471 void SAL_CALL SvxShape::addEventListener( const Reference< lang::XEventListener >& xListener ) 1472 throw(uno::RuntimeException) 1473 { 1474 mpImpl->maDisposeListeners.addInterface(xListener); 1475 } 1476 1477 //---------------------------------------------------------------------- 1478 1479 void SAL_CALL SvxShape::removeEventListener( const Reference< lang::XEventListener >& aListener ) throw(uno::RuntimeException) 1480 { 1481 mpImpl->maDisposeListeners.removeInterface(aListener); 1482 } 1483 1484 // XPropertySet 1485 1486 //---------------------------------------------------------------------- 1487 1488 Reference< beans::XPropertySetInfo > SAL_CALL 1489 SvxShape::getPropertySetInfo() throw(uno::RuntimeException) 1490 { 1491 if( mpImpl->mpMaster ) 1492 { 1493 return mpImpl->mpMaster->getPropertySetInfo(); 1494 } 1495 else 1496 { 1497 return _getPropertySetInfo(); 1498 } 1499 } 1500 1501 Reference< beans::XPropertySetInfo > SAL_CALL 1502 SvxShape::_getPropertySetInfo() throw(uno::RuntimeException) 1503 { 1504 return mpPropSet->getPropertySetInfo(); 1505 } 1506 1507 //---------------------------------------------------------------------- 1508 1509 void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1510 { 1511 ::osl::MutexGuard aGuard( maMutex ); 1512 mpImpl->maPropertyNotifier.addPropertyChangeListener( _propertyName, _listener ); 1513 } 1514 1515 //---------------------------------------------------------------------- 1516 1517 void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1518 { 1519 ::osl::MutexGuard aGuard( maMutex ); 1520 mpImpl->maPropertyNotifier.removePropertyChangeListener( _propertyName, _listener ); 1521 } 1522 1523 //---------------------------------------------------------------------- 1524 1525 void SAL_CALL SvxShape::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1526 { 1527 OSL_ENSURE( false, "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" ); 1528 } 1529 1530 //---------------------------------------------------------------------- 1531 1532 void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1533 { 1534 OSL_ENSURE( false, "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" ); 1535 } 1536 1537 //---------------------------------------------------------------------- 1538 1539 sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName ) 1540 { 1541 SfxItemSet aSet( mpModel->GetItemPool(), (sal_uInt16)nWID, (sal_uInt16)nWID ); 1542 1543 if( SetFillAttribute( nWID, rName, aSet, mpModel ) ) 1544 { 1545 //mpObj->SetItemSetAndBroadcast(aSet); 1546 mpObj->SetMergedItemSetAndBroadcast(aSet); 1547 1548 return sal_True; 1549 } 1550 else 1551 { 1552 return sal_False; 1553 } 1554 } 1555 1556 //---------------------------------------------------------------------- 1557 1558 sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const ::rtl::OUString& rName, SfxItemSet& rSet, SdrModel* pModel ) 1559 { 1560 // check if an item with the given name and which id is inside the models 1561 // pool or the stylesheet pool, if found its puttet in the itemse 1562 if( !SetFillAttribute( nWID, rName, rSet ) ) 1563 { 1564 // we did not find such item in one of the pools, so we check 1565 // the property lists that are loaded for the model for items 1566 // that support such. 1567 String aStrName; 1568 SvxUnogetInternalNameForItem( (sal_Int16)nWID, rName, aStrName ); 1569 1570 switch( nWID ) 1571 { 1572 case XATTR_FILLBITMAP: 1573 { 1574 XBitmapList* pBitmapList = pModel->GetBitmapList(); 1575 1576 if( !pBitmapList ) 1577 return sal_False; 1578 1579 long nPos = ((XPropertyList*)pBitmapList)->Get(aStrName); 1580 if( nPos == -1 ) 1581 return sal_False; 1582 1583 XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos ); 1584 XFillBitmapItem aBmpItem; 1585 aBmpItem.SetWhich( XATTR_FILLBITMAP ); 1586 aBmpItem.SetName( rName ); 1587 aBmpItem.SetBitmapValue( pEntry->GetXBitmap() ); 1588 rSet.Put( aBmpItem ); 1589 break; 1590 } 1591 case XATTR_FILLGRADIENT: 1592 { 1593 XGradientList* pGradientList = pModel->GetGradientList(); 1594 1595 if( !pGradientList ) 1596 return sal_False; 1597 1598 long nPos = ((XPropertyList*)pGradientList)->Get(aStrName); 1599 if( nPos == -1 ) 1600 return sal_False; 1601 1602 XGradientEntry* pEntry = pGradientList->GetGradient( nPos ); 1603 XFillGradientItem aGrdItem; 1604 aGrdItem.SetWhich( XATTR_FILLGRADIENT ); 1605 aGrdItem.SetName( rName ); 1606 aGrdItem.SetGradientValue( pEntry->GetGradient() ); 1607 rSet.Put( aGrdItem ); 1608 break; 1609 } 1610 case XATTR_FILLHATCH: 1611 { 1612 XHatchList* pHatchList = pModel->GetHatchList(); 1613 1614 if( !pHatchList ) 1615 return sal_False; 1616 1617 long nPos = ((XPropertyList*)pHatchList)->Get(aStrName); 1618 if( nPos == -1 ) 1619 return sal_False; 1620 1621 XHatchEntry* pEntry = pHatchList->GetHatch( nPos ); 1622 XFillHatchItem aHatchItem; 1623 aHatchItem.SetWhich( XATTR_FILLHATCH ); 1624 aHatchItem.SetName( rName ); 1625 aHatchItem.SetHatchValue( pEntry->GetHatch() ); 1626 rSet.Put( aHatchItem ); 1627 break; 1628 } 1629 case XATTR_LINEEND: 1630 case XATTR_LINESTART: 1631 { 1632 XLineEndList* pLineEndList = pModel->GetLineEndList(); 1633 1634 if( !pLineEndList ) 1635 return sal_False; 1636 1637 long nPos = ((XPropertyList*)pLineEndList)->Get(aStrName); 1638 if( nPos == -1 ) 1639 return sal_False; 1640 1641 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); 1642 if( XATTR_LINEEND == nWID ) 1643 { 1644 XLineEndItem aLEItem; 1645 aLEItem.SetWhich( XATTR_LINEEND ); 1646 aLEItem.SetName( rName ); 1647 aLEItem.SetLineEndValue( pEntry->GetLineEnd() ); 1648 rSet.Put( aLEItem ); 1649 } 1650 else 1651 { 1652 XLineStartItem aLSItem; 1653 aLSItem.SetWhich( XATTR_LINESTART ); 1654 aLSItem.SetName( rName ); 1655 aLSItem.SetLineStartValue( pEntry->GetLineEnd() ); 1656 rSet.Put( aLSItem ); 1657 } 1658 1659 break; 1660 } 1661 case XATTR_LINEDASH: 1662 { 1663 XDashList* pDashList = pModel->GetDashList(); 1664 1665 if( !pDashList ) 1666 return sal_False; 1667 1668 long nPos = ((XPropertyList*)pDashList)->Get(aStrName); 1669 if( nPos == -1 ) 1670 return sal_False; 1671 1672 XDashEntry* pEntry = pDashList->GetDash( nPos ); 1673 XLineDashItem aDashItem; 1674 aDashItem.SetWhich( XATTR_LINEDASH ); 1675 aDashItem.SetName( rName ); 1676 aDashItem.SetDashValue( pEntry->GetDash() ); 1677 rSet.Put( aDashItem ); 1678 break; 1679 } 1680 default: 1681 return sal_False; 1682 } 1683 } 1684 1685 return sal_True; 1686 } 1687 1688 //---------------------------------------------------------------------- 1689 1690 sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, SfxItemSet& rSet ) 1691 { 1692 String aName; 1693 SvxUnogetInternalNameForItem( (sal_Int16)nWID, rName, aName ); 1694 1695 if( aName.Len() == 0 ) 1696 { 1697 switch( nWID ) 1698 { 1699 case XATTR_LINEEND: 1700 case XATTR_LINESTART: 1701 { 1702 const String aEmpty; 1703 const basegfx::B2DPolyPolygon aEmptyPoly; 1704 if( nWID == XATTR_LINEEND ) 1705 rSet.Put( XLineEndItem( aEmpty, aEmptyPoly ) ); 1706 else 1707 rSet.Put( XLineStartItem( aEmpty, aEmptyPoly ) ); 1708 1709 return sal_True; 1710 } 1711 case XATTR_FILLFLOATTRANSPARENCE: 1712 { 1713 // #85953# Set a disabled XFillFloatTransparenceItem 1714 rSet.Put(XFillFloatTransparenceItem()); 1715 1716 return sal_True; 1717 } 1718 } 1719 1720 return sal_False; 1721 } 1722 1723 const SfxItemPool* pPool = rSet.GetPool(); 1724 1725 const String aSearchName( aName ); 1726 const sal_uInt32 nCount = pPool->GetItemCount2((sal_uInt16)nWID); 1727 const NameOrIndex* pItem; 1728 1729 for( sal_uInt32 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ ) 1730 { 1731 pItem = (NameOrIndex*)pPool->GetItem2((sal_uInt16)nWID, nSurrogate); 1732 if( pItem && ( pItem->GetName() == aSearchName ) ) 1733 { 1734 rSet.Put( *pItem ); 1735 return sal_True; 1736 } 1737 } 1738 1739 return sal_False; 1740 } 1741 1742 //---------------------------------------------------------------------- 1743 1744 // static 1745 /* os: unused function 1746 uno::Any SAL_CALL SvxShape::GetFillAttributeByName( 1747 const ::rtl::OUString& rPropertyName, const ::rtl::OUString& rName, SdrModel* pModel ) 1748 { 1749 uno::Any aResult; 1750 DBG_ASSERT( pModel, "Invalid Model in GetFillAttributeByName()" ); 1751 if( ! pModel ) 1752 return aResult; 1753 1754 sal_Int16 nWhich = SvxUnoGetWhichIdForNamedProperty( rPropertyName ); 1755 1756 // search pool for item 1757 const SfxItemPool& rPool = pModel->GetItemPool(); 1758 1759 const String aSearchName( rName ); 1760 const sal_uInt32 nCount = rPool.GetItemCount((sal_uInt16)nWhich); 1761 const NameOrIndex* pItem = 0; 1762 bool bFound = false; 1763 1764 for( sal_uInt32 nSurrogate = 0; ! bFound && nSurrogate < nCount; nSurrogate++ ) 1765 { 1766 pItem = (NameOrIndex*)rPool.GetItem((sal_uInt16)nWhich, nSurrogate); 1767 if( pItem && ( pItem->GetName() == aSearchName ) ) 1768 { 1769 bFound = true; 1770 } 1771 } 1772 1773 // check the property lists that are loaded for the model for items that 1774 // support such. 1775 String aStrName; 1776 SvxUnogetInternalNameForItem( nWhich, rName, aStrName ); 1777 1778 switch( nWhich ) 1779 { 1780 case XATTR_FILLBITMAP: 1781 { 1782 XFillBitmapItem aBmpItem; 1783 if( ! bFound ) 1784 { 1785 XBitmapList* pBitmapList = pModel->GetBitmapList(); 1786 1787 if( !pBitmapList ) 1788 break; 1789 1790 long nPos = ((XPropertyList*)pBitmapList)->Get(aStrName); 1791 if( nPos == -1 ) 1792 break; 1793 1794 XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos ); 1795 aBmpItem.SetWhich( XATTR_FILLBITMAP ); 1796 aBmpItem.SetName( rName ); 1797 aBmpItem.SetBitmapValue( pEntry->GetXBitmap() ); 1798 pItem = & aBmpItem; 1799 } 1800 DBG_ASSERT( pItem, "Invalid Item" ); 1801 if( pItem ) 1802 pItem->QueryValue( aResult ); // default: XBitmap. MID_GRAFURL instead? 1803 } 1804 break; 1805 1806 case XATTR_FILLGRADIENT: 1807 { 1808 XFillGradientItem aGrdItem; 1809 if( ! bFound ) 1810 { 1811 XGradientList* pGradientList = pModel->GetGradientList(); 1812 1813 if( !pGradientList ) 1814 break; 1815 1816 long nPos = ((XPropertyList*)pGradientList)->Get(aStrName); 1817 if( nPos == -1 ) 1818 break; 1819 1820 XGradientEntry* pEntry = pGradientList->GetGradient( nPos ); 1821 aGrdItem.SetWhich( XATTR_FILLGRADIENT ); 1822 aGrdItem.SetName( rName ); 1823 aGrdItem.SetGradientValue( pEntry->GetGradient() ); 1824 pItem = & aGrdItem; 1825 } 1826 DBG_ASSERT( pItem, "Invalid Item" ); 1827 if( pItem ) 1828 pItem->QueryValue( aResult, MID_FILLGRADIENT ); 1829 } 1830 break; 1831 1832 case XATTR_FILLHATCH: 1833 { 1834 XFillHatchItem aHatchItem; 1835 if( ! bFound ) 1836 { 1837 XHatchList* pHatchList = pModel->GetHatchList(); 1838 1839 if( !pHatchList ) 1840 break; 1841 1842 long nPos = ((XPropertyList*)pHatchList)->Get(aStrName); 1843 if( nPos == -1 ) 1844 break; 1845 1846 XHatchEntry* pEntry = pHatchList->GetHatch( nPos ); 1847 aHatchItem.SetWhich( XATTR_FILLHATCH ); 1848 aHatchItem.SetName( rName ); 1849 aHatchItem.SetHatchValue( pEntry->GetHatch() ); 1850 pItem = & aHatchItem; 1851 } 1852 DBG_ASSERT( pItem, "Invalid Item" ); 1853 if( pItem ) 1854 pItem->QueryValue( aResult, MID_FILLHATCH ); 1855 } 1856 break; 1857 1858 case XATTR_LINEEND: 1859 case XATTR_LINESTART: 1860 { 1861 if( ! bFound ) 1862 { 1863 XLineEndList* pLineEndList = pModel->GetLineEndList(); 1864 1865 if( !pLineEndList ) 1866 break; 1867 1868 long nPos = ((XPropertyList*)pLineEndList)->Get(aStrName); 1869 if( nPos == -1 ) 1870 break; 1871 1872 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos ); 1873 if( nWhich == XATTR_LINEEND ) 1874 { 1875 XLineEndItem aLEItem; 1876 aLEItem.SetWhich( XATTR_LINEEND ); 1877 aLEItem.SetName( rName ); 1878 aLEItem.SetLineEndValue( pEntry->GetLineEnd() ); 1879 aLEItem.QueryValue( aResult ); 1880 } 1881 else 1882 { 1883 XLineStartItem aLSItem; 1884 aLSItem.SetWhich( XATTR_LINESTART ); 1885 aLSItem.SetName( rName ); 1886 aLSItem.SetLineStartValue( pEntry->GetLineEnd() ); 1887 aLSItem.QueryValue( aResult ); 1888 } 1889 } 1890 else 1891 { 1892 DBG_ASSERT( pItem, "Invalid Item" ); 1893 if( pItem ) 1894 pItem->QueryValue( aResult ); 1895 } 1896 } 1897 break; 1898 1899 case XATTR_LINEDASH: 1900 { 1901 XLineDashItem aDashItem; 1902 if( ! bFound ) 1903 { 1904 XDashList* pDashList = pModel->GetDashList(); 1905 1906 if( !pDashList ) 1907 break; 1908 1909 long nPos = ((XPropertyList*)pDashList)->Get(aStrName); 1910 if( nPos == -1 ) 1911 break; 1912 1913 XDashEntry* pEntry = pDashList->GetDash( nPos ); 1914 aDashItem.SetWhich( XATTR_LINEDASH ); 1915 aDashItem.SetName( rName ); 1916 aDashItem.SetDashValue( pEntry->GetDash() ); 1917 pItem = & aDashItem; 1918 } 1919 DBG_ASSERT( pItem, "Invalid Item" ); 1920 if( pItem ) 1921 pItem->QueryValue( aResult, MID_LINEDASH ); 1922 } 1923 break; 1924 } 1925 1926 return aResult; 1927 } */ 1928 1929 //---------------------------------------------------------------------- 1930 1931 void SAL_CALL SvxShape::setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal ) 1932 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 1933 { 1934 if( mpImpl->mpMaster ) 1935 { 1936 mpImpl->mpMaster->setPropertyValue( rPropertyName, rVal ); 1937 } 1938 else 1939 { 1940 _setPropertyValue( rPropertyName, rVal ); 1941 } 1942 } 1943 1944 void SAL_CALL SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal ) 1945 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 1946 { 1947 OGuard aGuard( Application::GetSolarMutex() ); 1948 1949 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName); 1950 1951 if( mpObj.is() && mpModel ) 1952 { 1953 if( pMap == NULL ) 1954 throw beans::UnknownPropertyException(); 1955 1956 if( (pMap->nFlags & beans::PropertyAttribute::READONLY ) != 0 ) 1957 throw beans::PropertyVetoException(); 1958 1959 mpModel->SetChanged(); 1960 1961 if(!setPropertyValueImpl( rPropertyName, pMap, rVal ) ) 1962 { 1963 DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST, "Not persist item not handled!" ); 1964 DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" ); 1965 1966 sal_Bool bIsNotPersist = pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST && pMap->nWID != SDRATTR_TEXTDIRECTION; 1967 1968 if( pMap->nWID == SDRATTR_ECKENRADIUS ) 1969 { 1970 sal_Int32 nCornerRadius = 0; 1971 if( !(rVal >>= nCornerRadius) || (nCornerRadius < 0) || (nCornerRadius > 5000000)) 1972 throw IllegalArgumentException(); 1973 } 1974 1975 SfxItemSet* pSet; 1976 if( mbIsMultiPropertyCall && !bIsNotPersist ) 1977 { 1978 if( mpImpl->mpItemSet == NULL ) 1979 { 1980 pSet = mpImpl->mpItemSet = mpObj->GetMergedItemSet().Clone(); 1981 } 1982 else 1983 { 1984 pSet = mpImpl->mpItemSet; 1985 } 1986 } 1987 else 1988 { 1989 pSet = new SfxItemSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID); 1990 } 1991 1992 if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET ) 1993 pSet->Put(mpObj->GetMergedItem(pMap->nWID)); 1994 1995 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( *pSet, pMap, rVal, *pSet )) 1996 { 1997 if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET ) 1998 { 1999 if(bIsNotPersist) 2000 { 2001 // Not-Persistant Attribute, hole diese extra 2002 mpObj->TakeNotPersistAttr(*pSet, sal_False); 2003 } 2004 } 2005 2006 if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET ) 2007 { 2008 // Default aus ItemPool holen 2009 if(mpModel->GetItemPool().IsWhich(pMap->nWID)) 2010 pSet->Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID)); 2011 } 2012 2013 if( pSet->GetItemState( pMap->nWID ) == SFX_ITEM_SET ) 2014 { 2015 SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rVal, *pSet ); 2016 } 2017 } 2018 2019 if(bIsNotPersist) 2020 { 2021 // Not-Persist Attribute extra setzen 2022 mpObj->ApplyNotPersistAttr( *pSet ); 2023 delete pSet; 2024 } 2025 else 2026 { 2027 // if we have a XMultiProperty call then the item set 2028 // will be set in setPropertyValues later 2029 if( !mbIsMultiPropertyCall ) 2030 { 2031 mpObj->SetMergedItemSetAndBroadcast( *pSet ); 2032 2033 delete pSet; 2034 } 2035 } 2036 return; 2037 } 2038 } 2039 else 2040 { 2041 // since we have no actual sdr object right now 2042 // remember all properties in a list. These 2043 // properties will be set when the sdr object is 2044 // created 2045 2046 if(pMap && pMap->nWID) 2047 // Fixme: We should throw a UnknownPropertyException here. 2048 // But since this class is aggregated from classes 2049 // that support additional properties that we don't 2050 // know here we silently store *all* properties, even 2051 // if they may be not supported after creation 2052 mpPropSet->setPropertyValue( pMap, rVal ); 2053 } 2054 } 2055 2056 //---------------------------------------------------------------------- 2057 2058 uno::Any SAL_CALL SvxShape::getPropertyValue( const OUString& PropertyName ) 2059 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 2060 { 2061 if ( mpImpl->mpMaster ) 2062 return mpImpl->mpMaster->getPropertyValue( PropertyName ); 2063 else 2064 return _getPropertyValue( PropertyName ); 2065 } 2066 2067 //---------------------------------------------------------------------- 2068 2069 uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName ) 2070 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 2071 { 2072 OGuard aGuard( Application::GetSolarMutex() ); 2073 2074 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName); 2075 2076 uno::Any aAny; 2077 if( mpObj.is() && mpModel ) 2078 { 2079 if(pMap == NULL ) 2080 throw beans::UnknownPropertyException(); 2081 2082 if( !getPropertyValueImpl( PropertyName, pMap, aAny ) ) 2083 { 2084 DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || (pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST), "Not persist item not handled!" ); 2085 DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" ); 2086 2087 SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID); 2088 aSet.Put(mpObj->GetMergedItem(pMap->nWID)); 2089 2090 if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny )) 2091 return aAny; 2092 2093 if(!aSet.Count()) 2094 { 2095 if(pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST) 2096 { 2097 // Not-Persistant Attribute, hole diese extra 2098 mpObj->TakeNotPersistAttr(aSet, sal_False); 2099 } 2100 } 2101 2102 if(!aSet.Count()) 2103 { 2104 // Default aus ItemPool holen 2105 if(mpModel->GetItemPool().IsWhich(pMap->nWID)) 2106 aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID)); 2107 } 2108 2109 if(aSet.Count()) 2110 aAny = GetAnyForItem( aSet, pMap ); 2111 } 2112 } 2113 else 2114 { 2115 2116 // Fixme: we should return default values for OWN_ATTR ! 2117 2118 if(pMap && pMap->nWID) 2119 // FixMe: see setPropertyValue 2120 aAny = mpPropSet->getPropertyValue( pMap ); 2121 2122 } 2123 return aAny; 2124 } 2125 2126 //---------------------------------------------------------------------- 2127 2128 // XMultiPropertySet 2129 void SAL_CALL SvxShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) 2130 { 2131 OGuard aSolarGuard( Application::GetSolarMutex() ); 2132 2133 const sal_Int32 nCount = aPropertyNames.getLength(); 2134 const OUString* pNames = aPropertyNames.getConstArray(); 2135 2136 const uno::Any* pValues = aValues.getConstArray(); 2137 2138 // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are 2139 // reseted even when an execption is thrown 2140 const ::comphelper::ScopeGuard aGuard( boost::bind( &SvxShape::endSetPropertyValues, this ) ); 2141 2142 mbIsMultiPropertyCall = sal_True; 2143 2144 if( mpImpl->mpMaster ) 2145 { 2146 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ ) 2147 { 2148 try 2149 { 2150 setPropertyValue( *pNames, *pValues ); 2151 } 2152 catch( beans::UnknownPropertyException& e ) 2153 { 2154 (void)e; 2155 } 2156 catch( uno::Exception& ex ) 2157 { 2158 (void)ex; 2159 } 2160 } 2161 } 2162 else 2163 { 2164 uno::Reference< beans::XPropertySet > xSet; 2165 queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ) >>= xSet; 2166 2167 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ ) 2168 { 2169 try 2170 { 2171 xSet->setPropertyValue( *pNames, *pValues ); 2172 } 2173 catch( beans::UnknownPropertyException& e ) 2174 { 2175 (void)e; 2176 } 2177 catch( uno::Exception& ex ) 2178 { 2179 (void)ex; 2180 } 2181 } 2182 } 2183 2184 if( mpImpl->mpItemSet && mpObj.is() ) 2185 mpObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet ); 2186 } 2187 2188 //---------------------------------------------------------------------- 2189 2190 void SvxShape::endSetPropertyValues() 2191 { 2192 mbIsMultiPropertyCall = sal_False; 2193 if( mpImpl->mpItemSet ) 2194 { 2195 delete mpImpl->mpItemSet; 2196 mpImpl->mpItemSet = 0; 2197 } 2198 } 2199 2200 //---------------------------------------------------------------------- 2201 2202 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL SvxShape::getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException) 2203 { 2204 const sal_Int32 nCount = aPropertyNames.getLength(); 2205 const OUString* pNames = aPropertyNames.getConstArray(); 2206 2207 uno::Sequence< uno::Any > aRet( nCount ); 2208 uno::Any* pValue = aRet.getArray();; 2209 2210 if( mpImpl->mpMaster ) 2211 { 2212 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ ) 2213 { 2214 try 2215 { 2216 *pValue = getPropertyValue( *pNames ); 2217 } 2218 catch( uno::Exception& ) 2219 { 2220 DBG_ERROR( "SvxShape::getPropertyValues, unknown property asked" ); 2221 } 2222 } 2223 } 2224 else 2225 { 2226 uno::Reference< beans::XPropertySet > xSet; 2227 queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ) >>= xSet; 2228 2229 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ ) 2230 { 2231 try 2232 { 2233 *pValue = xSet->getPropertyValue( *pNames ); 2234 } 2235 catch( uno::Exception& ) 2236 { 2237 DBG_ERROR( "SvxShape::getPropertyValues, unknown property asked" ); 2238 } 2239 } 2240 } 2241 2242 return aRet; 2243 } 2244 2245 void SAL_CALL SvxShape::addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException) 2246 { 2247 } 2248 2249 void SAL_CALL SvxShape::removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException) 2250 { 2251 } 2252 2253 void SAL_CALL SvxShape::firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException) 2254 { 2255 } 2256 2257 //---------------------------------------------------------------------- 2258 2259 uno::Any SvxShape::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap ) const 2260 { 2261 DBG_TESTSOLARMUTEX(); 2262 uno::Any aAny; 2263 2264 switch(pMap->nWID) 2265 { 2266 case SDRATTR_CIRCSTARTANGLE: 2267 { 2268 const SfxPoolItem* pPoolItem=NULL; 2269 if(aSet.GetItemState(SDRATTR_CIRCSTARTANGLE,sal_False,&pPoolItem)==SFX_ITEM_SET) 2270 { 2271 sal_Int32 nAngle = ((SdrCircStartAngleItem*)pPoolItem)->GetValue(); 2272 aAny <<= nAngle; 2273 } 2274 break; 2275 } 2276 2277 case SDRATTR_CIRCENDANGLE: 2278 { 2279 const SfxPoolItem* pPoolItem=NULL; 2280 if (aSet.GetItemState(SDRATTR_CIRCENDANGLE,sal_False,&pPoolItem)==SFX_ITEM_SET) 2281 { 2282 sal_Int32 nAngle = ((SdrCircEndAngleItem*)pPoolItem)->GetValue(); 2283 aAny <<= nAngle; 2284 } 2285 break; 2286 } 2287 2288 case SDRATTR_CIRCKIND: 2289 { 2290 if( mpObj->GetObjInventor() == SdrInventor) 2291 { 2292 drawing::CircleKind eKind; 2293 switch(mpObj->GetObjIdentifier()) 2294 { 2295 case OBJ_CIRC: // Kreis, Ellipse 2296 eKind = drawing::CircleKind_FULL; 2297 break; 2298 case OBJ_CCUT: // Kreisabschnitt 2299 eKind = drawing::CircleKind_CUT; 2300 break; 2301 case OBJ_CARC: // Kreisbogen 2302 eKind = drawing::CircleKind_ARC; 2303 break; 2304 case OBJ_SECT: // Kreissektor 2305 eKind = drawing::CircleKind_SECTION; 2306 break; 2307 } 2308 aAny <<= eKind; 2309 } 2310 break; 2311 } 2312 default: 2313 { 2314 // Hole Wert aus ItemSet 2315 aAny = SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet ); 2316 2317 if( *pMap->pType != aAny.getValueType() ) 2318 { 2319 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here 2320 if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) ) 2321 { 2322 sal_Int32 nValue = 0; 2323 aAny >>= nValue; 2324 aAny <<= (sal_Int16)nValue; 2325 } 2326 else 2327 { 2328 DBG_ERROR("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" ); 2329 } 2330 } 2331 2332 } 2333 } 2334 2335 return aAny; 2336 } 2337 2338 //---------------------------------------------------------------------- 2339 2340 // XPropertyState 2341 beans::PropertyState SAL_CALL SvxShape::getPropertyState( const OUString& PropertyName ) 2342 throw(beans::UnknownPropertyException, uno::RuntimeException) 2343 { 2344 if( mpImpl->mpMaster ) 2345 { 2346 return mpImpl->mpMaster->getPropertyState( PropertyName ); 2347 } 2348 else 2349 { 2350 return _getPropertyState( PropertyName ); 2351 } 2352 } 2353 2354 beans::PropertyState SAL_CALL SvxShape::_getPropertyState( const OUString& PropertyName ) 2355 throw(beans::UnknownPropertyException, uno::RuntimeException) 2356 { 2357 OGuard aGuard( Application::GetSolarMutex() ); 2358 2359 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName); 2360 2361 if( !mpObj.is() || pMap == NULL ) 2362 throw beans::UnknownPropertyException(); 2363 2364 beans::PropertyState eState; 2365 if( !getPropertyStateImpl( pMap, eState ) ) 2366 { 2367 const SfxItemSet& rSet = mpObj->GetMergedItemSet(); 2368 2369 switch( rSet.GetItemState( pMap->nWID, sal_False ) ) 2370 { 2371 case SFX_ITEM_READONLY: 2372 case SFX_ITEM_SET: 2373 eState = beans::PropertyState_DIRECT_VALUE; 2374 break; 2375 case SFX_ITEM_DEFAULT: 2376 eState = beans::PropertyState_DEFAULT_VALUE; 2377 break; 2378 // case SFX_ITEM_UNKNOWN: 2379 // case SFX_ITEM_DONTCARE: 2380 // case SFX_ITEM_DISABLED: 2381 default: 2382 eState = beans::PropertyState_AMBIGUOUS_VALUE; 2383 break; 2384 } 2385 2386 // if a item is set, this doesn't mean we want it :) 2387 if( ( beans::PropertyState_DIRECT_VALUE == eState ) ) 2388 { 2389 switch( pMap->nWID ) 2390 { 2391 // the following items are disabled by changing the 2392 // fill style or the line style. so there is no need 2393 // to export items without names which should be empty 2394 case XATTR_FILLBITMAP: 2395 case XATTR_FILLGRADIENT: 2396 case XATTR_FILLHATCH: 2397 case XATTR_LINEDASH: 2398 { 2399 NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID); 2400 if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) ) 2401 eState = beans::PropertyState_DEFAULT_VALUE; 2402 } 2403 break; 2404 2405 // #i36115# 2406 // If e.g. the LineStart is on NONE and thus the string has length 0, it still 2407 // may be a hard attribute covering the set LineStart of the parent (Style). 2408 // #i37644# 2409 // same is for fill float transparency 2410 case XATTR_LINEEND: 2411 case XATTR_LINESTART: 2412 case XATTR_FILLFLOATTRANSPARENCE: 2413 { 2414 NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((sal_uInt16)pMap->nWID); 2415 if( ( pItem == NULL ) ) 2416 eState = beans::PropertyState_DEFAULT_VALUE; 2417 } 2418 break; 2419 } 2420 } 2421 } 2422 return eState; 2423 } 2424 2425 //---------------------------------------------------------------------- 2426 2427 bool SvxShape::setPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) 2428 { 2429 switch( pProperty->nWID ) 2430 { 2431 case OWN_ATTR_CAPTION_POINT: 2432 { 2433 awt::Point aPnt; 2434 if( rValue >>= aPnt ) 2435 { 2436 Point aVclPoint( aPnt.X, aPnt.Y ); 2437 2438 // #90763# position is relative to top left, make it absolute 2439 basegfx::B2DPolyPolygon aNewPolyPolygon; 2440 basegfx::B2DHomMatrix aNewHomogenMatrix; 2441 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); 2442 2443 aVclPoint.X() += basegfx::fround(aNewHomogenMatrix.get(0, 2)); 2444 aVclPoint.Y() += basegfx::fround(aNewHomogenMatrix.get(1, 2)); 2445 2446 // #88657# metric of pool maybe twips (writer) 2447 ForceMetricToItemPoolMetric(aVclPoint); 2448 2449 // #88491# position relative to anchor 2450 if( mpModel->IsWriter() ) 2451 { 2452 aVclPoint += mpObj->GetAnchorPos(); 2453 } 2454 2455 ((SdrCaptionObj*)mpObj.get())->SetTailPos(aVclPoint); 2456 2457 return true; 2458 } 2459 break; 2460 } 2461 case OWN_ATTR_TRANSFORMATION: 2462 { 2463 drawing::HomogenMatrix3 aMatrix; 2464 if(rValue >>= aMatrix) 2465 { 2466 basegfx::B2DPolyPolygon aNewPolyPolygon; 2467 basegfx::B2DHomMatrix aNewHomogenMatrix; 2468 2469 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); 2470 2471 aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1); 2472 aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2); 2473 aNewHomogenMatrix.set(0, 2, aMatrix.Line1.Column3); 2474 aNewHomogenMatrix.set(1, 0, aMatrix.Line2.Column1); 2475 aNewHomogenMatrix.set(1, 1, aMatrix.Line2.Column2); 2476 aNewHomogenMatrix.set(1, 2, aMatrix.Line2.Column3); 2477 aNewHomogenMatrix.set(2, 0, aMatrix.Line3.Column1); 2478 aNewHomogenMatrix.set(2, 1, aMatrix.Line3.Column2); 2479 aNewHomogenMatrix.set(2, 2, aMatrix.Line3.Column3); 2480 2481 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); 2482 return true; 2483 } 2484 break; 2485 } 2486 2487 case OWN_ATTR_ZORDER: 2488 { 2489 sal_Int32 nNewOrdNum = 0; 2490 if(rValue >>= nNewOrdNum) 2491 { 2492 SdrObjList* pObjList = mpObj->GetObjList(); 2493 if( pObjList ) 2494 { 2495 #ifdef DBG_UTIL 2496 SdrObject* pCheck = 2497 #endif 2498 pObjList->SetObjectOrdNum( mpObj->GetOrdNum(), (sal_uIntPtr)nNewOrdNum ); 2499 DBG_ASSERT( pCheck == mpObj.get(), "GetOrdNum() failed!" ); 2500 } 2501 return true; 2502 } 2503 break; 2504 } 2505 case OWN_ATTR_FRAMERECT: 2506 { 2507 awt::Rectangle aUnoRect; 2508 if(rValue >>= aUnoRect) 2509 { 2510 Point aTopLeft( aUnoRect.X, aUnoRect.Y ); 2511 Size aObjSize( aUnoRect.Width, aUnoRect.Height ); 2512 ForceMetricToItemPoolMetric(aTopLeft); 2513 ForceMetricToItemPoolMetric(aObjSize); 2514 Rectangle aRect; 2515 aRect.SetPos(aTopLeft); 2516 aRect.SetSize(aObjSize); 2517 mpObj->SetSnapRect(aRect); 2518 return true; 2519 } 2520 break; 2521 } 2522 case OWN_ATTR_MIRRORED: 2523 { 2524 sal_Bool bMirror = sal_Bool(); 2525 if(rValue >>= bMirror ) 2526 { 2527 SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( mpObj.get() ); 2528 if( pObj ) 2529 pObj->SetMirrored(bMirror); 2530 return true; 2531 } 2532 break; 2533 } 2534 case OWN_ATTR_EDGE_START_OBJ: 2535 case OWN_ATTR_EDGE_END_OBJ: 2536 case OWN_ATTR_GLUEID_HEAD: 2537 case OWN_ATTR_GLUEID_TAIL: 2538 case OWN_ATTR_EDGE_START_POS: 2539 case OWN_ATTR_EDGE_END_POS: 2540 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: 2541 { 2542 SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(mpObj.get()); 2543 if(pEdgeObj) 2544 { 2545 switch(pProperty->nWID) 2546 { 2547 case OWN_ATTR_EDGE_START_OBJ: 2548 case OWN_ATTR_EDGE_END_OBJ: 2549 { 2550 Reference< drawing::XShape > xShape; 2551 if( rValue >>= xShape ) 2552 { 2553 SdrObject* pNode = GetSdrObjectFromXShape( xShape ); 2554 if( pNode ) 2555 { 2556 pEdgeObj->ConnectToNode( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, pNode ); 2557 pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, -1 ); 2558 return true; 2559 } 2560 } 2561 break; 2562 } 2563 2564 case OWN_ATTR_EDGE_START_POS: 2565 case OWN_ATTR_EDGE_END_POS: 2566 { 2567 awt::Point aUnoPoint; 2568 if( rValue >>= aUnoPoint ) 2569 { 2570 Point aPoint( aUnoPoint.X, aUnoPoint.Y ); 2571 2572 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 2573 // perform metric change before applying anchor position, 2574 // because the anchor position is in pool metric. 2575 ForceMetricToItemPoolMetric( aPoint ); 2576 // <-- 2577 if( mpModel->IsWriter() ) 2578 aPoint += mpObj->GetAnchorPos(); 2579 2580 pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint ); 2581 return true; 2582 } 2583 break; 2584 } 2585 2586 case OWN_ATTR_GLUEID_HEAD: 2587 case OWN_ATTR_GLUEID_TAIL: 2588 { 2589 sal_Int32 nId = 0; 2590 if( rValue >>= nId ) 2591 { 2592 pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD, nId ); 2593 return true; 2594 } 2595 break; 2596 } 2597 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: 2598 { 2599 drawing::PolyPolygonBezierCoords aPolyPoly; 2600 if ( rValue >>= aPolyPoly ) 2601 { 2602 basegfx::B2DPolyPolygon aNewPolyPolygon( SvxConvertPolyPolygonBezierToB2DPolyPolygon( &aPolyPoly ) ); 2603 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 2604 ForceMetricToItemPoolMetric( aNewPolyPolygon ); 2605 // <-- 2606 if( mpModel->IsWriter() ) 2607 { 2608 Point aPoint( mpObj->GetAnchorPos() ); 2609 aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y())); 2610 } 2611 pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon ); 2612 return true; 2613 } 2614 } 2615 } 2616 } 2617 break; 2618 } 2619 case OWN_ATTR_MEASURE_START_POS: 2620 case OWN_ATTR_MEASURE_END_POS: 2621 { 2622 SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(mpObj.get()); 2623 awt::Point aUnoPoint; 2624 if(pMeasureObj && ( rValue >>= aUnoPoint ) ) 2625 { 2626 Point aPoint( aUnoPoint.X, aUnoPoint.Y ); 2627 2628 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051 2629 ForceMetricToItemPoolMetric( aPoint ); 2630 // <-- 2631 if( mpModel->IsWriter() ) 2632 aPoint += mpObj->GetAnchorPos(); 2633 2634 pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0L : 1L ); 2635 pMeasureObj->SetChanged(); 2636 pMeasureObj->BroadcastObjectChange(); 2637 return true; 2638 } 2639 break; 2640 } 2641 case OWN_ATTR_FILLBMP_MODE: 2642 { 2643 drawing::BitmapMode eMode; 2644 if(!(rValue >>= eMode) ) 2645 { 2646 sal_Int32 nMode = 0; 2647 if(!(rValue >>= nMode)) 2648 break; 2649 2650 eMode = (drawing::BitmapMode)nMode; 2651 } 2652 mpObj->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) ); 2653 mpObj->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) ); 2654 return true; 2655 } 2656 2657 case SDRATTR_LAYERID: 2658 { 2659 sal_Int16 nLayerId = sal_Int16(); 2660 if( rValue >>= nLayerId ) 2661 { 2662 SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID((unsigned char)nLayerId); 2663 if( pLayer ) 2664 { 2665 mpObj->SetLayer((unsigned char)nLayerId); 2666 return true; 2667 } 2668 } 2669 break; 2670 } 2671 2672 case SDRATTR_LAYERNAME: 2673 { 2674 OUString aLayerName; 2675 if( rValue >>= aLayerName ) 2676 { 2677 const SdrLayer* pLayer=mpModel->GetLayerAdmin().GetLayer(aLayerName, sal_True); 2678 if( pLayer != NULL ) 2679 { 2680 mpObj->SetLayer( pLayer->GetID() ); 2681 return true; 2682 } 2683 } 2684 break; 2685 } 2686 case SDRATTR_ROTATEANGLE: 2687 { 2688 sal_Int32 nAngle = 0; 2689 if( rValue >>= nAngle ) 2690 { 2691 Point aRef1(mpObj->GetSnapRect().Center()); 2692 nAngle -= mpObj->GetRotateAngle(); 2693 if (nAngle!=0) 2694 { 2695 double nSin=sin(nAngle*nPi180); 2696 double nCos=cos(nAngle*nPi180); 2697 mpObj->Rotate(aRef1,nAngle,nSin,nCos); 2698 } 2699 return true; 2700 } 2701 2702 break; 2703 } 2704 2705 case SDRATTR_SHEARANGLE: 2706 { 2707 sal_Int32 nShear = 0; 2708 if( rValue >>= nShear ) 2709 { 2710 nShear -= mpObj->GetShearAngle(); 2711 if(nShear != 0 ) 2712 { 2713 Point aRef1(mpObj->GetSnapRect().Center()); 2714 double nTan=tan(nShear*nPi180); 2715 mpObj->Shear(aRef1,nShear,nTan,sal_False); 2716 return true; 2717 } 2718 } 2719 2720 break; 2721 } 2722 2723 case SDRATTR_OBJMOVEPROTECT: 2724 { 2725 sal_Bool bMoveProtect = sal_Bool(); 2726 if( rValue >>= bMoveProtect ) 2727 { 2728 mpObj->SetMoveProtect(bMoveProtect); 2729 return true; 2730 } 2731 break; 2732 } 2733 case SDRATTR_OBJECTNAME: 2734 { 2735 OUString aName; 2736 if( rValue >>= aName ) 2737 { 2738 mpObj->SetName( aName ); 2739 return true; 2740 } 2741 break; 2742 } 2743 2744 // #i68101# 2745 case OWN_ATTR_MISC_OBJ_TITLE: 2746 { 2747 OUString aTitle; 2748 if( rValue >>= aTitle ) 2749 { 2750 mpObj->SetTitle( aTitle ); 2751 return true; 2752 } 2753 break; 2754 } 2755 case OWN_ATTR_MISC_OBJ_DESCRIPTION: 2756 { 2757 OUString aDescription; 2758 if( rValue >>= aDescription ) 2759 { 2760 mpObj->SetDescription( aDescription ); 2761 return true; 2762 } 2763 break; 2764 } 2765 2766 case SDRATTR_OBJPRINTABLE: 2767 { 2768 sal_Bool bPrintable = sal_Bool(); 2769 if( rValue >>= bPrintable ) 2770 { 2771 mpObj->SetPrintable(bPrintable); 2772 return true; 2773 } 2774 break; 2775 } 2776 case SDRATTR_OBJVISIBLE: 2777 { 2778 sal_Bool bVisible = sal_Bool(); 2779 if( rValue >>= bVisible ) 2780 { 2781 mpObj->SetVisible(bVisible); 2782 return true; 2783 } 2784 break; 2785 } 2786 case SDRATTR_OBJSIZEPROTECT: 2787 { 2788 sal_Bool bResizeProtect = sal_Bool(); 2789 if( rValue >>= bResizeProtect ) 2790 { 2791 mpObj->SetResizeProtect(bResizeProtect); 2792 return true; 2793 } 2794 break; 2795 } 2796 case OWN_ATTR_PAGE_NUMBER: 2797 { 2798 sal_Int32 nPageNum = 0; 2799 if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) ) 2800 { 2801 SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get()); 2802 if( pPageObj ) 2803 { 2804 SdrModel* pModel = pPageObj->GetModel(); 2805 SdrPage* pNewPage = 0L; 2806 const sal_uInt16 nDestinationPageNum((sal_uInt16)((nPageNum << 1L) - 1L)); 2807 2808 if(pModel) 2809 { 2810 if(nDestinationPageNum < pModel->GetPageCount()) 2811 { 2812 pNewPage = pModel->GetPage(nDestinationPageNum); 2813 } 2814 } 2815 2816 pPageObj->SetReferencedPage(pNewPage); 2817 } 2818 2819 return true; 2820 } 2821 break; 2822 } 2823 case XATTR_FILLBITMAP: 2824 case XATTR_FILLGRADIENT: 2825 case XATTR_FILLHATCH: 2826 case XATTR_FILLFLOATTRANSPARENCE: 2827 case XATTR_LINEEND: 2828 case XATTR_LINESTART: 2829 case XATTR_LINEDASH: 2830 { 2831 if( pProperty->nMemberId == MID_NAME ) 2832 { 2833 OUString aApiName; 2834 if( rValue >>= aApiName ) 2835 { 2836 if( SetFillAttribute( pProperty->nWID, aApiName ) ) 2837 return true; 2838 } 2839 break; 2840 } 2841 else 2842 { 2843 return false; 2844 } 2845 } 2846 default: 2847 { 2848 return false; 2849 } 2850 } 2851 throw lang::IllegalArgumentException(); 2852 } 2853 2854 //---------------------------------------------------------------------- 2855 2856 bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) 2857 { 2858 switch( pProperty->nWID ) 2859 { 2860 /* 2861 case OWN_ATTR_HASLEVELS: 2862 { 2863 rValue <<= SvxTextEditSource::hasLevels( mpObj.get() ); 2864 break; 2865 } 2866 */ 2867 case OWN_ATTR_CAPTION_POINT: 2868 { 2869 Point aVclPoint = ((SdrCaptionObj*)mpObj.get())->GetTailPos(); 2870 2871 // #88491# make pos relative to anchor 2872 if( mpModel->IsWriter() ) 2873 { 2874 aVclPoint -= mpObj->GetAnchorPos(); 2875 } 2876 2877 // #88657# metric of pool maybe twips (writer) 2878 ForceMetricTo100th_mm(aVclPoint); 2879 2880 // #90763# pos is absolute, make it relative to top left 2881 basegfx::B2DPolyPolygon aNewPolyPolygon; 2882 basegfx::B2DHomMatrix aNewHomogenMatrix; 2883 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); 2884 2885 aVclPoint.X() -= basegfx::fround(aNewHomogenMatrix.get(0, 2)); 2886 aVclPoint.Y() -= basegfx::fround(aNewHomogenMatrix.get(1, 2)); 2887 2888 awt::Point aPnt( aVclPoint.X(), aVclPoint.Y() ); 2889 rValue <<= aPnt; 2890 break; 2891 } 2892 2893 case OWN_ATTR_TRANSFORMATION: 2894 { 2895 basegfx::B2DPolyPolygon aNewPolyPolygon; 2896 basegfx::B2DHomMatrix aNewHomogenMatrix; 2897 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); 2898 drawing::HomogenMatrix3 aMatrix; 2899 2900 aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0); 2901 aMatrix.Line1.Column2 = aNewHomogenMatrix.get(0, 1); 2902 aMatrix.Line1.Column3 = aNewHomogenMatrix.get(0, 2); 2903 aMatrix.Line2.Column1 = aNewHomogenMatrix.get(1, 0); 2904 aMatrix.Line2.Column2 = aNewHomogenMatrix.get(1, 1); 2905 aMatrix.Line2.Column3 = aNewHomogenMatrix.get(1, 2); 2906 aMatrix.Line3.Column1 = aNewHomogenMatrix.get(2, 0); 2907 aMatrix.Line3.Column2 = aNewHomogenMatrix.get(2, 1); 2908 aMatrix.Line3.Column3 = aNewHomogenMatrix.get(2, 2); 2909 2910 rValue <<= aMatrix; 2911 2912 break; 2913 } 2914 2915 case OWN_ATTR_ZORDER: 2916 { 2917 rValue <<= (sal_Int32)mpObj->GetOrdNum(); 2918 break; 2919 } 2920 2921 case OWN_ATTR_BITMAP: 2922 { 2923 rValue = GetBitmap(); 2924 if(!rValue.hasValue()) 2925 throw uno::RuntimeException(); 2926 2927 break; 2928 } 2929 2930 case OWN_ATTR_ISFONTWORK: 2931 { 2932 rValue <<= (sal_Bool)(mpObj->ISA(SdrTextObj) && ((SdrTextObj*)mpObj.get())->IsFontwork()); 2933 break; 2934 } 2935 2936 case OWN_ATTR_FRAMERECT: 2937 { 2938 Rectangle aRect( mpObj->GetSnapRect() ); 2939 Point aTopLeft( aRect.TopLeft() ); 2940 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() ); 2941 ForceMetricTo100th_mm(aTopLeft); 2942 ForceMetricTo100th_mm(aObjSize); 2943 ::com::sun::star::awt::Rectangle aUnoRect( 2944 aTopLeft.X(), aTopLeft.Y(), 2945 aObjSize.getWidth(), aObjSize.getHeight() ); 2946 rValue <<= aUnoRect; 2947 break; 2948 } 2949 2950 case OWN_ATTR_BOUNDRECT: 2951 { 2952 Rectangle aRect( mpObj->GetCurrentBoundRect() ); 2953 Point aTopLeft( aRect.TopLeft() ); 2954 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() ); 2955 ForceMetricTo100th_mm(aTopLeft); 2956 ForceMetricTo100th_mm(aObjSize); 2957 ::com::sun::star::awt::Rectangle aUnoRect( 2958 aTopLeft.X(), aTopLeft.Y(), 2959 aObjSize.getWidth(), aObjSize.getHeight() ); 2960 rValue <<= aUnoRect; 2961 break; 2962 } 2963 2964 case OWN_ATTR_LDNAME: 2965 { 2966 OUString aName( mpObj->GetName() ); 2967 rValue <<= aName; 2968 break; 2969 } 2970 2971 case OWN_ATTR_LDBITMAP: 2972 { 2973 sal_uInt16 nId; 2974 if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_OLE2 ) 2975 { 2976 nId = RID_UNODRAW_OLE2; 2977 } 2978 else if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_GRAF ) 2979 { 2980 nId = RID_UNODRAW_GRAPHICS; 2981 } 2982 else 2983 { 2984 nId = RID_UNODRAW_OBJECTS; 2985 } 2986 2987 BitmapEx aBmp( SVX_RES(nId) ); 2988 Reference< awt::XBitmap > xBmp( VCLUnoHelper::CreateBitmap( aBmp ) ); 2989 2990 rValue <<= xBmp; 2991 break; 2992 } 2993 2994 case OWN_ATTR_MIRRORED: 2995 { 2996 sal_Bool bMirror = sal_False; 2997 if( mpObj.is() && mpObj->ISA(SdrGrafObj) ) 2998 bMirror = ((SdrGrafObj*)mpObj.get())->IsMirrored(); 2999 3000 rValue <<= bMirror; 3001 } 3002 3003 case OWN_ATTR_EDGE_START_OBJ: 3004 case OWN_ATTR_EDGE_START_POS: 3005 case OWN_ATTR_EDGE_END_POS: 3006 case OWN_ATTR_EDGE_END_OBJ: 3007 case OWN_ATTR_GLUEID_HEAD: 3008 case OWN_ATTR_GLUEID_TAIL: 3009 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: 3010 { 3011 SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(mpObj.get()); 3012 if(pEdgeObj) 3013 { 3014 switch(pProperty->nWID) 3015 { 3016 case OWN_ATTR_EDGE_START_OBJ: 3017 case OWN_ATTR_EDGE_END_OBJ: 3018 { 3019 SdrObject* pNode = pEdgeObj->GetConnectedNode(pProperty->nWID == OWN_ATTR_EDGE_START_OBJ); 3020 if(pNode) 3021 { 3022 Reference< drawing::XShape > xShape( GetXShapeForSdrObject( pNode ) ); 3023 if(xShape.is()) 3024 rValue <<= xShape; 3025 3026 } 3027 break; 3028 } 3029 3030 case OWN_ATTR_EDGE_START_POS: 3031 case OWN_ATTR_EDGE_END_POS: 3032 { 3033 Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) ); 3034 if( mpModel->IsWriter() ) 3035 aPoint -= mpObj->GetAnchorPos(); 3036 3037 ForceMetricTo100th_mm( aPoint ); 3038 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() ); 3039 3040 rValue <<= aUnoPoint; 3041 break; 3042 } 3043 case OWN_ATTR_GLUEID_HEAD: 3044 case OWN_ATTR_GLUEID_TAIL: 3045 { 3046 rValue <<= pEdgeObj->getGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD ); 3047 break; 3048 } 3049 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: 3050 { 3051 basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() ); 3052 if( mpModel->IsWriter() ) 3053 { 3054 Point aPoint( mpObj->GetAnchorPos() ); 3055 aPolyPoly.transform(basegfx::tools::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y())); 3056 } 3057 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051 3058 ForceMetricTo100th_mm( aPolyPoly ); 3059 // <-- 3060 drawing::PolyPolygonBezierCoords aRetval; 3061 SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPoly, aRetval); 3062 rValue <<= aRetval; 3063 break; 3064 } 3065 } 3066 } 3067 break; 3068 } 3069 3070 case OWN_ATTR_MEASURE_START_POS: 3071 case OWN_ATTR_MEASURE_END_POS: 3072 { 3073 SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(mpObj.get()); 3074 if(pMeasureObj) 3075 { 3076 Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) ); 3077 if( mpModel->IsWriter() ) 3078 aPoint -= mpObj->GetAnchorPos(); 3079 3080 // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051 3081 ForceMetricTo100th_mm( aPoint ); 3082 // <-- 3083 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() ); 3084 3085 rValue <<= aUnoPoint; 3086 break; 3087 } 3088 break; 3089 } 3090 3091 case OWN_ATTR_FILLBMP_MODE: 3092 { 3093 const SfxItemSet& rObjItemSet = mpObj->GetMergedItemSet(); 3094 3095 XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)&rObjItemSet.Get(XATTR_FILLBMP_STRETCH); 3096 XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)&rObjItemSet.Get(XATTR_FILLBMP_TILE); 3097 3098 if( pTileItem && pTileItem->GetValue() ) 3099 { 3100 rValue <<= drawing::BitmapMode_REPEAT; 3101 } 3102 else if( pStretchItem && pStretchItem->GetValue() ) 3103 { 3104 rValue <<= drawing::BitmapMode_STRETCH; 3105 } 3106 else 3107 { 3108 rValue <<= drawing::BitmapMode_NO_REPEAT; 3109 } 3110 break; 3111 } 3112 case SDRATTR_LAYERID: 3113 rValue <<= (sal_Int16)mpObj->GetLayer(); 3114 break; 3115 3116 case SDRATTR_LAYERNAME: 3117 { 3118 SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(mpObj->GetLayer()); 3119 if( pLayer ) 3120 { 3121 OUString aName( pLayer->GetName() ); 3122 rValue <<= aName; 3123 } 3124 break; 3125 } 3126 3127 case SDRATTR_ROTATEANGLE: 3128 rValue <<= mpObj->GetRotateAngle(); 3129 break; 3130 3131 case SDRATTR_SHEARANGLE: 3132 rValue <<= mpObj->GetShearAngle(); 3133 break; 3134 3135 case SDRATTR_OBJMOVEPROTECT: 3136 rValue = uno::makeAny( (sal_Bool) mpObj->IsMoveProtect() ); 3137 break; 3138 3139 case SDRATTR_OBJECTNAME: 3140 { 3141 OUString aName( mpObj->GetName() ); 3142 rValue <<= aName; 3143 break; 3144 } 3145 3146 // #i68101# 3147 case OWN_ATTR_MISC_OBJ_TITLE: 3148 { 3149 OUString aTitle( mpObj->GetTitle() ); 3150 rValue <<= aTitle; 3151 break; 3152 } 3153 3154 case OWN_ATTR_MISC_OBJ_DESCRIPTION: 3155 { 3156 OUString aDescription( mpObj->GetDescription() ); 3157 rValue <<= aDescription; 3158 break; 3159 } 3160 3161 case SDRATTR_OBJPRINTABLE: 3162 rValue <<= static_cast<sal_Bool>( mpObj->IsPrintable() ); 3163 break; 3164 3165 case SDRATTR_OBJVISIBLE: 3166 rValue <<= static_cast<sal_Bool>( mpObj->IsVisible() ); 3167 break; 3168 3169 case SDRATTR_OBJSIZEPROTECT: 3170 rValue <<= static_cast<sal_Bool>( mpObj->IsResizeProtect() ); 3171 break; 3172 3173 case OWN_ATTR_PAGE_NUMBER: 3174 { 3175 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(mpObj.get()); 3176 if(pPageObj) 3177 { 3178 SdrPage* pPage = pPageObj->GetReferencedPage(); 3179 sal_Int32 nPageNumber = (pPage) ? pPage->GetPageNum() : 0L; 3180 nPageNumber++; 3181 nPageNumber >>= 1; 3182 rValue <<= nPageNumber; 3183 } 3184 break; 3185 } 3186 3187 case OWN_ATTR_UINAME_SINGULAR: 3188 { 3189 String aTmp; 3190 mpObj->TakeObjNameSingul( aTmp ); 3191 rValue <<= OUString( aTmp ); 3192 break; 3193 } 3194 3195 case OWN_ATTR_UINAME_PLURAL: 3196 { 3197 String aTmp; 3198 mpObj->TakeObjNamePlural( aTmp ); 3199 rValue <<= OUString( aTmp ); 3200 break; 3201 } 3202 case OWN_ATTR_METAFILE: 3203 { 3204 SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get()); 3205 if( pObj ) 3206 { 3207 Graphic* pGraphic = pObj->GetGraphic(); 3208 if( pGraphic ) 3209 { 3210 sal_Bool bIsWMF = sal_False; 3211 if ( pGraphic->IsLink() ) 3212 { 3213 GfxLink aLnk = pGraphic->GetLink(); 3214 if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF ) 3215 { 3216 bIsWMF = sal_True; 3217 uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize()); 3218 rValue <<= aSeq; 3219 } 3220 } 3221 if ( !bIsWMF ) 3222 { 3223 GDIMetaFile aMtf; 3224 if ( pGraphic->GetType() != GRAPHIC_BITMAP ) 3225 aMtf = pObj->GetGraphic()->GetGDIMetaFile(); 3226 else 3227 { 3228 VirtualDevice aVirDev; 3229 aMtf.Record( &aVirDev ); 3230 pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() ); 3231 aMtf.Stop(); 3232 aMtf.SetPrefSize( pGraphic->GetPrefSize() ); 3233 aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() ); 3234 } 3235 SvMemoryStream aDestStrm( 65535, 65535 ); 3236 ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); 3237 const uno::Sequence<sal_Int8> aSeq( 3238 static_cast< const sal_Int8* >(aDestStrm.GetData()), 3239 aDestStrm.GetEndOfData()); 3240 rValue <<= aSeq; 3241 } 3242 } 3243 } 3244 else 3245 { 3246 rValue = GetBitmap( sal_True ); 3247 } 3248 break; 3249 } 3250 3251 3252 default: 3253 return false; 3254 } 3255 return true; 3256 } 3257 3258 //---------------------------------------------------------------------- 3259 3260 bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) 3261 { 3262 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE ) 3263 { 3264 const SfxItemSet& rSet = mpObj->GetMergedItemSet(); 3265 3266 if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET || 3267 rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET ) 3268 { 3269 rState = beans::PropertyState_DIRECT_VALUE; 3270 } 3271 else 3272 { 3273 rState = beans::PropertyState_AMBIGUOUS_VALUE; 3274 } 3275 } 3276 else if((( pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) || 3277 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) && ( pProperty->nWID != SDRATTR_TEXTDIRECTION ) ) 3278 { 3279 rState = beans::PropertyState_DIRECT_VALUE; 3280 } 3281 else 3282 { 3283 return false; 3284 } 3285 3286 return true; 3287 } 3288 3289 //---------------------------------------------------------------------- 3290 3291 bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) 3292 { 3293 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE ) 3294 { 3295 mpObj->ClearMergedItem( XATTR_FILLBMP_STRETCH ); 3296 mpObj->ClearMergedItem( XATTR_FILLBMP_TILE ); 3297 return true; 3298 } 3299 else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) || 3300 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) 3301 { 3302 return true; 3303 } 3304 else 3305 { 3306 return false; 3307 } 3308 } 3309 3310 //---------------------------------------------------------------------- 3311 3312 uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( const uno::Sequence< OUString >& aPropertyName ) 3313 throw(beans::UnknownPropertyException, uno::RuntimeException) 3314 { 3315 const sal_Int32 nCount = aPropertyName.getLength(); 3316 const OUString* pNames = aPropertyName.getConstArray(); 3317 3318 uno::Sequence< beans::PropertyState > aRet( nCount ); 3319 beans::PropertyState* pState = aRet.getArray(); 3320 3321 if( mpImpl->mpMaster ) 3322 { 3323 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ ) 3324 pState[nIdx] = getPropertyState( pNames[nIdx] ); 3325 3326 } 3327 else 3328 { 3329 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ ) 3330 pState[nIdx] = getPropertyState( pNames[nIdx] ); 3331 } 3332 3333 return aRet; 3334 } 3335 3336 //---------------------------------------------------------------------- 3337 3338 void SAL_CALL SvxShape::setPropertyToDefault( const OUString& PropertyName ) 3339 throw(beans::UnknownPropertyException, uno::RuntimeException) 3340 { 3341 if( mpImpl->mpMaster ) 3342 { 3343 mpImpl->mpMaster->setPropertyToDefault( PropertyName ); 3344 } 3345 else 3346 { 3347 _setPropertyToDefault( PropertyName ); 3348 } 3349 } 3350 3351 void SAL_CALL SvxShape::_setPropertyToDefault( const OUString& PropertyName ) 3352 throw(beans::UnknownPropertyException, uno::RuntimeException) 3353 { 3354 OGuard aGuard( Application::GetSolarMutex() ); 3355 3356 const SfxItemPropertySimpleEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName); 3357 3358 if( !mpObj.is() || mpModel == NULL || pProperty == NULL ) 3359 throw beans::UnknownPropertyException(); 3360 3361 if( !setPropertyToDefaultImpl( pProperty ) ) 3362 { 3363 mpObj->ClearMergedItem( pProperty->nWID ); 3364 } 3365 3366 mpModel->SetChanged(); 3367 } 3368 3369 //---------------------------------------------------------------------- 3370 3371 uno::Any SAL_CALL SvxShape::getPropertyDefault( const OUString& aPropertyName ) 3372 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 3373 { 3374 if( mpImpl->mpMaster ) 3375 { 3376 return mpImpl->mpMaster->getPropertyDefault( aPropertyName ); 3377 } 3378 else 3379 { 3380 return _getPropertyDefault( aPropertyName ); 3381 } 3382 } 3383 3384 uno::Any SAL_CALL SvxShape::_getPropertyDefault( const OUString& aPropertyName ) 3385 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 3386 { 3387 OGuard aGuard( Application::GetSolarMutex() ); 3388 3389 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName); 3390 3391 if( !mpObj.is() || pMap == NULL || mpModel == NULL ) 3392 throw beans::UnknownPropertyException(); 3393 3394 if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) || 3395 ( pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST )) 3396 { 3397 return getPropertyValue( aPropertyName ); 3398 } 3399 3400 // Default aus ItemPool holen 3401 if(!mpModel->GetItemPool().IsWhich(pMap->nWID)) 3402 throw beans::UnknownPropertyException(); 3403 3404 SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID); 3405 aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID)); 3406 3407 return GetAnyForItem( aSet, pMap ); 3408 } 3409 3410 // XMultiPropertyStates 3411 void SvxShape::setAllPropertiesToDefault() throw (uno::RuntimeException) 3412 { 3413 OGuard aGuard( Application::GetSolarMutex() ); 3414 3415 if( !mpObj.is() ) 3416 throw lang::DisposedException(); 3417 mpObj->ClearMergedItem(); // nWhich == 0 => all 3418 3419 if(mpObj->ISA(SdrGrafObj)) 3420 { 3421 // defaults for graphic objects have changed: 3422 mpObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) ); 3423 mpObj->SetMergedItem( XLineStyleItem( XLINE_NONE ) ); 3424 } 3425 3426 // #i68523# special handling for Svx3DCharacterModeItem, this is not saved 3427 // but needs to be sal_True in svx, pool default (false) in sch. Since sch 3428 // does not load lathe or extrude objects, it is possible to set the items 3429 // here. 3430 // For other solution possibilities, see task description. 3431 if(mpObj->ISA(E3dLatheObj) || mpObj->ISA(E3dExtrudeObj)) 3432 { 3433 mpObj->SetMergedItem(Svx3DCharacterModeItem(true)); 3434 } 3435 3436 mpModel->SetChanged(); 3437 } 3438 3439 void SvxShape::setPropertiesToDefault( 3440 const uno::Sequence<OUString>& aPropertyNames ) 3441 throw (beans::UnknownPropertyException, uno::RuntimeException) 3442 { 3443 for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos ) 3444 setPropertyToDefault( aPropertyNames[pos] ); 3445 } 3446 3447 uno::Sequence<uno::Any> SvxShape::getPropertyDefaults( 3448 const uno::Sequence<OUString>& aPropertyNames ) 3449 throw (beans::UnknownPropertyException, lang::WrappedTargetException, 3450 uno::RuntimeException) 3451 { 3452 ::std::vector<uno::Any> ret; 3453 for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos ) 3454 ret.push_back( getPropertyDefault( aPropertyNames[pos] ) ); 3455 return uno::Sequence<uno::Any>( &ret[0], ret.size() ); 3456 } 3457 3458 //---------------------------------------------------------------------- 3459 3460 //---------------------------------------------------------------------- 3461 // XServiceInfo 3462 //---------------------------------------------------------------------- 3463 OUString SAL_CALL SvxShape::getImplementationName() 3464 throw(uno::RuntimeException) 3465 { 3466 static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShape") ); 3467 return aServiceName; 3468 } 3469 3470 #define STAR_NAMESPACE "com.sun.star." 3471 3472 const char* sUNO_service_style_ParagraphProperties = STAR_NAMESPACE "style.ParagraphProperties"; 3473 const char* sUNO_service_style_ParagraphPropertiesComplex = STAR_NAMESPACE "style.ParagraphPropertiesComplex"; 3474 const char* sUNO_service_style_ParagraphPropertiesAsian = STAR_NAMESPACE "style.ParagraphPropertiesAsian"; 3475 const char* sUNO_service_style_CharacterProperties = STAR_NAMESPACE "style.CharacterProperties"; 3476 const char* sUNO_service_style_CharacterPropertiesComplex = STAR_NAMESPACE "style.CharacterPropertiesComplex"; 3477 const char* sUNO_service_style_CharacterPropertiesAsian = STAR_NAMESPACE "style.CharacterPropertiesAsian"; 3478 3479 const char* sUNO_service_drawing_FillProperties = STAR_NAMESPACE "drawing.FillProperties"; 3480 const char* sUNO_service_drawing_TextProperties = STAR_NAMESPACE "drawing.TextProperties"; 3481 const char* sUNO_service_drawing_LineProperties = STAR_NAMESPACE "drawing.LineProperties"; 3482 const char* sUNO_service_drawing_ConnectorProperties = STAR_NAMESPACE "drawing.ConnectorProperties"; 3483 const char* sUNO_service_drawing_MeasureProperties = STAR_NAMESPACE "drawing.MeasureProperties"; 3484 const char* sUNO_service_drawing_ShadowProperties = STAR_NAMESPACE "drawing.ShadowProperties"; 3485 3486 const char* sUNO_service_drawing_RotationDescriptor = STAR_NAMESPACE "drawing.RotationDescriptor"; 3487 3488 const char* sUNO_service_drawing_Text = STAR_NAMESPACE "drawing.Text"; 3489 const char* sUNO_service_drawing_GroupShape = STAR_NAMESPACE "drawing.GroupShape"; 3490 3491 const char* sUNO_service_drawing_CustomShapeProperties = STAR_NAMESPACE "drawing.CustomShapeProperties"; 3492 const char* sUNO_service_drawing_CustomShape = STAR_NAMESPACE "drawing.CustomShape"; 3493 3494 const char* sUNO_service_drawing_PolyPolygonDescriptor = STAR_NAMESPACE "drawing.PolyPolygonDescriptor"; 3495 const char* sUNO_service_drawing_PolyPolygonBezierDescriptor= STAR_NAMESPACE "drawing.PolyPolygonBezierDescriptor"; 3496 3497 const char* sUNO_service_drawing_LineShape = STAR_NAMESPACE "drawing.LineShape"; 3498 const char* sUNO_service_drawing_Shape = STAR_NAMESPACE "drawing.Shape"; 3499 const char* sUNO_service_drawing_RectangleShape = STAR_NAMESPACE "drawing.RectangleShape"; 3500 const char* sUNO_service_drawing_EllipseShape = STAR_NAMESPACE "drawing.EllipseShape"; 3501 const char* sUNO_service_drawing_PolyPolygonShape = STAR_NAMESPACE "drawing.PolyPolygonShape"; 3502 const char* sUNO_service_drawing_PolyLineShape = STAR_NAMESPACE "drawing.PolyLineShape"; 3503 const char* sUNO_service_drawing_OpenBezierShape = STAR_NAMESPACE "drawing.OpenBezierShape"; 3504 const char* sUNO_service_drawing_ClosedBezierShape = STAR_NAMESPACE "drawing.ClosedBezierShape"; 3505 const char* sUNO_service_drawing_TextShape = STAR_NAMESPACE "drawing.TextShape"; 3506 const char* sUNO_service_drawing_GraphicObjectShape = STAR_NAMESPACE "drawing.GraphicObjectShape"; 3507 const char* sUNO_service_drawing_OLE2Shape = STAR_NAMESPACE "drawing.OLE2Shape"; 3508 const char* sUNO_service_drawing_PageShape = STAR_NAMESPACE "drawing.PageShape"; 3509 const char* sUNO_service_drawing_CaptionShape = STAR_NAMESPACE "drawing.CaptionShape"; 3510 const char* sUNO_service_drawing_MeasureShape = STAR_NAMESPACE "drawing.MeasureShape"; 3511 const char* sUNO_service_drawing_FrameShape = STAR_NAMESPACE "drawing.FrameShape"; 3512 const char* sUNO_service_drawing_ControlShape = STAR_NAMESPACE "drawing.ControlShape"; 3513 const char* sUNO_service_drawing_ConnectorShape = STAR_NAMESPACE "drawing.ConnectorShape"; 3514 const char* sUNO_service_drawing_MediaShape = STAR_NAMESPACE "drawing.MediaShape"; 3515 3516 3517 uno::Sequence< OUString > SAL_CALL SvxShape::getSupportedServiceNames() 3518 throw(uno::RuntimeException) 3519 { 3520 if( mpImpl->mpMaster ) 3521 { 3522 return mpImpl->mpMaster->getSupportedServiceNames(); 3523 } 3524 else 3525 { 3526 return _getSupportedServiceNames(); 3527 } 3528 } 3529 3530 uno::Sequence< OUString > SAL_CALL SvxShape::_getSupportedServiceNames() 3531 throw(uno::RuntimeException) 3532 { 3533 OGuard aGuard( Application::GetSolarMutex() ); 3534 3535 if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor) 3536 { 3537 const sal_uInt16 nIdent = mpObj->GetObjIdentifier(); 3538 3539 switch(nIdent) 3540 { 3541 case OBJ_GRUP: 3542 { 3543 static uno::Sequence< OUString > *pSeq = 0; 3544 if( 0 == pSeq ) 3545 { 3546 // OGuard aGuard( Application::GetSolarMutex() ); 3547 // if( 0 == pSeq ) 3548 { 3549 static uno::Sequence< OUString > SvxShape_GroupServices; 3550 3551 comphelper::ServiceInfoHelper::addToSequence( SvxShape_GroupServices, 2, 3552 sUNO_service_drawing_GroupShape, 3553 sUNO_service_drawing_Shape ); 3554 3555 pSeq = &SvxShape_GroupServices; 3556 } 3557 } 3558 3559 return *pSeq; 3560 } 3561 case OBJ_CUSTOMSHAPE: 3562 { 3563 static uno::Sequence< OUString > *pSeq = 0; 3564 if( 0 == pSeq ) 3565 { 3566 // OGuard aGuard( Application::GetSolarMutex() ); 3567 // if( 0 == pSeq ) 3568 { 3569 static uno::Sequence< OUString > SvxShape_CustomShapeServices; 3570 3571 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CustomShapeServices, 13, 3572 sUNO_service_drawing_CustomShape, 3573 sUNO_service_drawing_Shape, 3574 sUNO_service_drawing_CustomShapeProperties, 3575 sUNO_service_drawing_FillProperties, 3576 sUNO_service_drawing_LineProperties, 3577 sUNO_service_drawing_Text, 3578 sUNO_service_drawing_TextProperties, 3579 sUNO_service_style_ParagraphProperties, 3580 sUNO_service_style_ParagraphPropertiesComplex, 3581 sUNO_service_style_ParagraphPropertiesAsian, 3582 sUNO_service_style_CharacterProperties, 3583 sUNO_service_style_CharacterPropertiesComplex, 3584 sUNO_service_style_CharacterPropertiesAsian, 3585 sUNO_service_drawing_ShadowProperties, 3586 sUNO_service_drawing_RotationDescriptor); 3587 pSeq = &SvxShape_CustomShapeServices; 3588 } 3589 } 3590 return *pSeq; 3591 } 3592 case OBJ_LINE: 3593 { 3594 static uno::Sequence< OUString > *pSeq = 0; 3595 if( 0 == pSeq ) 3596 { 3597 // OGuard aGuard( Application::GetSolarMutex() ); 3598 // if( 0 == pSeq ) 3599 { 3600 static uno::Sequence< OUString > SvxShape_LineServices; 3601 3602 comphelper::ServiceInfoHelper::addToSequence( SvxShape_LineServices,14, 3603 sUNO_service_drawing_LineShape, 3604 3605 sUNO_service_drawing_Shape, 3606 sUNO_service_drawing_LineProperties, 3607 3608 sUNO_service_drawing_Text, 3609 sUNO_service_drawing_TextProperties, 3610 sUNO_service_style_ParagraphProperties, 3611 sUNO_service_style_ParagraphPropertiesComplex, 3612 sUNO_service_style_ParagraphPropertiesAsian, 3613 sUNO_service_style_CharacterProperties, 3614 sUNO_service_style_CharacterPropertiesComplex, 3615 sUNO_service_style_CharacterPropertiesAsian, 3616 3617 sUNO_service_drawing_PolyPolygonDescriptor, 3618 sUNO_service_drawing_ShadowProperties, 3619 sUNO_service_drawing_RotationDescriptor); 3620 3621 pSeq = &SvxShape_LineServices; 3622 } 3623 } 3624 return *pSeq; 3625 } 3626 3627 case OBJ_RECT: 3628 { 3629 static uno::Sequence< OUString > *pSeq = 0; 3630 if( 0 == pSeq ) 3631 { 3632 // OGuard aGuard( Application::GetSolarMutex() ); 3633 // if( 0 == pSeq ) 3634 { 3635 static uno::Sequence< OUString > SvxShape_RectServices; 3636 3637 comphelper::ServiceInfoHelper::addToSequence( SvxShape_RectServices,14, 3638 sUNO_service_drawing_RectangleShape, 3639 3640 sUNO_service_drawing_Shape, 3641 sUNO_service_drawing_FillProperties, 3642 sUNO_service_drawing_LineProperties, 3643 sUNO_service_drawing_Text, 3644 sUNO_service_drawing_TextProperties, 3645 sUNO_service_style_ParagraphProperties, 3646 sUNO_service_style_ParagraphPropertiesComplex, 3647 sUNO_service_style_ParagraphPropertiesAsian, 3648 sUNO_service_style_CharacterProperties, 3649 sUNO_service_style_CharacterPropertiesComplex, 3650 sUNO_service_style_CharacterPropertiesAsian, 3651 3652 sUNO_service_drawing_ShadowProperties, 3653 sUNO_service_drawing_RotationDescriptor); 3654 pSeq = &SvxShape_RectServices; 3655 } 3656 3657 } 3658 return *pSeq; 3659 } 3660 3661 case OBJ_CIRC: 3662 case OBJ_SECT: 3663 case OBJ_CARC: 3664 case OBJ_CCUT: 3665 { 3666 static uno::Sequence< OUString > *pSeq = 0; 3667 if( 0 == pSeq ) 3668 { 3669 // OGuard aGuard( Application::GetSolarMutex() ); 3670 // if( 0 == pSeq ) 3671 { 3672 static uno::Sequence< OUString > SvxShape_CircServices; 3673 3674 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CircServices,14, 3675 sUNO_service_drawing_EllipseShape, 3676 3677 sUNO_service_drawing_Shape, 3678 sUNO_service_drawing_FillProperties, 3679 sUNO_service_drawing_LineProperties, 3680 3681 sUNO_service_drawing_Text, 3682 sUNO_service_drawing_TextProperties, 3683 sUNO_service_style_ParagraphProperties, 3684 sUNO_service_style_ParagraphPropertiesComplex, 3685 sUNO_service_style_ParagraphPropertiesAsian, 3686 sUNO_service_style_CharacterProperties, 3687 sUNO_service_style_CharacterPropertiesComplex, 3688 sUNO_service_style_CharacterPropertiesAsian, 3689 3690 sUNO_service_drawing_ShadowProperties, 3691 sUNO_service_drawing_RotationDescriptor); 3692 3693 pSeq = &SvxShape_CircServices; 3694 } 3695 } 3696 3697 return *pSeq; 3698 } 3699 3700 case OBJ_PATHPLIN: 3701 case OBJ_PLIN: 3702 { 3703 static uno::Sequence< OUString > *pSeq = 0; 3704 if( 0 == pSeq ) 3705 { 3706 // OGuard aGuard( Application::GetSolarMutex() ); 3707 // if( 0 == pSeq ) 3708 { 3709 static uno::Sequence< OUString > SvxShape_PathServices; 3710 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PathServices,14, 3711 sUNO_service_drawing_PolyLineShape, 3712 3713 sUNO_service_drawing_Shape, 3714 sUNO_service_drawing_LineProperties, 3715 3716 sUNO_service_drawing_PolyPolygonDescriptor, 3717 3718 sUNO_service_drawing_Text, 3719 sUNO_service_drawing_TextProperties, 3720 sUNO_service_style_ParagraphProperties, 3721 sUNO_service_style_ParagraphPropertiesComplex, 3722 sUNO_service_style_ParagraphPropertiesAsian, 3723 sUNO_service_style_CharacterProperties, 3724 sUNO_service_style_CharacterPropertiesComplex, 3725 sUNO_service_style_CharacterPropertiesAsian, 3726 3727 sUNO_service_drawing_ShadowProperties, 3728 sUNO_service_drawing_RotationDescriptor); 3729 pSeq = &SvxShape_PathServices; 3730 } 3731 } 3732 return *pSeq; 3733 } 3734 3735 case OBJ_PATHPOLY: 3736 case OBJ_POLY: 3737 { 3738 static uno::Sequence< OUString > *pSeq = 0; 3739 if( 0 == pSeq ) 3740 { 3741 // OGuard aGuard( Application::GetSolarMutex() ); 3742 // if( 0 == pSeq ) 3743 { 3744 static uno::Sequence< OUString > SvxShape_PolyServices; 3745 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PolyServices,15, 3746 sUNO_service_drawing_PolyPolygonShape, 3747 3748 sUNO_service_drawing_Shape, 3749 sUNO_service_drawing_LineProperties, 3750 sUNO_service_drawing_FillProperties, 3751 3752 sUNO_service_drawing_PolyPolygonDescriptor, 3753 3754 sUNO_service_drawing_Text, 3755 sUNO_service_drawing_TextProperties, 3756 sUNO_service_style_ParagraphProperties, 3757 sUNO_service_style_ParagraphPropertiesComplex, 3758 sUNO_service_style_ParagraphPropertiesAsian, 3759 sUNO_service_style_CharacterProperties, 3760 sUNO_service_style_CharacterPropertiesComplex, 3761 sUNO_service_style_CharacterPropertiesAsian, 3762 3763 sUNO_service_drawing_ShadowProperties, 3764 sUNO_service_drawing_RotationDescriptor); 3765 3766 pSeq = &SvxShape_PolyServices; 3767 } 3768 } 3769 return *pSeq; 3770 } 3771 3772 case OBJ_FREELINE: 3773 case OBJ_PATHLINE: 3774 { 3775 static uno::Sequence< OUString > *pSeq = 0; 3776 if( 0 == pSeq ) 3777 { 3778 // OGuard aGuard( Application::GetSolarMutex() ); 3779 // if( 0 == pSeq ) 3780 { 3781 static uno::Sequence< OUString > SvxShape_FreeLineServices; 3782 3783 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeLineServices,15, 3784 sUNO_service_drawing_OpenBezierShape, 3785 3786 sUNO_service_drawing_Shape, 3787 sUNO_service_drawing_LineProperties, 3788 sUNO_service_drawing_FillProperties, 3789 3790 sUNO_service_drawing_PolyPolygonBezierDescriptor, 3791 3792 sUNO_service_drawing_Text, 3793 sUNO_service_drawing_TextProperties, 3794 sUNO_service_style_ParagraphProperties, 3795 sUNO_service_style_ParagraphPropertiesComplex, 3796 sUNO_service_style_ParagraphPropertiesAsian, 3797 sUNO_service_style_CharacterProperties, 3798 sUNO_service_style_CharacterPropertiesComplex, 3799 sUNO_service_style_CharacterPropertiesAsian, 3800 3801 sUNO_service_drawing_ShadowProperties, 3802 sUNO_service_drawing_RotationDescriptor); 3803 3804 pSeq = &SvxShape_FreeLineServices; 3805 } 3806 } 3807 3808 return *pSeq; 3809 } 3810 3811 case OBJ_FREEFILL: 3812 case OBJ_PATHFILL: 3813 { 3814 static uno::Sequence< OUString > *pSeq = 0; 3815 if( 0 == pSeq ) 3816 { 3817 // OGuard aGuard( Application::GetSolarMutex() ); 3818 // if( 0 == pSeq ) 3819 { 3820 static uno::Sequence< OUString > SvxShape_FreeFillServices; 3821 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeFillServices,15, 3822 sUNO_service_drawing_ClosedBezierShape, 3823 3824 sUNO_service_drawing_Shape, 3825 sUNO_service_drawing_LineProperties, 3826 sUNO_service_drawing_FillProperties, 3827 3828 sUNO_service_drawing_PolyPolygonBezierDescriptor, 3829 3830 sUNO_service_drawing_Text, 3831 sUNO_service_drawing_TextProperties, 3832 sUNO_service_style_ParagraphProperties, 3833 sUNO_service_style_ParagraphPropertiesComplex, 3834 sUNO_service_style_ParagraphPropertiesAsian, 3835 sUNO_service_style_CharacterProperties, 3836 sUNO_service_style_CharacterPropertiesComplex, 3837 sUNO_service_style_CharacterPropertiesAsian, 3838 3839 sUNO_service_drawing_ShadowProperties, 3840 sUNO_service_drawing_RotationDescriptor); 3841 3842 pSeq = &SvxShape_FreeFillServices; 3843 } 3844 } 3845 return *pSeq; 3846 } 3847 3848 case OBJ_OUTLINETEXT: 3849 case OBJ_TITLETEXT: 3850 case OBJ_TEXT: 3851 { 3852 static uno::Sequence< OUString > *pSeq = 0; 3853 if( 0 == pSeq ) 3854 { 3855 // OGuard aGuard( Application::GetSolarMutex() ); 3856 // if( 0 == pSeq ) 3857 { 3858 static uno::Sequence< OUString > SvxShape_TextServices; 3859 comphelper::ServiceInfoHelper::addToSequence( SvxShape_TextServices,14, 3860 sUNO_service_drawing_TextShape, 3861 3862 sUNO_service_drawing_Shape, 3863 sUNO_service_drawing_FillProperties, 3864 sUNO_service_drawing_LineProperties, 3865 3866 sUNO_service_drawing_Text, 3867 sUNO_service_drawing_TextProperties, 3868 sUNO_service_style_ParagraphProperties, 3869 sUNO_service_style_ParagraphPropertiesComplex, 3870 sUNO_service_style_ParagraphPropertiesAsian, 3871 sUNO_service_style_CharacterProperties, 3872 sUNO_service_style_CharacterPropertiesComplex, 3873 sUNO_service_style_CharacterPropertiesAsian, 3874 3875 sUNO_service_drawing_ShadowProperties, 3876 sUNO_service_drawing_RotationDescriptor); 3877 3878 pSeq = &SvxShape_TextServices; 3879 } 3880 } 3881 return *pSeq; 3882 } 3883 3884 case OBJ_GRAF: 3885 { 3886 static uno::Sequence< OUString > *pSeq = 0; 3887 if( 0 == pSeq ) 3888 { 3889 // OGuard aGuard( Application::GetSolarMutex() ); 3890 // if( 0 == pSeq ) 3891 { 3892 static uno::Sequence< OUString > SvxShape_GrafServices; 3893 comphelper::ServiceInfoHelper::addToSequence( SvxShape_GrafServices, 12, 3894 sUNO_service_drawing_GraphicObjectShape, 3895 3896 sUNO_service_drawing_Shape, 3897 3898 sUNO_service_drawing_Text, 3899 sUNO_service_drawing_TextProperties, 3900 sUNO_service_style_ParagraphProperties, 3901 sUNO_service_style_ParagraphPropertiesComplex, 3902 sUNO_service_style_ParagraphPropertiesAsian, 3903 sUNO_service_style_CharacterProperties, 3904 sUNO_service_style_CharacterPropertiesComplex, 3905 sUNO_service_style_CharacterPropertiesAsian, 3906 3907 sUNO_service_drawing_ShadowProperties, 3908 sUNO_service_drawing_RotationDescriptor); 3909 3910 pSeq = &SvxShape_GrafServices; 3911 } 3912 } 3913 return *pSeq; 3914 } 3915 3916 case OBJ_OLE2: 3917 { 3918 static uno::Sequence< OUString > *pSeq = 0; 3919 if( 0 == pSeq ) 3920 { 3921 // OGuard aGuard( Application::GetSolarMutex() ); 3922 // if( 0 == pSeq ) 3923 { 3924 static uno::Sequence< OUString > SvxShape_Ole2Services; 3925 3926 comphelper::ServiceInfoHelper::addToSequence( SvxShape_Ole2Services, 2, 3927 sUNO_service_drawing_OLE2Shape, 3928 sUNO_service_drawing_Shape); 3929 3930 pSeq = &SvxShape_Ole2Services; 3931 } 3932 } 3933 return *pSeq; 3934 } 3935 3936 case OBJ_CAPTION: 3937 { 3938 static uno::Sequence< OUString > *pSeq = 0; 3939 if( 0 == pSeq ) 3940 { 3941 // OGuard aGuard( Application::GetSolarMutex() ); 3942 // if( 0 == pSeq ) 3943 { 3944 static uno::Sequence< OUString > SvxShape_CaptionServices; 3945 3946 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CaptionServices,14, 3947 sUNO_service_drawing_CaptionShape, 3948 3949 sUNO_service_drawing_Shape, 3950 sUNO_service_drawing_FillProperties, 3951 sUNO_service_drawing_LineProperties, 3952 3953 sUNO_service_drawing_Text, 3954 sUNO_service_drawing_TextProperties, 3955 sUNO_service_style_ParagraphProperties, 3956 sUNO_service_style_ParagraphPropertiesComplex, 3957 sUNO_service_style_ParagraphPropertiesAsian, 3958 sUNO_service_style_CharacterProperties, 3959 sUNO_service_style_CharacterPropertiesComplex, 3960 sUNO_service_style_CharacterPropertiesAsian, 3961 3962 sUNO_service_drawing_ShadowProperties, 3963 sUNO_service_drawing_RotationDescriptor); 3964 3965 pSeq = &SvxShape_CaptionServices; 3966 } 3967 } 3968 3969 return *pSeq; 3970 } 3971 3972 case OBJ_PAGE: 3973 { 3974 static uno::Sequence< OUString > *pSeq = 0; 3975 if( 0 == pSeq ) 3976 { 3977 // OGuard aGuard( Application::GetSolarMutex() ); 3978 // if( 0 == pSeq ) 3979 { 3980 static uno::Sequence< OUString > SvxShape_PageServices; 3981 3982 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PageServices, 2, 3983 sUNO_service_drawing_PageShape, 3984 sUNO_service_drawing_Shape ); 3985 3986 pSeq = &SvxShape_PageServices; 3987 } 3988 } 3989 3990 return *pSeq; 3991 } 3992 3993 case OBJ_MEASURE: 3994 { 3995 static uno::Sequence< OUString > *pSeq = 0; 3996 if( 0 == pSeq ) 3997 { 3998 // OGuard aGuard( Application::GetSolarMutex() ); 3999 // if( 0 == pSeq ) 4000 { 4001 static uno::Sequence< OUString > SvxShape_MeasureServices; 4002 comphelper::ServiceInfoHelper::addToSequence( SvxShape_MeasureServices,15, 4003 sUNO_service_drawing_MeasureShape, 4004 4005 sUNO_service_drawing_MeasureProperties, 4006 4007 sUNO_service_drawing_Shape, 4008 sUNO_service_drawing_LineProperties, 4009 4010 sUNO_service_drawing_Text, 4011 sUNO_service_drawing_TextProperties, 4012 sUNO_service_style_ParagraphProperties, 4013 sUNO_service_style_ParagraphPropertiesComplex, 4014 sUNO_service_style_ParagraphPropertiesAsian, 4015 sUNO_service_style_CharacterProperties, 4016 sUNO_service_style_CharacterPropertiesComplex, 4017 sUNO_service_style_CharacterPropertiesAsian, 4018 4019 sUNO_service_drawing_PolyPolygonDescriptor, 4020 sUNO_service_drawing_ShadowProperties, 4021 sUNO_service_drawing_RotationDescriptor); 4022 4023 pSeq = &SvxShape_MeasureServices; 4024 } 4025 } 4026 4027 return *pSeq; 4028 } 4029 4030 case OBJ_FRAME: 4031 { 4032 static uno::Sequence< OUString > *pSeq = 0; 4033 if( 0 == pSeq ) 4034 { 4035 // OGuard aGuard( Application::GetSolarMutex() ); 4036 // if( 0 == pSeq ) 4037 { 4038 static uno::Sequence< OUString > SvxShape_FrameServices; 4039 4040 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FrameServices, 2, 4041 sUNO_service_drawing_FrameShape, 4042 sUNO_service_drawing_Shape ); 4043 4044 pSeq = &SvxShape_FrameServices; 4045 } 4046 } 4047 4048 return *pSeq; 4049 } 4050 4051 case OBJ_UNO: 4052 { 4053 static uno::Sequence< OUString > *pSeq = 0; 4054 if( 0 == pSeq ) 4055 { 4056 // OGuard _aGuard( Application::GetSolarMutex() ); 4057 // if( 0 == pSeq ) 4058 { 4059 static uno::Sequence< OUString > SvxShape_UnoServices; 4060 comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2, 4061 sUNO_service_drawing_ControlShape, 4062 sUNO_service_drawing_Shape ); 4063 4064 pSeq = &SvxShape_UnoServices; 4065 } 4066 } 4067 return *pSeq; 4068 } 4069 4070 case OBJ_EDGE: 4071 { 4072 static uno::Sequence< OUString > *pSeq = 0; 4073 if( 0 == pSeq ) 4074 { 4075 // OGuard aGuard( Application::GetSolarMutex() ); 4076 // if( 0 == pSeq ) 4077 { 4078 static uno::Sequence< OUString > SvxShape_EdgeServices; 4079 4080 comphelper::ServiceInfoHelper::addToSequence( SvxShape_EdgeServices,15, 4081 sUNO_service_drawing_ConnectorShape, 4082 sUNO_service_drawing_ConnectorProperties, 4083 4084 sUNO_service_drawing_Shape, 4085 sUNO_service_drawing_LineProperties, 4086 4087 sUNO_service_drawing_Text, 4088 sUNO_service_drawing_TextProperties, 4089 sUNO_service_style_ParagraphProperties, 4090 sUNO_service_style_ParagraphPropertiesComplex, 4091 sUNO_service_style_ParagraphPropertiesAsian, 4092 sUNO_service_style_CharacterProperties, 4093 sUNO_service_style_CharacterPropertiesComplex, 4094 sUNO_service_style_CharacterPropertiesAsian, 4095 4096 sUNO_service_drawing_PolyPolygonDescriptor, 4097 sUNO_service_drawing_ShadowProperties, 4098 sUNO_service_drawing_RotationDescriptor); 4099 4100 pSeq = &SvxShape_EdgeServices; 4101 } 4102 } 4103 return *pSeq; 4104 } 4105 case OBJ_MEDIA: 4106 { 4107 static uno::Sequence< OUString > *pSeq = 0; 4108 if( 0 == pSeq ) 4109 { 4110 // OGuard aGuard( Application::GetSolarMutex() ); 4111 // if( 0 == pSeq ) 4112 { 4113 static uno::Sequence< OUString > SvxShape_MediaServices; 4114 4115 comphelper::ServiceInfoHelper::addToSequence( SvxShape_MediaServices, 2, 4116 sUNO_service_drawing_MediaShape, 4117 sUNO_service_drawing_Shape); 4118 4119 pSeq = &SvxShape_MediaServices; 4120 } 4121 } 4122 return *pSeq; 4123 } 4124 } 4125 } 4126 else if( mpObj.is() && mpObj->GetObjInventor() == FmFormInventor) 4127 { 4128 #if OSL_DEBUG_LEVEL > 0 4129 const sal_uInt16 nIdent = mpObj->GetObjIdentifier(); 4130 OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: FmFormInventor, but no UNO object?" ); 4131 #endif 4132 static uno::Sequence< OUString > *pSeq = 0; 4133 if( 0 == pSeq ) 4134 { 4135 // OGuard aGuard( Application::GetSolarMutex() ); 4136 // if( 0 == pSeq ) 4137 { 4138 static uno::Sequence< OUString > SvxShape_UnoServices; 4139 comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2, 4140 sUNO_service_drawing_ControlShape, 4141 sUNO_service_drawing_Shape ); 4142 4143 pSeq = &SvxShape_UnoServices; 4144 } 4145 } 4146 return *pSeq; 4147 } 4148 OSL_ENSURE( false, "SvxShape::_getSupportedServiceNames: could not determine object type!" ); 4149 uno::Sequence< OUString > aSeq; 4150 return aSeq; 4151 } 4152 4153 //---------------------------------------------------------------------- 4154 sal_Bool SAL_CALL SvxShape::supportsService( const OUString& ServiceName ) throw ( uno::RuntimeException ) 4155 { 4156 Sequence< OUString > SupportedServices( getSupportedServiceNames() ); 4157 const ::rtl::OUString * pArray = SupportedServices.getConstArray(); 4158 const sal_Int32 nCount = SupportedServices.getLength(); 4159 sal_Int32 i; 4160 for( i = 0; i < nCount; i++ ) 4161 if( *pArray++ == ServiceName ) 4162 return sal_True; 4163 return sal_False; 4164 } 4165 4166 //---------------------------------------------------------------------- 4167 4168 // XGluePointsSupplier 4169 uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints() 4170 throw(uno::RuntimeException) 4171 { 4172 OGuard aGuard( Application::GetSolarMutex() ); 4173 uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints ); 4174 4175 if( mpObj.is() && !xGluePoints.is() ) 4176 { 4177 uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( mpObj.get() ), uno::UNO_QUERY ); 4178 mxGluePoints = xGluePoints = xNew; 4179 } 4180 4181 return xGluePoints; 4182 } 4183 4184 //---------------------------------------------------------------------- 4185 4186 // XChild 4187 uno::Reference< uno::XInterface > SAL_CALL SvxShape::getParent( ) 4188 throw(uno::RuntimeException) 4189 { 4190 OGuard aGuard( Application::GetSolarMutex() ); 4191 4192 if( mpObj.is() && mpObj->GetObjList() ) 4193 { 4194 SdrObjList* pObjList = mpObj->GetObjList(); 4195 4196 switch( pObjList->GetListKind() ) 4197 { 4198 case SDROBJLIST_GROUPOBJ: 4199 if( pObjList->GetOwnerObj()->ISA( SdrObjGroup ) ) 4200 return PTR_CAST( SdrObjGroup, pObjList->GetOwnerObj())->getUnoShape(); 4201 else if( pObjList->GetOwnerObj()->ISA( E3dScene ) ) 4202 return PTR_CAST( E3dScene, pObjList->GetOwnerObj())->getUnoShape(); 4203 break; 4204 case SDROBJLIST_DRAWPAGE: 4205 case SDROBJLIST_MASTERPAGE: 4206 return PTR_CAST( SdrPage, pObjList )->getUnoPage(); 4207 default: 4208 DBG_ERROR( "SvxShape::getParent( ): unexpected SdrObjListKind" ); 4209 break; 4210 } 4211 } 4212 4213 uno::Reference< uno::XInterface > xParent; 4214 return xParent; 4215 } 4216 4217 //---------------------------------------------------------------------- 4218 4219 void SAL_CALL SvxShape::setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& ) 4220 throw(lang::NoSupportException, uno::RuntimeException) 4221 { 4222 throw lang::NoSupportException(); 4223 } 4224 4225 //---------------------------------------------------------------------- 4226 4227 /** called from the XActionLockable interface methods on initial locking */ 4228 void SvxShape::lock() 4229 { 4230 } 4231 4232 //---------------------------------------------------------------------- 4233 4234 /** called from the XActionLockable interface methods on final unlock */ 4235 void SvxShape::unlock() 4236 { 4237 } 4238 4239 //---------------------------------------------------------------------- 4240 4241 // XActionLockable 4242 sal_Bool SAL_CALL SvxShape::isActionLocked( ) throw (::com::sun::star::uno::RuntimeException) 4243 { 4244 OGuard aGuard( Application::GetSolarMutex() ); 4245 4246 return mnLockCount != 0; 4247 } 4248 4249 //---------------------------------------------------------------------- 4250 4251 void SAL_CALL SvxShape::addActionLock( ) throw (::com::sun::star::uno::RuntimeException) 4252 { 4253 OGuard aGuard( Application::GetSolarMutex() ); 4254 4255 DBG_ASSERT( mnLockCount < 0xffff, "lock overflow in SvxShape!" ); 4256 mnLockCount++; 4257 4258 if( mnLockCount == 1 ) 4259 lock(); 4260 } 4261 4262 //---------------------------------------------------------------------- 4263 4264 void SAL_CALL SvxShape::removeActionLock( ) throw (::com::sun::star::uno::RuntimeException) 4265 { 4266 OGuard aGuard( Application::GetSolarMutex() ); 4267 4268 DBG_ASSERT( mnLockCount > 0, "lock underflow in SvxShape!" ); 4269 mnLockCount--; 4270 4271 if( mnLockCount == 0 ) 4272 unlock(); 4273 } 4274 4275 //---------------------------------------------------------------------- 4276 4277 void SAL_CALL SvxShape::setActionLocks( sal_Int16 nLock ) throw (::com::sun::star::uno::RuntimeException ) 4278 { 4279 OGuard aGuard( Application::GetSolarMutex() ); 4280 4281 if( (mnLockCount == 0) && (nLock != 0) ) 4282 unlock(); 4283 4284 if( (mnLockCount != 0) && (nLock == 0) ) 4285 lock(); 4286 4287 mnLockCount = (sal_uInt16)nLock; 4288 } 4289 4290 //---------------------------------------------------------------------- 4291 4292 sal_Int16 SAL_CALL SvxShape::resetActionLocks( ) throw (::com::sun::star::uno::RuntimeException) 4293 { 4294 OGuard aGuard( Application::GetSolarMutex() ); 4295 4296 if( mnLockCount != 0 ) 4297 unlock(); 4298 4299 sal_Int16 nOldLocks = (sal_Int16)mnLockCount; 4300 mnLockCount = 0; 4301 4302 return nOldLocks; 4303 } 4304 4305 //---------------------------------------------------------------------- 4306 4307 /** since polygon shapes can change theire kind during editing, we have 4308 to recheck it here. 4309 Circle shapes also change theire kind, but theire all treated equal 4310 so no update is necessary. 4311 */ 4312 void SvxShape::updateShapeKind() 4313 { 4314 switch( mpImpl->mnObjId ) 4315 { 4316 case OBJ_LINE: 4317 case OBJ_POLY: 4318 case OBJ_PLIN: 4319 case OBJ_PATHLINE: 4320 case OBJ_PATHFILL: 4321 case OBJ_FREELINE: 4322 case OBJ_FREEFILL: 4323 case OBJ_PATHPOLY: 4324 case OBJ_PATHPLIN: 4325 { 4326 const sal_uInt32 nId = mpObj->GetObjIdentifier(); 4327 4328 if( nId != mpImpl->mnObjId ) 4329 { 4330 mpImpl->mnObjId = nId; 4331 4332 } 4333 break; 4334 } 4335 }; 4336 } 4337 4338 /*********************************************************************** 4339 * class SvxShapeText * 4340 ***********************************************************************/ 4341 SvxShapeText::SvxShapeText() throw () 4342 : SvxShape(NULL, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() ) 4343 { 4344 } 4345 4346 //---------------------------------------------------------------------- 4347 SvxShapeText::SvxShapeText( SdrObject* pObject ) throw () 4348 : SvxShape( pObject, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() ) 4349 { 4350 if( pObject && pObject->GetModel() ) 4351 SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) ); 4352 } 4353 4354 //---------------------------------------------------------------------- 4355 SvxShapeText::SvxShapeText( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw () 4356 : SvxShape( pObject, pPropertyMap, pPropertySet ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() ) 4357 { 4358 if( pObject && pObject->GetModel() ) 4359 SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) ); 4360 } 4361 4362 //---------------------------------------------------------------------- 4363 SvxShapeText::~SvxShapeText() throw () 4364 { 4365 // check if only this instance is registered at the ranges 4366 DBG_ASSERT( (NULL == GetEditSource()) || (GetEditSource()->getRanges().size()==1), 4367 "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!"); 4368 } 4369 4370 void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) 4371 { 4372 if( pNewObj && (NULL == GetEditSource())) 4373 SetEditSource( new SvxTextEditSource( pNewObj, 0, static_cast< uno::XWeak* >(this) ) ); 4374 4375 SvxShape::Create( pNewObj, pNewPage ); 4376 } 4377 4378 // XInterface 4379 //---------------------------------------------------------------------- 4380 uno::Any SAL_CALL SvxShapeText::queryInterface( const uno::Type & rType ) 4381 throw( uno::RuntimeException ) 4382 { 4383 return SvxShape::queryInterface( rType ); 4384 } 4385 4386 //---------------------------------------------------------------------- 4387 4388 uno::Any SAL_CALL SvxShapeText::queryAggregation( const uno::Type & rType ) 4389 throw( uno::RuntimeException ) 4390 { 4391 uno::Any aAny( SvxShape::queryAggregation( rType ) ); 4392 if( aAny.hasValue() ) 4393 return aAny; 4394 4395 return SvxUnoTextBase::queryAggregation( rType ); 4396 } 4397 4398 //---------------------------------------------------------------------- 4399 4400 void SAL_CALL SvxShapeText::acquire() throw() 4401 { 4402 SvxShape::acquire(); 4403 } 4404 4405 //---------------------------------------------------------------------- 4406 void SAL_CALL SvxShapeText::release() throw() 4407 { 4408 SvxShape::release(); 4409 } 4410 4411 // XServiceInfo 4412 //---------------------------------------------------------------------- 4413 OUString SAL_CALL SvxShapeText::getImplementationName() throw( uno::RuntimeException ) 4414 { 4415 static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShapeText") ); 4416 return aServiceName; 4417 } 4418 4419 //---------------------------------------------------------------------- 4420 uno::Sequence< OUString > SAL_CALL SvxShapeText::getSupportedServiceNames() throw( uno::RuntimeException ) 4421 { 4422 return SvxShape::getSupportedServiceNames(); 4423 } 4424 4425 //---------------------------------------------------------------------- 4426 sal_Bool SAL_CALL SvxShapeText::supportsService( const OUString& ServiceName ) throw ( uno::RuntimeException ) 4427 { 4428 return SvxShape::supportsService(ServiceName); 4429 } 4430 4431 // XTypeProvider 4432 //---------------------------------------------------------------------- 4433 uno::Sequence< uno::Type > SAL_CALL SvxShapeText::getTypes() 4434 throw( uno::RuntimeException ) 4435 { 4436 return SvxShape::getTypes(); 4437 } 4438 4439 sal_Int64 SAL_CALL SvxShapeText::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException) \ 4440 { 4441 const sal_Int64 nReturn = SvxShape::getSomething( rId ); 4442 if( nReturn ) 4443 return nReturn; 4444 4445 return SvxUnoTextBase::getSomething( rId ); 4446 } 4447 4448 //---------------------------------------------------------------------- 4449 uno::Sequence< sal_Int8 > SAL_CALL SvxShapeText::getImplementationId() 4450 throw( uno::RuntimeException ) 4451 { 4452 static ::cppu::OImplementationId* pID = NULL ; 4453 4454 if ( pID == NULL ) 4455 { 4456 // Ready for multithreading; get global mutex for first call of this method only! see before 4457 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ; 4458 4459 // Control these pointer again ... it can be, that another instance will be faster then these! 4460 if ( pID == NULL ) 4461 { 4462 // Create a new static ID ... 4463 static ::cppu::OImplementationId aID( sal_False ) ; 4464 // ... and set his address to static pointer! 4465 pID = &aID ; 4466 } 4467 } 4468 4469 return pID->getImplementationId() ; 4470 } 4471 4472 //---------------------------------------------------------------------- 4473 4474 /** called from the XActionLockable interface methods on initial locking */ 4475 void SvxShapeText::lock() 4476 { 4477 SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource(); 4478 if( pEditSource ) 4479 pEditSource->lock(); 4480 } 4481 4482 //---------------------------------------------------------------------- 4483 4484 /** called from the XActionLockable interface methods on final unlock */ 4485 void SvxShapeText::unlock() 4486 { 4487 SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource(); 4488 if( pEditSource ) 4489 pEditSource->unlock(); 4490 } 4491 4492 // ::com::sun::star::text::XTextRange 4493 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getStart() throw(uno::RuntimeException) 4494 { 4495 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 4496 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 4497 if( pForwarder ) 4498 ::GetSelection( maSelection, pForwarder ); 4499 return SvxUnoTextBase::getStart(); 4500 4501 } 4502 4503 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getEnd() throw(uno::RuntimeException) 4504 { 4505 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 4506 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 4507 if( pForwarder ) 4508 ::GetSelection( maSelection, pForwarder ); 4509 return SvxUnoTextBase::getEnd(); 4510 } 4511 4512 OUString SAL_CALL SvxShapeText::getString() throw(uno::RuntimeException) 4513 { 4514 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 4515 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 4516 if( pForwarder ) 4517 ::GetSelection( maSelection, pForwarder ); 4518 return SvxUnoTextBase::getString(); 4519 } 4520 4521 4522 void SAL_CALL SvxShapeText::setString( const OUString& aString ) throw(uno::RuntimeException) 4523 { 4524 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 4525 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL; 4526 if( pForwarder ) 4527 ::GetSelection( maSelection, pForwarder ); 4528 SvxUnoTextBase::setString( aString ); 4529 } 4530 4531 // overide these for special property handling in subcasses. Return true if property is handled 4532 bool SvxShapeText::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) 4533 { 4534 // HACK-fix #99090# 4535 // since SdrTextObj::SetVerticalWriting exchanges 4536 // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT, 4537 // we have to set the textdirection here 4538 4539 if( pProperty->nWID == SDRATTR_TEXTDIRECTION ) 4540 { 4541 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() ); 4542 if( pTextObj ) 4543 { 4544 com::sun::star::text::WritingMode eMode; 4545 if( rValue >>= eMode ) 4546 { 4547 pTextObj->SetVerticalWriting( eMode == com::sun::star::text::WritingMode_TB_RL ); 4548 } 4549 } 4550 return true; 4551 } 4552 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); 4553 } 4554 4555 bool SvxShapeText::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) 4556 { 4557 if( pProperty->nWID == SDRATTR_TEXTDIRECTION ) 4558 { 4559 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() ); 4560 if( pTextObj && pTextObj->IsVerticalWriting() ) 4561 rValue <<= com::sun::star::text::WritingMode_TB_RL; 4562 else 4563 rValue <<= com::sun::star::text::WritingMode_LR_TB; 4564 return true; 4565 } 4566 4567 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); 4568 } 4569 4570 bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) 4571 { 4572 return SvxShape::getPropertyStateImpl( pProperty, rState ); 4573 } 4574 4575 bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) 4576 { 4577 return SvxShape::setPropertyToDefaultImpl( pProperty ); 4578 } 4579 4580 /*********************************************************************** 4581 * class SvxShapeRect * 4582 ***********************************************************************/ 4583 DBG_NAME(SvxShapeRect) 4584 SvxShapeRect::SvxShapeRect( SdrObject* pObj ) throw() 4585 : SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_SHAPE), aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool())) 4586 { 4587 DBG_CTOR(SvxShapeRect,NULL); 4588 } 4589 4590 SvxShapeRect::~SvxShapeRect() throw() 4591 { 4592 DBG_DTOR(SvxShapeRect,NULL); 4593 } 4594 4595 uno::Any SAL_CALL SvxShapeRect::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException) 4596 { 4597 return SvxShapeText::queryInterface( rType ); 4598 } 4599 4600 uno::Any SAL_CALL SvxShapeRect::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) 4601 { 4602 return SvxShapeText::queryAggregation( rType ); 4603 } 4604 4605 void SAL_CALL SvxShapeRect::acquire() throw() 4606 { 4607 OWeakAggObject::acquire(); 4608 } 4609 4610 void SAL_CALL SvxShapeRect::release() throw() 4611 { 4612 OWeakAggObject::release(); 4613 } 4614 //---------------------------------------------------------------------- 4615 // XServiceInfo 4616 //---------------------------------------------------------------------- 4617 uno::Sequence< OUString > SvxShapeRect::getSupportedServiceNames(void) throw( uno::RuntimeException ) 4618 { 4619 return SvxShape::getSupportedServiceNames(); 4620 } 4621 4622 /** returns a StarOffice API wrapper for the given SdrObject */ 4623 uno::Reference< drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) throw () 4624 { 4625 uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY ); 4626 return xShape; 4627 } 4628 4629 /** returns the SdrObject from the given StarOffice API wrapper */ 4630 SdrObject* GetSdrObjectFromXShape( uno::Reference< drawing::XShape > xShape ) throw() 4631 { 4632 SvxShape* pShape = SvxShape::getImplementation( xShape ); 4633 return pShape ? pShape->GetSdrObject() : 0; 4634 } 4635 4636 //---------------------------------------------------------------------- 4637 4638 SdrObject* SdrObject::getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt ) 4639 { 4640 SvxShape* pSvxShape = SvxShape::getImplementation( xInt ); 4641 return pSvxShape ? pSvxShape->GetSdrObject() : 0; 4642 } 4643 4644 uno::Any SvxItemPropertySet_getPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet ) 4645 { 4646 if(!pMap || !pMap->nWID) 4647 return uno::Any(); 4648 4649 // Check is for items that store either metric values if thei are positiv or percentage if thei are negativ. 4650 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY ); 4651 return rPropSet.getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES), bDontConvertNegativeValues ); 4652 } 4653 4654 void SvxItemPropertySet_setPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet ) 4655 { 4656 if(!pMap || !pMap->nWID) 4657 return; 4658 4659 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY ); 4660 rPropSet.setPropertyValue( pMap, rVal, rSet, bDontConvertNegativeValues ); 4661 } 4662