bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / unodraw / unoshape.cxx
blob5a376d3e33354e04367479244a3d558216f765a9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <cppuhelper/typeprovider.hxx>
21 #include <cppuhelper/supportsservice.hxx>
22 #include <com/sun/star/awt/XBitmap.hpp>
23 #include <com/sun/star/awt/Rectangle.hpp>
24 #include <com/sun/star/drawing/CircleKind.hpp>
25 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
26 #include <vcl/svapp.hxx>
27 #include <svl/itemprop.hxx>
28 #include <vcl/fltcall.hxx>
29 #include <osl/mutex.hxx>
30 #include <editeng/unotext.hxx>
31 #include <svx/svdobj.hxx>
32 #include <svx/svdoole2.hxx>
33 #include "svx/shapepropertynotifier.hxx"
34 #include <comphelper/extract.hxx>
35 #include <comphelper/scopeguard.hxx>
36 #include <comphelper/servicehelper.hxx>
37 #include <comphelper/serviceinfohelper.hxx>
38 #include <toolkit/helper/vclunohelper.hxx>
39 #include <vcl/gfxlink.hxx>
40 #include <vcl/virdev.hxx>
41 #include <sfx2/objsh.hxx>
42 #include <sfx2/viewsh.hxx>
43 #include "svx/svdopage.hxx"
44 #include "svx/xflbstit.hxx"
45 #include "svx/xflbmtit.hxx"
46 #include "svx/xlnstit.hxx"
47 #include "svx/xlnedit.hxx"
48 #include "svx/svdogrp.hxx"
49 #include "svx/scene3d.hxx"
50 #include "svx/svdmodel.hxx"
51 #include "svx/globl3d.hxx"
52 #include "svx/fmglob.hxx"
53 #include "svx/unopage.hxx"
54 #include "svx/view3d.hxx"
55 #include "svx/unoshape.hxx"
56 #include "svx/svxids.hrc"
57 #include "svx/unoshtxt.hxx"
58 #include "svx/svdpage.hxx"
59 #include "svx/unoshprp.hxx"
60 #include "svx/sxciaitm.hxx"
61 #include "svx/svdograf.hxx"
62 #include "svx/unoapi.hxx"
63 #include "svx/svdomeas.hxx"
64 #include "svx/svdpagv.hxx"
65 #include "svx/svdpool.hxx"
66 #include <tools/gen.hxx>
67 #include "svx/dialmgr.hxx"
68 #include "svx/dialogs.hrc"
69 #include "svx/svdocapt.hxx"
70 #include <svx/obj3d.hxx>
71 #include <tools/diagnose_ex.h>
72 #include "svx/xflftrit.hxx"
73 #include "svx/xtable.hxx"
74 #include "svx/xbtmpit.hxx"
75 #include "svx/xflgrit.hxx"
76 #include "svx/xflhtit.hxx"
77 #include "svx/xlndsit.hxx"
78 #include "svdglob.hxx"
79 #include "svx/svdstr.hrc"
80 #include "svx/unomaster.hxx"
81 #include <editeng/outlobj.hxx>
82 #include <basegfx/matrix/b2dhommatrix.hxx>
83 #include <basegfx/matrix/b2dhommatrixtools.hxx>
84 #include <basegfx/polygon/b2dpolypolygontools.hxx>
85 #include <basegfx/tools/unotools.hxx>
86 #include "gluepts.hxx"
87 #include "shapeimpl.hxx"
88 #include <sal/log.hxx>
90 #include <vector>
92 #include "svx/lathe3d.hxx"
93 #include "svx/extrud3d.hxx"
95 #include <boost/bind.hpp>
96 #include <boost/scoped_ptr.hpp>
97 #include <vcl/wmf.hxx>
99 using namespace ::osl;
100 using namespace ::cppu;
101 using namespace ::com::sun::star;
102 using namespace ::com::sun::star::uno;
103 using namespace ::com::sun::star::lang;
104 using namespace ::com::sun::star::container;
105 using svx::PropertyValueProvider;
106 using svx::IPropertyValueProvider;
108 class GDIMetaFile;
110 struct SvxShapeImpl
112 SvxShape& mrAntiImpl;
113 SfxItemSet* mpItemSet;
114 sal_uInt32 mnObjId;
115 SvxShapeMaster* mpMaster;
116 bool mbHasSdrObjectOwnership;
117 bool mbDisposing;
119 /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when
120 * a SvxShape::Create() call is executed. It is then set to the created
121 * SdrObject so a multiple call to SvxShape::Create() with same SdrObject
122 * is prohibited.
124 ::tools::WeakReference< SdrObject > mpCreatedObj;
126 // for xComponent
127 ::cppu::OInterfaceContainerHelper maDisposeListeners;
128 svx::PropertyChangeNotifier maPropertyNotifier;
130 SvxShapeImpl( SvxShape& _rAntiImpl, ::osl::Mutex& _rMutex )
131 :mrAntiImpl( _rAntiImpl )
132 ,mpItemSet( NULL )
133 ,mnObjId( 0 )
134 ,mpMaster( NULL )
135 ,mbHasSdrObjectOwnership( false )
136 ,mbDisposing( false )
137 ,mpCreatedObj()
138 ,maDisposeListeners( _rMutex )
139 ,maPropertyNotifier( _rAntiImpl, _rMutex )
144 class ShapePositionProvider : public PropertyValueProvider
146 public:
147 ShapePositionProvider( const SvxShapeImpl& _shapeImpl )
148 :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Position" )
152 protected:
153 virtual void getCurrentValue( Any& _out_rCurrentValue ) const SAL_OVERRIDE
155 _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getPosition();
160 class ShapeSizeProvider : public PropertyValueProvider
162 public:
163 ShapeSizeProvider( const SvxShapeImpl& _shapeImpl )
164 :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Size" )
168 protected:
169 virtual void getCurrentValue( Any& _out_rCurrentValue ) const SAL_OVERRIDE
171 _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getSize();
175 SvxShape::SvxShape( SdrObject* pObject ) throw( uno::RuntimeException )
176 : maSize(100,100)
177 , mpImpl( new SvxShapeImpl( *this, maMutex ) )
178 , mbIsMultiPropertyCall(false)
179 , mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
180 , maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
181 , mpObj(pObject)
182 , mpModel(NULL)
183 , mnLockCount(0)
185 impl_construct();
189 SvxShape::SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries, const SvxItemPropertySet* pPropertySet ) throw( uno::RuntimeException )
190 : maSize(100,100)
191 , mpImpl( new SvxShapeImpl( *this, maMutex ) )
192 , mbIsMultiPropertyCall(false)
193 , mpPropSet(pPropertySet)
194 , maPropMapEntries(pEntries)
195 , mpObj(pObject)
196 , mpModel(NULL)
197 , mnLockCount(0)
199 impl_construct();
203 SvxShape::SvxShape() throw( uno::RuntimeException )
204 : maSize(100,100)
205 , mpImpl( new SvxShapeImpl( *this, maMutex ) )
206 , mbIsMultiPropertyCall(false)
207 , mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
208 , maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
209 , mpObj(NULL)
210 , mpModel(NULL)
211 , mnLockCount(0)
213 impl_construct();
217 SvxShape::~SvxShape() throw()
219 ::SolarMutexGuard aGuard;
221 DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" );
223 if ( mpModel )
224 EndListening( *mpModel );
226 if ( mpImpl->mpMaster )
227 mpImpl->mpMaster->dispose();
229 if ( mpObj.is() )
230 mpObj->setUnoShape(NULL);
232 if( HasSdrObjectOwnership() && mpObj.is() )
234 mpImpl->mbHasSdrObjectOwnership = false;
235 SdrObject* pObject = mpObj.get();
236 SdrObject::Free( pObject );
239 delete mpImpl, mpImpl = NULL;
241 EndListeningAll(); // call explictily within SolarMutexGuard
246 void SvxShape::TakeSdrObjectOwnership()
248 mpImpl->mbHasSdrObjectOwnership = true;
253 bool SvxShape::HasSdrObjectOwnership() const
255 if ( !mpImpl->mbHasSdrObjectOwnership )
256 return false;
258 OSL_ENSURE( mpObj.is(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
259 return mpObj.is();
264 void SvxShape::setShapeKind( sal_uInt32 nKind )
266 mpImpl->mnObjId = nKind;
271 sal_uInt32 SvxShape::getShapeKind() const
273 return mpImpl->mnObjId;
278 void SvxShape::setMaster( SvxShapeMaster* pMaster )
280 mpImpl->mpMaster = pMaster;
285 uno::Any SAL_CALL SvxShape::queryAggregation( const uno::Type& rType ) throw (uno::RuntimeException, std::exception)
287 if( mpImpl->mpMaster )
289 uno::Any aAny;
290 if( mpImpl->mpMaster->queryAggregation( rType, aAny ) )
291 return aAny;
294 return SvxShape_UnoImplHelper::queryAggregation(rType);
297 namespace
299 class theSvxShapeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvxShapeUnoTunnelId > {};
302 const ::com::sun::star::uno::Sequence< sal_Int8 > & SvxShape::getUnoTunnelId() throw()
304 return theSvxShapeUnoTunnelId::get().getSeq();
308 SvxShape* SvxShape::getImplementation( const uno::Reference< uno::XInterface >& xInt )
310 uno::Reference< lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY );
311 if( xUT.is() )
312 return reinterpret_cast<SvxShape*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxShape::getUnoTunnelId())));
313 else
314 return NULL;
318 sal_Int64 SAL_CALL SvxShape::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException, std::exception) \
320 if( rId.getLength() == 16 && 0 == memcmp( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) )
322 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
324 else
326 return 0;
331 svx::PropertyChangeNotifier& SvxShape::getShapePropertyChangeNotifier()
333 return mpImpl->maPropertyNotifier;
337 void SvxShape::impl_construct()
339 mpImpl->maPropertyNotifier.registerProvider( svx::eShapePosition,
340 svx::PPropertyValueProvider( new ShapePositionProvider( *mpImpl ) ) );
341 mpImpl->maPropertyNotifier.registerProvider( svx::eShapeSize,
342 svx::PPropertyValueProvider( new ShapeSizeProvider( *mpImpl ) ) );
344 if ( mpObj.is() )
345 impl_initFromSdrObject();
349 void SvxShape::impl_initFromSdrObject()
351 DBG_TESTSOLARMUTEX();
352 OSL_PRECOND( mpObj.is(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
353 if ( !mpObj.is() )
354 return;
356 osl_atomic_increment( &m_refCount );
358 mpObj->setUnoShape(*this);
360 osl_atomic_decrement( &m_refCount );
362 mpModel = mpObj->GetModel();
364 // #i40944#
365 // Do not simply return when no model but do the type corrections
366 // following below.
367 if(mpModel)
369 StartListening( *mpModel );
372 const sal_uInt32 nInventor = mpObj->GetObjInventor();
374 // is it one of ours (svx) ?
375 if( nInventor == SdrInventor || nInventor == E3dInventor || nInventor == FmFormInventor )
377 if(nInventor == FmFormInventor)
379 mpImpl->mnObjId = OBJ_UNO;
381 else
383 mpImpl->mnObjId = mpObj->GetObjIdentifier();
384 if( nInventor == E3dInventor )
385 mpImpl->mnObjId |= E3D_INVENTOR_FLAG;
388 switch(mpImpl->mnObjId)
390 case OBJ_CCUT: // segment of circle
391 case OBJ_CARC: // arc of circle
392 case OBJ_SECT: // sector
393 mpImpl->mnObjId = OBJ_CIRC;
394 break;
396 case E3D_SCENE_ID | E3D_INVENTOR_FLAG:
397 mpImpl->mnObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG;
398 break;
404 void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
406 DBG_TESTSOLARMUTEX();
408 OSL_PRECOND( pNewObj, "SvxShape::Create: invalid new object!" );
409 if ( !pNewObj )
410 return;
412 SdrObject* pCreatedObj = mpImpl->mpCreatedObj.get();
413 OSL_ENSURE( ( pCreatedObj == NULL ) || ( pCreatedObj == pNewObj ),
414 "SvxShape::Create: the same shape used for two different objects?! Strange ..." );
416 // Correct condition (#i52126#)
417 if ( pCreatedObj != pNewObj )
419 DBG_ASSERT( pNewObj->GetModel(), "no model for SdrObject?" );
420 // Correct condition (#i52126#)
421 mpImpl->mpCreatedObj = pNewObj;
423 if( mpObj.is() && mpObj->GetModel() )
425 EndListening( *mpObj->GetModel() );
428 mpObj.reset( pNewObj );
430 OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" );
431 // this was previously set in impl_initFromSdrObject, but I think it was superfluous
432 // (it definitely was in the other context where it was called, but I strongly suppose
433 // it was also superfluous when called from here)
434 impl_initFromSdrObject();
436 ObtainSettingsFromPropertySet( *mpPropSet );
438 // save user call
439 SdrObjUserCall* pUser = mpObj->GetUserCall();
440 mpObj->SetUserCall(NULL);
442 setPosition( maPosition );
443 setSize( maSize );
445 // restore user call after we set the initial size
446 mpObj->SetUserCall( pUser );
448 // if this shape was already named, use this name
449 if( !maShapeName.isEmpty() )
451 mpObj->SetName( maShapeName );
452 maShapeName.clear();
459 void SvxShape::ChangeModel( SdrModel* pNewModel )
461 DBG_TESTSOLARMUTEX();
462 if( mpObj.is() && mpObj->GetModel() )
464 if( mpObj->GetModel() != pNewModel )
466 EndListening( *mpObj->GetModel() );
470 // Always listen to new model (#i52126#)
471 if( pNewModel )
473 StartListening( *pNewModel );
476 // HACK #i53696# ChangeModel should be virtual, but it isn't. can't change that for 2.0.1
477 SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( this );
478 if( pShapeText )
480 SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() );
481 if( pTextEditSource )
482 pTextEditSource->ChangeModel( pNewModel );
485 mpModel = pNewModel;
487 if( mpImpl->mpMaster )
488 mpImpl->mpMaster->modelChanged( pNewModel );
493 void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw()
495 DBG_TESTSOLARMUTEX();
496 if(mpModel)
498 SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
499 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
501 switch(eMapUnit)
503 case SFX_MAPUNIT_TWIP :
505 rPoint.A() = MM_TO_TWIPS(rPoint.A());
506 rPoint.B() = MM_TO_TWIPS(rPoint.B());
507 break;
509 default:
511 OSL_FAIL("AW: Missing unit translation to PoolMetric!");
518 // Reintroduction of fix for issue i59051 (#i108851#)
519 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
521 DBG_TESTSOLARMUTEX();
522 if(mpModel)
524 SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
525 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
527 switch(eMapUnit)
529 case SFX_MAPUNIT_TWIP :
531 basegfx::B2DHomMatrix aTransform;
532 const double fMMToTWIPS(72.0 / 127.0);
534 aTransform.scale(fMMToTWIPS, fMMToTWIPS);
535 rPolyPolygon.transform(aTransform);
536 break;
538 default:
540 OSL_FAIL("Missing unit translation to PoolMetric!");
548 void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw()
550 DBG_TESTSOLARMUTEX();
551 SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM;
552 if(mpModel)
554 eMapUnit = mpModel->GetItemPool().GetMetric(0);
555 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
557 switch(eMapUnit)
559 case SFX_MAPUNIT_TWIP :
561 rPoint.A() = TWIPS_TO_MM(rPoint.A());
562 rPoint.B() = TWIPS_TO_MM(rPoint.B());
563 break;
565 default:
567 OSL_FAIL("AW: Missing unit translation to 100th mm!");
574 // Reintroduction of fix for issue i59051 (#i108851#)
575 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
577 DBG_TESTSOLARMUTEX();
578 SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM;
579 if(mpModel)
581 eMapUnit = mpModel->GetItemPool().GetMetric(0);
582 if(eMapUnit != SFX_MAPUNIT_100TH_MM)
584 switch(eMapUnit)
586 case SFX_MAPUNIT_TWIP :
588 basegfx::B2DHomMatrix aTransform;
589 const double fTWIPSToMM(127.0 / 72.0);
590 aTransform.scale(fTWIPSToMM, fTWIPSToMM);
591 rPolyPolygon.transform(aTransform);
592 break;
594 default:
596 OSL_FAIL("Missing unit translation to 100th mm!");
604 void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet,
605 SfxItemSet& rSet, uno::Reference< beans::XPropertySet > xSet, const SfxItemPropertyMap* pMap )
607 if(rPropSet.AreThereOwnUsrAnys())
609 const SfxItemPropertyMap& rSrc = rPropSet.getPropertyMap();
610 PropertyEntryVector_t aSrcPropVector = rSrc.getPropertyEntries();
611 PropertyEntryVector_t::const_iterator aSrcIt = aSrcPropVector.begin();
612 while(aSrcIt != aSrcPropVector.end())
614 if(aSrcIt->nWID)
616 uno::Any* pUsrAny = rPropSet.GetUsrAnyForID(aSrcIt->nWID);
617 if(pUsrAny)
619 // search for equivalent entry in pDst
620 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aSrcIt->sName );
621 if(pEntry)
623 // entry found
624 if(pEntry->nWID >= OWN_ATTR_VALUE_START && pEntry->nWID <= OWN_ATTR_VALUE_END)
626 // special ID in PropertySet, can only be set
627 // directly at the object
628 xSet->setPropertyValue( aSrcIt->sName, *pUsrAny);
630 else
632 if(SfxItemPool::IsWhich(pEntry->nWID))
633 rSet.Put(rSet.GetPool()->GetDefaultItem(pEntry->nWID));
634 // set
635 SvxItemPropertySet_setPropertyValue(pEntry, *pUsrAny, rSet);
641 // next entry
642 ++aSrcIt;
644 const_cast< SvxItemPropertySet& >(rPropSet).ClearAllUsrAny();
649 void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet)
651 DBG_TESTSOLARMUTEX();
652 if(mpObj.is() && rPropSet.AreThereOwnUsrAnys() && mpModel)
654 SfxItemSet aSet( mpModel->GetItemPool(), SDRATTR_START, SDRATTR_END);
655 Reference< beans::XPropertySet > xShape( (OWeakObject*)this, UNO_QUERY );
656 SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet, aSet, xShape, &mpPropSet->getPropertyMap() );
658 mpObj->SetMergedItemSetAndBroadcast(aSet);
660 mpObj->ApplyNotPersistAttr( aSet );
664 uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
665 throw (uno::RuntimeException, std::exception)
667 DBG_TESTSOLARMUTEX();
668 uno::Any aAny;
670 if( !mpObj.is() || mpModel == NULL || !mpObj->IsInserted() || NULL == mpObj->GetPage() )
671 return aAny;
673 ScopedVclPtrInstance< VirtualDevice > pVDev;
674 pVDev->SetMapMode(MapMode(MAP_100TH_MM));
676 SdrModel* pModel = mpObj->GetModel();
677 SdrPage* pPage = mpObj->GetPage();
679 boost::scoped_ptr<E3dView> pView(new E3dView( pModel, pVDev.get() ));
680 pView->hideMarkHandles();
681 SdrPageView* pPageView = pView->ShowSdrPage(pPage);
683 SdrObject *pTempObj = mpObj.get();
684 pView->MarkObj(pTempObj,pPageView);
686 Rectangle aRect(pTempObj->GetCurrentBoundRect());
687 aRect.Justify();
688 Size aSize(aRect.GetSize());
690 GDIMetaFile aMtf( pView->GetMarkedObjMetaFile() );
691 if( bMetaFile )
693 SvMemoryStream aDestStrm( 65535, 65535 );
694 ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, false );
695 const uno::Sequence<sal_Int8> aSeq(
696 static_cast< const sal_Int8* >(aDestStrm.GetData()),
697 aDestStrm.GetEndOfData());
698 aAny.setValue( &aSeq, cppu::UnoType<uno::Sequence< sal_Int8 >>::get() );
700 else
702 Graphic aGraph(aMtf);
703 aGraph.SetPrefSize(aSize);
704 aGraph.SetPrefMapMode(MAP_100TH_MM);
706 Reference< awt::XBitmap > xBmp( aGraph.GetXGraphic(), UNO_QUERY );
707 aAny <<= xBmp;
710 pView->UnmarkAll();
712 return aAny;
715 uno::Sequence< uno::Type > SAL_CALL SvxShape::getTypes()
716 throw (uno::RuntimeException, std::exception)
718 if( mpImpl->mpMaster )
720 return mpImpl->mpMaster->getTypes();
722 else
724 return _getTypes();
730 uno::Sequence< uno::Type > SAL_CALL SvxShape::_getTypes()
731 throw(uno::RuntimeException)
733 switch( mpImpl->mnObjId )
735 // shapes without text
736 case OBJ_PAGE:
737 case OBJ_FRAME:
738 case OBJ_OLE2_PLUGIN:
739 case OBJ_OLE2_APPLET:
740 case E3D_CUBEOBJ_ID|E3D_INVENTOR_FLAG:
741 case E3D_SPHEREOBJ_ID|E3D_INVENTOR_FLAG:
742 case E3D_LATHEOBJ_ID|E3D_INVENTOR_FLAG:
743 case E3D_EXTRUDEOBJ_ID|E3D_INVENTOR_FLAG:
744 case E3D_POLYGONOBJ_ID|E3D_INVENTOR_FLAG:
745 case OBJ_MEDIA:
747 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
749 if( aTypeSequence.getLength() == 0 )
751 // Ready for multithreading; get global mutex for first call of this method only! see before
752 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
754 // Control these pointer again ... it can be, that another instance will be faster then these!
755 if( aTypeSequence.getLength() == 0 )
757 aTypeSequence.realloc( 12 );
758 uno::Type* pTypes = aTypeSequence.getArray();
760 *pTypes++ = cppu::UnoType<drawing::XShape>::get();
761 *pTypes++ = cppu::UnoType<lang::XComponent>::get();
762 *pTypes++ = cppu::UnoType<beans::XPropertySet>::get();
763 *pTypes++ = cppu::UnoType<beans::XMultiPropertySet>::get();
764 *pTypes++ = cppu::UnoType<beans::XPropertyState>::get();
765 *pTypes++ = cppu::UnoType<beans::XMultiPropertyStates>::get();
766 *pTypes++ = cppu::UnoType<drawing::XGluePointsSupplier>::get();
767 *pTypes++ = cppu::UnoType<container::XChild>::get();
768 *pTypes++ = cppu::UnoType<lang::XServiceInfo>::get();
769 *pTypes++ = cppu::UnoType<lang::XTypeProvider>::get();
770 *pTypes++ = cppu::UnoType<lang::XUnoTunnel>::get();
771 *pTypes++ = cppu::UnoType<container::XNamed>::get();
774 return aTypeSequence;
776 // group shape
777 case OBJ_GRUP:
779 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
781 if( aTypeSequence.getLength() == 0 )
783 // Ready for multithreading; get global mutex for first call of this method only! see before
784 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
786 // Control these pointer again ... it can be, that another instance will be faster then these!
787 if( aTypeSequence.getLength() == 0 )
789 aTypeSequence.realloc( 14 );
790 uno::Type* pTypes = aTypeSequence.getArray();
792 *pTypes++ = cppu::UnoType<drawing::XShape>::get();
793 *pTypes++ = cppu::UnoType<lang::XComponent>::get();
794 *pTypes++ = cppu::UnoType<beans::XPropertySet>::get();
795 *pTypes++ = cppu::UnoType<beans::XMultiPropertySet>::get();
796 *pTypes++ = cppu::UnoType<beans::XPropertyState>::get();
797 *pTypes++ = cppu::UnoType<beans::XMultiPropertyStates>::get();
798 *pTypes++ = cppu::UnoType<drawing::XGluePointsSupplier>::get();
799 *pTypes++ = cppu::UnoType<container::XChild>::get();
800 *pTypes++ = cppu::UnoType<lang::XServiceInfo>::get();
801 *pTypes++ = cppu::UnoType<lang::XTypeProvider>::get();
802 *pTypes++ = cppu::UnoType<lang::XUnoTunnel>::get();
803 *pTypes++ = cppu::UnoType<container::XNamed>::get();
804 *pTypes++ = cppu::UnoType<drawing::XShapes>::get();
805 *pTypes++ = cppu::UnoType<drawing::XShapeGroup>::get();
808 return aTypeSequence;
810 // connector shape
811 case OBJ_EDGE:
813 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
815 if( aTypeSequence.getLength() == 0 )
817 // Ready for multithreading; get global mutex for first call of this method only! see before
818 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
820 // Control these pointer again ... it can be, that another instance will be faster then these!
821 if( aTypeSequence.getLength() == 0 )
823 aTypeSequence.realloc( 17 );
824 uno::Type* pTypes = aTypeSequence.getArray();
826 *pTypes++ = cppu::UnoType<drawing::XShape>::get();
827 *pTypes++ = cppu::UnoType<lang::XComponent>::get();
828 *pTypes++ = cppu::UnoType<beans::XPropertySet>::get();
829 *pTypes++ = cppu::UnoType<beans::XMultiPropertySet>::get();
830 *pTypes++ = cppu::UnoType<beans::XPropertyState>::get();
831 *pTypes++ = cppu::UnoType<beans::XMultiPropertyStates>::get();
832 *pTypes++ = cppu::UnoType<drawing::XGluePointsSupplier>::get();
833 *pTypes++ = cppu::UnoType<container::XChild>::get();
834 *pTypes++ = cppu::UnoType<lang::XServiceInfo>::get();
835 *pTypes++ = cppu::UnoType<lang::XTypeProvider>::get();
836 *pTypes++ = cppu::UnoType<lang::XUnoTunnel>::get();
837 *pTypes++ = cppu::UnoType<container::XNamed>::get();
838 *pTypes++ = cppu::UnoType<drawing::XConnectorShape>::get();
839 // from SvxUnoTextBase::getTypes()
840 *pTypes++ = cppu::UnoType<text::XTextAppend>::get();
841 *pTypes++ = cppu::UnoType<text::XTextCopy>::get();
842 *pTypes++ = cppu::UnoType<container::XEnumerationAccess>::get();
843 *pTypes++ = cppu::UnoType<text::XTextRangeMover>::get();
846 return aTypeSequence;
848 // control shape
849 case OBJ_UNO:
851 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
853 if( aTypeSequence.getLength() == 0 )
855 // Ready for multithreading; get global mutex for first call of this method only! see before
856 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
858 // Control these pointer again ... it can be, that another instance will be faster then these!
859 if( aTypeSequence.getLength() == 0 )
861 aTypeSequence.realloc( 13 );
862 uno::Type* pTypes = aTypeSequence.getArray();
864 *pTypes++ = cppu::UnoType<drawing::XShape>::get();
865 *pTypes++ = cppu::UnoType<lang::XComponent>::get();
866 *pTypes++ = cppu::UnoType<beans::XPropertySet>::get();
867 *pTypes++ = cppu::UnoType<beans::XMultiPropertySet>::get();
868 *pTypes++ = cppu::UnoType<beans::XPropertyState>::get();
869 *pTypes++ = cppu::UnoType<beans::XMultiPropertyStates>::get();
870 *pTypes++ = cppu::UnoType<drawing::XGluePointsSupplier>::get();
871 *pTypes++ = cppu::UnoType<container::XChild>::get();
872 *pTypes++ = cppu::UnoType<lang::XServiceInfo>::get();
873 *pTypes++ = cppu::UnoType<lang::XTypeProvider>::get();
874 *pTypes++ = cppu::UnoType<lang::XUnoTunnel>::get();
875 *pTypes++ = cppu::UnoType<container::XNamed>::get();
876 *pTypes++ = cppu::UnoType<drawing::XControlShape>::get();
879 return aTypeSequence;
881 // 3d scene shape
882 case E3D_POLYSCENE_ID|E3D_INVENTOR_FLAG:
884 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
886 if( aTypeSequence.getLength() == 0 )
888 // Ready for multithreading; get global mutex for first call of this method only! see before
889 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
891 // Control these pointer again ... it can be, that another instance will be faster then these!
892 if( aTypeSequence.getLength() == 0 )
894 aTypeSequence.realloc( 13 );
895 uno::Type* pTypes = aTypeSequence.getArray();
897 *pTypes++ = cppu::UnoType<drawing::XShape>::get();
898 *pTypes++ = cppu::UnoType<lang::XComponent>::get();
899 *pTypes++ = cppu::UnoType<beans::XPropertySet>::get();
900 *pTypes++ = cppu::UnoType<beans::XMultiPropertySet>::get();
901 *pTypes++ = cppu::UnoType<beans::XPropertyState>::get();
902 *pTypes++ = cppu::UnoType<beans::XMultiPropertyStates>::get();
903 *pTypes++ = cppu::UnoType<drawing::XGluePointsSupplier>::get();
904 *pTypes++ = cppu::UnoType<container::XChild>::get();
905 *pTypes++ = cppu::UnoType<lang::XServiceInfo>::get();
906 *pTypes++ = cppu::UnoType<lang::XTypeProvider>::get();
907 *pTypes++ = cppu::UnoType<lang::XUnoTunnel>::get();
908 *pTypes++ = cppu::UnoType<container::XNamed>::get();
909 *pTypes++ = cppu::UnoType<drawing::XShapes>::get();
912 return aTypeSequence;
914 case OBJ_CUSTOMSHAPE:
916 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
918 if( aTypeSequence.getLength() == 0 )
920 // Ready for multithreading; get global mutex for first call of this method only! see before
921 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
923 // Control these pointer again ... it can be, that another instance will be faster then these!
924 if( aTypeSequence.getLength() == 0 )
926 aTypeSequence.realloc( 16 );
927 uno::Type* pTypes = aTypeSequence.getArray();
929 *pTypes++ = cppu::UnoType<drawing::XShape>::get();
930 *pTypes++ = cppu::UnoType<lang::XComponent>::get();
931 *pTypes++ = cppu::UnoType<beans::XPropertySet>::get();
932 *pTypes++ = cppu::UnoType<beans::XMultiPropertySet>::get();
933 *pTypes++ = cppu::UnoType<beans::XPropertyState>::get();
934 *pTypes++ = cppu::UnoType<beans::XMultiPropertyStates>::get();
935 *pTypes++ = cppu::UnoType<drawing::XGluePointsSupplier>::get();
936 *pTypes++ = cppu::UnoType<container::XChild>::get();
937 *pTypes++ = cppu::UnoType<lang::XServiceInfo>::get();
938 *pTypes++ = cppu::UnoType<lang::XTypeProvider>::get();
939 *pTypes++ = cppu::UnoType<lang::XUnoTunnel>::get();
940 *pTypes++ = cppu::UnoType<container::XNamed>::get();
941 // from SvxUnoTextBase::getTypes()
942 *pTypes++ = cppu::UnoType<text::XText>::get();
943 *pTypes++ = cppu::UnoType<container::XEnumerationAccess>::get();
944 *pTypes++ = cppu::UnoType<text::XTextRangeMover>::get();
945 *pTypes++ = cppu::UnoType<drawing::XEnhancedCustomShapeDefaulter>::get();
948 return aTypeSequence;
950 // shapes with text
951 case OBJ_RECT:
952 case OBJ_CIRC:
953 case OBJ_MEASURE:
954 case OBJ_LINE:
955 case OBJ_POLY:
956 case OBJ_PLIN:
957 case OBJ_PATHLINE:
958 case OBJ_PATHFILL:
959 case OBJ_FREELINE:
960 case OBJ_FREEFILL:
961 case OBJ_PATHPOLY:
962 case OBJ_PATHPLIN:
963 case OBJ_GRAF:
964 case OBJ_TEXT:
965 case OBJ_CAPTION:
966 case OBJ_TABLE:
967 case OBJ_OLE2: // #i118485# Moved to shapes with text
968 default:
970 static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
972 if( aTypeSequence.getLength() == 0 )
974 // Ready for multithreading; get global mutex for first call of this method only! see before
975 MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
977 // Control these pointer again ... it can be, that another instance will be faster then these!
978 if( aTypeSequence.getLength() == 0 )
980 aTypeSequence.realloc( 16 );
981 uno::Type* pTypes = aTypeSequence.getArray();
983 *pTypes++ = cppu::UnoType<drawing::XShape>::get();
984 *pTypes++ = cppu::UnoType<lang::XComponent>::get();
985 *pTypes++ = cppu::UnoType<beans::XPropertySet>::get();
986 *pTypes++ = cppu::UnoType<beans::XMultiPropertySet>::get();
987 *pTypes++ = cppu::UnoType<beans::XPropertyState>::get();
988 *pTypes++ = cppu::UnoType<beans::XMultiPropertyStates>::get();
989 *pTypes++ = cppu::UnoType<drawing::XGluePointsSupplier>::get();
990 *pTypes++ = cppu::UnoType<container::XChild>::get();
991 *pTypes++ = cppu::UnoType<lang::XServiceInfo>::get();
992 *pTypes++ = cppu::UnoType<lang::XTypeProvider>::get();
993 *pTypes++ = cppu::UnoType<lang::XUnoTunnel>::get();
994 *pTypes++ = cppu::UnoType<container::XNamed>::get();
995 // from SvxUnoTextBase::getTypes()
996 *pTypes++ = cppu::UnoType<text::XTextAppend>::get();
997 *pTypes++ = cppu::UnoType<text::XTextCopy>::get();
998 *pTypes++ = cppu::UnoType<container::XEnumerationAccess>::get();
999 *pTypes++ = cppu::UnoType<text::XTextRangeMover>::get();
1002 return aTypeSequence;
1009 uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId()
1010 throw (uno::RuntimeException, std::exception)
1012 return css::uno::Sequence<sal_Int8>();
1015 void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
1017 DBG_TESTSOLARMUTEX();
1018 if( !mpObj.is() )
1019 return;
1021 // #i55919# HINT_OBJCHG is only interesting if it's for this object
1023 const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint);
1024 if (!pSdrHint || ( /* (pSdrHint->GetKind() != HINT_OBJREMOVED) && */
1025 (pSdrHint->GetKind() != HINT_MODELCLEARED) &&
1026 // #110094#-9 (pSdrHint->GetKind() != HINT_OBJLISTCLEAR) &&
1027 ((pSdrHint->GetKind() != HINT_OBJCHG || pSdrHint->GetObject() != mpObj.get() ))))
1028 return;
1030 uno::Reference< uno::XInterface > xSelf( mpObj->getWeakUnoShape() );
1031 if( !xSelf.is() )
1033 mpObj.reset( NULL );
1034 return;
1037 bool bClearMe = false;
1039 switch( pSdrHint->GetKind() )
1041 case HINT_OBJCHG:
1043 updateShapeKind();
1044 break;
1046 case HINT_MODELCLEARED:
1048 bClearMe = true;
1049 mpModel = NULL;
1050 break;
1052 default:
1053 break;
1056 if( bClearMe )
1058 if( !HasSdrObjectOwnership() ) {
1059 if( mpObj.is() )
1060 mpObj->setUnoShape( NULL );
1061 mpObj.reset( NULL );
1063 if ( !mpImpl->mbDisposing )
1064 dispose();
1068 // XShape
1071 // The "*LogicRectHack" functions also existed in sch, and those
1072 // duplicate symbols cause Bad Things To Happen (TM) #i9462#.
1073 // Prefixing with 'svx' and marking static to make sure name collisions
1074 // do not occur.
1076 static bool svx_needLogicRectHack( SdrObject* pObj )
1078 if( pObj->GetObjInventor() == SdrInventor)
1080 switch(pObj->GetObjIdentifier())
1082 case OBJ_GRUP:
1083 case OBJ_LINE:
1084 case OBJ_POLY:
1085 case OBJ_PLIN:
1086 case OBJ_PATHLINE:
1087 case OBJ_PATHFILL:
1088 case OBJ_FREELINE:
1089 case OBJ_FREEFILL:
1090 case OBJ_SPLNLINE:
1091 case OBJ_SPLNFILL:
1092 case OBJ_EDGE:
1093 case OBJ_PATHPOLY:
1094 case OBJ_PATHPLIN:
1095 case OBJ_MEASURE:
1096 return true;
1099 return false;
1104 static Rectangle svx_getLogicRectHack( SdrObject* pObj )
1106 if(svx_needLogicRectHack(pObj))
1108 return pObj->GetSnapRect();
1110 else
1112 return pObj->GetLogicRect();
1118 static void svx_setLogicRectHack( SdrObject* pObj, const Rectangle& rRect )
1120 if(svx_needLogicRectHack(pObj))
1122 pObj->SetSnapRect( rRect );
1124 else
1126 pObj->SetLogicRect( rRect );
1132 awt::Point SAL_CALL SvxShape::getPosition() throw(uno::RuntimeException, std::exception)
1134 ::SolarMutexGuard aGuard;
1136 if( mpObj.is() && mpModel)
1138 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
1139 Point aPt( aRect.Left(), aRect.Top() );
1141 // Position is relativ to anchor, so recalc to absolut position
1142 if( mpModel->IsWriter() )
1143 aPt -= mpObj->GetAnchorPos();
1145 ForceMetricTo100th_mm(aPt);
1146 return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
1148 else
1150 return maPosition;
1155 void SAL_CALL SvxShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException, std::exception)
1157 ::SolarMutexGuard aGuard;
1159 if( mpObj.is() && mpModel )
1161 // do NOT move 3D objects, this would change the homogen
1162 // transformation matrix
1163 if(!mpObj->ISA(E3dCompoundObject))
1165 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
1166 Point aLocalPos( Position.X, Position.Y );
1167 ForceMetricToItemPoolMetric(aLocalPos);
1169 // Position is absolut, so recalc to position relativ to anchor
1170 if( mpModel->IsWriter() )
1171 aLocalPos += mpObj->GetAnchorPos();
1173 long nDX = aLocalPos.X() - aRect.Left();
1174 long nDY = aLocalPos.Y() - aRect.Top();
1176 mpObj->Move( Size( nDX, nDY ) );
1177 mpModel->SetChanged();
1181 maPosition = Position;
1185 awt::Size SAL_CALL SvxShape::getSize() throw(uno::RuntimeException, std::exception)
1187 ::SolarMutexGuard aGuard;
1189 if( mpObj.is() && mpModel)
1191 Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
1192 Size aObjSize( aRect.getWidth(), aRect.getHeight() );
1193 ForceMetricTo100th_mm(aObjSize);
1194 return ::com::sun::star::awt::Size( aObjSize.getWidth(), aObjSize.getHeight() );
1196 else
1197 return maSize;
1201 void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
1202 throw(beans::PropertyVetoException, uno::RuntimeException, std::exception)
1204 ::SolarMutexGuard aGuard;
1206 if( mpObj.is() && mpModel)
1208 // #i123539# optimization for 3D chart object generation: do not use UNO
1209 // API commmands to get the range, this is too expensive since for 3D
1210 // scenes it may recalculate the whole scene since in AOO this depends
1211 // on the contained geometry (layouted to show all content)
1212 const bool b3DConstruction(dynamic_cast< E3dObject* >(mpObj.get()) && mpModel->isLocked());
1213 Rectangle aRect(
1214 b3DConstruction ?
1215 Rectangle(maPosition.X, maPosition.Y, maSize.Width, maSize.Height) :
1216 svx_getLogicRectHack(mpObj.get()) );
1217 Size aLocalSize( rSize.Width, rSize.Height );
1218 ForceMetricToItemPoolMetric(aLocalSize);
1220 if(mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_MEASURE )
1222 Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left());
1223 Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top());
1224 Point aPt = mpObj->GetSnapRect().TopLeft();
1225 mpObj->Resize(aPt,aWdt,aHgt);
1227 else
1229 //aRect.SetSize(aLocalSize); // this call subtract 1 // http://www.openoffice.org/issues/show_bug.cgi?id=83193
1230 if ( !aLocalSize.Width() )
1232 aRect.Right() = RECT_EMPTY;
1234 else
1235 aRect.setWidth(aLocalSize.Width());
1236 if ( !aLocalSize.Height() )
1238 aRect.Bottom() = RECT_EMPTY;
1240 else
1241 aRect.setHeight(aLocalSize.Height());
1243 svx_setLogicRectHack( mpObj.get(), aRect );
1246 mpModel->SetChanged();
1248 maSize = rSize;
1253 // XNamed
1254 OUString SAL_CALL SvxShape::getName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1256 ::SolarMutexGuard aGuard;
1257 if( mpObj.is() )
1259 return mpObj->GetName();
1261 else
1263 return maShapeName;
1269 void SAL_CALL SvxShape::setName( const OUString& aName ) throw(::com::sun::star::uno::RuntimeException, std::exception)
1271 ::SolarMutexGuard aGuard;
1272 if( mpObj.is() )
1274 mpObj->SetName( aName );
1276 else
1278 maShapeName = aName;
1282 // XShapeDescriptor
1285 OUString SAL_CALL SvxShape::getShapeType() throw(uno::RuntimeException, std::exception)
1287 if( !maShapeType.getLength() )
1288 return UHashMap::getNameFromId( mpImpl->mnObjId );
1289 else
1290 return maShapeType;
1293 // XComponent
1296 void SAL_CALL SvxShape::dispose() throw(uno::RuntimeException, std::exception)
1298 ::SolarMutexGuard aGuard;
1300 if( mpImpl->mbDisposing )
1301 return; // caught a recursion
1303 mpImpl->mbDisposing = true;
1305 lang::EventObject aEvt;
1306 aEvt.Source = *(OWeakAggObject*) this;
1307 mpImpl->maDisposeListeners.disposeAndClear(aEvt);
1308 mpImpl->maPropertyNotifier.disposing();
1310 if ( mpObj.is() )
1312 bool bFreeSdrObject = false;
1314 if ( mpObj->IsInserted() && mpObj->GetPage() )
1316 OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" );
1317 // normally, we are allowed to free the SdrObject only if we have its ownership.
1318 // Why isn't this checked here?
1320 SdrPage* pPage = mpObj->GetPage();
1321 // SdrObject aus der Page loeschen
1322 const size_t nCount = pPage->GetObjCount();
1323 for ( size_t nNum = 0; nNum < nCount; ++nNum )
1325 if ( pPage->GetObj( nNum ) == mpObj.get() )
1327 OSL_VERIFY( pPage->RemoveObject( nNum ) == mpObj.get() );
1328 bFreeSdrObject = true;
1329 break;
1334 mpObj->setUnoShape(NULL);
1336 if ( bFreeSdrObject )
1338 // in case we have the ownership of the SdrObject, a Free
1339 // would do nothing. So ensure the ownership is reset.
1340 mpImpl->mbHasSdrObjectOwnership = false;
1341 SdrObject* pObject = mpObj.get();
1342 SdrObject::Free( pObject );
1346 if( mpModel )
1348 EndListening( *mpModel );
1349 mpModel = NULL;
1355 void SAL_CALL SvxShape::addEventListener( const Reference< lang::XEventListener >& xListener )
1356 throw(uno::RuntimeException, std::exception)
1358 mpImpl->maDisposeListeners.addInterface(xListener);
1363 void SAL_CALL SvxShape::removeEventListener( const Reference< lang::XEventListener >& aListener ) throw(uno::RuntimeException, std::exception)
1365 mpImpl->maDisposeListeners.removeInterface(aListener);
1368 // XPropertySet
1372 Reference< beans::XPropertySetInfo > SAL_CALL
1373 SvxShape::getPropertySetInfo() throw(uno::RuntimeException, std::exception)
1375 if( mpImpl->mpMaster )
1377 return mpImpl->mpMaster->getPropertySetInfo();
1379 else
1381 return _getPropertySetInfo();
1385 Reference< beans::XPropertySetInfo > SAL_CALL
1386 SvxShape::_getPropertySetInfo() throw(uno::RuntimeException)
1388 return mpPropSet->getPropertySetInfo();
1393 void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1395 ::osl::MutexGuard aGuard( maMutex );
1396 mpImpl->maPropertyNotifier.addPropertyChangeListener( _propertyName, _listener );
1401 void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1403 ::osl::MutexGuard aGuard( maMutex );
1404 mpImpl->maPropertyNotifier.removePropertyChangeListener( _propertyName, _listener );
1409 void SAL_CALL SvxShape::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1411 OSL_FAIL( "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1416 void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1418 OSL_FAIL( "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1423 bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName )
1425 SfxItemSet aSet( mpModel->GetItemPool(), (sal_uInt16)nWID, (sal_uInt16)nWID );
1427 if( SetFillAttribute( nWID, rName, aSet, mpModel ) )
1429 //mpObj->SetItemSetAndBroadcast(aSet);
1430 mpObj->SetMergedItemSetAndBroadcast(aSet);
1432 return true;
1434 else
1436 return false;
1442 bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, SfxItemSet& rSet, SdrModel* pModel )
1444 // check if an item with the given name and which id is inside the models
1445 // pool or the stylesheet pool, if found its puttet in the itemse
1446 if( !SetFillAttribute( nWID, rName, rSet ) )
1448 // we did not find such item in one of the pools, so we check
1449 // the property lists that are loaded for the model for items
1450 // that support such.
1451 OUString aStrName = SvxUnogetInternalNameForItem((sal_Int16)nWID, rName);
1453 switch( nWID )
1455 case XATTR_FILLBITMAP:
1457 XBitmapListRef pBitmapList = pModel->GetBitmapList();
1459 if( !pBitmapList.is() )
1460 return false;
1462 long nPos = pBitmapList->GetIndex(aStrName);
1463 if( nPos == -1 )
1464 return false;
1466 XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos );
1467 XFillBitmapItem aBmpItem;
1468 aBmpItem.SetWhich( XATTR_FILLBITMAP );
1469 aBmpItem.SetName( rName );
1470 aBmpItem.SetGraphicObject(pEntry->GetGraphicObject());
1471 rSet.Put( aBmpItem );
1472 break;
1474 case XATTR_FILLGRADIENT:
1476 XGradientListRef pGradientList = pModel->GetGradientList();
1478 if( !pGradientList.is() )
1479 return false;
1481 long nPos = pGradientList->GetIndex(aStrName);
1482 if( nPos == -1 )
1483 return false;
1485 XGradientEntry* pEntry = pGradientList->GetGradient( nPos );
1486 XFillGradientItem aGrdItem;
1487 aGrdItem.SetWhich( XATTR_FILLGRADIENT );
1488 aGrdItem.SetName( rName );
1489 aGrdItem.SetGradientValue( pEntry->GetGradient() );
1490 rSet.Put( aGrdItem );
1491 break;
1493 case XATTR_FILLHATCH:
1495 XHatchListRef pHatchList = pModel->GetHatchList();
1497 if( !pHatchList.is() )
1498 return false;
1500 long nPos = pHatchList->GetIndex(aStrName);
1501 if( nPos == -1 )
1502 return false;
1504 XHatchEntry* pEntry = pHatchList->GetHatch( nPos );
1505 XFillHatchItem aHatchItem;
1506 aHatchItem.SetWhich( XATTR_FILLHATCH );
1507 aHatchItem.SetName( rName );
1508 aHatchItem.SetHatchValue( pEntry->GetHatch() );
1509 rSet.Put( aHatchItem );
1510 break;
1512 case XATTR_LINEEND:
1513 case XATTR_LINESTART:
1515 XLineEndListRef pLineEndList = pModel->GetLineEndList();
1517 if( !pLineEndList.is() )
1518 return false;
1520 long nPos = pLineEndList->GetIndex(aStrName);
1521 if( nPos == -1 )
1522 return false;
1524 XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
1525 if( XATTR_LINEEND == nWID )
1527 XLineEndItem aLEItem;
1528 aLEItem.SetWhich( XATTR_LINEEND );
1529 aLEItem.SetName( rName );
1530 aLEItem.SetLineEndValue( pEntry->GetLineEnd() );
1531 rSet.Put( aLEItem );
1533 else
1535 XLineStartItem aLSItem;
1536 aLSItem.SetWhich( XATTR_LINESTART );
1537 aLSItem.SetName( rName );
1538 aLSItem.SetLineStartValue( pEntry->GetLineEnd() );
1539 rSet.Put( aLSItem );
1542 break;
1544 case XATTR_LINEDASH:
1546 XDashListRef pDashList = pModel->GetDashList();
1548 if( !pDashList.is() )
1549 return false;
1551 long nPos = pDashList->GetIndex(aStrName);
1552 if( nPos == -1 )
1553 return false;
1555 XDashEntry* pEntry = pDashList->GetDash( nPos );
1556 XLineDashItem aDashItem;
1557 aDashItem.SetWhich( XATTR_LINEDASH );
1558 aDashItem.SetName( rName );
1559 aDashItem.SetDashValue( pEntry->GetDash() );
1560 rSet.Put( aDashItem );
1561 break;
1563 default:
1564 return false;
1568 return true;
1573 bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, SfxItemSet& rSet )
1575 OUString aName = SvxUnogetInternalNameForItem((sal_Int16)nWID, rName);
1577 if (aName.isEmpty())
1579 switch( nWID )
1581 case XATTR_LINEEND:
1582 case XATTR_LINESTART:
1584 const OUString aEmpty;
1585 const basegfx::B2DPolyPolygon aEmptyPoly;
1586 if( nWID == XATTR_LINEEND )
1587 rSet.Put( XLineEndItem( aEmpty, aEmptyPoly ) );
1588 else
1589 rSet.Put( XLineStartItem( aEmpty, aEmptyPoly ) );
1591 return true;
1593 case XATTR_FILLFLOATTRANSPARENCE:
1595 // #85953# Set a disabled XFillFloatTransparenceItem
1596 rSet.Put(XFillFloatTransparenceItem());
1598 return true;
1602 return false;
1605 const SfxItemPool* pPool = rSet.GetPool();
1607 const OUString aSearchName( aName );
1608 const sal_uInt32 nCount = pPool->GetItemCount2((sal_uInt16)nWID);
1610 for( sal_uInt32 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
1612 const NameOrIndex* pItem = static_cast<const NameOrIndex*>(pPool->GetItem2((sal_uInt16)nWID, nSurrogate));
1613 if( pItem && ( pItem->GetName() == aSearchName ) )
1615 rSet.Put( *pItem );
1616 return true;
1620 return false;
1625 void SAL_CALL SvxShape::setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal )
1626 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1628 if( mpImpl->mpMaster )
1630 mpImpl->mpMaster->setPropertyValue( rPropertyName, rVal );
1632 else
1634 _setPropertyValue( rPropertyName, rVal );
1638 void SAL_CALL SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal )
1639 throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1641 ::SolarMutexGuard aGuard;
1643 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
1645 if (!mpObj.is() || !mpModel)
1647 // Since we have no actual sdr object right now, remember all
1648 // properties in a list. These properties will be set when the sdr
1649 // object is created.
1651 if (pMap && pMap->nWID)
1653 // FIXME: We should throw a UnknownPropertyException here.
1654 // But since this class is aggregated from classes that
1655 // support additional properties that we don't know here we
1656 // silently store *all* properties, even if they may be not
1657 // supported after creation.
1658 mpPropSet->setPropertyValue( pMap, rVal );
1660 return;
1663 if (!pMap)
1664 throw beans::UnknownPropertyException();
1666 if ((pMap->nFlags & beans::PropertyAttribute::READONLY) != 0)
1667 throw beans::PropertyVetoException(
1668 "Readonly property can't be set: " + rPropertyName,
1669 uno::Reference<drawing::XShape>(this));
1671 mpModel->SetChanged();
1673 if (setPropertyValueImpl(rPropertyName, pMap, rVal))
1674 return;
1676 DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST, "Not persist item not handled!" );
1677 DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
1679 bool bIsNotPersist = pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST && pMap->nWID != SDRATTR_TEXTDIRECTION;
1681 if( pMap->nWID == SDRATTR_ECKENRADIUS )
1683 sal_Int32 nCornerRadius = 0;
1684 if( !(rVal >>= nCornerRadius) || (nCornerRadius < 0) || (nCornerRadius > 5000000))
1685 throw IllegalArgumentException();
1688 SfxItemSet* pSet;
1689 if( mbIsMultiPropertyCall && !bIsNotPersist )
1691 if( mpImpl->mpItemSet == NULL )
1693 pSet = mpImpl->mpItemSet = mpObj->GetMergedItemSet().Clone();
1695 else
1697 pSet = mpImpl->mpItemSet;
1700 else
1702 pSet = new SfxItemSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
1705 if( pSet->GetItemState( pMap->nWID ) != SfxItemState::SET )
1706 pSet->Put(mpObj->GetMergedItem(pMap->nWID));
1708 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( *pSet, pMap, rVal, *pSet ))
1710 if( pSet->GetItemState( pMap->nWID ) != SfxItemState::SET )
1712 if(bIsNotPersist)
1714 // not-persistent attribute, get those extra
1715 mpObj->TakeNotPersistAttr(*pSet, false);
1719 if( pSet->GetItemState( pMap->nWID ) != SfxItemState::SET )
1721 // get default from ItemPool
1722 if(SfxItemPool::IsWhich(pMap->nWID))
1723 pSet->Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
1726 if( pSet->GetItemState( pMap->nWID ) == SfxItemState::SET )
1728 SvxItemPropertySet_setPropertyValue( pMap, rVal, *pSet );
1732 if(bIsNotPersist)
1734 // set not-persistent attribute extra
1735 mpObj->ApplyNotPersistAttr( *pSet );
1736 delete pSet;
1738 else
1740 // if we have a XMultiProperty call then the item set
1741 // will be set in setPropertyValues later
1742 if( !mbIsMultiPropertyCall )
1744 mpObj->SetMergedItemSetAndBroadcast( *pSet );
1746 delete pSet;
1753 uno::Any SAL_CALL SvxShape::getPropertyValue( const OUString& PropertyName )
1754 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
1756 if ( mpImpl->mpMaster )
1757 return mpImpl->mpMaster->getPropertyValue( PropertyName );
1758 else
1759 return _getPropertyValue( PropertyName );
1764 uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
1765 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1767 ::SolarMutexGuard aGuard;
1769 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1771 uno::Any aAny;
1772 if( mpObj.is() && mpModel )
1774 if(pMap == NULL )
1775 throw beans::UnknownPropertyException();
1777 if( !getPropertyValueImpl( PropertyName, pMap, aAny ) )
1779 DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || (pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST), "Not persist item not handled!" );
1780 DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
1782 SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
1783 aSet.Put(mpObj->GetMergedItem(pMap->nWID));
1785 if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
1786 return aAny;
1788 if(!aSet.Count())
1790 if(pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST)
1792 // not-persistent attribute, get those extra
1793 mpObj->TakeNotPersistAttr(aSet, false);
1797 if(!aSet.Count())
1799 // get default from ItemPool
1800 if(SfxItemPool::IsWhich(pMap->nWID))
1801 aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
1804 if(aSet.Count())
1805 aAny = GetAnyForItem( aSet, pMap );
1808 else
1811 // Fixme: we should return default values for OWN_ATTR !
1813 if(pMap && pMap->nWID)
1814 // FixMe: see setPropertyValue
1815 aAny = mpPropSet->getPropertyValue( pMap );
1818 return aAny;
1823 // XMultiPropertySet
1824 void SAL_CALL SvxShape::setPropertyValues( const ::com::sun::star::uno::Sequence< 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, std::exception)
1826 ::SolarMutexGuard aSolarGuard;
1828 const sal_Int32 nCount = aPropertyNames.getLength();
1829 const OUString* pNames = aPropertyNames.getConstArray();
1831 const uno::Any* pValues = aValues.getConstArray();
1833 // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are
1834 // reseted even when an exception is thrown
1835 const ::comphelper::ScopeGuard aGuard( boost::bind( &SvxShape::endSetPropertyValues, this ) );
1837 mbIsMultiPropertyCall = true;
1839 if( mpImpl->mpMaster )
1841 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1845 setPropertyValue( *pNames, *pValues );
1847 catch( beans::UnknownPropertyException& e )
1849 (void)e;
1851 catch( uno::Exception& ex )
1853 (void)ex;
1857 else
1859 uno::Reference< beans::XPropertySet > xSet;
1860 queryInterface( cppu::UnoType<beans::XPropertySet>::get()) >>= xSet;
1862 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1866 xSet->setPropertyValue( *pNames, *pValues );
1868 catch( beans::UnknownPropertyException& e )
1870 (void)e;
1872 catch( uno::Exception& ex )
1874 (void)ex;
1879 if( mpImpl->mpItemSet && mpObj.is() )
1880 mpObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
1885 void SvxShape::endSetPropertyValues()
1887 mbIsMultiPropertyCall = false;
1888 if( mpImpl->mpItemSet )
1890 delete mpImpl->mpItemSet;
1891 mpImpl->mpItemSet = 0;
1897 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL SvxShape::getPropertyValues( const ::com::sun::star::uno::Sequence< OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException, std::exception)
1899 const sal_Int32 nCount = aPropertyNames.getLength();
1900 const OUString* pNames = aPropertyNames.getConstArray();
1902 uno::Sequence< uno::Any > aRet( nCount );
1903 uno::Any* pValue = aRet.getArray();;
1905 if( mpImpl->mpMaster )
1907 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
1911 *pValue = getPropertyValue( *pNames );
1913 catch( uno::Exception& )
1915 OSL_FAIL( "SvxShape::getPropertyValues, unknown property asked" );
1919 else
1921 uno::Reference< beans::XPropertySet > xSet;
1922 queryInterface( cppu::UnoType<beans::XPropertySet>::get()) >>= xSet;
1924 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
1928 *pValue = xSet->getPropertyValue( *pNames );
1930 catch( uno::Exception& )
1932 OSL_FAIL( "SvxShape::getPropertyValues, unknown property asked" );
1937 return aRet;
1940 void SAL_CALL SvxShape::addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException, std::exception)
1944 void SAL_CALL SvxShape::removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException, std::exception)
1948 void SAL_CALL SvxShape::firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException, std::exception)
1954 uno::Any SvxShape::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap ) const
1956 DBG_TESTSOLARMUTEX();
1957 uno::Any aAny;
1959 switch(pMap->nWID)
1961 case SDRATTR_CIRCSTARTANGLE:
1963 const SfxPoolItem* pPoolItem=NULL;
1964 if(aSet.GetItemState(SDRATTR_CIRCSTARTANGLE,false,&pPoolItem)==SfxItemState::SET)
1966 sal_Int32 nAngle = static_cast<const SdrAngleItem*>(pPoolItem)->GetValue();
1967 aAny <<= nAngle;
1969 break;
1972 case SDRATTR_CIRCENDANGLE:
1974 const SfxPoolItem* pPoolItem=NULL;
1975 if (aSet.GetItemState(SDRATTR_CIRCENDANGLE,false,&pPoolItem)==SfxItemState::SET)
1977 sal_Int32 nAngle = static_cast<const SdrAngleItem*>(pPoolItem)->GetValue();
1978 aAny <<= nAngle;
1980 break;
1983 case SDRATTR_CIRCKIND:
1985 if( mpObj->GetObjInventor() == SdrInventor)
1987 drawing::CircleKind eKind;
1988 switch(mpObj->GetObjIdentifier())
1990 case OBJ_CIRC: // circle, ellipse
1991 eKind = drawing::CircleKind_FULL;
1992 break;
1993 case OBJ_CCUT: // segment of circle
1994 eKind = drawing::CircleKind_CUT;
1995 break;
1996 case OBJ_CARC: // arc of circle
1997 eKind = drawing::CircleKind_ARC;
1998 break;
1999 case OBJ_SECT: // sector
2000 eKind = drawing::CircleKind_SECTION;
2001 break;
2003 aAny <<= eKind;
2005 break;
2007 default:
2009 // get value form ItemSet
2010 aAny = SvxItemPropertySet_getPropertyValue( pMap, aSet );
2012 if( pMap->aType != aAny.getValueType() )
2014 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
2015 if( ( pMap->aType == ::cppu::UnoType<sal_Int16>::get()) && aAny.getValueType() == ::cppu::UnoType<sal_Int32>::get() )
2017 sal_Int32 nValue = 0;
2018 aAny >>= nValue;
2019 aAny <<= (sal_Int16)nValue;
2021 else
2023 OSL_FAIL("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" );
2030 return aAny;
2035 // XPropertyState
2036 beans::PropertyState SAL_CALL SvxShape::getPropertyState( const OUString& PropertyName )
2037 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2039 if( mpImpl->mpMaster )
2041 return mpImpl->mpMaster->getPropertyState( PropertyName );
2043 else
2045 return _getPropertyState( PropertyName );
2049 beans::PropertyState SAL_CALL SvxShape::_getPropertyState( const OUString& PropertyName )
2050 throw(beans::UnknownPropertyException, uno::RuntimeException)
2052 ::SolarMutexGuard aGuard;
2054 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
2056 if( !mpObj.is() || pMap == NULL )
2057 throw beans::UnknownPropertyException();
2059 beans::PropertyState eState;
2060 if( !getPropertyStateImpl( pMap, eState ) )
2062 const SfxItemSet& rSet = mpObj->GetMergedItemSet();
2064 switch( rSet.GetItemState( pMap->nWID, false ) )
2066 case SfxItemState::READONLY:
2067 case SfxItemState::SET:
2068 eState = beans::PropertyState_DIRECT_VALUE;
2069 break;
2070 case SfxItemState::DEFAULT:
2071 eState = beans::PropertyState_DEFAULT_VALUE;
2072 break;
2073 default:
2074 eState = beans::PropertyState_AMBIGUOUS_VALUE;
2075 break;
2078 // if a item is set, this doesn't mean we want it :)
2079 if( ( beans::PropertyState_DIRECT_VALUE == eState ) )
2081 switch( pMap->nWID )
2083 // the following items are disabled by changing the
2084 // fill style or the line style. so there is no need
2085 // to export items without names which should be empty
2086 case XATTR_FILLBITMAP:
2087 case XATTR_FILLGRADIENT:
2088 case XATTR_FILLHATCH:
2089 case XATTR_LINEDASH:
2091 const NameOrIndex* pItem = static_cast<const NameOrIndex*>(rSet.GetItem((sal_uInt16)pMap->nWID));
2092 if( ( pItem == NULL ) || pItem->GetName().isEmpty() )
2093 eState = beans::PropertyState_DEFAULT_VALUE;
2095 break;
2097 // #i36115#
2098 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
2099 // may be a hard attribute covering the set LineStart of the parent (Style).
2100 // #i37644#
2101 // same is for fill float transparency
2102 case XATTR_LINEEND:
2103 case XATTR_LINESTART:
2104 case XATTR_FILLFLOATTRANSPARENCE:
2106 const NameOrIndex* pItem = static_cast<const NameOrIndex*>(rSet.GetItem((sal_uInt16)pMap->nWID));
2107 if ( pItem == NULL )
2108 eState = beans::PropertyState_DEFAULT_VALUE;
2110 break;
2114 return eState;
2117 bool SvxShape::setPropertyValueImpl( const 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, std::exception)
2119 switch( pProperty->nWID )
2121 case OWN_ATTR_CAPTION_POINT:
2123 awt::Point aPnt;
2124 if( rValue >>= aPnt )
2126 Point aVclPoint( aPnt.X, aPnt.Y );
2128 // #90763# position is relative to top left, make it absolute
2129 basegfx::B2DPolyPolygon aNewPolyPolygon;
2130 basegfx::B2DHomMatrix aNewHomogenMatrix;
2131 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2133 aVclPoint.X() += basegfx::fround(aNewHomogenMatrix.get(0, 2));
2134 aVclPoint.Y() += basegfx::fround(aNewHomogenMatrix.get(1, 2));
2136 // #88657# metric of pool maybe twips (writer)
2137 ForceMetricToItemPoolMetric(aVclPoint);
2139 // #88491# position relative to anchor
2140 if( mpModel->IsWriter() )
2142 aVclPoint += mpObj->GetAnchorPos();
2145 static_cast<SdrCaptionObj*>(mpObj.get())->SetTailPos(aVclPoint);
2147 return true;
2149 break;
2151 case OWN_ATTR_TRANSFORMATION:
2153 drawing::HomogenMatrix3 aMatrix;
2154 if(rValue >>= aMatrix)
2156 basegfx::B2DPolyPolygon aNewPolyPolygon;
2157 basegfx::B2DHomMatrix aNewHomogenMatrix;
2159 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2161 aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1);
2162 aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2);
2163 aNewHomogenMatrix.set(0, 2, aMatrix.Line1.Column3);
2164 aNewHomogenMatrix.set(1, 0, aMatrix.Line2.Column1);
2165 aNewHomogenMatrix.set(1, 1, aMatrix.Line2.Column2);
2166 aNewHomogenMatrix.set(1, 2, aMatrix.Line2.Column3);
2167 aNewHomogenMatrix.set(2, 0, aMatrix.Line3.Column1);
2168 aNewHomogenMatrix.set(2, 1, aMatrix.Line3.Column2);
2169 aNewHomogenMatrix.set(2, 2, aMatrix.Line3.Column3);
2171 mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2172 return true;
2174 break;
2177 case OWN_ATTR_ZORDER:
2179 sal_Int32 nNewOrdNum = 0;
2180 if(rValue >>= nNewOrdNum)
2182 SdrObjList* pObjList = mpObj->GetObjList();
2183 if( pObjList )
2185 #ifdef DBG_UTIL
2186 SdrObject* pCheck =
2187 #endif
2188 pObjList->SetObjectOrdNum( mpObj->GetOrdNum(), static_cast<size_t>(nNewOrdNum) );
2189 DBG_ASSERT( pCheck == mpObj.get(), "GetOrdNum() failed!" );
2191 return true;
2193 break;
2195 case OWN_ATTR_FRAMERECT:
2197 awt::Rectangle aUnoRect;
2198 if(rValue >>= aUnoRect)
2200 Point aTopLeft( aUnoRect.X, aUnoRect.Y );
2201 Size aObjSize( aUnoRect.Width, aUnoRect.Height );
2202 ForceMetricToItemPoolMetric(aTopLeft);
2203 ForceMetricToItemPoolMetric(aObjSize);
2204 Rectangle aRect;
2205 aRect.SetPos(aTopLeft);
2206 aRect.SetSize(aObjSize);
2207 mpObj->SetSnapRect(aRect);
2208 return true;
2210 break;
2212 case OWN_ATTR_MIRRORED:
2214 bool bMirror;
2215 if(rValue >>= bMirror )
2217 SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( mpObj.get() );
2218 if( pObj )
2219 pObj->SetMirrored(bMirror);
2220 return true;
2222 break;
2224 case OWN_ATTR_EDGE_START_OBJ:
2225 case OWN_ATTR_EDGE_END_OBJ:
2226 case OWN_ATTR_GLUEID_HEAD:
2227 case OWN_ATTR_GLUEID_TAIL:
2228 case OWN_ATTR_EDGE_START_POS:
2229 case OWN_ATTR_EDGE_END_POS:
2230 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2232 SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(mpObj.get());
2233 if(pEdgeObj)
2235 switch(pProperty->nWID)
2237 case OWN_ATTR_EDGE_START_OBJ:
2238 case OWN_ATTR_EDGE_END_OBJ:
2240 Reference< drawing::XShape > xShape;
2241 if( rValue >>= xShape )
2243 SdrObject* pNode = GetSdrObjectFromXShape( xShape );
2244 if( pNode )
2246 pEdgeObj->ConnectToNode( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, pNode );
2247 pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, -1 );
2248 return true;
2251 break;
2254 case OWN_ATTR_EDGE_START_POS:
2255 case OWN_ATTR_EDGE_END_POS:
2257 awt::Point aUnoPoint;
2258 if( rValue >>= aUnoPoint )
2260 Point aPoint( aUnoPoint.X, aUnoPoint.Y );
2262 // Reintroduction of fix for issue i59051 (#i108851#)
2263 // perform metric change before applying anchor position,
2264 // because the anchor position is in pool metric.
2265 ForceMetricToItemPoolMetric( aPoint );
2266 if( mpModel->IsWriter() )
2267 aPoint += mpObj->GetAnchorPos();
2269 pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint );
2270 return true;
2272 break;
2275 case OWN_ATTR_GLUEID_HEAD:
2276 case OWN_ATTR_GLUEID_TAIL:
2278 sal_Int32 nId = 0;
2279 if( rValue >>= nId )
2281 pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD, nId );
2282 return true;
2284 break;
2286 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2288 basegfx::B2DPolyPolygon aNewPolyPolygon;
2290 // #123616# be a little bit more flexible regardin gthe data type used
2291 if( rValue.getValueType() == cppu::UnoType<drawing::PointSequenceSequence>::get())
2293 // get polygpon data from PointSequenceSequence
2294 aNewPolyPolygon = basegfx::tools::UnoPointSequenceSequenceToB2DPolyPolygon(
2295 *static_cast<const drawing::PointSequenceSequence*>(rValue.getValue()));
2297 else if( rValue.getValueType() == cppu::UnoType<drawing::PolyPolygonBezierCoords>::get())
2299 // get polygpon data from PolyPolygonBezierCoords
2300 aNewPolyPolygon = basegfx::tools::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
2301 *static_cast<const drawing::PolyPolygonBezierCoords*>(rValue.getValue()));
2304 if(aNewPolyPolygon.count())
2306 // Reintroduction of fix for issue i59051 (#i108851#)
2307 ForceMetricToItemPoolMetric( aNewPolyPolygon );
2308 if( mpModel->IsWriter() )
2310 Point aPoint( mpObj->GetAnchorPos() );
2311 aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y()));
2313 pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon );
2314 return true;
2319 break;
2321 case OWN_ATTR_MEASURE_START_POS:
2322 case OWN_ATTR_MEASURE_END_POS:
2324 SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(mpObj.get());
2325 awt::Point aUnoPoint;
2326 if(pMeasureObj && ( rValue >>= aUnoPoint ) )
2328 Point aPoint( aUnoPoint.X, aUnoPoint.Y );
2330 // Reintroduction of fix for issue #i59051# (#i108851#)
2331 ForceMetricToItemPoolMetric( aPoint );
2332 if( mpModel->IsWriter() )
2333 aPoint += mpObj->GetAnchorPos();
2335 pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0L : 1L );
2336 pMeasureObj->SetChanged();
2337 pMeasureObj->BroadcastObjectChange();
2338 return true;
2340 break;
2342 case OWN_ATTR_FILLBMP_MODE:
2344 drawing::BitmapMode eMode;
2345 if(!(rValue >>= eMode) )
2347 sal_Int32 nMode = 0;
2348 if(!(rValue >>= nMode))
2349 break;
2351 eMode = (drawing::BitmapMode)nMode;
2353 mpObj->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
2354 mpObj->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
2355 return true;
2358 case SDRATTR_LAYERID:
2360 sal_Int16 nLayerId = sal_Int16();
2361 if( rValue >>= nLayerId )
2363 SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID((unsigned char)nLayerId);
2364 if( pLayer )
2366 mpObj->SetLayer((unsigned char)nLayerId);
2367 return true;
2370 break;
2373 case SDRATTR_LAYERNAME:
2375 OUString aLayerName;
2376 if( rValue >>= aLayerName )
2378 const SdrLayer* pLayer=mpModel->GetLayerAdmin().GetLayer(aLayerName, true);
2379 if( pLayer != NULL )
2381 mpObj->SetLayer( pLayer->GetID() );
2382 return true;
2385 break;
2387 case SDRATTR_ROTATEANGLE:
2389 sal_Int32 nAngle = 0;
2390 if( rValue >>= nAngle )
2392 Point aRef1(mpObj->GetSnapRect().Center());
2393 nAngle -= mpObj->GetRotateAngle();
2394 if (nAngle!=0)
2396 double nSin=sin(nAngle*nPi180);
2397 double nCos=cos(nAngle*nPi180);
2398 mpObj->Rotate(aRef1,nAngle,nSin,nCos);
2400 return true;
2403 break;
2406 case SDRATTR_SHEARANGLE:
2408 sal_Int32 nShear = 0;
2409 if( rValue >>= nShear )
2411 nShear -= mpObj->GetShearAngle();
2412 if(nShear != 0 )
2414 Point aRef1(mpObj->GetSnapRect().Center());
2415 double nTan=tan(nShear*nPi180);
2416 mpObj->Shear(aRef1,nShear,nTan,false);
2417 return true;
2421 break;
2424 case OWN_ATTR_INTEROPGRABBAG:
2426 mpObj->SetGrabBagItem(rValue);
2427 return true;
2430 case SDRATTR_OBJMOVEPROTECT:
2432 bool bMoveProtect;
2433 if( rValue >>= bMoveProtect )
2435 mpObj->SetMoveProtect(bMoveProtect);
2436 return true;
2438 break;
2440 case SDRATTR_OBJECTNAME:
2442 OUString aName;
2443 if( rValue >>= aName )
2445 mpObj->SetName( aName );
2446 return true;
2448 break;
2451 // #i68101#
2452 case OWN_ATTR_MISC_OBJ_TITLE:
2454 OUString aTitle;
2455 if( rValue >>= aTitle )
2457 mpObj->SetTitle( aTitle );
2458 return true;
2460 break;
2462 case OWN_ATTR_MISC_OBJ_DESCRIPTION:
2464 OUString aDescription;
2465 if( rValue >>= aDescription )
2467 mpObj->SetDescription( aDescription );
2468 return true;
2470 break;
2473 case SDRATTR_OBJPRINTABLE:
2475 bool bPrintable;
2476 if( rValue >>= bPrintable )
2478 mpObj->SetPrintable(bPrintable);
2479 return true;
2481 break;
2483 case SDRATTR_OBJVISIBLE:
2485 bool bVisible;
2486 if( rValue >>= bVisible )
2488 mpObj->SetVisible(bVisible);
2489 return true;
2491 break;
2493 case SDRATTR_OBJSIZEPROTECT:
2495 bool bResizeProtect;
2496 if( rValue >>= bResizeProtect )
2498 mpObj->SetResizeProtect(bResizeProtect);
2499 return true;
2501 break;
2503 case OWN_ATTR_PAGE_NUMBER:
2505 sal_Int32 nPageNum = 0;
2506 if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) )
2508 SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get());
2509 if( pPageObj )
2511 SdrModel* pModel = pPageObj->GetModel();
2512 SdrPage* pNewPage = 0L;
2513 const sal_uInt16 nDestinationPageNum((sal_uInt16)((nPageNum << 1L) - 1L));
2515 if(pModel)
2517 if(nDestinationPageNum < pModel->GetPageCount())
2519 pNewPage = pModel->GetPage(nDestinationPageNum);
2523 pPageObj->SetReferencedPage(pNewPage);
2526 return true;
2528 break;
2530 case XATTR_FILLBITMAP:
2531 case XATTR_FILLGRADIENT:
2532 case XATTR_FILLHATCH:
2533 case XATTR_FILLFLOATTRANSPARENCE:
2534 case XATTR_LINEEND:
2535 case XATTR_LINESTART:
2536 case XATTR_LINEDASH:
2538 if( pProperty->nMemberId == MID_NAME )
2540 OUString aApiName;
2541 if( rValue >>= aApiName )
2543 if( SetFillAttribute( pProperty->nWID, aApiName ) )
2544 return true;
2546 break;
2548 else
2550 return false;
2553 default:
2555 return false;
2558 throw lang::IllegalArgumentException();
2563 bool SvxShape::getPropertyValueImpl( const 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, std::exception)
2565 switch( pProperty->nWID )
2567 case OWN_ATTR_CAPTION_POINT:
2569 Point aVclPoint = static_cast<SdrCaptionObj*>(mpObj.get())->GetTailPos();
2571 // #88491# make pos relative to anchor
2572 if( mpModel->IsWriter() )
2574 aVclPoint -= mpObj->GetAnchorPos();
2577 // #88657# metric of pool maybe twips (writer)
2578 ForceMetricTo100th_mm(aVclPoint);
2580 // #90763# pos is absolute, make it relative to top left
2581 basegfx::B2DPolyPolygon aNewPolyPolygon;
2582 basegfx::B2DHomMatrix aNewHomogenMatrix;
2583 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2585 aVclPoint.X() -= basegfx::fround(aNewHomogenMatrix.get(0, 2));
2586 aVclPoint.Y() -= basegfx::fround(aNewHomogenMatrix.get(1, 2));
2588 awt::Point aPnt( aVclPoint.X(), aVclPoint.Y() );
2589 rValue <<= aPnt;
2590 break;
2593 case OWN_ATTR_TRANSFORMATION:
2595 basegfx::B2DPolyPolygon aNewPolyPolygon;
2596 basegfx::B2DHomMatrix aNewHomogenMatrix;
2597 mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2598 drawing::HomogenMatrix3 aMatrix;
2600 aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0);
2601 aMatrix.Line1.Column2 = aNewHomogenMatrix.get(0, 1);
2602 aMatrix.Line1.Column3 = aNewHomogenMatrix.get(0, 2);
2603 aMatrix.Line2.Column1 = aNewHomogenMatrix.get(1, 0);
2604 aMatrix.Line2.Column2 = aNewHomogenMatrix.get(1, 1);
2605 aMatrix.Line2.Column3 = aNewHomogenMatrix.get(1, 2);
2606 aMatrix.Line3.Column1 = aNewHomogenMatrix.get(2, 0);
2607 aMatrix.Line3.Column2 = aNewHomogenMatrix.get(2, 1);
2608 aMatrix.Line3.Column3 = aNewHomogenMatrix.get(2, 2);
2610 rValue <<= aMatrix;
2612 break;
2615 case OWN_ATTR_ZORDER:
2617 rValue <<= (sal_Int32)mpObj->GetOrdNum();
2618 break;
2621 case OWN_ATTR_BITMAP:
2623 rValue = GetBitmap();
2624 if(!rValue.hasValue())
2625 throw uno::RuntimeException();
2627 break;
2630 case OWN_ATTR_ISFONTWORK:
2632 rValue <<= mpObj->ISA(SdrTextObj) && static_cast<SdrTextObj*>(mpObj.get())->IsFontwork();
2633 break;
2636 case OWN_ATTR_FRAMERECT:
2638 Rectangle aRect( mpObj->GetSnapRect() );
2639 Point aTopLeft( aRect.TopLeft() );
2640 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
2641 ForceMetricTo100th_mm(aTopLeft);
2642 ForceMetricTo100th_mm(aObjSize);
2643 ::com::sun::star::awt::Rectangle aUnoRect(
2644 aTopLeft.X(), aTopLeft.Y(),
2645 aObjSize.getWidth(), aObjSize.getHeight() );
2646 rValue <<= aUnoRect;
2647 break;
2650 case OWN_ATTR_BOUNDRECT:
2652 Rectangle aRect( mpObj->GetCurrentBoundRect() );
2653 Point aTopLeft( aRect.TopLeft() );
2654 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
2655 ForceMetricTo100th_mm(aTopLeft);
2656 ForceMetricTo100th_mm(aObjSize);
2657 ::com::sun::star::awt::Rectangle aUnoRect(
2658 aTopLeft.X(), aTopLeft.Y(),
2659 aObjSize.getWidth(), aObjSize.getHeight() );
2660 rValue <<= aUnoRect;
2661 break;
2664 case OWN_ATTR_LDNAME:
2666 OUString aName( mpObj->GetName() );
2667 rValue <<= aName;
2668 break;
2671 case OWN_ATTR_LDBITMAP:
2673 sal_uInt16 nId;
2674 if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_OLE2 )
2676 nId = RID_UNODRAW_OLE2;
2678 else if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_GRAF )
2680 nId = RID_UNODRAW_GRAPHICS;
2682 else
2684 nId = RID_UNODRAW_OBJECTS;
2687 BitmapEx aBmp( SVX_RES(nId) );
2688 Reference< awt::XBitmap > xBmp( VCLUnoHelper::CreateBitmap( aBmp ) );
2690 rValue <<= xBmp;
2691 break;
2694 case OWN_ATTR_MIRRORED:
2696 bool bMirror = false;
2697 if( mpObj.is() && mpObj->ISA(SdrGrafObj) )
2698 bMirror = static_cast<SdrGrafObj*>(mpObj.get())->IsMirrored();
2700 rValue <<= bMirror;
2701 break;
2704 case OWN_ATTR_EDGE_START_OBJ:
2705 case OWN_ATTR_EDGE_START_POS:
2706 case OWN_ATTR_EDGE_END_POS:
2707 case OWN_ATTR_EDGE_END_OBJ:
2708 case OWN_ATTR_GLUEID_HEAD:
2709 case OWN_ATTR_GLUEID_TAIL:
2710 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2712 SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(mpObj.get());
2713 if(pEdgeObj)
2715 switch(pProperty->nWID)
2717 case OWN_ATTR_EDGE_START_OBJ:
2718 case OWN_ATTR_EDGE_END_OBJ:
2720 SdrObject* pNode = pEdgeObj->GetConnectedNode(pProperty->nWID == OWN_ATTR_EDGE_START_OBJ);
2721 if(pNode)
2723 Reference< drawing::XShape > xShape( GetXShapeForSdrObject( pNode ) );
2724 if(xShape.is())
2725 rValue <<= xShape;
2728 break;
2731 case OWN_ATTR_EDGE_START_POS:
2732 case OWN_ATTR_EDGE_END_POS:
2734 Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) );
2735 if( mpModel->IsWriter() )
2736 aPoint -= mpObj->GetAnchorPos();
2738 ForceMetricTo100th_mm( aPoint );
2739 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
2741 rValue <<= aUnoPoint;
2742 break;
2744 case OWN_ATTR_GLUEID_HEAD:
2745 case OWN_ATTR_GLUEID_TAIL:
2747 rValue <<= (sal_Int32)pEdgeObj->getGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD );
2748 break;
2750 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2752 basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() );
2753 if( mpModel->IsWriter() )
2755 Point aPoint( mpObj->GetAnchorPos() );
2756 aPolyPoly.transform(basegfx::tools::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y()));
2758 // Reintroduction of fix for issue #i59051# (#i108851#)
2759 ForceMetricTo100th_mm( aPolyPoly );
2760 drawing::PolyPolygonBezierCoords aRetval;
2761 basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier( aPolyPoly, aRetval);
2762 rValue <<= aRetval;
2763 break;
2767 break;
2770 case OWN_ATTR_MEASURE_START_POS:
2771 case OWN_ATTR_MEASURE_END_POS:
2773 SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(mpObj.get());
2774 if(pMeasureObj)
2776 Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) );
2777 if( mpModel->IsWriter() )
2778 aPoint -= mpObj->GetAnchorPos();
2780 // Reintroduction of fix for issue #i59051# (#i108851#)
2781 ForceMetricTo100th_mm( aPoint );
2782 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
2784 rValue <<= aUnoPoint;
2785 break;
2787 break;
2790 case OWN_ATTR_FILLBMP_MODE:
2792 const SfxItemSet& rObjItemSet = mpObj->GetMergedItemSet();
2794 const XFillBmpStretchItem* pStretchItem = static_cast<const XFillBmpStretchItem*>(&rObjItemSet.Get(XATTR_FILLBMP_STRETCH));
2795 const XFillBmpTileItem* pTileItem = static_cast<const XFillBmpTileItem*>(&rObjItemSet.Get(XATTR_FILLBMP_TILE));
2797 if( pTileItem && pTileItem->GetValue() )
2799 rValue <<= drawing::BitmapMode_REPEAT;
2801 else if( pStretchItem && pStretchItem->GetValue() )
2803 rValue <<= drawing::BitmapMode_STRETCH;
2805 else
2807 rValue <<= drawing::BitmapMode_NO_REPEAT;
2809 break;
2811 case SDRATTR_LAYERID:
2812 rValue <<= (sal_Int16)mpObj->GetLayer();
2813 break;
2815 case SDRATTR_LAYERNAME:
2817 SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(mpObj->GetLayer());
2818 if( pLayer )
2820 OUString aName( pLayer->GetName() );
2821 rValue <<= aName;
2823 break;
2826 case SDRATTR_ROTATEANGLE:
2827 rValue <<= (sal_Int32)mpObj->GetRotateAngle();
2828 break;
2830 case SDRATTR_SHEARANGLE:
2831 rValue <<= (sal_Int32)mpObj->GetShearAngle();
2832 break;
2834 case OWN_ATTR_INTEROPGRABBAG:
2836 mpObj->GetGrabBagItem(rValue);
2837 break;
2840 case SDRATTR_OBJMOVEPROTECT:
2841 rValue = uno::makeAny( mpObj->IsMoveProtect() );
2842 break;
2844 case SDRATTR_OBJECTNAME:
2846 OUString aName( mpObj->GetName() );
2847 rValue <<= aName;
2848 break;
2851 // #i68101#
2852 case OWN_ATTR_MISC_OBJ_TITLE:
2854 OUString aTitle( mpObj->GetTitle() );
2855 rValue <<= aTitle;
2856 break;
2859 case OWN_ATTR_MISC_OBJ_DESCRIPTION:
2861 OUString aDescription( mpObj->GetDescription() );
2862 rValue <<= aDescription;
2863 break;
2866 case SDRATTR_OBJPRINTABLE:
2867 rValue <<= mpObj->IsPrintable();
2868 break;
2870 case SDRATTR_OBJVISIBLE:
2871 rValue <<= mpObj->IsVisible();
2872 break;
2874 case SDRATTR_OBJSIZEPROTECT:
2875 rValue <<= mpObj->IsResizeProtect();
2876 break;
2878 case OWN_ATTR_PAGE_NUMBER:
2880 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(mpObj.get());
2881 if(pPageObj)
2883 SdrPage* pPage = pPageObj->GetReferencedPage();
2884 sal_Int32 nPageNumber = (pPage) ? pPage->GetPageNum() : 0L;
2885 nPageNumber++;
2886 nPageNumber >>= 1;
2887 rValue <<= nPageNumber;
2889 break;
2892 case OWN_ATTR_UINAME_SINGULAR:
2894 rValue <<= mpObj->TakeObjNameSingul();
2895 break;
2898 case OWN_ATTR_UINAME_PLURAL:
2900 rValue <<= mpObj->TakeObjNamePlural();
2901 break;
2903 case OWN_ATTR_METAFILE:
2905 SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
2906 if( pObj )
2908 const Graphic* pGraphic = pObj->GetGraphic();
2909 if( pGraphic )
2911 bool bIsWMF = false;
2912 if ( pGraphic->IsLink() )
2914 GfxLink aLnk = pGraphic->GetLink();
2915 if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF )
2917 bIsWMF = true;
2918 uno::Sequence<sal_Int8> aSeq(reinterpret_cast<sal_Int8 const *>(aLnk.GetData()), (sal_Int32) aLnk.GetDataSize());
2919 rValue <<= aSeq;
2922 if ( !bIsWMF )
2924 // #119735# just use GetGDIMetaFile, it will create a bufferd version of contained bitmap now automatically
2925 GDIMetaFile aMtf(pObj->GetGraphic()->GetGDIMetaFile());
2926 SvMemoryStream aDestStrm( 65535, 65535 );
2927 ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, false );
2928 const uno::Sequence<sal_Int8> aSeq(
2929 static_cast< const sal_Int8* >(aDestStrm.GetData()),
2930 aDestStrm.GetEndOfData());
2931 rValue <<= aSeq;
2935 else
2937 rValue = GetBitmap( true );
2939 break;
2943 default:
2944 return false;
2946 return true;
2951 bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
2953 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
2955 const SfxItemSet& rSet = mpObj->GetMergedItemSet();
2957 if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SfxItemState::SET ||
2958 rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SfxItemState::SET )
2960 rState = beans::PropertyState_DIRECT_VALUE;
2962 else
2964 rState = beans::PropertyState_AMBIGUOUS_VALUE;
2967 else if((( pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
2968 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) && ( pProperty->nWID != SDRATTR_TEXTDIRECTION ) )
2970 rState = beans::PropertyState_DIRECT_VALUE;
2972 else
2974 return false;
2977 return true;
2982 bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
2984 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
2986 mpObj->ClearMergedItem( XATTR_FILLBMP_STRETCH );
2987 mpObj->ClearMergedItem( XATTR_FILLBMP_TILE );
2988 return true;
2990 else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
2991 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST ))
2993 return true;
2995 else
2997 return false;
3003 uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
3004 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
3006 const sal_Int32 nCount = aPropertyName.getLength();
3007 const OUString* pNames = aPropertyName.getConstArray();
3009 uno::Sequence< beans::PropertyState > aRet( nCount );
3010 beans::PropertyState* pState = aRet.getArray();
3012 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
3013 pState[nIdx] = getPropertyState( pNames[nIdx] );
3015 return aRet;
3020 void SAL_CALL SvxShape::setPropertyToDefault( const OUString& PropertyName )
3021 throw(beans::UnknownPropertyException, uno::RuntimeException, std::exception)
3023 if( mpImpl->mpMaster )
3025 mpImpl->mpMaster->setPropertyToDefault( PropertyName );
3027 else
3029 _setPropertyToDefault( PropertyName );
3033 void SAL_CALL SvxShape::_setPropertyToDefault( const OUString& PropertyName )
3034 throw(beans::UnknownPropertyException, uno::RuntimeException)
3036 ::SolarMutexGuard aGuard;
3038 const SfxItemPropertySimpleEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName);
3040 if( !mpObj.is() || mpModel == NULL || pProperty == NULL )
3041 throw beans::UnknownPropertyException();
3043 if( !setPropertyToDefaultImpl( pProperty ) )
3045 mpObj->ClearMergedItem( pProperty->nWID );
3048 mpModel->SetChanged();
3053 uno::Any SAL_CALL SvxShape::getPropertyDefault( const OUString& aPropertyName )
3054 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
3056 if( mpImpl->mpMaster )
3058 return mpImpl->mpMaster->getPropertyDefault( aPropertyName );
3060 else
3062 return _getPropertyDefault( aPropertyName );
3066 uno::Any SAL_CALL SvxShape::_getPropertyDefault( const OUString& aPropertyName )
3067 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
3069 ::SolarMutexGuard aGuard;
3071 const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
3073 if( !mpObj.is() || pMap == NULL || mpModel == NULL )
3074 throw beans::UnknownPropertyException();
3076 if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) ||
3077 ( pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST ))
3079 return getPropertyValue( aPropertyName );
3082 // get default from ItemPool
3083 if(!SfxItemPool::IsWhich(pMap->nWID))
3084 throw beans::UnknownPropertyException();
3086 SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
3087 aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
3089 return GetAnyForItem( aSet, pMap );
3092 // XMultiPropertyStates
3093 void SvxShape::setAllPropertiesToDefault() throw (uno::RuntimeException, std::exception)
3095 ::SolarMutexGuard aGuard;
3097 if( !mpObj.is() )
3098 throw lang::DisposedException();
3099 mpObj->ClearMergedItem(); // nWhich == 0 => all
3101 if(mpObj->ISA(SdrGrafObj))
3103 // defaults for graphic objects have changed:
3104 mpObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
3105 mpObj->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
3108 // #i68523# special handling for Svx3DCharacterModeItem, this is not saved
3109 // but needs to be sal_True in svx, pool default (false) in sch. Since sch
3110 // does not load lathe or extrude objects, it is possible to set the items
3111 // here.
3112 // For other solution possibilities, see task description.
3113 if(mpObj->ISA(E3dLatheObj) || mpObj->ISA(E3dExtrudeObj))
3115 mpObj->SetMergedItem(Svx3DCharacterModeItem(true));
3118 mpModel->SetChanged();
3121 void SvxShape::setPropertiesToDefault(
3122 const uno::Sequence<OUString>& aPropertyNames )
3123 throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
3125 for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos )
3126 setPropertyToDefault( aPropertyNames[pos] );
3129 uno::Sequence<uno::Any> SvxShape::getPropertyDefaults(
3130 const uno::Sequence<OUString>& aPropertyNames )
3131 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
3132 uno::RuntimeException, std::exception)
3134 ::std::vector<uno::Any> ret;
3135 for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos )
3136 ret.push_back( getPropertyDefault( aPropertyNames[pos] ) );
3137 return uno::Sequence<uno::Any>( &ret[0], ret.size() );
3143 // XServiceInfo
3145 OUString SAL_CALL SvxShape::getImplementationName()
3146 throw(uno::RuntimeException, std::exception)
3148 return OUString("SvxShape");
3151 #define STAR_NAMESPACE "com.sun.star."
3153 const char* sUNO_service_style_ParagraphProperties = STAR_NAMESPACE "style.ParagraphProperties";
3154 const char* sUNO_service_style_ParagraphPropertiesComplex = STAR_NAMESPACE "style.ParagraphPropertiesComplex";
3155 const char* sUNO_service_style_ParagraphPropertiesAsian = STAR_NAMESPACE "style.ParagraphPropertiesAsian";
3156 const char* sUNO_service_style_CharacterProperties = STAR_NAMESPACE "style.CharacterProperties";
3157 const char* sUNO_service_style_CharacterPropertiesComplex = STAR_NAMESPACE "style.CharacterPropertiesComplex";
3158 const char* sUNO_service_style_CharacterPropertiesAsian = STAR_NAMESPACE "style.CharacterPropertiesAsian";
3160 const char* sUNO_service_drawing_FillProperties = STAR_NAMESPACE "drawing.FillProperties";
3161 const char* sUNO_service_drawing_TextProperties = STAR_NAMESPACE "drawing.TextProperties";
3162 const char* sUNO_service_drawing_LineProperties = STAR_NAMESPACE "drawing.LineProperties";
3163 const char* sUNO_service_drawing_ConnectorProperties = STAR_NAMESPACE "drawing.ConnectorProperties";
3164 const char* sUNO_service_drawing_MeasureProperties = STAR_NAMESPACE "drawing.MeasureProperties";
3165 const char* sUNO_service_drawing_ShadowProperties = STAR_NAMESPACE "drawing.ShadowProperties";
3167 const char* sUNO_service_drawing_RotationDescriptor = STAR_NAMESPACE "drawing.RotationDescriptor";
3169 const char* sUNO_service_drawing_Text = STAR_NAMESPACE "drawing.Text";
3170 const char* sUNO_service_drawing_GroupShape = STAR_NAMESPACE "drawing.GroupShape";
3172 const char* sUNO_service_drawing_CustomShapeProperties = STAR_NAMESPACE "drawing.CustomShapeProperties";
3173 const char* sUNO_service_drawing_CustomShape = STAR_NAMESPACE "drawing.CustomShape";
3175 const char* sUNO_service_drawing_PolyPolygonDescriptor = STAR_NAMESPACE "drawing.PolyPolygonDescriptor";
3176 const char* sUNO_service_drawing_PolyPolygonBezierDescriptor= STAR_NAMESPACE "drawing.PolyPolygonBezierDescriptor";
3178 const char* sUNO_service_drawing_LineShape = STAR_NAMESPACE "drawing.LineShape";
3179 const char* sUNO_service_drawing_Shape = STAR_NAMESPACE "drawing.Shape";
3180 const char* sUNO_service_drawing_RectangleShape = STAR_NAMESPACE "drawing.RectangleShape";
3181 const char* sUNO_service_drawing_EllipseShape = STAR_NAMESPACE "drawing.EllipseShape";
3182 const char* sUNO_service_drawing_PolyPolygonShape = STAR_NAMESPACE "drawing.PolyPolygonShape";
3183 const char* sUNO_service_drawing_PolyLineShape = STAR_NAMESPACE "drawing.PolyLineShape";
3184 const char* sUNO_service_drawing_OpenBezierShape = STAR_NAMESPACE "drawing.OpenBezierShape";
3185 const char* sUNO_service_drawing_ClosedBezierShape = STAR_NAMESPACE "drawing.ClosedBezierShape";
3186 const char* sUNO_service_drawing_TextShape = STAR_NAMESPACE "drawing.TextShape";
3187 const char* sUNO_service_drawing_GraphicObjectShape = STAR_NAMESPACE "drawing.GraphicObjectShape";
3188 const char* sUNO_service_drawing_OLE2Shape = STAR_NAMESPACE "drawing.OLE2Shape";
3189 const char* sUNO_service_drawing_PageShape = STAR_NAMESPACE "drawing.PageShape";
3190 const char* sUNO_service_drawing_CaptionShape = STAR_NAMESPACE "drawing.CaptionShape";
3191 const char* sUNO_service_drawing_MeasureShape = STAR_NAMESPACE "drawing.MeasureShape";
3192 const char* sUNO_service_drawing_FrameShape = STAR_NAMESPACE "drawing.FrameShape";
3193 const char* sUNO_service_drawing_ControlShape = STAR_NAMESPACE "drawing.ControlShape";
3194 const char* sUNO_service_drawing_ConnectorShape = STAR_NAMESPACE "drawing.ConnectorShape";
3195 const char* sUNO_service_drawing_MediaShape = STAR_NAMESPACE "drawing.MediaShape";
3198 uno::Sequence< OUString > SAL_CALL SvxShape::getSupportedServiceNames()
3199 throw(uno::RuntimeException, std::exception)
3201 if( mpImpl->mpMaster )
3203 return mpImpl->mpMaster->getSupportedServiceNames();
3205 else
3207 return _getSupportedServiceNames();
3211 uno::Sequence< OUString > SAL_CALL SvxShape::_getSupportedServiceNames()
3212 throw(uno::RuntimeException)
3214 ::SolarMutexGuard aGuard;
3216 if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor)
3218 const sal_uInt16 nIdent = mpObj->GetObjIdentifier();
3220 switch(nIdent)
3222 case OBJ_GRUP:
3224 static uno::Sequence< OUString > *pSeq = 0;
3225 if( 0 == pSeq )
3227 static uno::Sequence< OUString > SvxShape_GroupServices;
3229 comphelper::ServiceInfoHelper::addToSequence( SvxShape_GroupServices, 2,
3230 sUNO_service_drawing_GroupShape,
3231 sUNO_service_drawing_Shape );
3233 pSeq = &SvxShape_GroupServices;
3236 return *pSeq;
3238 case OBJ_CUSTOMSHAPE:
3240 static uno::Sequence< OUString > *pSeq = 0;
3241 if( 0 == pSeq )
3243 static uno::Sequence< OUString > SvxShape_CustomShapeServices;
3245 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CustomShapeServices, 13,
3246 sUNO_service_drawing_CustomShape,
3247 sUNO_service_drawing_Shape,
3248 sUNO_service_drawing_CustomShapeProperties,
3249 sUNO_service_drawing_FillProperties,
3250 sUNO_service_drawing_LineProperties,
3251 sUNO_service_drawing_Text,
3252 sUNO_service_drawing_TextProperties,
3253 sUNO_service_style_ParagraphProperties,
3254 sUNO_service_style_ParagraphPropertiesComplex,
3255 sUNO_service_style_ParagraphPropertiesAsian,
3256 sUNO_service_style_CharacterProperties,
3257 sUNO_service_style_CharacterPropertiesComplex,
3258 sUNO_service_style_CharacterPropertiesAsian,
3259 sUNO_service_drawing_ShadowProperties,
3260 sUNO_service_drawing_RotationDescriptor);
3261 pSeq = &SvxShape_CustomShapeServices;
3263 return *pSeq;
3265 case OBJ_LINE:
3267 static uno::Sequence< OUString > *pSeq = 0;
3268 if( 0 == pSeq )
3270 static uno::Sequence< OUString > SvxShape_LineServices;
3272 comphelper::ServiceInfoHelper::addToSequence( SvxShape_LineServices,14,
3273 sUNO_service_drawing_LineShape,
3275 sUNO_service_drawing_Shape,
3276 sUNO_service_drawing_LineProperties,
3278 sUNO_service_drawing_Text,
3279 sUNO_service_drawing_TextProperties,
3280 sUNO_service_style_ParagraphProperties,
3281 sUNO_service_style_ParagraphPropertiesComplex,
3282 sUNO_service_style_ParagraphPropertiesAsian,
3283 sUNO_service_style_CharacterProperties,
3284 sUNO_service_style_CharacterPropertiesComplex,
3285 sUNO_service_style_CharacterPropertiesAsian,
3287 sUNO_service_drawing_PolyPolygonDescriptor,
3288 sUNO_service_drawing_ShadowProperties,
3289 sUNO_service_drawing_RotationDescriptor);
3291 pSeq = &SvxShape_LineServices;
3293 return *pSeq;
3296 case OBJ_RECT:
3298 static uno::Sequence< OUString > *pSeq = 0;
3299 if( 0 == pSeq )
3301 static uno::Sequence< OUString > SvxShape_RectServices;
3303 comphelper::ServiceInfoHelper::addToSequence( SvxShape_RectServices,14,
3304 sUNO_service_drawing_RectangleShape,
3306 sUNO_service_drawing_Shape,
3307 sUNO_service_drawing_FillProperties,
3308 sUNO_service_drawing_LineProperties,
3309 sUNO_service_drawing_Text,
3310 sUNO_service_drawing_TextProperties,
3311 sUNO_service_style_ParagraphProperties,
3312 sUNO_service_style_ParagraphPropertiesComplex,
3313 sUNO_service_style_ParagraphPropertiesAsian,
3314 sUNO_service_style_CharacterProperties,
3315 sUNO_service_style_CharacterPropertiesComplex,
3316 sUNO_service_style_CharacterPropertiesAsian,
3318 sUNO_service_drawing_ShadowProperties,
3319 sUNO_service_drawing_RotationDescriptor);
3320 pSeq = &SvxShape_RectServices;
3322 return *pSeq;
3325 case OBJ_CIRC:
3326 case OBJ_SECT:
3327 case OBJ_CARC:
3328 case OBJ_CCUT:
3330 static uno::Sequence< OUString > *pSeq = 0;
3331 if( 0 == pSeq )
3333 static uno::Sequence< OUString > SvxShape_CircServices;
3335 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CircServices,14,
3336 sUNO_service_drawing_EllipseShape,
3338 sUNO_service_drawing_Shape,
3339 sUNO_service_drawing_FillProperties,
3340 sUNO_service_drawing_LineProperties,
3342 sUNO_service_drawing_Text,
3343 sUNO_service_drawing_TextProperties,
3344 sUNO_service_style_ParagraphProperties,
3345 sUNO_service_style_ParagraphPropertiesComplex,
3346 sUNO_service_style_ParagraphPropertiesAsian,
3347 sUNO_service_style_CharacterProperties,
3348 sUNO_service_style_CharacterPropertiesComplex,
3349 sUNO_service_style_CharacterPropertiesAsian,
3351 sUNO_service_drawing_ShadowProperties,
3352 sUNO_service_drawing_RotationDescriptor);
3354 pSeq = &SvxShape_CircServices;
3357 return *pSeq;
3360 case OBJ_PATHPLIN:
3361 case OBJ_PLIN:
3363 static uno::Sequence< OUString > *pSeq = 0;
3364 if( 0 == pSeq )
3366 static uno::Sequence< OUString > SvxShape_PathServices;
3367 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PathServices,14,
3368 sUNO_service_drawing_PolyLineShape,
3370 sUNO_service_drawing_Shape,
3371 sUNO_service_drawing_LineProperties,
3373 sUNO_service_drawing_PolyPolygonDescriptor,
3375 sUNO_service_drawing_Text,
3376 sUNO_service_drawing_TextProperties,
3377 sUNO_service_style_ParagraphProperties,
3378 sUNO_service_style_ParagraphPropertiesComplex,
3379 sUNO_service_style_ParagraphPropertiesAsian,
3380 sUNO_service_style_CharacterProperties,
3381 sUNO_service_style_CharacterPropertiesComplex,
3382 sUNO_service_style_CharacterPropertiesAsian,
3384 sUNO_service_drawing_ShadowProperties,
3385 sUNO_service_drawing_RotationDescriptor);
3386 pSeq = &SvxShape_PathServices;
3388 return *pSeq;
3391 case OBJ_PATHPOLY:
3392 case OBJ_POLY:
3394 static uno::Sequence< OUString > *pSeq = 0;
3395 if( 0 == pSeq )
3397 static uno::Sequence< OUString > SvxShape_PolyServices;
3398 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PolyServices,15,
3399 sUNO_service_drawing_PolyPolygonShape,
3401 sUNO_service_drawing_Shape,
3402 sUNO_service_drawing_LineProperties,
3403 sUNO_service_drawing_FillProperties,
3405 sUNO_service_drawing_PolyPolygonDescriptor,
3407 sUNO_service_drawing_Text,
3408 sUNO_service_drawing_TextProperties,
3409 sUNO_service_style_ParagraphProperties,
3410 sUNO_service_style_ParagraphPropertiesComplex,
3411 sUNO_service_style_ParagraphPropertiesAsian,
3412 sUNO_service_style_CharacterProperties,
3413 sUNO_service_style_CharacterPropertiesComplex,
3414 sUNO_service_style_CharacterPropertiesAsian,
3416 sUNO_service_drawing_ShadowProperties,
3417 sUNO_service_drawing_RotationDescriptor);
3419 pSeq = &SvxShape_PolyServices;
3421 return *pSeq;
3424 case OBJ_FREELINE:
3425 case OBJ_PATHLINE:
3427 static uno::Sequence< OUString > *pSeq = 0;
3428 if( 0 == pSeq )
3430 static uno::Sequence< OUString > SvxShape_FreeLineServices;
3432 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeLineServices,15,
3433 sUNO_service_drawing_OpenBezierShape,
3435 sUNO_service_drawing_Shape,
3436 sUNO_service_drawing_LineProperties,
3437 sUNO_service_drawing_FillProperties,
3439 sUNO_service_drawing_PolyPolygonBezierDescriptor,
3441 sUNO_service_drawing_Text,
3442 sUNO_service_drawing_TextProperties,
3443 sUNO_service_style_ParagraphProperties,
3444 sUNO_service_style_ParagraphPropertiesComplex,
3445 sUNO_service_style_ParagraphPropertiesAsian,
3446 sUNO_service_style_CharacterProperties,
3447 sUNO_service_style_CharacterPropertiesComplex,
3448 sUNO_service_style_CharacterPropertiesAsian,
3450 sUNO_service_drawing_ShadowProperties,
3451 sUNO_service_drawing_RotationDescriptor);
3453 pSeq = &SvxShape_FreeLineServices;
3456 return *pSeq;
3459 case OBJ_FREEFILL:
3460 case OBJ_PATHFILL:
3462 static uno::Sequence< OUString > *pSeq = 0;
3463 if( 0 == pSeq )
3465 static uno::Sequence< OUString > SvxShape_FreeFillServices;
3466 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeFillServices,15,
3467 sUNO_service_drawing_ClosedBezierShape,
3469 sUNO_service_drawing_Shape,
3470 sUNO_service_drawing_LineProperties,
3471 sUNO_service_drawing_FillProperties,
3473 sUNO_service_drawing_PolyPolygonBezierDescriptor,
3475 sUNO_service_drawing_Text,
3476 sUNO_service_drawing_TextProperties,
3477 sUNO_service_style_ParagraphProperties,
3478 sUNO_service_style_ParagraphPropertiesComplex,
3479 sUNO_service_style_ParagraphPropertiesAsian,
3480 sUNO_service_style_CharacterProperties,
3481 sUNO_service_style_CharacterPropertiesComplex,
3482 sUNO_service_style_CharacterPropertiesAsian,
3484 sUNO_service_drawing_ShadowProperties,
3485 sUNO_service_drawing_RotationDescriptor);
3487 pSeq = &SvxShape_FreeFillServices;
3489 return *pSeq;
3492 case OBJ_OUTLINETEXT:
3493 case OBJ_TITLETEXT:
3494 case OBJ_TEXT:
3496 static uno::Sequence< OUString > *pSeq = 0;
3497 if( 0 == pSeq )
3499 static uno::Sequence< OUString > SvxShape_TextServices;
3500 comphelper::ServiceInfoHelper::addToSequence( SvxShape_TextServices,14,
3501 sUNO_service_drawing_TextShape,
3503 sUNO_service_drawing_Shape,
3504 sUNO_service_drawing_FillProperties,
3505 sUNO_service_drawing_LineProperties,
3507 sUNO_service_drawing_Text,
3508 sUNO_service_drawing_TextProperties,
3509 sUNO_service_style_ParagraphProperties,
3510 sUNO_service_style_ParagraphPropertiesComplex,
3511 sUNO_service_style_ParagraphPropertiesAsian,
3512 sUNO_service_style_CharacterProperties,
3513 sUNO_service_style_CharacterPropertiesComplex,
3514 sUNO_service_style_CharacterPropertiesAsian,
3516 sUNO_service_drawing_ShadowProperties,
3517 sUNO_service_drawing_RotationDescriptor);
3519 pSeq = &SvxShape_TextServices;
3521 return *pSeq;
3524 case OBJ_GRAF:
3526 static uno::Sequence< OUString > *pSeq = 0;
3527 if( 0 == pSeq )
3529 static uno::Sequence< OUString > SvxShape_GrafServices;
3530 comphelper::ServiceInfoHelper::addToSequence( SvxShape_GrafServices, 12,
3531 sUNO_service_drawing_GraphicObjectShape,
3533 sUNO_service_drawing_Shape,
3535 sUNO_service_drawing_Text,
3536 sUNO_service_drawing_TextProperties,
3537 sUNO_service_style_ParagraphProperties,
3538 sUNO_service_style_ParagraphPropertiesComplex,
3539 sUNO_service_style_ParagraphPropertiesAsian,
3540 sUNO_service_style_CharacterProperties,
3541 sUNO_service_style_CharacterPropertiesComplex,
3542 sUNO_service_style_CharacterPropertiesAsian,
3544 sUNO_service_drawing_ShadowProperties,
3545 sUNO_service_drawing_RotationDescriptor);
3547 pSeq = &SvxShape_GrafServices;
3549 return *pSeq;
3552 case OBJ_OLE2:
3554 static uno::Sequence< OUString > *pSeq = 0;
3555 if( 0 == pSeq )
3557 static uno::Sequence< OUString > SvxShape_Ole2Services;
3559 comphelper::ServiceInfoHelper::addToSequence( SvxShape_Ole2Services, 12,
3560 sUNO_service_drawing_OLE2Shape,
3561 sUNO_service_drawing_Shape,
3563 // #i118485# Added Text, Shadow and Rotation
3564 sUNO_service_drawing_Text,
3565 sUNO_service_drawing_TextProperties,
3566 sUNO_service_style_ParagraphProperties,
3567 sUNO_service_style_ParagraphPropertiesComplex,
3568 sUNO_service_style_ParagraphPropertiesAsian,
3569 sUNO_service_style_CharacterProperties,
3570 sUNO_service_style_CharacterPropertiesComplex,
3571 sUNO_service_style_CharacterPropertiesAsian,
3573 sUNO_service_drawing_ShadowProperties,
3574 sUNO_service_drawing_RotationDescriptor);
3576 pSeq = &SvxShape_Ole2Services;
3578 return *pSeq;
3581 case OBJ_CAPTION:
3583 static uno::Sequence< OUString > *pSeq = 0;
3584 if( 0 == pSeq )
3586 static uno::Sequence< OUString > SvxShape_CaptionServices;
3588 comphelper::ServiceInfoHelper::addToSequence( SvxShape_CaptionServices,14,
3589 sUNO_service_drawing_CaptionShape,
3591 sUNO_service_drawing_Shape,
3592 sUNO_service_drawing_FillProperties,
3593 sUNO_service_drawing_LineProperties,
3595 sUNO_service_drawing_Text,
3596 sUNO_service_drawing_TextProperties,
3597 sUNO_service_style_ParagraphProperties,
3598 sUNO_service_style_ParagraphPropertiesComplex,
3599 sUNO_service_style_ParagraphPropertiesAsian,
3600 sUNO_service_style_CharacterProperties,
3601 sUNO_service_style_CharacterPropertiesComplex,
3602 sUNO_service_style_CharacterPropertiesAsian,
3604 sUNO_service_drawing_ShadowProperties,
3605 sUNO_service_drawing_RotationDescriptor);
3607 pSeq = &SvxShape_CaptionServices;
3610 return *pSeq;
3613 case OBJ_PAGE:
3615 static uno::Sequence< OUString > *pSeq = 0;
3616 if( 0 == pSeq )
3618 static uno::Sequence< OUString > SvxShape_PageServices;
3620 comphelper::ServiceInfoHelper::addToSequence( SvxShape_PageServices, 2,
3621 sUNO_service_drawing_PageShape,
3622 sUNO_service_drawing_Shape );
3624 pSeq = &SvxShape_PageServices;
3627 return *pSeq;
3630 case OBJ_MEASURE:
3632 static uno::Sequence< OUString > *pSeq = 0;
3633 if( 0 == pSeq )
3635 static uno::Sequence< OUString > SvxShape_MeasureServices;
3636 comphelper::ServiceInfoHelper::addToSequence( SvxShape_MeasureServices,15,
3637 sUNO_service_drawing_MeasureShape,
3639 sUNO_service_drawing_MeasureProperties,
3641 sUNO_service_drawing_Shape,
3642 sUNO_service_drawing_LineProperties,
3644 sUNO_service_drawing_Text,
3645 sUNO_service_drawing_TextProperties,
3646 sUNO_service_style_ParagraphProperties,
3647 sUNO_service_style_ParagraphPropertiesComplex,
3648 sUNO_service_style_ParagraphPropertiesAsian,
3649 sUNO_service_style_CharacterProperties,
3650 sUNO_service_style_CharacterPropertiesComplex,
3651 sUNO_service_style_CharacterPropertiesAsian,
3653 sUNO_service_drawing_PolyPolygonDescriptor,
3654 sUNO_service_drawing_ShadowProperties,
3655 sUNO_service_drawing_RotationDescriptor);
3657 pSeq = &SvxShape_MeasureServices;
3660 return *pSeq;
3663 case OBJ_FRAME:
3665 static uno::Sequence< OUString > *pSeq = 0;
3666 if( 0 == pSeq )
3668 static uno::Sequence< OUString > SvxShape_FrameServices;
3670 comphelper::ServiceInfoHelper::addToSequence( SvxShape_FrameServices, 2,
3671 sUNO_service_drawing_FrameShape,
3672 sUNO_service_drawing_Shape );
3674 pSeq = &SvxShape_FrameServices;
3677 return *pSeq;
3680 case OBJ_UNO:
3682 static uno::Sequence< OUString > *pSeq = 0;
3683 if( 0 == pSeq )
3685 static uno::Sequence< OUString > SvxShape_UnoServices;
3686 comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2,
3687 sUNO_service_drawing_ControlShape,
3688 sUNO_service_drawing_Shape );
3690 pSeq = &SvxShape_UnoServices;
3692 return *pSeq;
3695 case OBJ_EDGE:
3697 static uno::Sequence< OUString > *pSeq = 0;
3698 if( 0 == pSeq )
3700 static uno::Sequence< OUString > SvxShape_EdgeServices;
3702 comphelper::ServiceInfoHelper::addToSequence( SvxShape_EdgeServices,15,
3703 sUNO_service_drawing_ConnectorShape,
3704 sUNO_service_drawing_ConnectorProperties,
3706 sUNO_service_drawing_Shape,
3707 sUNO_service_drawing_LineProperties,
3709 sUNO_service_drawing_Text,
3710 sUNO_service_drawing_TextProperties,
3711 sUNO_service_style_ParagraphProperties,
3712 sUNO_service_style_ParagraphPropertiesComplex,
3713 sUNO_service_style_ParagraphPropertiesAsian,
3714 sUNO_service_style_CharacterProperties,
3715 sUNO_service_style_CharacterPropertiesComplex,
3716 sUNO_service_style_CharacterPropertiesAsian,
3718 sUNO_service_drawing_PolyPolygonDescriptor,
3719 sUNO_service_drawing_ShadowProperties,
3720 sUNO_service_drawing_RotationDescriptor);
3722 pSeq = &SvxShape_EdgeServices;
3724 return *pSeq;
3726 case OBJ_MEDIA:
3728 static uno::Sequence< OUString > *pSeq = 0;
3729 if( 0 == pSeq )
3731 static uno::Sequence< OUString > SvxShape_MediaServices;
3733 comphelper::ServiceInfoHelper::addToSequence( SvxShape_MediaServices, 2,
3734 sUNO_service_drawing_MediaShape,
3735 sUNO_service_drawing_Shape);
3737 pSeq = &SvxShape_MediaServices;
3739 return *pSeq;
3743 else if( mpObj.is() && mpObj->GetObjInventor() == FmFormInventor)
3745 #if OSL_DEBUG_LEVEL > 0
3746 const sal_uInt16 nIdent = mpObj->GetObjIdentifier();
3747 OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: FmFormInventor, but no UNO object?" );
3748 #endif
3749 static uno::Sequence< OUString > *pSeq = 0;
3750 if( 0 == pSeq )
3752 static uno::Sequence< OUString > SvxShape_UnoServices;
3753 comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2,
3754 sUNO_service_drawing_ControlShape,
3755 sUNO_service_drawing_Shape );
3757 pSeq = &SvxShape_UnoServices;
3759 return *pSeq;
3761 OSL_FAIL( "SvxShape::_getSupportedServiceNames: could not determine object type!" );
3762 uno::Sequence< OUString > aSeq;
3763 return aSeq;
3766 sal_Bool SAL_CALL SvxShape::supportsService( const OUString& ServiceName ) throw ( uno::RuntimeException, std::exception )
3768 return cppu::supportsService(this, ServiceName);
3771 // XGluePointsSupplier
3772 uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints()
3773 throw(uno::RuntimeException, std::exception)
3775 ::SolarMutexGuard aGuard;
3776 uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints );
3778 if( mpObj.is() && !xGluePoints.is() )
3780 uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( mpObj.get() ), uno::UNO_QUERY );
3781 mxGluePoints = xGluePoints = xNew;
3784 return xGluePoints;
3789 // XChild
3790 uno::Reference< uno::XInterface > SAL_CALL SvxShape::getParent( )
3791 throw(uno::RuntimeException, std::exception)
3793 ::SolarMutexGuard aGuard;
3795 if( mpObj.is() && mpObj->GetObjList() )
3797 SdrObjList* pObjList = mpObj->GetObjList();
3799 switch( pObjList->GetListKind() )
3801 case SDROBJLIST_GROUPOBJ:
3802 if( pObjList->GetOwnerObj()->ISA( SdrObjGroup ) )
3803 return PTR_CAST( SdrObjGroup, pObjList->GetOwnerObj())->getUnoShape();
3804 else if( pObjList->GetOwnerObj()->ISA( E3dScene ) )
3805 return PTR_CAST( E3dScene, pObjList->GetOwnerObj())->getUnoShape();
3806 break;
3807 case SDROBJLIST_DRAWPAGE:
3808 case SDROBJLIST_MASTERPAGE:
3809 return PTR_CAST( SdrPage, pObjList )->getUnoPage();
3810 default:
3811 OSL_FAIL( "SvxShape::getParent( ): unexpected SdrObjListKind" );
3812 break;
3816 uno::Reference< uno::XInterface > xParent;
3817 return xParent;
3822 void SAL_CALL SvxShape::setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& )
3823 throw(lang::NoSupportException, uno::RuntimeException, std::exception)
3825 throw lang::NoSupportException();
3830 /** called from the XActionLockable interface methods on initial locking */
3831 void SvxShape::lock()
3837 /** called from the XActionLockable interface methods on final unlock */
3838 void SvxShape::unlock()
3844 // XActionLockable
3845 sal_Bool SAL_CALL SvxShape::isActionLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
3847 ::SolarMutexGuard aGuard;
3849 return mnLockCount != 0;
3854 void SAL_CALL SvxShape::addActionLock( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
3856 ::SolarMutexGuard aGuard;
3858 DBG_ASSERT( mnLockCount < 0xffff, "lock overflow in SvxShape!" );
3859 mnLockCount++;
3861 if( mnLockCount == 1 )
3862 lock();
3867 void SAL_CALL SvxShape::removeActionLock( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
3869 ::SolarMutexGuard aGuard;
3871 DBG_ASSERT( mnLockCount > 0, "lock underflow in SvxShape!" );
3872 mnLockCount--;
3874 if( mnLockCount == 0 )
3875 unlock();
3880 void SAL_CALL SvxShape::setActionLocks( sal_Int16 nLock ) throw (::com::sun::star::uno::RuntimeException, std::exception )
3882 ::SolarMutexGuard aGuard;
3884 if( (mnLockCount == 0) && (nLock != 0) )
3885 unlock();
3887 if( (mnLockCount != 0) && (nLock == 0) )
3888 lock();
3890 mnLockCount = (sal_uInt16)nLock;
3895 sal_Int16 SAL_CALL SvxShape::resetActionLocks( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
3897 ::SolarMutexGuard aGuard;
3899 if( mnLockCount != 0 )
3900 unlock();
3902 sal_Int16 nOldLocks = (sal_Int16)mnLockCount;
3903 mnLockCount = 0;
3905 return nOldLocks;
3910 /** since polygon shapes can change theire kind during editing, we have
3911 to recheck it here.
3912 Circle shapes also change theire kind, but theire all treated equal
3913 so no update is necessary.
3915 void SvxShape::updateShapeKind()
3917 switch( mpImpl->mnObjId )
3919 case OBJ_LINE:
3920 case OBJ_POLY:
3921 case OBJ_PLIN:
3922 case OBJ_PATHLINE:
3923 case OBJ_PATHFILL:
3924 case OBJ_FREELINE:
3925 case OBJ_FREEFILL:
3926 case OBJ_PATHPOLY:
3927 case OBJ_PATHPLIN:
3929 const sal_uInt32 nId = mpObj->GetObjIdentifier();
3931 if( nId != mpImpl->mnObjId )
3933 mpImpl->mnObjId = nId;
3936 break;
3941 SvxShapeText::SvxShapeText( SdrObject* pObject ) throw ()
3942 : SvxShape( pObject, getSvxMapProvider().GetMap(SVXMAP_TEXT), getSvxMapProvider().GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
3944 if( pObject && pObject->GetModel() )
3945 SetEditSource( new SvxTextEditSource( pObject, 0 ) );
3949 SvxShapeText::SvxShapeText( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw ()
3950 : SvxShape( pObject, pPropertyMap, pPropertySet ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
3952 if( pObject && pObject->GetModel() )
3953 SetEditSource( new SvxTextEditSource( pObject, 0 ) );
3957 SvxShapeText::~SvxShapeText() throw ()
3959 // check if only this instance is registered at the ranges
3960 DBG_ASSERT( (NULL == GetEditSource()) || (GetEditSource()->getRanges().size()==1),
3961 "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!");
3964 void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
3966 if( pNewObj && (NULL == GetEditSource()))
3967 SetEditSource( new SvxTextEditSource( pNewObj, 0 ) );
3968 SvxShape::Create( pNewObj, pNewPage );
3971 // XInterface
3973 uno::Any SAL_CALL SvxShapeText::queryInterface( const uno::Type & rType )
3974 throw( uno::RuntimeException, std::exception )
3976 return SvxShape::queryInterface( rType );
3981 uno::Any SAL_CALL SvxShapeText::queryAggregation( const uno::Type & rType )
3982 throw( uno::RuntimeException, std::exception )
3984 uno::Any aAny( SvxShape::queryAggregation( rType ) );
3985 if( aAny.hasValue() )
3986 return aAny;
3988 return SvxUnoTextBase::queryAggregation( rType );
3993 void SAL_CALL SvxShapeText::acquire() throw()
3995 SvxShape::acquire();
3999 void SAL_CALL SvxShapeText::release() throw()
4001 SvxShape::release();
4004 // XServiceInfo
4006 OUString SAL_CALL SvxShapeText::getImplementationName() throw( uno::RuntimeException, std::exception )
4008 return OUString("SvxShapeText");
4012 uno::Sequence< OUString > SAL_CALL SvxShapeText::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
4014 return SvxShape::getSupportedServiceNames();
4018 sal_Bool SAL_CALL SvxShapeText::supportsService( const OUString& ServiceName ) throw ( uno::RuntimeException, std::exception )
4020 return cppu::supportsService(static_cast<SvxShape*>(this), ServiceName);
4023 // XTypeProvider
4025 uno::Sequence< uno::Type > SAL_CALL SvxShapeText::getTypes()
4026 throw( uno::RuntimeException, std::exception )
4028 return SvxShape::getTypes();
4031 sal_Int64 SAL_CALL SvxShapeText::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException, std::exception) \
4033 const sal_Int64 nReturn = SvxShape::getSomething( rId );
4034 if( nReturn )
4035 return nReturn;
4037 return SvxUnoTextBase::getSomething( rId );
4041 uno::Sequence< sal_Int8 > SAL_CALL SvxShapeText::getImplementationId()
4042 throw( uno::RuntimeException, std::exception )
4044 return css::uno::Sequence<sal_Int8>();
4049 /** called from the XActionLockable interface methods on initial locking */
4050 void SvxShapeText::lock()
4052 SvxTextEditSource* pEditSource = static_cast<SvxTextEditSource*>(GetEditSource());
4053 if( pEditSource )
4054 pEditSource->lock();
4059 /** called from the XActionLockable interface methods on final unlock */
4060 void SvxShapeText::unlock()
4062 SvxTextEditSource* pEditSource = static_cast<SvxTextEditSource*>(GetEditSource());
4063 if( pEditSource )
4064 pEditSource->unlock();
4067 // ::com::sun::star::text::XTextRange
4068 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getStart() throw(uno::RuntimeException, std::exception)
4070 ::SolarMutexGuard aGuard;
4071 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4072 if( pForwarder )
4073 ::GetSelection( maSelection, pForwarder );
4074 return SvxUnoTextBase::getStart();
4078 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getEnd() throw(uno::RuntimeException, std::exception)
4080 ::SolarMutexGuard aGuard;
4081 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4082 if( pForwarder )
4083 ::GetSelection( maSelection, pForwarder );
4084 return SvxUnoTextBase::getEnd();
4087 OUString SAL_CALL SvxShapeText::getString() throw(uno::RuntimeException, std::exception)
4089 ::SolarMutexGuard aGuard;
4090 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4091 if( pForwarder )
4092 ::GetSelection( maSelection, pForwarder );
4093 return SvxUnoTextBase::getString();
4097 void SAL_CALL SvxShapeText::setString( const OUString& aString ) throw(uno::RuntimeException, std::exception)
4099 ::SolarMutexGuard aGuard;
4100 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
4101 if( pForwarder )
4102 ::GetSelection( maSelection, pForwarder );
4103 SvxUnoTextBase::setString( aString );
4106 // override these for special property handling in subcasses. Return true if property is handled
4107 bool SvxShapeText::setPropertyValueImpl( const 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, std::exception)
4109 // HACK-fix #99090#
4110 // since SdrTextObj::SetVerticalWriting exchanges
4111 // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT,
4112 // we have to set the textdirection here
4114 if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
4116 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
4117 if( pTextObj )
4119 com::sun::star::text::WritingMode eMode;
4120 if( rValue >>= eMode )
4122 pTextObj->SetVerticalWriting( eMode == com::sun::star::text::WritingMode_TB_RL );
4125 return true;
4127 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
4130 bool SvxShapeText::getPropertyValueImpl( const 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, std::exception)
4132 if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
4134 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
4135 if( pTextObj && pTextObj->IsVerticalWriting() )
4136 rValue <<= com::sun::star::text::WritingMode_TB_RL;
4137 else
4138 rValue <<= com::sun::star::text::WritingMode_LR_TB;
4139 return true;
4142 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
4145 bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
4147 return SvxShape::getPropertyStateImpl( pProperty, rState );
4150 bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
4152 return SvxShape::setPropertyToDefaultImpl( pProperty );
4155 SvxShapeRect::SvxShapeRect( SdrObject* pObj ) throw()
4156 : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_SHAPE), getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
4160 SvxShapeRect::~SvxShapeRect() throw()
4164 uno::Any SAL_CALL SvxShapeRect::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
4166 return SvxShapeText::queryInterface( rType );
4169 uno::Any SAL_CALL SvxShapeRect::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
4171 return SvxShapeText::queryAggregation( rType );
4174 void SAL_CALL SvxShapeRect::acquire() throw()
4176 OWeakAggObject::acquire();
4179 void SAL_CALL SvxShapeRect::release() throw()
4181 OWeakAggObject::release();
4184 // XServiceInfo
4186 uno::Sequence< OUString > SvxShapeRect::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
4188 return SvxShape::getSupportedServiceNames();
4191 /** returns a StarOffice API wrapper for the given SdrObject */
4192 uno::Reference< drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) throw ()
4194 uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
4195 return xShape;
4198 /** returns the SdrObject from the given StarOffice API wrapper */
4199 SdrObject* GetSdrObjectFromXShape( uno::Reference< drawing::XShape > xShape ) throw()
4201 SvxShape* pShape = SvxShape::getImplementation( xShape );
4202 return pShape ? pShape->GetSdrObject() : 0;
4207 SdrObject* SdrObject::getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt )
4209 SvxShape* pSvxShape = SvxShape::getImplementation( xInt );
4210 return pSvxShape ? pSvxShape->GetSdrObject() : 0;
4213 uno::Any SvxItemPropertySet_getPropertyValue( const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet )
4215 if(!pMap || !pMap->nWID)
4216 return uno::Any();
4218 // Check is for items that store either metric values if thei are positiv or percentage if thei are negativ.
4219 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
4220 return SvxItemPropertySet::getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES), bDontConvertNegativeValues );
4223 void SvxItemPropertySet_setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet )
4225 if(!pMap || !pMap->nWID)
4226 return;
4228 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
4229 SvxItemPropertySet::setPropertyValue( pMap, rVal, rSet, bDontConvertNegativeValues );
4232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */