1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/supportsservice.hxx>
21 #include <com/sun/star/awt/XBitmap.hpp>
22 #include <com/sun/star/awt/Rectangle.hpp>
23 #include <com/sun/star/drawing/CircleKind.hpp>
24 #include <com/sun/star/lang/NoSupportException.hpp>
25 #include <vcl/svapp.hxx>
26 #include <svl/itemprop.hxx>
27 #include <o3tl/any.hxx>
28 #include <osl/mutex.hxx>
29 #include <editeng/unotext.hxx>
30 #include <svx/svdobj.hxx>
31 #include <svx/svdoole2.hxx>
32 #include <svx/shapepropertynotifier.hxx>
33 #include <comphelper/scopeguard.hxx>
34 #include <comphelper/servicehelper.hxx>
35 #include <toolkit/helper/vclunohelper.hxx>
36 #include <vcl/gfxlink.hxx>
37 #include <vcl/virdev.hxx>
38 #include <svx/sdangitm.hxx>
39 #include <svx/svdlayer.hxx>
40 #include <svx/svdopage.hxx>
41 #include <svx/xflbstit.hxx>
42 #include <svx/xflbmtit.hxx>
43 #include <svx/xlnstit.hxx>
44 #include <svx/xlnedit.hxx>
45 #include <svx/svdmodel.hxx>
46 #include <svx/svdobjkind.hxx>
47 #include <svx/unopage.hxx>
48 #include <svx/unoshape.hxx>
49 #include <svx/unoshtxt.hxx>
50 #include <svx/svdpage.hxx>
51 #include <svx/unoshprp.hxx>
52 #include <svx/svdograf.hxx>
53 #include <svx/unoapi.hxx>
54 #include <svx/svdomeas.hxx>
55 #include <svx/svdpool.hxx>
56 #include <tools/stream.hxx>
57 #include <tools/gen.hxx>
58 #include <svx/svdoedge.hxx>
59 #include <svx/svdocapt.hxx>
60 #include <svx/obj3d.hxx>
61 #include <svx/xflftrit.hxx>
62 #include <svx/xtable.hxx>
63 #include <svx/xbtmpit.hxx>
64 #include <svx/xfillit0.hxx>
65 #include <svx/xflgrit.hxx>
66 #include <svx/xflhtit.hxx>
67 #include <svx/xlineit0.hxx>
68 #include <svx/xlndsit.hxx>
69 #include <svx/unomaster.hxx>
70 #include <basegfx/matrix/b2dhommatrix.hxx>
71 #include <basegfx/matrix/b2dhommatrixtools.hxx>
72 #include <basegfx/polygon/b2dpolypolygontools.hxx>
73 #include "gluepts.hxx"
74 #include "shapeimpl.hxx"
75 #include <sal/log.hxx>
77 #include <svx/lathe3d.hxx>
78 #include <extrud3d.hxx>
79 #include <svx/sdr/contact/viewcontact.hxx>
80 #include <drawinglayer/geometry/viewinformation2d.hxx>
81 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
83 #include <vcl/gdimtf.hxx>
84 #include <vcl/wmf.hxx>
85 #include <svx/sdtfsitm.hxx>
86 #include <svx/svdoutl.hxx>
92 #include <bitmaps.hlst>
94 using namespace ::osl
;
95 using namespace ::cppu
;
96 using namespace ::com::sun::star
;
97 using namespace ::com::sun::star::uno
;
98 using namespace ::com::sun::star::lang
;
99 using namespace ::com::sun::star::container
;
100 using svx::PropertyValueProvider
;
106 SvxShape
& mrAntiImpl
;
107 std::unique_ptr
<SfxItemSet
> mpItemSet
;
109 SvxShapeMaster
* mpMaster
;
110 bool mbHasSdrObjectOwnership
;
113 /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when
114 * a SvxShape::Create() call is executed. It is then set to the created
115 * SdrObject so a multiple call to SvxShape::Create() with same SdrObject
118 ::tools::WeakReference
< SdrObject
> mpCreatedObj
;
121 ::comphelper::OInterfaceContainerHelper2 maDisposeListeners
;
122 svx::PropertyChangeNotifier maPropertyNotifier
;
124 SvxShapeImpl( SvxShape
& _rAntiImpl
, ::osl::Mutex
& _rMutex
)
125 :mrAntiImpl( _rAntiImpl
)
128 ,mbHasSdrObjectOwnership( false )
129 ,mbDisposing( false )
131 ,maDisposeListeners( _rMutex
)
132 ,maPropertyNotifier( _rAntiImpl
, _rMutex
)
139 class ShapePositionProvider
: public PropertyValueProvider
142 explicit ShapePositionProvider( const SvxShapeImpl
& _shapeImpl
)
143 :PropertyValueProvider( _shapeImpl
.mrAntiImpl
, "Position" )
148 virtual void getCurrentValue( Any
& _out_rCurrentValue
) const override
150 _out_rCurrentValue
<<= static_cast< SvxShape
& >( getContext() ).getPosition();
155 class ShapeSizeProvider
: public PropertyValueProvider
158 explicit ShapeSizeProvider( const SvxShapeImpl
& _shapeImpl
)
159 :PropertyValueProvider( _shapeImpl
.mrAntiImpl
, "Size" )
164 virtual void getCurrentValue( Any
& _out_rCurrentValue
) const override
166 _out_rCurrentValue
<<= static_cast< SvxShape
& >( getContext() ).getSize();
170 /// Calculates what scaling factor will be used for autofit text scaling of this shape.
171 sal_Int16
GetTextFitToSizeScale(SdrObject
* pObject
)
173 SdrTextObj
* pTextObj
= dynamic_cast<SdrTextObj
*>(pObject
);
179 const SfxItemSet
& rTextObjSet
= pTextObj
->GetMergedItemSet();
180 if (rTextObjSet
.GetItem
<SdrTextFitToSizeTypeItem
>(SDRATTR_TEXT_FITTOSIZE
)->GetValue()
181 != drawing::TextFitToSizeType_AUTOFIT
)
186 std::unique_ptr
<SdrOutliner
> pOutliner
187 = pTextObj
->getSdrModelFromSdrObject().createOutliner(OutlinerMode::TextObject
);
188 tools::Rectangle
aBoundRect(pTextObj
->GetCurrentBoundRect());
189 pTextObj
->SetupOutlinerFormatting(*pOutliner
, aBoundRect
);
192 pOutliner
->GetGlobalCharStretching(nX
, nY
);
197 SvxShape::SvxShape( SdrObject
* pObject
)
199 , mpImpl( new SvxShapeImpl( *this, maMutex
) )
200 , mbIsMultiPropertyCall(false)
201 , mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE
, SdrObject::GetGlobalDrawObjectItemPool()))
202 , maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE
))
203 , mpSdrObjectWeakReference(pObject
)
210 SvxShape::SvxShape( SdrObject
* pObject
, const SfxItemPropertyMapEntry
* pEntries
, const SvxItemPropertySet
* pPropertySet
)
212 , mpImpl( new SvxShapeImpl( *this, maMutex
) )
213 , mbIsMultiPropertyCall(false)
214 , mpPropSet(pPropertySet
)
215 , maPropMapEntries(pEntries
)
216 , mpSdrObjectWeakReference(pObject
)
223 SvxShape::~SvxShape() throw()
225 ::SolarMutexGuard aGuard
;
227 DBG_ASSERT( mnLockCount
== 0, "Locked shape was disposed!" );
229 if ( mpImpl
->mpMaster
)
230 mpImpl
->mpMaster
->dispose();
232 if ( HasSdrObject() )
234 EndListening(GetSdrObject()->getSdrModelFromSdrObject());
235 GetSdrObject()->setUnoShape(nullptr);
238 if( HasSdrObjectOwnership() && HasSdrObject() )
240 mpImpl
->mbHasSdrObjectOwnership
= false;
241 SdrObject
* pObject
= GetSdrObject();
242 SdrObject::Free( pObject
);
245 EndListeningAll(); // call explicitly within SolarMutexGuard
249 void SvxShape::TakeSdrObjectOwnership()
251 mpImpl
->mbHasSdrObjectOwnership
= true;
255 void SvxShape::InvalidateSdrObject()
259 EndListening(GetSdrObject()->getSdrModelFromSdrObject());
262 if (HasSdrObjectOwnership())
265 mpSdrObjectWeakReference
.reset(nullptr);
268 bool SvxShape::HasSdrObjectOwnership() const
270 if ( !mpImpl
->mbHasSdrObjectOwnership
)
273 OSL_ENSURE( HasSdrObject(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
274 return HasSdrObject();
278 void SvxShape::setShapeKind( sal_uInt32 nKind
)
280 mpImpl
->mnObjId
= nKind
;
284 sal_uInt32
SvxShape::getShapeKind() const
286 return mpImpl
->mnObjId
;
290 void SvxShape::setMaster( SvxShapeMaster
* pMaster
)
292 mpImpl
->mpMaster
= pMaster
;
296 uno::Any SAL_CALL
SvxShape::queryAggregation( const uno::Type
& rType
)
298 if( mpImpl
->mpMaster
)
301 if( mpImpl
->mpMaster
->queryAggregation( rType
, aAny
) )
305 return SvxShape_UnoImplHelper::queryAggregation(rType
);
310 class theSvxShapeUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSvxShapeUnoTunnelId
> {};
313 const css::uno::Sequence
< sal_Int8
> & SvxShape::getUnoTunnelId() throw()
315 return theSvxShapeUnoTunnelId::get().getSeq();
318 sal_Int64 SAL_CALL
SvxShape::getSomething( const css::uno::Sequence
< sal_Int8
>& rId
)
320 if( isUnoTunnelId
<SvxShape
>(rId
) )
322 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_uIntPtr
>(this));
331 svx::PropertyChangeNotifier
& SvxShape::getShapePropertyChangeNotifier()
333 return mpImpl
->maPropertyNotifier
;
337 void SvxShape::impl_construct()
339 mpImpl
->maPropertyNotifier
.registerProvider( svx::ShapeProperty::Position
,
340 std::make_shared
<ShapePositionProvider
>( *mpImpl
) );
341 mpImpl
->maPropertyNotifier
.registerProvider( svx::ShapeProperty::Size
,
342 std::make_shared
<ShapeSizeProvider
>( *mpImpl
) );
344 if ( HasSdrObject() )
346 StartListening(GetSdrObject()->getSdrModelFromSdrObject());
347 impl_initFromSdrObject();
352 void SvxShape::impl_initFromSdrObject()
354 DBG_TESTSOLARMUTEX();
355 OSL_PRECOND( HasSdrObject(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
356 if ( !HasSdrObject() )
359 osl_atomic_increment( &m_refCount
);
361 GetSdrObject()->setUnoShape(*this);
363 osl_atomic_decrement( &m_refCount
);
366 // Do not simply return when no model but do the type corrections
368 const SdrInventor nInventor
= GetSdrObject()->GetObjInventor();
370 // is it one of ours (svx) ?
371 if( !(nInventor
== SdrInventor::Default
|| nInventor
== SdrInventor::E3d
|| nInventor
== SdrInventor::FmForm
) )
374 if(nInventor
== SdrInventor::FmForm
)
376 mpImpl
->mnObjId
= OBJ_UNO
;
380 mpImpl
->mnObjId
= GetSdrObject()->GetObjIdentifier();
381 if( nInventor
== SdrInventor::E3d
)
382 mpImpl
->mnObjId
|= E3D_INVENTOR_FLAG
;
385 switch(mpImpl
->mnObjId
)
387 case OBJ_CCUT
: // segment of circle
388 case OBJ_CARC
: // arc of circle
389 case OBJ_SECT
: // sector
390 mpImpl
->mnObjId
= OBJ_CIRC
;
396 void SvxShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* /*pNewPage*/ )
398 DBG_TESTSOLARMUTEX();
400 OSL_PRECOND( pNewObj
, "SvxShape::Create: invalid new object!" );
404 SdrObject
* pCreatedObj
= mpImpl
->mpCreatedObj
.get();
405 OSL_ENSURE( ( pCreatedObj
== nullptr ) || ( pCreatedObj
== pNewObj
),
406 "SvxShape::Create: the same shape used for two different objects?! Strange ..." );
408 // Correct condition (#i52126#)
409 if ( pCreatedObj
== pNewObj
)
412 // Correct condition (#i52126#)
413 mpImpl
->mpCreatedObj
= pNewObj
;
417 EndListening( GetSdrObject()->getSdrModelFromSdrObject() );
420 mpSdrObjectWeakReference
.reset( pNewObj
);
424 StartListening( GetSdrObject()->getSdrModelFromSdrObject() );
427 OSL_ENSURE( !mbIsMultiPropertyCall
, "SvxShape::Create: hmm?" );
428 // this was previously set in impl_initFromSdrObject, but I think it was superfluous
429 // (it definitely was in the other context where it was called, but I strongly suppose
430 // it was also superfluous when called from here)
431 impl_initFromSdrObject();
433 ObtainSettingsFromPropertySet( *mpPropSet
);
436 SdrObjUserCall
* pUser
= GetSdrObject()->GetUserCall();
437 GetSdrObject()->SetUserCall(nullptr);
439 setPosition( maPosition
);
442 // restore user call after we set the initial size
443 GetSdrObject()->SetUserCall( pUser
);
445 // if this shape was already named, use this name
446 if( !maShapeName
.isEmpty() )
448 GetSdrObject()->SetName( maShapeName
);
453 void SvxShape::ForceMetricToItemPoolMetric(Pair
& rPoint
) const throw()
455 DBG_TESTSOLARMUTEX();
459 MapUnit
eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
460 if(eMapUnit
== MapUnit::Map100thMM
)
465 case MapUnit::MapTwip
:
467 rPoint
.A() = MM_TO_TWIPS(rPoint
.A());
468 rPoint
.B() = MM_TO_TWIPS(rPoint
.B());
473 OSL_FAIL("AW: Missing unit translation to PoolMetric!");
478 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon
& rPolyPolygon
) const throw()
480 DBG_TESTSOLARMUTEX();
484 MapUnit
eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
485 if(eMapUnit
== MapUnit::Map100thMM
)
490 case MapUnit::MapTwip
:
492 basegfx::B2DHomMatrix aTransform
;
493 const double fMMToTWIPS(72.0 / 127.0);
495 aTransform
.scale(fMMToTWIPS
, fMMToTWIPS
);
496 rPolyPolygon
.transform(aTransform
);
501 OSL_FAIL("Missing unit translation to PoolMetric!");
506 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DHomMatrix
& rB2DHomMatrix
) const throw()
508 DBG_TESTSOLARMUTEX();
512 MapUnit
eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
513 if(eMapUnit
== MapUnit::Map100thMM
)
518 case MapUnit::MapTwip
:
520 const double fMMToTWIPS(72.0 / 127.0);
521 const basegfx::utils::B2DHomMatrixBufferedDecompose
aDecomposedTransform(rB2DHomMatrix
);
522 rB2DHomMatrix
= basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
523 aDecomposedTransform
.getScale() * fMMToTWIPS
,
524 aDecomposedTransform
.getShearX(),
525 aDecomposedTransform
.getRotate(),
526 aDecomposedTransform
.getTranslate() * fMMToTWIPS
);
531 OSL_FAIL("Missing unit translation to PoolMetric!");
536 void SvxShape::ForceMetricTo100th_mm(Pair
& rPoint
) const throw()
538 DBG_TESTSOLARMUTEX();
539 MapUnit eMapUnit
= MapUnit::Map100thMM
;
543 eMapUnit
= GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
544 if(eMapUnit
== MapUnit::Map100thMM
)
549 case MapUnit::MapTwip
:
551 rPoint
.A() = TWIPS_TO_MM(rPoint
.A());
552 rPoint
.B() = TWIPS_TO_MM(rPoint
.B());
557 OSL_FAIL("AW: Missing unit translation to 100th mm!");
562 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon
& rPolyPolygon
) const throw()
564 DBG_TESTSOLARMUTEX();
565 MapUnit eMapUnit
= MapUnit::Map100thMM
;
569 eMapUnit
= GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
570 if(eMapUnit
== MapUnit::Map100thMM
)
575 case MapUnit::MapTwip
:
577 basegfx::B2DHomMatrix aTransform
;
578 const double fTWIPSToMM(127.0 / 72.0);
579 aTransform
.scale(fTWIPSToMM
, fTWIPSToMM
);
580 rPolyPolygon
.transform(aTransform
);
585 OSL_FAIL("Missing unit translation to 100th mm!");
590 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DHomMatrix
& rB2DHomMatrix
) const throw()
592 DBG_TESTSOLARMUTEX();
593 MapUnit eMapUnit
= MapUnit::Map100thMM
;
597 eMapUnit
= GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
598 if(eMapUnit
== MapUnit::Map100thMM
)
603 case MapUnit::MapTwip
:
605 const double fTWIPSToMM(127.0 / 72.0);
606 const basegfx::utils::B2DHomMatrixBufferedDecompose
aDecomposedTransform(rB2DHomMatrix
);
607 rB2DHomMatrix
= basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
608 aDecomposedTransform
.getScale() * fTWIPSToMM
,
609 aDecomposedTransform
.getShearX(),
610 aDecomposedTransform
.getRotate(),
611 aDecomposedTransform
.getTranslate() * fTWIPSToMM
);
616 OSL_FAIL("Missing unit translation to 100th mm!");
621 static void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet
& rPropSet
,
622 SfxItemSet
& rSet
, const uno::Reference
< beans::XPropertySet
>& xSet
, const SfxItemPropertyMap
* pMap
)
624 if(!rPropSet
.AreThereOwnUsrAnys())
627 const SfxItemPropertyMap
& rSrc
= rPropSet
.getPropertyMap();
628 PropertyEntryVector_t aSrcPropVector
= rSrc
.getPropertyEntries();
630 for(const auto& rSrcProp
: aSrcPropVector
)
632 const sal_uInt16 nWID
= rSrcProp
.nWID
;
633 if(SfxItemPool::IsWhich(nWID
)
634 && (nWID
< OWN_ATTR_VALUE_START
|| nWID
> OWN_ATTR_VALUE_END
)
635 && rPropSet
.GetUsrAnyForID(rSrcProp
))
636 rSet
.Put(rSet
.GetPool()->GetDefaultItem(nWID
));
639 for(const auto& rSrcProp
: aSrcPropVector
)
643 uno::Any
* pUsrAny
= rPropSet
.GetUsrAnyForID(rSrcProp
);
646 // search for equivalent entry in pDst
647 const SfxItemPropertySimpleEntry
* pEntry
= pMap
->getByName( rSrcProp
.sName
);
651 if(pEntry
->nWID
>= OWN_ATTR_VALUE_START
&& pEntry
->nWID
<= OWN_ATTR_VALUE_END
)
653 // special ID in PropertySet, can only be set
654 // directly at the object
655 xSet
->setPropertyValue( rSrcProp
.sName
, *pUsrAny
);
659 SvxItemPropertySet_setPropertyValue(pEntry
, *pUsrAny
, rSet
);
665 const_cast< SvxItemPropertySet
& >(rPropSet
).ClearAllUsrAny();
669 void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet
& rPropSet
)
671 DBG_TESTSOLARMUTEX();
672 if(HasSdrObject() && rPropSet
.AreThereOwnUsrAnys())
674 SfxItemSet
aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), svl::Items
<SDRATTR_START
, SDRATTR_END
>{});
675 Reference
< beans::XPropertySet
> xShape( static_cast<OWeakObject
*>(this), UNO_QUERY
);
676 SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet
, aSet
, xShape
, &mpPropSet
->getPropertyMap() );
678 GetSdrObject()->SetMergedItemSetAndBroadcast(aSet
);
680 GetSdrObject()->ApplyNotPersistAttr( aSet
);
684 uno::Any
SvxShape::GetBitmap( bool bMetaFile
/* = false */ ) const
686 DBG_TESTSOLARMUTEX();
689 if(!HasSdrObject() || nullptr == GetSdrObject()->getSdrPageFromSdrObject())
694 // tdf#118662 Emulate old behaviour of XclObjComment (see there)
695 const SdrCaptionObj
* pSdrCaptionObj(dynamic_cast<SdrCaptionObj
*>(GetSdrObject()));
696 if(nullptr != pSdrCaptionObj
&& pSdrCaptionObj
->isSuppressGetBitmap())
701 // tdf#119180 If we do not ask for Metafile and we access a SdrGrafObj,
702 // and content exists and is a Bitmap, take the shortcut.
703 // Do *not* do this for Metafile - as can be seen, requested in that case
704 // is a byte-sequence of a saved WMF format file (see below)
707 const SdrGrafObj
* pSdrGrafObj(dynamic_cast<SdrGrafObj
*>(GetSdrObject()));
709 if(nullptr != pSdrGrafObj
)
711 const Graphic
& rGraphic(pSdrGrafObj
->GetGraphic());
713 if(GraphicType::Bitmap
== rGraphic
.GetType())
715 Reference
< awt::XBitmap
> xBmp( rGraphic
.GetXGraphic(), UNO_QUERY
);
723 // tdf#118662 instead of creating an E3dView instance every time to paint
724 // a single SdrObject, use the existing SdrObject::SingleObjectPainter to
725 // use less resources and runtime
728 ScopedVclPtrInstance
< VirtualDevice
> pVDev
;
729 const tools::Rectangle
aBoundRect(GetSdrObject()->GetCurrentBoundRect());
732 pVDev
->SetMapMode(MapMode(MapUnit::Map100thMM
));
733 pVDev
->EnableOutput(false);
735 GetSdrObject()->SingleObjectPainter(*pVDev
);
738 aMtf
.Move(-aBoundRect
.Left(), -aBoundRect
.Top());
739 aMtf
.SetPrefMapMode(MapMode(MapUnit::Map100thMM
));
740 aMtf
.SetPrefSize(aBoundRect
.GetSize());
742 SvMemoryStream
aDestStrm(65535, 65535);
744 ConvertGDIMetaFileToWMF(
750 const uno::Sequence
<sal_Int8
> aSeq(
751 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
752 aDestStrm
.GetEndOfData());
758 drawinglayer::primitive2d::Primitive2DContainer
xPrimitives(
759 GetSdrObject()->GetViewContact().getViewIndependentPrimitive2DContainer());
761 if(!xPrimitives
.empty())
763 const drawinglayer::geometry::ViewInformation2D aViewInformation2D
;
764 basegfx::B2DRange
aRange(
765 xPrimitives
.getB2DRange(aViewInformation2D
));
767 if(!aRange
.isEmpty())
769 const MapUnit
aSourceMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetScaleUnit());
771 if(MapUnit::Map100thMM
!= aSourceMapUnit
)
773 // tdf#119180 This is UNO API and thus works in 100th_mm,
774 // so if the MapMode from the used SdrModel is *not* equal
775 // to Map100thMM we need to embed the primitives to an adapting
776 // homogen transformation for correct values
777 const basegfx::B2DHomMatrix
aMapTransform(
778 OutputDevice::LogicToLogic(
779 MapMode(aSourceMapUnit
),
780 MapMode(MapUnit::Map100thMM
)));
782 // Embed primitives to get them in 100th mm
783 const drawinglayer::primitive2d::Primitive2DReference
xEmbedRef(
784 new drawinglayer::primitive2d::TransformPrimitive2D(
788 xPrimitives
= drawinglayer::primitive2d::Primitive2DContainer
{ xEmbedRef
};
790 // Update basegfx::B2DRange aRange, too. Here we have the
791 // choice of transforming the existing value or get newly by
792 // again using 'xPrimitives.getB2DRange(aViewInformation2D)'
793 aRange
.transform(aMapTransform
);
797 convertPrimitive2DSequenceToBitmapEx(
801 Graphic
aGraph(aBmp
);
803 aGraph
.SetPrefSize(aBmp
.GetPrefSize());
804 aGraph
.SetPrefMapMode(aBmp
.GetPrefMapMode());
806 Reference
< awt::XBitmap
> xBmp( aGraph
.GetXGraphic(), UNO_QUERY
);
815 uno::Sequence
< uno::Type
> SAL_CALL
SvxShape::getTypes()
817 if( mpImpl
->mpMaster
)
819 return mpImpl
->mpMaster
->getTypes();
828 uno::Sequence
< uno::Type
> const & SvxShape::_getTypes()
830 switch( mpImpl
->mnObjId
)
832 // shapes without text
835 case OBJ_OLE2_PLUGIN
:
836 case OBJ_OLE2_APPLET
:
837 case E3D_CUBEOBJ_ID
|E3D_INVENTOR_FLAG
:
838 case E3D_SPHEREOBJ_ID
|E3D_INVENTOR_FLAG
:
839 case E3D_LATHEOBJ_ID
|E3D_INVENTOR_FLAG
:
840 case E3D_EXTRUDEOBJ_ID
|E3D_INVENTOR_FLAG
:
841 case E3D_POLYGONOBJ_ID
|E3D_INVENTOR_FLAG
:
845 static uno::Sequence
<uno::Type
> aTypeSequence
{
846 cppu::UnoType
<drawing::XShape
>::get(),
847 cppu::UnoType
<lang::XComponent
>::get(),
848 cppu::UnoType
<beans::XPropertySet
>::get(),
849 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
850 cppu::UnoType
<beans::XPropertyState
>::get(),
851 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
852 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
853 cppu::UnoType
<container::XChild
>::get(),
854 cppu::UnoType
<lang::XServiceInfo
>::get(),
855 cppu::UnoType
<lang::XTypeProvider
>::get(),
856 cppu::UnoType
<lang::XUnoTunnel
>::get(),
857 cppu::UnoType
<container::XNamed
>::get(),
860 return aTypeSequence
;
865 static uno::Sequence
<uno::Type
> aTypeSequence
{
866 cppu::UnoType
<drawing::XShape
>::get(),
867 cppu::UnoType
<lang::XComponent
>::get(),
868 cppu::UnoType
<beans::XPropertySet
>::get(),
869 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
870 cppu::UnoType
<beans::XPropertyState
>::get(),
871 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
872 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
873 cppu::UnoType
<container::XChild
>::get(),
874 cppu::UnoType
<lang::XServiceInfo
>::get(),
875 cppu::UnoType
<lang::XTypeProvider
>::get(),
876 cppu::UnoType
<lang::XUnoTunnel
>::get(),
877 cppu::UnoType
<container::XNamed
>::get(),
878 cppu::UnoType
<drawing::XShapes
>::get(),
879 cppu::UnoType
<drawing::XShapeGroup
>::get(),
882 return aTypeSequence
;
887 static uno::Sequence
<uno::Type
> aTypeSequence
{
888 cppu::UnoType
<drawing::XShape
>::get(),
889 cppu::UnoType
<lang::XComponent
>::get(),
890 cppu::UnoType
<beans::XPropertySet
>::get(),
891 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
892 cppu::UnoType
<beans::XPropertyState
>::get(),
893 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
894 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
895 cppu::UnoType
<container::XChild
>::get(),
896 cppu::UnoType
<lang::XServiceInfo
>::get(),
897 cppu::UnoType
<lang::XTypeProvider
>::get(),
898 cppu::UnoType
<lang::XUnoTunnel
>::get(),
899 cppu::UnoType
<container::XNamed
>::get(),
900 cppu::UnoType
<drawing::XConnectorShape
>::get(),
901 // from SvxUnoTextBase::getTypes()
902 cppu::UnoType
<text::XTextAppend
>::get(),
903 cppu::UnoType
<text::XTextCopy
>::get(),
904 cppu::UnoType
<container::XEnumerationAccess
>::get(),
905 cppu::UnoType
<text::XTextRangeMover
>::get(),
908 return aTypeSequence
;
913 static uno::Sequence
<uno::Type
> aTypeSequence
{
914 cppu::UnoType
<drawing::XShape
>::get(),
915 cppu::UnoType
<lang::XComponent
>::get(),
916 cppu::UnoType
<beans::XPropertySet
>::get(),
917 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
918 cppu::UnoType
<beans::XPropertyState
>::get(),
919 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
920 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
921 cppu::UnoType
<container::XChild
>::get(),
922 cppu::UnoType
<lang::XServiceInfo
>::get(),
923 cppu::UnoType
<lang::XTypeProvider
>::get(),
924 cppu::UnoType
<lang::XUnoTunnel
>::get(),
925 cppu::UnoType
<container::XNamed
>::get(),
926 cppu::UnoType
<drawing::XControlShape
>::get(),
929 return aTypeSequence
;
932 case E3D_SCENE_ID
|E3D_INVENTOR_FLAG
:
934 static uno::Sequence
<uno::Type
> aTypeSequence
{
935 cppu::UnoType
<drawing::XShape
>::get(),
936 cppu::UnoType
<lang::XComponent
>::get(),
937 cppu::UnoType
<beans::XPropertySet
>::get(),
938 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
939 cppu::UnoType
<beans::XPropertyState
>::get(),
940 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
941 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
942 cppu::UnoType
<container::XChild
>::get(),
943 cppu::UnoType
<lang::XServiceInfo
>::get(),
944 cppu::UnoType
<lang::XTypeProvider
>::get(),
945 cppu::UnoType
<lang::XUnoTunnel
>::get(),
946 cppu::UnoType
<container::XNamed
>::get(),
947 cppu::UnoType
<drawing::XShapes
>::get(),
950 return aTypeSequence
;
952 case OBJ_CUSTOMSHAPE
:
954 static uno::Sequence
<uno::Type
> aTypeSequence
{
955 cppu::UnoType
<drawing::XShape
>::get(),
956 cppu::UnoType
<lang::XComponent
>::get(),
957 cppu::UnoType
<beans::XPropertySet
>::get(),
958 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
959 cppu::UnoType
<beans::XPropertyState
>::get(),
960 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
961 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
962 cppu::UnoType
<container::XChild
>::get(),
963 cppu::UnoType
<lang::XServiceInfo
>::get(),
964 cppu::UnoType
<lang::XTypeProvider
>::get(),
965 cppu::UnoType
<lang::XUnoTunnel
>::get(),
966 cppu::UnoType
<container::XNamed
>::get(),
967 // from SvxUnoTextBase::getTypes()
968 cppu::UnoType
<text::XText
>::get(),
969 cppu::UnoType
<container::XEnumerationAccess
>::get(),
970 cppu::UnoType
<text::XTextRangeMover
>::get(),
971 cppu::UnoType
<drawing::XEnhancedCustomShapeDefaulter
>::get(),
974 return aTypeSequence
;
992 case OBJ_OLE2
: // #i118485# Moved to shapes with text
995 static uno::Sequence
<uno::Type
> aTypeSequence
{
996 cppu::UnoType
<drawing::XShape
>::get(),
997 cppu::UnoType
<lang::XComponent
>::get(),
998 cppu::UnoType
<beans::XPropertySet
>::get(),
999 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
1000 cppu::UnoType
<beans::XPropertyState
>::get(),
1001 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
1002 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
1003 cppu::UnoType
<container::XChild
>::get(),
1004 cppu::UnoType
<lang::XServiceInfo
>::get(),
1005 cppu::UnoType
<lang::XTypeProvider
>::get(),
1006 cppu::UnoType
<lang::XUnoTunnel
>::get(),
1007 cppu::UnoType
<container::XNamed
>::get(),
1008 // from SvxUnoTextBase::getTypes()
1009 cppu::UnoType
<text::XTextAppend
>::get(),
1010 cppu::UnoType
<text::XTextCopy
>::get(),
1011 cppu::UnoType
<container::XEnumerationAccess
>::get(),
1012 cppu::UnoType
<text::XTextRangeMover
>::get(),
1015 return aTypeSequence
;
1021 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShape::getImplementationId()
1023 return css::uno::Sequence
<sal_Int8
>();
1026 void SvxShape::Notify( SfxBroadcaster
&, const SfxHint
& rHint
) throw()
1028 DBG_TESTSOLARMUTEX();
1029 if( !HasSdrObject() )
1032 // #i55919# SdrHintKind::ObjectChange is only interesting if it's for this object
1033 if (rHint
.GetId() != SfxHintId::ThisIsAnSdrHint
)
1035 SdrObject
* pSdrObject(GetSdrObject());
1036 const SdrHint
* pSdrHint
= static_cast<const SdrHint
*>(&rHint
);
1037 if ((pSdrHint
->GetKind() != SdrHintKind::ModelCleared
) &&
1038 (pSdrHint
->GetKind() != SdrHintKind::ObjectChange
|| pSdrHint
->GetObject() != pSdrObject
))
1041 uno::Reference
< uno::XInterface
> xSelf( pSdrObject
->getWeakUnoShape() );
1044 EndListening(pSdrObject
->getSdrModelFromSdrObject());
1045 mpSdrObjectWeakReference
.reset(nullptr);
1049 bool bClearMe
= false;
1051 switch( pSdrHint
->GetKind() )
1053 case SdrHintKind::ObjectChange
:
1058 case SdrHintKind::ModelCleared
:
1070 if(!HasSdrObjectOwnership())
1072 if(nullptr != pSdrObject
)
1074 EndListening(pSdrObject
->getSdrModelFromSdrObject());
1075 pSdrObject
->setUnoShape(nullptr);
1078 mpSdrObjectWeakReference
.reset(nullptr);
1080 // SdrModel *is* going down, try to Free SdrObject even
1081 // when !HasSdrObjectOwnership
1082 if(nullptr != pSdrObject
&& !pSdrObject
->IsInserted())
1084 SdrObject::Free(pSdrObject
);
1088 if(!mpImpl
->mbDisposing
)
1097 // The "*LogicRectHack" functions also existed in sch, and those
1098 // duplicate symbols cause Bad Things To Happen (TM) #i9462#.
1099 // Prefixing with 'svx' and marking static to make sure name collisions
1102 static bool svx_needLogicRectHack( SdrObject
const * pObj
)
1104 if( pObj
->GetObjInventor() == SdrInventor::Default
)
1106 switch(pObj
->GetObjIdentifier())
1131 static tools::Rectangle
svx_getLogicRectHack( SdrObject
const * pObj
)
1133 if(svx_needLogicRectHack(pObj
))
1135 return pObj
->GetSnapRect();
1139 return pObj
->GetLogicRect();
1144 static void svx_setLogicRectHack( SdrObject
* pObj
, const tools::Rectangle
& rRect
)
1146 if(svx_needLogicRectHack(pObj
))
1148 pObj
->SetSnapRect( rRect
);
1152 pObj
->SetLogicRect( rRect
);
1157 awt::Point SAL_CALL
SvxShape::getPosition()
1159 ::SolarMutexGuard aGuard
;
1163 tools::Rectangle
aRect( svx_getLogicRectHack(GetSdrObject()) );
1164 Point
aPt( aRect
.Left(), aRect
.Top() );
1166 // Position is relative to anchor, so recalc to absolute position
1167 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1168 aPt
-= GetSdrObject()->GetAnchorPos();
1170 ForceMetricTo100th_mm(aPt
);
1171 return css::awt::Point( aPt
.X(), aPt
.Y() );
1180 void SAL_CALL
SvxShape::setPosition( const awt::Point
& Position
)
1182 ::SolarMutexGuard aGuard
;
1186 // do NOT move 3D objects, this would change the homogen
1187 // transformation matrix
1188 if(dynamic_cast<const E3dCompoundObject
* >(GetSdrObject()) == nullptr)
1190 tools::Rectangle
aRect( svx_getLogicRectHack(GetSdrObject()) );
1191 Point
aLocalPos( Position
.X
, Position
.Y
);
1192 ForceMetricToItemPoolMetric(aLocalPos
);
1194 // Position is absolute, so recalc to position relative to anchor
1195 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1196 aLocalPos
+= GetSdrObject()->GetAnchorPos();
1198 tools::Long nDX
= aLocalPos
.X() - aRect
.Left();
1199 tools::Long nDY
= aLocalPos
.Y() - aRect
.Top();
1201 GetSdrObject()->Move( Size( nDX
, nDY
) );
1202 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1206 maPosition
= Position
;
1210 awt::Size SAL_CALL
SvxShape::getSize()
1212 ::SolarMutexGuard aGuard
;
1216 tools::Rectangle
aRect( svx_getLogicRectHack(GetSdrObject()) );
1217 Size
aObjSize( aRect
.getWidth(), aRect
.getHeight() );
1218 ForceMetricTo100th_mm(aObjSize
);
1219 return css::awt::Size( aObjSize
.getWidth(), aObjSize
.getHeight() );
1226 void SAL_CALL
SvxShape::setSize( const awt::Size
& rSize
)
1228 ::SolarMutexGuard aGuard
;
1232 tools::Rectangle
aRect( svx_getLogicRectHack(GetSdrObject()) );
1233 Size
aLocalSize( rSize
.Width
, rSize
.Height
);
1234 ForceMetricToItemPoolMetric(aLocalSize
);
1236 if(GetSdrObject()->GetObjInventor() == SdrInventor::Default
&& GetSdrObject()->GetObjIdentifier() == OBJ_MEASURE
)
1238 Fraction
aWdt(aLocalSize
.Width(),aRect
.Right()-aRect
.Left());
1239 Fraction
aHgt(aLocalSize
.Height(),aRect
.Bottom()-aRect
.Top());
1240 Point aPt
= GetSdrObject()->GetSnapRect().TopLeft();
1241 GetSdrObject()->Resize(aPt
,aWdt
,aHgt
);
1245 //aRect.SetSize(aLocalSize); // this call subtract 1 // https://bz.apache.org/ooo/show_bug.cgi?id=83193
1246 if ( !aLocalSize
.Width() )
1248 aRect
.SetWidthEmpty();
1251 aRect
.setWidth(aLocalSize
.Width());
1252 if ( !aLocalSize
.Height() )
1254 aRect
.SetHeightEmpty();
1257 aRect
.setHeight(aLocalSize
.Height());
1259 svx_setLogicRectHack( GetSdrObject(), aRect
);
1262 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1269 OUString SAL_CALL
SvxShape::getName( )
1271 ::SolarMutexGuard aGuard
;
1272 if( HasSdrObject() )
1274 return GetSdrObject()->GetName();
1283 void SAL_CALL
SvxShape::setName( const OUString
& aName
)
1285 ::SolarMutexGuard aGuard
;
1286 if( HasSdrObject() )
1288 GetSdrObject()->SetName( aName
);
1292 maShapeName
= aName
;
1299 OUString SAL_CALL
SvxShape::getShapeType()
1301 if( !maShapeType
.getLength() )
1302 return UHashMap::getNameFromId( mpImpl
->mnObjId
);
1310 void SAL_CALL
SvxShape::dispose()
1312 ::SolarMutexGuard aGuard
;
1314 if( mpImpl
->mbDisposing
)
1315 return; // caught a recursion
1317 mpImpl
->mbDisposing
= true;
1319 lang::EventObject aEvt
;
1320 aEvt
.Source
= *static_cast<OWeakAggObject
*>(this);
1321 mpImpl
->maDisposeListeners
.disposeAndClear(aEvt
);
1322 mpImpl
->maPropertyNotifier
.disposing();
1324 if ( !HasSdrObject() )
1327 SdrObject
* pObject
= GetSdrObject();
1329 EndListening( pObject
->getSdrModelFromSdrObject() );
1330 bool bFreeSdrObject
= false;
1332 if ( pObject
->IsInserted() && pObject
->getSdrPageFromSdrObject() )
1334 OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" );
1335 // normally, we are allowed to free the SdrObject only if we have its ownership.
1336 // Why isn't this checked here?
1338 SdrPage
* pPage
= pObject
->getSdrPageFromSdrObject();
1339 // delete the SdrObject from the page
1340 const size_t nCount
= pPage
->GetObjCount();
1341 for ( size_t nNum
= 0; nNum
< nCount
; ++nNum
)
1343 if ( pPage
->GetObj( nNum
) == pObject
)
1345 OSL_VERIFY( pPage
->RemoveObject( nNum
) == pObject
);
1346 bFreeSdrObject
= true;
1352 pObject
->setUnoShape(nullptr);
1354 if ( bFreeSdrObject
)
1356 // in case we have the ownership of the SdrObject, a Free
1357 // would do nothing. So ensure the ownership is reset.
1358 mpImpl
->mbHasSdrObjectOwnership
= false;
1359 SdrObject::Free( pObject
);
1364 void SAL_CALL
SvxShape::addEventListener( const Reference
< lang::XEventListener
>& xListener
)
1366 mpImpl
->maDisposeListeners
.addInterface(xListener
);
1370 void SAL_CALL
SvxShape::removeEventListener( const Reference
< lang::XEventListener
>& aListener
)
1372 mpImpl
->maDisposeListeners
.removeInterface(aListener
);
1378 Reference
< beans::XPropertySetInfo
> SAL_CALL
1379 SvxShape::getPropertySetInfo()
1381 if( mpImpl
->mpMaster
)
1383 return mpImpl
->mpMaster
->getPropertySetInfo();
1387 return _getPropertySetInfo();
1391 Reference
< beans::XPropertySetInfo
> const &
1392 SvxShape::_getPropertySetInfo()
1394 return mpPropSet
->getPropertySetInfo();
1398 void SAL_CALL
SvxShape::addPropertyChangeListener( const OUString
& _propertyName
, const Reference
< beans::XPropertyChangeListener
>& _listener
)
1400 ::osl::MutexGuard
aGuard( maMutex
);
1401 mpImpl
->maPropertyNotifier
.addPropertyChangeListener( _propertyName
, _listener
);
1405 void SAL_CALL
SvxShape::removePropertyChangeListener( const OUString
& _propertyName
, const Reference
< beans::XPropertyChangeListener
>& _listener
)
1407 ::osl::MutexGuard
aGuard( maMutex
);
1408 mpImpl
->maPropertyNotifier
.removePropertyChangeListener( _propertyName
, _listener
);
1412 void SAL_CALL
SvxShape::addVetoableChangeListener( const OUString
& , const Reference
< beans::XVetoableChangeListener
>& )
1414 OSL_FAIL( "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1418 void SAL_CALL
SvxShape::removeVetoableChangeListener( const OUString
& , const Reference
< beans::XVetoableChangeListener
>& )
1420 OSL_FAIL( "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1424 bool SvxShape::SetFillAttribute( sal_uInt16 nWID
, const OUString
& rName
)
1428 SfxItemSet
aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{nWID
, nWID
}} );
1430 if( SetFillAttribute( nWID
, rName
, aSet
, &GetSdrObject()->getSdrModelFromSdrObject() ) )
1432 //GetSdrObject()->SetItemSetAndBroadcast(aSet);
1433 GetSdrObject()->SetMergedItemSetAndBroadcast(aSet
);
1443 bool SvxShape::SetFillAttribute( sal_uInt16 nWID
, const OUString
& rName
, SfxItemSet
& rSet
, SdrModel
const * pModel
)
1445 // check if an item with the given name and which id is inside the models
1446 // pool or the stylesheet pool, if found it's put in the itemset
1447 if( !SetFillAttribute( nWID
, rName
, rSet
) )
1449 // we did not find such item in one of the pools, so we check
1450 // the property lists that are loaded for the model for items
1451 // that support such.
1452 OUString aStrName
= SvxUnogetInternalNameForItem(nWID
, rName
);
1456 case XATTR_FILLBITMAP
:
1458 XBitmapListRef pBitmapList
= pModel
->GetBitmapList();
1460 if( !pBitmapList
.is() )
1463 tools::Long nPos
= pBitmapList
->GetIndex(aStrName
);
1467 const XBitmapEntry
* pEntry
= pBitmapList
->GetBitmap(nPos
);
1468 XFillBitmapItem
aBmpItem(rName
, pEntry
->GetGraphicObject());
1472 case XATTR_FILLGRADIENT
:
1474 XGradientListRef pGradientList
= pModel
->GetGradientList();
1476 if( !pGradientList
.is() )
1479 tools::Long nPos
= pGradientList
->GetIndex(aStrName
);
1483 const XGradientEntry
* pEntry
= pGradientList
->GetGradient(nPos
);
1484 XFillGradientItem
aGrdItem(rName
, pEntry
->GetGradient());
1485 rSet
.Put( aGrdItem
);
1488 case XATTR_FILLHATCH
:
1490 XHatchListRef pHatchList
= pModel
->GetHatchList();
1492 if( !pHatchList
.is() )
1495 tools::Long nPos
= pHatchList
->GetIndex(aStrName
);
1499 const XHatchEntry
* pEntry
= pHatchList
->GetHatch( nPos
);
1500 XFillHatchItem
aHatchItem(rName
, pEntry
->GetHatch());
1501 rSet
.Put( aHatchItem
);
1505 case XATTR_LINESTART
:
1507 XLineEndListRef pLineEndList
= pModel
->GetLineEndList();
1509 if( !pLineEndList
.is() )
1512 tools::Long nPos
= pLineEndList
->GetIndex(aStrName
);
1516 const XLineEndEntry
* pEntry
= pLineEndList
->GetLineEnd(nPos
);
1517 if( sal_uInt16(XATTR_LINEEND
) == nWID
)
1519 XLineEndItem
aLEItem(rName
, pEntry
->GetLineEnd());
1520 rSet
.Put( aLEItem
);
1524 XLineStartItem
aLSItem(rName
, pEntry
->GetLineEnd());
1525 rSet
.Put( aLSItem
);
1530 case XATTR_LINEDASH
:
1532 XDashListRef pDashList
= pModel
->GetDashList();
1534 if( !pDashList
.is() )
1537 tools::Long nPos
= pDashList
->GetIndex(aStrName
);
1541 const XDashEntry
* pEntry
= pDashList
->GetDash(nPos
);
1542 XLineDashItem
aDashItem(rName
, pEntry
->GetDash());
1543 rSet
.Put( aDashItem
);
1555 bool SvxShape::SetFillAttribute( sal_uInt16 nWID
, const OUString
& rName
, SfxItemSet
& rSet
)
1557 OUString aName
= SvxUnogetInternalNameForItem(nWID
, rName
);
1559 if (aName
.isEmpty())
1564 case XATTR_LINESTART
:
1566 const basegfx::B2DPolyPolygon aEmptyPoly
;
1567 if( nWID
== sal_uInt16(XATTR_LINEEND
) )
1568 rSet
.Put( XLineEndItem( "", aEmptyPoly
) );
1570 rSet
.Put( XLineStartItem( "", aEmptyPoly
) );
1574 case XATTR_FILLFLOATTRANSPARENCE
:
1576 // #85953# Set a disabled XFillFloatTransparenceItem
1577 rSet
.Put(XFillFloatTransparenceItem());
1586 for (const SfxPoolItem
* p
: rSet
.GetPool()->GetItemSurrogates(nWID
))
1588 const NameOrIndex
* pItem
= static_cast<const NameOrIndex
*>(p
);
1589 if( pItem
->GetName() == aName
)
1600 void SAL_CALL
SvxShape::setPropertyValue( const OUString
& rPropertyName
, const uno::Any
& rVal
)
1602 if( mpImpl
->mpMaster
)
1604 mpImpl
->mpMaster
->setPropertyValue( rPropertyName
, rVal
);
1608 _setPropertyValue( rPropertyName
, rVal
);
1612 void SvxShape::_setPropertyValue( const OUString
& rPropertyName
, const uno::Any
& rVal
)
1614 ::SolarMutexGuard aGuard
;
1616 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(rPropertyName
);
1618 if (!HasSdrObject())
1620 // Since we have no actual sdr object right now, remember all
1621 // properties in a list. These properties will be set when the sdr
1622 // object is created.
1624 if (pMap
&& pMap
->nWID
)
1626 // FIXME: We should throw a UnknownPropertyException here.
1627 // But since this class is aggregated from classes that
1628 // support additional properties that we don't know here we
1629 // silently store *all* properties, even if they may be not
1630 // supported after creation.
1631 mpPropSet
->setPropertyValue( pMap
, rVal
);
1639 // reduce log noise by ignoring two properties that higher level code queries for on all objects
1640 SAL_WARN_IF(rPropertyName
!= "FromWordArt" && rPropertyName
!= "GraphicColorMode",
1641 "svx.uno", "Unknown Property: " << rPropertyName
);
1642 throw beans::UnknownPropertyException( rPropertyName
, static_cast<cppu::OWeakObject
*>(this));
1645 if ((pMap
->nFlags
& beans::PropertyAttribute::READONLY
) != 0)
1646 throw beans::PropertyVetoException(
1647 "Readonly property can't be set: " + rPropertyName
,
1648 uno::Reference
<drawing::XShape
>(this));
1650 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1652 if (setPropertyValueImpl(rPropertyName
, pMap
, rVal
))
1655 DBG_ASSERT( pMap
->nWID
== SDRATTR_TEXTDIRECTION
|| pMap
->nWID
< SDRATTR_NOTPERSIST_FIRST
|| pMap
->nWID
> SDRATTR_NOTPERSIST_LAST
, "Not persist item not handled!" );
1656 DBG_ASSERT( pMap
->nWID
< OWN_ATTR_VALUE_START
|| pMap
->nWID
> OWN_ATTR_VALUE_END
, "Not item property not handled!" );
1658 bool bIsNotPersist
= pMap
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pMap
->nWID
<= SDRATTR_NOTPERSIST_LAST
&& pMap
->nWID
!= SDRATTR_TEXTDIRECTION
;
1660 if( pMap
->nWID
== SDRATTR_ECKENRADIUS
)
1662 sal_Int32 nCornerRadius
= 0;
1663 if( !(rVal
>>= nCornerRadius
) || (nCornerRadius
< 0) || (nCornerRadius
> 5000000))
1664 throw IllegalArgumentException();
1668 if( mbIsMultiPropertyCall
&& !bIsNotPersist
)
1670 if( mpImpl
->mpItemSet
== nullptr )
1672 mpImpl
->mpItemSet
.reset(new SfxItemSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{pMap
->nWID
, pMap
->nWID
}}));
1676 mpImpl
->mpItemSet
->MergeRange(pMap
->nWID
, pMap
->nWID
);
1678 pSet
= mpImpl
->mpItemSet
.get();
1682 pSet
= new SfxItemSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{pMap
->nWID
, pMap
->nWID
}});
1685 if( pSet
->GetItemState( pMap
->nWID
) != SfxItemState::SET
)
1686 pSet
->Put(GetSdrObject()->GetMergedItem(pMap
->nWID
));
1688 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( pMap
, rVal
, *pSet
))
1690 if( pSet
->GetItemState( pMap
->nWID
) != SfxItemState::SET
)
1694 // not-persistent attribute, get those extra
1695 GetSdrObject()->TakeNotPersistAttr(*pSet
);
1699 if( pSet
->GetItemState( pMap
->nWID
) != SfxItemState::SET
)
1701 // get default from ItemPool
1702 if(SfxItemPool::IsWhich(pMap
->nWID
))
1703 pSet
->Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap
->nWID
));
1706 if( pSet
->GetItemState( pMap
->nWID
) == SfxItemState::SET
)
1708 SvxItemPropertySet_setPropertyValue( pMap
, rVal
, *pSet
);
1714 // set not-persistent attribute extra
1715 GetSdrObject()->ApplyNotPersistAttr( *pSet
);
1720 // if we have a XMultiProperty call then the item set
1721 // will be set in setPropertyValues later
1722 if( !mbIsMultiPropertyCall
)
1724 GetSdrObject()->SetMergedItemSetAndBroadcast( *pSet
);
1732 uno::Any SAL_CALL
SvxShape::getPropertyValue( const OUString
& PropertyName
)
1734 if ( mpImpl
->mpMaster
)
1735 return mpImpl
->mpMaster
->getPropertyValue( PropertyName
);
1737 return _getPropertyValue( PropertyName
);
1741 uno::Any
SvxShape::_getPropertyValue( const OUString
& PropertyName
)
1743 ::SolarMutexGuard aGuard
;
1745 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1750 if(pMap
== nullptr )
1751 throw beans::UnknownPropertyException( PropertyName
, static_cast<cppu::OWeakObject
*>(this));
1753 if( !getPropertyValueImpl( PropertyName
, pMap
, aAny
) )
1755 DBG_ASSERT( pMap
->nWID
== SDRATTR_TEXTDIRECTION
|| (pMap
->nWID
< SDRATTR_NOTPERSIST_FIRST
|| pMap
->nWID
> SDRATTR_NOTPERSIST_LAST
), "Not persist item not handled!" );
1756 DBG_ASSERT( pMap
->nWID
< OWN_ATTR_VALUE_START
|| pMap
->nWID
> OWN_ATTR_VALUE_END
, "Not item property not handled!" );
1758 SfxItemSet
aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{pMap
->nWID
, pMap
->nWID
}});
1759 aSet
.Put(GetSdrObject()->GetMergedItem(pMap
->nWID
));
1761 if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet
, pMap
, aAny
))
1766 if(pMap
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pMap
->nWID
<= SDRATTR_NOTPERSIST_LAST
)
1768 // not-persistent attribute, get those extra
1769 GetSdrObject()->TakeNotPersistAttr(aSet
);
1775 // get default from ItemPool
1776 if(SfxItemPool::IsWhich(pMap
->nWID
))
1777 aSet
.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap
->nWID
));
1781 aAny
= GetAnyForItem( aSet
, pMap
);
1787 // Fixme: we should return default values for OWN_ATTR !
1789 if(pMap
&& pMap
->nWID
)
1790 // FixMe: see setPropertyValue
1791 aAny
= mpPropSet
->getPropertyValue( pMap
);
1798 // XMultiPropertySet
1799 void SAL_CALL
SvxShape::setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& aValues
)
1801 ::SolarMutexGuard aSolarGuard
;
1803 const sal_Int32 nCount
= aPropertyNames
.getLength();
1804 const OUString
* pNames
= aPropertyNames
.getConstArray();
1806 const uno::Any
* pValues
= aValues
.getConstArray();
1808 // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are
1809 // reset even when an exception is thrown
1810 const ::comphelper::ScopeGuard
aGuard( [this] () { return this->endSetPropertyValues(); } );
1812 mbIsMultiPropertyCall
= true;
1814 if( mpImpl
->mpMaster
)
1816 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pNames
++, pValues
++ )
1820 setPropertyValue( *pNames
, *pValues
);
1822 catch( beans::UnknownPropertyException
& ) {}
1823 catch( uno::Exception
& ) {}
1828 uno::Reference
< beans::XPropertySet
> xSet
;
1829 queryInterface( cppu::UnoType
<beans::XPropertySet
>::get()) >>= xSet
;
1831 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pNames
++, pValues
++ )
1835 xSet
->setPropertyValue( *pNames
, *pValues
);
1837 catch( beans::UnknownPropertyException
& ) {}
1838 catch( uno::Exception
& ) {}
1842 if( mpImpl
->mpItemSet
&& HasSdrObject() )
1843 GetSdrObject()->SetMergedItemSetAndBroadcast( *mpImpl
->mpItemSet
);
1847 void SvxShape::endSetPropertyValues()
1849 mbIsMultiPropertyCall
= false;
1850 mpImpl
->mpItemSet
.reset();
1854 css::uno::Sequence
< css::uno::Any
> SAL_CALL
SvxShape::getPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
)
1856 const sal_Int32 nCount
= aPropertyNames
.getLength();
1857 const OUString
* pNames
= aPropertyNames
.getConstArray();
1859 uno::Sequence
< uno::Any
> aRet( nCount
);
1860 uno::Any
* pValue
= aRet
.getArray();
1862 if( mpImpl
->mpMaster
)
1864 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pValue
++, pNames
++ )
1868 *pValue
= getPropertyValue( *pNames
);
1870 catch( uno::Exception
& )
1872 OSL_FAIL( "SvxShape::getPropertyValues, unknown property asked" );
1878 uno::Reference
< beans::XPropertySet
> xSet
;
1879 queryInterface( cppu::UnoType
<beans::XPropertySet
>::get()) >>= xSet
;
1881 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pValue
++, pNames
++ )
1885 *pValue
= xSet
->getPropertyValue( *pNames
);
1887 catch( uno::Exception
& )
1889 OSL_FAIL( "SvxShape::getPropertyValues, unknown property asked" );
1897 void SAL_CALL
SvxShape::addPropertiesChangeListener( const css::uno::Sequence
< OUString
>& , const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& )
1901 void SAL_CALL
SvxShape::removePropertiesChangeListener( const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& )
1905 void SAL_CALL
SvxShape::firePropertiesChangeEvent( const css::uno::Sequence
< OUString
>& , const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& )
1910 uno::Any
SvxShape::GetAnyForItem( SfxItemSet
const & aSet
, const SfxItemPropertySimpleEntry
* pMap
) const
1912 DBG_TESTSOLARMUTEX();
1917 case SDRATTR_CIRCSTARTANGLE
:
1919 const SfxPoolItem
* pPoolItem
=nullptr;
1920 if(aSet
.GetItemState(SDRATTR_CIRCSTARTANGLE
,false,&pPoolItem
)==SfxItemState::SET
)
1922 sal_Int32 nAngle
= static_cast<const SdrAngleItem
*>(pPoolItem
)->GetValue();
1928 case SDRATTR_CIRCENDANGLE
:
1930 const SfxPoolItem
* pPoolItem
=nullptr;
1931 if (aSet
.GetItemState(SDRATTR_CIRCENDANGLE
,false,&pPoolItem
)==SfxItemState::SET
)
1933 sal_Int32 nAngle
= static_cast<const SdrAngleItem
*>(pPoolItem
)->GetValue();
1939 case SDRATTR_CIRCKIND
:
1941 if( GetSdrObject()->GetObjInventor() == SdrInventor::Default
)
1943 drawing::CircleKind eKind
;
1944 switch(GetSdrObject()->GetObjIdentifier())
1946 case OBJ_CIRC
: // circle, ellipse
1947 eKind
= drawing::CircleKind_FULL
;
1949 case OBJ_CCUT
: // segment of circle
1950 eKind
= drawing::CircleKind_CUT
;
1952 case OBJ_CARC
: // arc of circle
1953 eKind
= drawing::CircleKind_ARC
;
1955 case OBJ_SECT
: // sector
1956 eKind
= drawing::CircleKind_SECTION
;
1967 // get value from ItemSet
1968 aAny
= SvxItemPropertySet_getPropertyValue( pMap
, aSet
);
1970 if( pMap
->aType
!= aAny
.getValueType() )
1972 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
1973 if( ( pMap
->aType
== ::cppu::UnoType
<sal_Int16
>::get()) && aAny
.getValueType() == ::cppu::UnoType
<sal_Int32
>::get() )
1975 sal_Int32 nValue
= 0;
1977 aAny
<<= static_cast<sal_Int16
>(nValue
);
1981 OSL_FAIL("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" );
1993 beans::PropertyState SAL_CALL
SvxShape::getPropertyState( const OUString
& PropertyName
)
1995 if( mpImpl
->mpMaster
)
1997 return mpImpl
->mpMaster
->getPropertyState( PropertyName
);
2001 return _getPropertyState( PropertyName
);
2005 beans::PropertyState
SvxShape::_getPropertyState( const OUString
& PropertyName
)
2007 ::SolarMutexGuard aGuard
;
2009 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
2011 if( !HasSdrObject() || pMap
== nullptr )
2012 throw beans::UnknownPropertyException( PropertyName
, static_cast<cppu::OWeakObject
*>(this));
2014 beans::PropertyState eState
;
2015 if( !getPropertyStateImpl( pMap
, eState
) )
2017 const SfxItemSet
& rSet
= GetSdrObject()->GetMergedItemSet();
2019 switch( rSet
.GetItemState( pMap
->nWID
, false ) )
2021 case SfxItemState::READONLY
:
2022 case SfxItemState::SET
:
2023 eState
= beans::PropertyState_DIRECT_VALUE
;
2025 case SfxItemState::DEFAULT
:
2026 eState
= beans::PropertyState_DEFAULT_VALUE
;
2029 eState
= beans::PropertyState_AMBIGUOUS_VALUE
;
2033 // if an item is set, this doesn't mean we want it :)
2034 if( beans::PropertyState_DIRECT_VALUE
== eState
)
2036 switch( pMap
->nWID
)
2038 // the following items are disabled by changing the
2039 // fill style or the line style. so there is no need
2040 // to export items without names which should be empty
2041 case XATTR_FILLBITMAP
:
2042 case XATTR_FILLGRADIENT
:
2043 case XATTR_FILLHATCH
:
2044 case XATTR_LINEDASH
:
2046 const NameOrIndex
* pItem
= rSet
.GetItem
<NameOrIndex
>(pMap
->nWID
);
2047 if( ( pItem
== nullptr ) || pItem
->GetName().isEmpty() )
2048 eState
= beans::PropertyState_DEFAULT_VALUE
;
2053 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
2054 // may be a hard attribute covering the set LineStart of the parent (Style).
2056 // same is for fill float transparency
2058 case XATTR_LINESTART
:
2059 case XATTR_FILLFLOATTRANSPARENCE
:
2061 const NameOrIndex
* pItem
= rSet
.GetItem
<NameOrIndex
>(pMap
->nWID
);
2062 if ( pItem
== nullptr )
2063 eState
= beans::PropertyState_DEFAULT_VALUE
;
2072 bool SvxShape::setPropertyValueImpl( const OUString
&, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
2074 switch( pProperty
->nWID
)
2076 case OWN_ATTR_CAPTION_POINT
:
2079 if( rValue
>>= aPnt
)
2081 Point
aVclPoint( aPnt
.X
, aPnt
.Y
);
2083 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2084 // Need to adapt aVclPoint from 100thmm to app-specific
2085 ForceMetricToItemPoolMetric(aVclPoint
);
2087 // #90763# position is relative to top left, make it absolute
2088 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2089 basegfx::B2DHomMatrix aNewHomogenMatrix
;
2090 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2092 aVclPoint
.AdjustX(basegfx::fround(aNewHomogenMatrix
.get(0, 2)) );
2093 aVclPoint
.AdjustY(basegfx::fround(aNewHomogenMatrix
.get(1, 2)) );
2095 // #88491# position relative to anchor
2096 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2098 aVclPoint
+= GetSdrObject()->GetAnchorPos();
2101 static_cast<SdrCaptionObj
*>(GetSdrObject())->SetTailPos(aVclPoint
);
2107 case OWN_ATTR_TRANSFORMATION
:
2109 drawing::HomogenMatrix3 aMatrix
;
2110 if(rValue
>>= aMatrix
)
2112 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2113 basegfx::B2DHomMatrix aNewHomogenMatrix
;
2115 // tdf#117145 SdrModel data is app-specific
2116 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2118 aNewHomogenMatrix
.set(0, 0, aMatrix
.Line1
.Column1
);
2119 aNewHomogenMatrix
.set(0, 1, aMatrix
.Line1
.Column2
);
2120 aNewHomogenMatrix
.set(0, 2, aMatrix
.Line1
.Column3
);
2121 aNewHomogenMatrix
.set(1, 0, aMatrix
.Line2
.Column1
);
2122 aNewHomogenMatrix
.set(1, 1, aMatrix
.Line2
.Column2
);
2123 aNewHomogenMatrix
.set(1, 2, aMatrix
.Line2
.Column3
);
2124 aNewHomogenMatrix
.set(2, 0, aMatrix
.Line3
.Column1
);
2125 aNewHomogenMatrix
.set(2, 1, aMatrix
.Line3
.Column2
);
2126 aNewHomogenMatrix
.set(2, 2, aMatrix
.Line3
.Column3
);
2128 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2129 // Need to adapt aNewHomogenMatrix from 100thmm to app-specific
2130 ForceMetricToItemPoolMetric(aNewHomogenMatrix
);
2132 GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2138 case OWN_ATTR_ZORDER
:
2140 sal_Int32 nNewOrdNum
= 0;
2141 if(rValue
>>= nNewOrdNum
)
2143 SdrObjList
* pObjList
= GetSdrObject()->getParentSdrObjListFromSdrObject();
2147 pObjList
->SetObjectOrdNum( GetSdrObject()->GetOrdNum(), static_cast<size_t>(nNewOrdNum
) );
2148 DBG_ASSERT( pCheck
== GetSdrObject(), "GetOrdNum() failed!" );
2154 case OWN_ATTR_FRAMERECT
:
2156 awt::Rectangle aUnoRect
;
2157 if(rValue
>>= aUnoRect
)
2159 Point
aTopLeft( aUnoRect
.X
, aUnoRect
.Y
);
2160 Size
aObjSize( aUnoRect
.Width
, aUnoRect
.Height
);
2161 ForceMetricToItemPoolMetric(aTopLeft
);
2162 ForceMetricToItemPoolMetric(aObjSize
);
2163 tools::Rectangle aRect
;
2164 aRect
.SetPos(aTopLeft
);
2165 aRect
.SetSize(aObjSize
);
2166 GetSdrObject()->SetSnapRect(aRect
);
2171 case OWN_ATTR_MIRRORED
:
2174 if(rValue
>>= bMirror
)
2176 SdrGrafObj
* pObj
= dynamic_cast< SdrGrafObj
* >( GetSdrObject() );
2178 pObj
->SetMirrored(bMirror
);
2183 case OWN_ATTR_EDGE_START_OBJ
:
2184 case OWN_ATTR_EDGE_END_OBJ
:
2185 case OWN_ATTR_GLUEID_HEAD
:
2186 case OWN_ATTR_GLUEID_TAIL
:
2187 case OWN_ATTR_EDGE_START_POS
:
2188 case OWN_ATTR_EDGE_END_POS
:
2189 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER
:
2191 SdrEdgeObj
* pEdgeObj
= dynamic_cast< SdrEdgeObj
* >(GetSdrObject());
2194 switch(pProperty
->nWID
)
2196 case OWN_ATTR_EDGE_START_OBJ
:
2197 case OWN_ATTR_EDGE_END_OBJ
:
2199 Reference
< drawing::XShape
> xShape
;
2200 if( rValue
>>= xShape
)
2202 SdrObject
* pNode
= GetSdrObjectFromXShape( xShape
);
2205 pEdgeObj
->ConnectToNode( pProperty
->nWID
== OWN_ATTR_EDGE_START_OBJ
, pNode
);
2206 pEdgeObj
->setGluePointIndex( pProperty
->nWID
== OWN_ATTR_EDGE_START_OBJ
);
2213 case OWN_ATTR_EDGE_START_POS
:
2214 case OWN_ATTR_EDGE_END_POS
:
2216 awt::Point aUnoPoint
;
2217 if( rValue
>>= aUnoPoint
)
2219 Point
aPoint( aUnoPoint
.X
, aUnoPoint
.Y
);
2221 // Reintroduction of fix for issue i59051 (#i108851#)
2222 // perform metric change before applying anchor position,
2223 // because the anchor position is in pool metric.
2224 ForceMetricToItemPoolMetric( aPoint
);
2225 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2226 aPoint
+= GetSdrObject()->GetAnchorPos();
2228 pEdgeObj
->SetTailPoint( pProperty
->nWID
== OWN_ATTR_EDGE_START_POS
, aPoint
);
2234 case OWN_ATTR_GLUEID_HEAD
:
2235 case OWN_ATTR_GLUEID_TAIL
:
2238 if( rValue
>>= nId
)
2240 pEdgeObj
->setGluePointIndex( pProperty
->nWID
== OWN_ATTR_GLUEID_HEAD
, nId
);
2245 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER
:
2247 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2249 // #123616# be a little bit more flexible regarding the data type used
2250 if( auto s
= o3tl::tryAccess
<drawing::PointSequenceSequence
>(rValue
) )
2252 // get polygpon data from PointSequenceSequence
2253 aNewPolyPolygon
= basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(
2256 else if( auto cs
= o3tl::tryAccess
<drawing::PolyPolygonBezierCoords
>(rValue
) )
2258 // get polygpon data from PolyPolygonBezierCoords
2259 aNewPolyPolygon
= basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
2263 if(aNewPolyPolygon
.count())
2265 // Reintroduction of fix for issue i59051 (#i108851#)
2266 ForceMetricToItemPoolMetric( aNewPolyPolygon
);
2267 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2269 Point
aPoint( GetSdrObject()->GetAnchorPos() );
2270 aNewPolyPolygon
.transform(basegfx::utils::createTranslateB2DHomMatrix(aPoint
.X(), aPoint
.Y()));
2272 pEdgeObj
->SetEdgeTrackPath( aNewPolyPolygon
);
2280 case OWN_ATTR_MEASURE_START_POS
:
2281 case OWN_ATTR_MEASURE_END_POS
:
2283 SdrMeasureObj
* pMeasureObj
= dynamic_cast< SdrMeasureObj
* >(GetSdrObject());
2284 awt::Point aUnoPoint
;
2285 if(pMeasureObj
&& ( rValue
>>= aUnoPoint
) )
2287 Point
aPoint( aUnoPoint
.X
, aUnoPoint
.Y
);
2289 // Reintroduction of fix for issue #i59051# (#i108851#)
2290 ForceMetricToItemPoolMetric( aPoint
);
2291 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2292 aPoint
+= GetSdrObject()->GetAnchorPos();
2294 pMeasureObj
->NbcSetPoint( aPoint
, pProperty
->nWID
== OWN_ATTR_MEASURE_START_POS
? 0 : 1 );
2295 pMeasureObj
->SetChanged();
2296 pMeasureObj
->BroadcastObjectChange();
2301 case OWN_ATTR_FILLBMP_MODE
:
2303 drawing::BitmapMode eMode
;
2304 if(!(rValue
>>= eMode
) )
2306 sal_Int32 nMode
= 0;
2307 if(!(rValue
>>= nMode
))
2310 eMode
= static_cast<drawing::BitmapMode
>(nMode
);
2312 GetSdrObject()->SetMergedItem( XFillBmpStretchItem( eMode
== drawing::BitmapMode_STRETCH
) );
2313 GetSdrObject()->SetMergedItem( XFillBmpTileItem( eMode
== drawing::BitmapMode_REPEAT
) );
2317 case SDRATTR_LAYERID
:
2319 sal_Int16 nLayerId
= sal_Int16();
2320 if( rValue
>>= nLayerId
)
2322 SdrLayer
* pLayer
= GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId
));
2325 GetSdrObject()->SetLayer(SdrLayerID(nLayerId
));
2332 case SDRATTR_LAYERNAME
:
2334 OUString aLayerName
;
2335 if( rValue
>>= aLayerName
)
2337 const SdrLayer
* pLayer
= GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayer(aLayerName
);
2338 if( pLayer
!= nullptr )
2340 GetSdrObject()->SetLayer( pLayer
->GetID() );
2346 case SDRATTR_ROTATEANGLE
:
2348 sal_Int32 nAngle
= 0;
2349 if( rValue
>>= nAngle
)
2351 Point
aRef1(GetSdrObject()->GetSnapRect().Center());
2352 nAngle
-= GetSdrObject()->GetRotateAngle();
2355 double nSin
= sin(nAngle
* F_PI18000
);
2356 double nCos
= cos(nAngle
* F_PI18000
);
2357 GetSdrObject()->Rotate(aRef1
,nAngle
,nSin
,nCos
);
2365 case SDRATTR_SHEARANGLE
:
2367 sal_Int32 nShear
= 0;
2368 if( rValue
>>= nShear
)
2370 nShear
-= GetSdrObject()->GetShearAngle();
2373 Point
aRef1(GetSdrObject()->GetSnapRect().Center());
2374 double nTan
= tan(nShear
* F_PI18000
);
2375 GetSdrObject()->Shear(aRef1
,nShear
,nTan
,false);
2383 case OWN_ATTR_INTEROPGRABBAG
:
2385 GetSdrObject()->SetGrabBagItem(rValue
);
2389 case SDRATTR_OBJMOVEPROTECT
:
2392 if( rValue
>>= bMoveProtect
)
2394 GetSdrObject()->SetMoveProtect(bMoveProtect
);
2399 case SDRATTR_OBJECTNAME
:
2402 if( rValue
>>= aName
)
2404 GetSdrObject()->SetName( aName
);
2410 case OWN_ATTR_TEXTFITTOSIZESCALE
:
2412 sal_Int16 nMaxScale
= 0;
2413 if (rValue
>>= nMaxScale
)
2415 SdrTextFitToSizeTypeItem
aItem(GetSdrObject()->GetMergedItem(SDRATTR_TEXT_FITTOSIZE
));
2416 aItem
.SetMaxScale(nMaxScale
);
2417 GetSdrObject()->SetMergedItem(aItem
);
2424 case OWN_ATTR_MISC_OBJ_TITLE
:
2427 if( rValue
>>= aTitle
)
2429 GetSdrObject()->SetTitle( aTitle
);
2434 case OWN_ATTR_MISC_OBJ_DESCRIPTION
:
2436 OUString aDescription
;
2437 if( rValue
>>= aDescription
)
2439 GetSdrObject()->SetDescription( aDescription
);
2445 case SDRATTR_OBJPRINTABLE
:
2448 if( rValue
>>= bPrintable
)
2450 GetSdrObject()->SetPrintable(bPrintable
);
2455 case SDRATTR_OBJVISIBLE
:
2458 if( rValue
>>= bVisible
)
2460 GetSdrObject()->SetVisible(bVisible
);
2465 case SDRATTR_OBJSIZEPROTECT
:
2467 bool bResizeProtect
;
2468 if( rValue
>>= bResizeProtect
)
2470 GetSdrObject()->SetResizeProtect(bResizeProtect
);
2475 case OWN_ATTR_PAGE_NUMBER
:
2477 sal_Int32 nPageNum
= 0;
2478 if( (rValue
>>= nPageNum
) && ( nPageNum
>= 0 ) && ( nPageNum
<= 0xffff ) )
2480 SdrPageObj
* pPageObj
= dynamic_cast< SdrPageObj
* >(GetSdrObject());
2483 SdrModel
& rModel(pPageObj
->getSdrModelFromSdrObject());
2484 SdrPage
* pNewPage
= nullptr;
2485 const sal_uInt16
nDestinationPageNum(static_cast<sal_uInt16
>((nPageNum
<< 1) - 1));
2487 if(nDestinationPageNum
< rModel
.GetPageCount())
2489 pNewPage
= rModel
.GetPage(nDestinationPageNum
);
2492 pPageObj
->SetReferencedPage(pNewPage
);
2499 case XATTR_FILLBITMAP
:
2500 case XATTR_FILLGRADIENT
:
2501 case XATTR_FILLHATCH
:
2502 case XATTR_FILLFLOATTRANSPARENCE
:
2504 case XATTR_LINESTART
:
2505 case XATTR_LINEDASH
:
2507 if( pProperty
->nMemberId
== MID_NAME
)
2510 if( rValue
>>= aApiName
)
2512 if( SetFillAttribute( pProperty
->nWID
, aApiName
) )
2528 OUString
sExceptionMessage ("IllegalArgumentException in SvxShape::setPropertyValueImpl."
2529 " Property Type: " + pProperty
->aType
.getTypeName() + " Property nWID: " + OUString::number(pProperty
->nWID
)
2530 + " Value Type: " + (rValue
.hasValue() ? rValue
.getValueTypeName() : "void (no value)"));
2532 throw lang::IllegalArgumentException(sExceptionMessage
, nullptr, 1);
2536 bool SvxShape::getPropertyValueImpl( const OUString
&, const SfxItemPropertySimpleEntry
* pProperty
, css::uno::Any
& rValue
)
2538 switch( pProperty
->nWID
)
2540 case OWN_ATTR_CAPTION_POINT
:
2542 Point aVclPoint
= static_cast<SdrCaptionObj
*>(GetSdrObject())->GetTailPos();
2544 // #88491# make pos relative to anchor
2545 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2547 aVclPoint
-= GetSdrObject()->GetAnchorPos();
2550 // #90763# pos is absolute, make it relative to top left
2551 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2552 basegfx::B2DHomMatrix aNewHomogenMatrix
;
2553 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2555 aVclPoint
.AdjustX( -(basegfx::fround(aNewHomogenMatrix
.get(0, 2))) );
2556 aVclPoint
.AdjustY( -(basegfx::fround(aNewHomogenMatrix
.get(1, 2))) );
2558 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2559 // Need to adapt aVclPoint from app-specific to 100thmm
2560 ForceMetricTo100th_mm(aVclPoint
);
2562 awt::Point
aPnt( aVclPoint
.X(), aVclPoint
.Y() );
2567 case OWN_ATTR_TRANSFORMATION
:
2569 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2570 basegfx::B2DHomMatrix aNewHomogenMatrix
;
2571 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2572 drawing::HomogenMatrix3 aMatrix
;
2574 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2575 // Need to adapt aNewHomogenMatrix from app-specific to 100thmm
2576 ForceMetricTo100th_mm(aNewHomogenMatrix
);
2578 aMatrix
.Line1
.Column1
= aNewHomogenMatrix
.get(0, 0);
2579 aMatrix
.Line1
.Column2
= aNewHomogenMatrix
.get(0, 1);
2580 aMatrix
.Line1
.Column3
= aNewHomogenMatrix
.get(0, 2);
2581 aMatrix
.Line2
.Column1
= aNewHomogenMatrix
.get(1, 0);
2582 aMatrix
.Line2
.Column2
= aNewHomogenMatrix
.get(1, 1);
2583 aMatrix
.Line2
.Column3
= aNewHomogenMatrix
.get(1, 2);
2584 aMatrix
.Line3
.Column1
= aNewHomogenMatrix
.get(2, 0);
2585 aMatrix
.Line3
.Column2
= aNewHomogenMatrix
.get(2, 1);
2586 aMatrix
.Line3
.Column3
= aNewHomogenMatrix
.get(2, 2);
2593 case OWN_ATTR_ZORDER
:
2595 rValue
<<= static_cast<sal_Int32
>(GetSdrObject()->GetOrdNum());
2599 case OWN_ATTR_BITMAP
:
2601 rValue
= GetBitmap();
2602 if(!rValue
.hasValue())
2603 throw uno::RuntimeException();
2608 case OWN_ATTR_ISFONTWORK
:
2610 rValue
<<= dynamic_cast<const SdrTextObj
*>(GetSdrObject()) != nullptr && static_cast<SdrTextObj
*>(GetSdrObject())->IsFontwork();
2614 case OWN_ATTR_FRAMERECT
:
2616 tools::Rectangle
aRect( GetSdrObject()->GetSnapRect() );
2617 Point
aTopLeft( aRect
.TopLeft() );
2618 Size
aObjSize( aRect
.GetWidth(), aRect
.GetHeight() );
2619 ForceMetricTo100th_mm(aTopLeft
);
2620 ForceMetricTo100th_mm(aObjSize
);
2621 css::awt::Rectangle
aUnoRect(
2622 aTopLeft
.X(), aTopLeft
.Y(),
2623 aObjSize
.getWidth(), aObjSize
.getHeight() );
2624 rValue
<<= aUnoRect
;
2628 case OWN_ATTR_BOUNDRECT
:
2630 tools::Rectangle
aRect( GetSdrObject()->GetCurrentBoundRect() );
2631 Point
aTopLeft( aRect
.TopLeft() );
2632 Size
aObjSize( aRect
.GetWidth(), aRect
.GetHeight() );
2633 ForceMetricTo100th_mm(aTopLeft
);
2634 ForceMetricTo100th_mm(aObjSize
);
2635 css::awt::Rectangle
aUnoRect(
2636 aTopLeft
.X(), aTopLeft
.Y(),
2637 aObjSize
.getWidth(), aObjSize
.getHeight() );
2638 rValue
<<= aUnoRect
;
2642 case OWN_ATTR_LDNAME
:
2644 OUString
aName( GetSdrObject()->GetName() );
2649 case OWN_ATTR_LDBITMAP
:
2652 if( GetSdrObject()->GetObjInventor() == SdrInventor::Default
&& GetSdrObject()->GetObjIdentifier() == OBJ_OLE2
)
2654 sId
= RID_UNODRAW_OLE2
;
2656 else if( GetSdrObject()->GetObjInventor() == SdrInventor::Default
&& GetSdrObject()->GetObjIdentifier() == OBJ_GRAF
)
2658 sId
= RID_UNODRAW_GRAPHICS
;
2662 sId
= RID_UNODRAW_OBJECTS
;
2666 Reference
<awt::XBitmap
> xBmp(VCLUnoHelper::CreateBitmap(aBmp
));
2672 case OWN_ATTR_MIRRORED
:
2674 bool bMirror
= false;
2675 if( HasSdrObject() && dynamic_cast<const SdrGrafObj
*>(GetSdrObject()) != nullptr )
2676 bMirror
= static_cast<SdrGrafObj
*>(GetSdrObject())->IsMirrored();
2682 case OWN_ATTR_EDGE_START_OBJ
:
2683 case OWN_ATTR_EDGE_START_POS
:
2684 case OWN_ATTR_EDGE_END_POS
:
2685 case OWN_ATTR_EDGE_END_OBJ
:
2686 case OWN_ATTR_GLUEID_HEAD
:
2687 case OWN_ATTR_GLUEID_TAIL
:
2688 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER
:
2690 SdrEdgeObj
* pEdgeObj
= dynamic_cast<SdrEdgeObj
*>(GetSdrObject());
2693 switch(pProperty
->nWID
)
2695 case OWN_ATTR_EDGE_START_OBJ
:
2696 case OWN_ATTR_EDGE_END_OBJ
:
2698 SdrObject
* pNode
= pEdgeObj
->GetConnectedNode(pProperty
->nWID
== OWN_ATTR_EDGE_START_OBJ
);
2701 Reference
< drawing::XShape
> xShape( GetXShapeForSdrObject( pNode
) );
2709 case OWN_ATTR_EDGE_START_POS
:
2710 case OWN_ATTR_EDGE_END_POS
:
2712 Point
aPoint( pEdgeObj
->GetTailPoint( pProperty
->nWID
== OWN_ATTR_EDGE_START_POS
) );
2713 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2714 aPoint
-= GetSdrObject()->GetAnchorPos();
2716 ForceMetricTo100th_mm( aPoint
);
2717 awt::Point
aUnoPoint( aPoint
.X(), aPoint
.Y() );
2719 rValue
<<= aUnoPoint
;
2722 case OWN_ATTR_GLUEID_HEAD
:
2723 case OWN_ATTR_GLUEID_TAIL
:
2725 rValue
<<= pEdgeObj
->getGluePointIndex( pProperty
->nWID
== OWN_ATTR_GLUEID_HEAD
);
2728 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER
:
2730 basegfx::B2DPolyPolygon
aPolyPoly( pEdgeObj
->GetEdgeTrackPath() );
2731 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2733 Point
aPoint( GetSdrObject()->GetAnchorPos() );
2734 aPolyPoly
.transform(basegfx::utils::createTranslateB2DHomMatrix(-aPoint
.X(), -aPoint
.Y()));
2736 // Reintroduction of fix for issue #i59051# (#i108851#)
2737 ForceMetricTo100th_mm( aPolyPoly
);
2738 drawing::PolyPolygonBezierCoords aRetval
;
2739 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPoly
, aRetval
);
2748 case OWN_ATTR_MEASURE_START_POS
:
2749 case OWN_ATTR_MEASURE_END_POS
:
2751 SdrMeasureObj
* pMeasureObj
= dynamic_cast<SdrMeasureObj
*>(GetSdrObject());
2754 Point
aPoint( pMeasureObj
->GetPoint( pProperty
->nWID
== OWN_ATTR_MEASURE_START_POS
? 0 : 1 ) );
2755 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2756 aPoint
-= GetSdrObject()->GetAnchorPos();
2758 // Reintroduction of fix for issue #i59051# (#i108851#)
2759 ForceMetricTo100th_mm( aPoint
);
2760 awt::Point
aUnoPoint( aPoint
.X(), aPoint
.Y() );
2762 rValue
<<= aUnoPoint
;
2768 case OWN_ATTR_FILLBMP_MODE
:
2770 const SfxItemSet
& rObjItemSet
= GetSdrObject()->GetMergedItemSet();
2772 if (rObjItemSet
.Get(XATTR_FILLBMP_TILE
).GetValue())
2774 rValue
<<= drawing::BitmapMode_REPEAT
;
2776 else if (rObjItemSet
.Get(XATTR_FILLBMP_STRETCH
).GetValue())
2778 rValue
<<= drawing::BitmapMode_STRETCH
;
2782 rValue
<<= drawing::BitmapMode_NO_REPEAT
;
2786 case SDRATTR_LAYERID
:
2787 rValue
<<= sal_uInt16(sal_uInt8(GetSdrObject()->GetLayer()));
2790 case SDRATTR_LAYERNAME
:
2792 SdrLayer
* pLayer
= GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(GetSdrObject()->GetLayer());
2795 rValue
<<= pLayer
->GetName();
2800 case SDRATTR_ROTATEANGLE
:
2801 rValue
<<= static_cast<sal_Int32
>(GetSdrObject()->GetRotateAngle());
2804 case SDRATTR_SHEARANGLE
:
2805 rValue
<<= static_cast<sal_Int32
>(GetSdrObject()->GetShearAngle());
2808 case OWN_ATTR_INTEROPGRABBAG
:
2810 GetSdrObject()->GetGrabBagItem(rValue
);
2814 case SDRATTR_OBJMOVEPROTECT
:
2815 rValue
<<= GetSdrObject()->IsMoveProtect();
2818 case SDRATTR_OBJECTNAME
:
2820 OUString
aName( GetSdrObject()->GetName() );
2826 case OWN_ATTR_MISC_OBJ_TITLE
:
2828 OUString
aTitle( GetSdrObject()->GetTitle() );
2833 case OWN_ATTR_MISC_OBJ_DESCRIPTION
:
2835 OUString
aDescription( GetSdrObject()->GetDescription() );
2836 rValue
<<= aDescription
;
2840 case SDRATTR_OBJPRINTABLE
:
2841 rValue
<<= GetSdrObject()->IsPrintable();
2844 case SDRATTR_OBJVISIBLE
:
2845 rValue
<<= GetSdrObject()->IsVisible();
2848 case SDRATTR_OBJSIZEPROTECT
:
2849 rValue
<<= GetSdrObject()->IsResizeProtect();
2852 case OWN_ATTR_PAGE_NUMBER
:
2854 SdrPageObj
* pPageObj
= dynamic_cast<SdrPageObj
*>(GetSdrObject());
2857 SdrPage
* pPage
= pPageObj
->GetReferencedPage();
2858 sal_Int32 nPageNumber
= pPage
? pPage
->GetPageNum() : 0;
2861 rValue
<<= nPageNumber
;
2866 case OWN_ATTR_UINAME_SINGULAR
:
2868 rValue
<<= GetSdrObject()->TakeObjNameSingul();
2872 case OWN_ATTR_TEXTFITTOSIZESCALE
:
2874 rValue
<<= GetTextFitToSizeScale(GetSdrObject());
2878 case OWN_ATTR_UINAME_PLURAL
:
2880 rValue
<<= GetSdrObject()->TakeObjNamePlural();
2883 case OWN_ATTR_METAFILE
:
2885 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>(GetSdrObject());
2888 const Graphic
* pGraphic
= pObj
->GetGraphic();
2891 bool bIsWMF
= false;
2892 if ( pGraphic
->IsGfxLink() )
2894 GfxLink aLnk
= pGraphic
->GetGfxLink();
2895 if ( aLnk
.GetType() == GfxLinkType::NativeWmf
)
2898 uno::Sequence
<sal_Int8
> aSeq(reinterpret_cast<sal_Int8
const *>(aLnk
.GetData()), static_cast<sal_Int32
>(aLnk
.GetDataSize()));
2904 // #119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically
2905 GDIMetaFile
aMtf(pObj
->GetGraphic()->GetGDIMetaFile());
2906 SvMemoryStream
aDestStrm( 65535, 65535 );
2907 ConvertGDIMetaFileToWMF( aMtf
, aDestStrm
, nullptr, false );
2908 const uno::Sequence
<sal_Int8
> aSeq(
2909 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
2910 aDestStrm
.GetEndOfData());
2917 rValue
= GetBitmap( true );
2930 bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry
* pProperty
, css::beans::PropertyState
& rState
)
2932 if( pProperty
->nWID
== OWN_ATTR_FILLBMP_MODE
)
2934 const SfxItemSet
& rSet
= GetSdrObject()->GetMergedItemSet();
2936 if( rSet
.GetItemState( XATTR_FILLBMP_STRETCH
, false ) == SfxItemState::SET
||
2937 rSet
.GetItemState( XATTR_FILLBMP_TILE
, false ) == SfxItemState::SET
)
2939 rState
= beans::PropertyState_DIRECT_VALUE
;
2943 rState
= beans::PropertyState_AMBIGUOUS_VALUE
;
2946 else if((( pProperty
->nWID
>= OWN_ATTR_VALUE_START
&& pProperty
->nWID
<= OWN_ATTR_VALUE_END
) ||
2947 ( pProperty
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pProperty
->nWID
<= SDRATTR_NOTPERSIST_LAST
)) && ( pProperty
->nWID
!= SDRATTR_TEXTDIRECTION
) )
2949 rState
= beans::PropertyState_DIRECT_VALUE
;
2960 bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry
* pProperty
)
2962 if( pProperty
->nWID
== OWN_ATTR_FILLBMP_MODE
)
2964 GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_STRETCH
);
2965 GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_TILE
);
2968 else if((pProperty
->nWID
>= OWN_ATTR_VALUE_START
&& pProperty
->nWID
<= OWN_ATTR_VALUE_END
) ||
2969 ( pProperty
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pProperty
->nWID
<= SDRATTR_NOTPERSIST_LAST
))
2980 uno::Sequence
< beans::PropertyState
> SAL_CALL
SvxShape::getPropertyStates( const uno::Sequence
< OUString
>& aPropertyName
)
2982 const sal_Int32 nCount
= aPropertyName
.getLength();
2983 uno::Sequence
< beans::PropertyState
> aRet( nCount
);
2985 std::transform(aPropertyName
.begin(), aPropertyName
.end(), aRet
.begin(),
2986 [this](const OUString
& rName
) -> beans::PropertyState
{ return getPropertyState(rName
); });
2992 void SAL_CALL
SvxShape::setPropertyToDefault( const OUString
& PropertyName
)
2994 if( mpImpl
->mpMaster
)
2996 mpImpl
->mpMaster
->setPropertyToDefault( PropertyName
);
3000 _setPropertyToDefault( PropertyName
);
3004 void SvxShape::_setPropertyToDefault( const OUString
& PropertyName
)
3006 ::SolarMutexGuard aGuard
;
3008 const SfxItemPropertySimpleEntry
* pProperty
= mpPropSet
->getPropertyMapEntry(PropertyName
);
3010 if( !HasSdrObject() || pProperty
== nullptr )
3011 throw beans::UnknownPropertyException( PropertyName
, static_cast<cppu::OWeakObject
*>(this));
3013 if( !setPropertyToDefaultImpl( pProperty
) )
3015 GetSdrObject()->ClearMergedItem( pProperty
->nWID
);
3018 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
3022 uno::Any SAL_CALL
SvxShape::getPropertyDefault( const OUString
& aPropertyName
)
3024 if( mpImpl
->mpMaster
)
3026 return mpImpl
->mpMaster
->getPropertyDefault( aPropertyName
);
3030 return _getPropertyDefault( aPropertyName
);
3034 uno::Any
SvxShape::_getPropertyDefault( const OUString
& aPropertyName
)
3036 ::SolarMutexGuard aGuard
;
3038 const SfxItemPropertySimpleEntry
* pMap
= mpPropSet
->getPropertyMapEntry(aPropertyName
);
3040 if( !HasSdrObject() || pMap
== nullptr )
3041 throw beans::UnknownPropertyException( aPropertyName
, static_cast<cppu::OWeakObject
*>(this));
3043 if(( pMap
->nWID
>= OWN_ATTR_VALUE_START
&& pMap
->nWID
<= OWN_ATTR_VALUE_END
) ||
3044 ( pMap
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pMap
->nWID
<= SDRATTR_NOTPERSIST_LAST
))
3046 return getPropertyValue( aPropertyName
);
3049 // get default from ItemPool
3050 if(!SfxItemPool::IsWhich(pMap
->nWID
))
3051 throw beans::UnknownPropertyException( "No WhichID " + OUString::number(pMap
->nWID
) + " for " + aPropertyName
, static_cast<cppu::OWeakObject
*>(this));
3053 SfxItemSet
aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{pMap
->nWID
, pMap
->nWID
}});
3054 aSet
.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap
->nWID
));
3056 return GetAnyForItem( aSet
, pMap
);
3059 // XMultiPropertyStates
3060 void SvxShape::setAllPropertiesToDefault()
3062 ::SolarMutexGuard aGuard
;
3064 if( !HasSdrObject() )
3065 throw lang::DisposedException();
3066 GetSdrObject()->ClearMergedItem(); // nWhich == 0 => all
3068 if(dynamic_cast<const SdrGrafObj
*>(GetSdrObject()) != nullptr)
3070 // defaults for graphic objects have changed:
3071 GetSdrObject()->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE
) );
3072 GetSdrObject()->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE
) );
3075 // #i68523# special handling for Svx3DCharacterModeItem, this is not saved
3076 // but needs to be sal_True in svx, pool default (false) in sch. Since sch
3077 // does not load lathe or extrude objects, it is possible to set the items
3079 // For other solution possibilities, see task description.
3080 if( dynamic_cast<const E3dLatheObj
* >(GetSdrObject()) != nullptr|| dynamic_cast<const E3dExtrudeObj
* >(GetSdrObject()) != nullptr)
3082 GetSdrObject()->SetMergedItem(Svx3DCharacterModeItem(true));
3085 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
3088 void SvxShape::setPropertiesToDefault(
3089 const uno::Sequence
<OUString
>& aPropertyNames
)
3091 for ( const auto& rPropertyName
: aPropertyNames
)
3092 setPropertyToDefault( rPropertyName
);
3095 uno::Sequence
<uno::Any
> SvxShape::getPropertyDefaults(
3096 const uno::Sequence
<OUString
>& aPropertyNames
)
3098 ::std::vector
<uno::Any
> ret
;
3099 ret
.reserve(aPropertyNames
.getLength());
3100 std::transform(aPropertyNames
.begin(), aPropertyNames
.end(), std::back_inserter(ret
),
3101 [this](const OUString
& rName
) -> uno::Any
{ return getPropertyDefault(rName
); });
3102 return uno::Sequence
<uno::Any
>( ret
.data(), ret
.size() );
3108 OUString SAL_CALL
SvxShape::getImplementationName()
3113 const char sUNO_service_style_ParagraphProperties
[] = "com.sun.star.style.ParagraphProperties";
3114 const char sUNO_service_style_ParagraphPropertiesComplex
[] = "com.sun.star.style.ParagraphPropertiesComplex";
3115 const char sUNO_service_style_ParagraphPropertiesAsian
[] = "com.sun.star.style.ParagraphPropertiesAsian";
3116 const char sUNO_service_style_CharacterProperties
[] = "com.sun.star.style.CharacterProperties";
3117 const char sUNO_service_style_CharacterPropertiesComplex
[] = "com.sun.star.style.CharacterPropertiesComplex";
3118 const char sUNO_service_style_CharacterPropertiesAsian
[] = "com.sun.star.style.CharacterPropertiesAsian";
3120 const char sUNO_service_drawing_FillProperties
[] = "com.sun.star.drawing.FillProperties";
3121 const char sUNO_service_drawing_TextProperties
[] = "com.sun.star.drawing.TextProperties";
3122 const char sUNO_service_drawing_LineProperties
[] = "com.sun.star.drawing.LineProperties";
3123 const char sUNO_service_drawing_ConnectorProperties
[] = "com.sun.star.drawing.ConnectorProperties";
3124 const char sUNO_service_drawing_MeasureProperties
[] = "com.sun.star.drawing.MeasureProperties";
3125 const char sUNO_service_drawing_ShadowProperties
[] = "com.sun.star.drawing.ShadowProperties";
3127 const char sUNO_service_drawing_RotationDescriptor
[] = "com.sun.star.drawing.RotationDescriptor";
3129 const char sUNO_service_drawing_Text
[] = "com.sun.star.drawing.Text";
3130 const char sUNO_service_drawing_GroupShape
[] = "com.sun.star.drawing.GroupShape";
3132 const char sUNO_service_drawing_CustomShapeProperties
[] = "com.sun.star.drawing.CustomShapeProperties";
3133 const char sUNO_service_drawing_CustomShape
[] = "com.sun.star.drawing.CustomShape";
3135 const char sUNO_service_drawing_PolyPolygonDescriptor
[] = "com.sun.star.drawing.PolyPolygonDescriptor";
3136 const char sUNO_service_drawing_PolyPolygonBezierDescriptor
[]= "com.sun.star.drawing.PolyPolygonBezierDescriptor";
3138 const char sUNO_service_drawing_LineShape
[] = "com.sun.star.drawing.LineShape";
3139 const char sUNO_service_drawing_Shape
[] = "com.sun.star.drawing.Shape";
3140 const char sUNO_service_drawing_RectangleShape
[] = "com.sun.star.drawing.RectangleShape";
3141 const char sUNO_service_drawing_EllipseShape
[] = "com.sun.star.drawing.EllipseShape";
3142 const char sUNO_service_drawing_PolyPolygonShape
[] = "com.sun.star.drawing.PolyPolygonShape";
3143 const char sUNO_service_drawing_PolyLineShape
[] = "com.sun.star.drawing.PolyLineShape";
3144 const char sUNO_service_drawing_OpenBezierShape
[] = "com.sun.star.drawing.OpenBezierShape";
3145 const char sUNO_service_drawing_ClosedBezierShape
[] = "com.sun.star.drawing.ClosedBezierShape";
3146 const char sUNO_service_drawing_TextShape
[] = "com.sun.star.drawing.TextShape";
3147 const char sUNO_service_drawing_GraphicObjectShape
[] = "com.sun.star.drawing.GraphicObjectShape";
3148 const char sUNO_service_drawing_OLE2Shape
[] = "com.sun.star.drawing.OLE2Shape";
3149 const char sUNO_service_drawing_PageShape
[] = "com.sun.star.drawing.PageShape";
3150 const char sUNO_service_drawing_CaptionShape
[] = "com.sun.star.drawing.CaptionShape";
3151 const char sUNO_service_drawing_MeasureShape
[] = "com.sun.star.drawing.MeasureShape";
3152 const char sUNO_service_drawing_FrameShape
[] = "com.sun.star.drawing.FrameShape";
3153 const char sUNO_service_drawing_ControlShape
[] = "com.sun.star.drawing.ControlShape";
3154 const char sUNO_service_drawing_ConnectorShape
[] = "com.sun.star.drawing.ConnectorShape";
3155 const char sUNO_service_drawing_MediaShape
[] = "com.sun.star.drawing.MediaShape";
3158 uno::Sequence
< OUString
> SAL_CALL
SvxShape::getSupportedServiceNames()
3160 if( mpImpl
->mpMaster
)
3162 return mpImpl
->mpMaster
->getSupportedServiceNames();
3166 return _getSupportedServiceNames();
3170 uno::Sequence
< OUString
> SvxShape::_getSupportedServiceNames()
3172 ::SolarMutexGuard aGuard
;
3174 if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::Default
)
3176 const sal_uInt16 nIdent
= GetSdrObject()->GetObjIdentifier();
3182 static const uno::Sequence
<OUString
> aSvxShape_GroupServices
3183 = { sUNO_service_drawing_GroupShape
,
3184 sUNO_service_drawing_Shape
};
3185 return aSvxShape_GroupServices
;
3187 case OBJ_CUSTOMSHAPE
:
3189 static const uno::Sequence
<OUString
> aSvxShape_CustomShapeServices
3190 = { sUNO_service_drawing_CustomShape
,
3191 sUNO_service_drawing_Shape
,
3192 sUNO_service_drawing_CustomShapeProperties
,
3193 sUNO_service_drawing_FillProperties
,
3194 sUNO_service_drawing_LineProperties
,
3195 sUNO_service_drawing_Text
,
3196 sUNO_service_drawing_TextProperties
,
3197 sUNO_service_style_ParagraphProperties
,
3198 sUNO_service_style_ParagraphPropertiesComplex
,
3199 sUNO_service_style_ParagraphPropertiesAsian
,
3200 sUNO_service_style_CharacterProperties
,
3201 sUNO_service_style_CharacterPropertiesComplex
,
3202 sUNO_service_style_CharacterPropertiesAsian
,
3203 sUNO_service_drawing_ShadowProperties
,
3204 sUNO_service_drawing_RotationDescriptor
};
3205 return aSvxShape_CustomShapeServices
;
3209 static const uno::Sequence
<OUString
> aSvxShape_LineServices
3210 = { sUNO_service_drawing_LineShape
,
3212 sUNO_service_drawing_Shape
,
3213 sUNO_service_drawing_LineProperties
,
3215 sUNO_service_drawing_Text
,
3216 sUNO_service_drawing_TextProperties
,
3217 sUNO_service_style_ParagraphProperties
,
3218 sUNO_service_style_ParagraphPropertiesComplex
,
3219 sUNO_service_style_ParagraphPropertiesAsian
,
3220 sUNO_service_style_CharacterProperties
,
3221 sUNO_service_style_CharacterPropertiesComplex
,
3222 sUNO_service_style_CharacterPropertiesAsian
,
3224 sUNO_service_drawing_PolyPolygonDescriptor
,
3225 sUNO_service_drawing_ShadowProperties
,
3226 sUNO_service_drawing_RotationDescriptor
};
3227 return aSvxShape_LineServices
;
3232 static const uno::Sequence
<OUString
> aSvxShape_RectServices
3233 = { sUNO_service_drawing_RectangleShape
,
3235 sUNO_service_drawing_Shape
,
3236 sUNO_service_drawing_FillProperties
,
3237 sUNO_service_drawing_LineProperties
,
3238 sUNO_service_drawing_Text
,
3239 sUNO_service_drawing_TextProperties
,
3240 sUNO_service_style_ParagraphProperties
,
3241 sUNO_service_style_ParagraphPropertiesComplex
,
3242 sUNO_service_style_ParagraphPropertiesAsian
,
3243 sUNO_service_style_CharacterProperties
,
3244 sUNO_service_style_CharacterPropertiesComplex
,
3245 sUNO_service_style_CharacterPropertiesAsian
,
3247 sUNO_service_drawing_ShadowProperties
,
3248 sUNO_service_drawing_RotationDescriptor
};
3249 return aSvxShape_RectServices
;
3257 static const uno::Sequence
<OUString
> aSvxShape_CircServices
3258 = { sUNO_service_drawing_EllipseShape
,
3260 sUNO_service_drawing_Shape
,
3261 sUNO_service_drawing_FillProperties
,
3262 sUNO_service_drawing_LineProperties
,
3264 sUNO_service_drawing_Text
,
3265 sUNO_service_drawing_TextProperties
,
3266 sUNO_service_style_ParagraphProperties
,
3267 sUNO_service_style_ParagraphPropertiesComplex
,
3268 sUNO_service_style_ParagraphPropertiesAsian
,
3269 sUNO_service_style_CharacterProperties
,
3270 sUNO_service_style_CharacterPropertiesComplex
,
3271 sUNO_service_style_CharacterPropertiesAsian
,
3273 sUNO_service_drawing_ShadowProperties
,
3274 sUNO_service_drawing_RotationDescriptor
};
3275 return aSvxShape_CircServices
;
3281 static const uno::Sequence
<OUString
> aSvxShape_PathServices
3282 = { sUNO_service_drawing_PolyLineShape
,
3284 sUNO_service_drawing_Shape
,
3285 sUNO_service_drawing_LineProperties
,
3287 sUNO_service_drawing_PolyPolygonDescriptor
,
3289 sUNO_service_drawing_Text
,
3290 sUNO_service_drawing_TextProperties
,
3291 sUNO_service_style_ParagraphProperties
,
3292 sUNO_service_style_ParagraphPropertiesComplex
,
3293 sUNO_service_style_ParagraphPropertiesAsian
,
3294 sUNO_service_style_CharacterProperties
,
3295 sUNO_service_style_CharacterPropertiesComplex
,
3296 sUNO_service_style_CharacterPropertiesAsian
,
3298 sUNO_service_drawing_ShadowProperties
,
3299 sUNO_service_drawing_RotationDescriptor
};
3300 return aSvxShape_PathServices
;
3306 static const uno::Sequence
<OUString
> aSvxShape_PolyServices
3307 = { sUNO_service_drawing_PolyPolygonShape
,
3309 sUNO_service_drawing_Shape
,
3310 sUNO_service_drawing_LineProperties
,
3311 sUNO_service_drawing_FillProperties
,
3313 sUNO_service_drawing_PolyPolygonDescriptor
,
3315 sUNO_service_drawing_Text
,
3316 sUNO_service_drawing_TextProperties
,
3317 sUNO_service_style_ParagraphProperties
,
3318 sUNO_service_style_ParagraphPropertiesComplex
,
3319 sUNO_service_style_ParagraphPropertiesAsian
,
3320 sUNO_service_style_CharacterProperties
,
3321 sUNO_service_style_CharacterPropertiesComplex
,
3322 sUNO_service_style_CharacterPropertiesAsian
,
3324 sUNO_service_drawing_ShadowProperties
,
3325 sUNO_service_drawing_RotationDescriptor
};
3326 return aSvxShape_PolyServices
;
3332 static const uno::Sequence
<OUString
> aSvxShape_FreeLineServices
3333 = { sUNO_service_drawing_OpenBezierShape
,
3335 sUNO_service_drawing_Shape
,
3336 sUNO_service_drawing_LineProperties
,
3337 sUNO_service_drawing_FillProperties
,
3339 sUNO_service_drawing_PolyPolygonBezierDescriptor
,
3341 sUNO_service_drawing_Text
,
3342 sUNO_service_drawing_TextProperties
,
3343 sUNO_service_style_ParagraphProperties
,
3344 sUNO_service_style_ParagraphPropertiesComplex
,
3345 sUNO_service_style_ParagraphPropertiesAsian
,
3346 sUNO_service_style_CharacterProperties
,
3347 sUNO_service_style_CharacterPropertiesComplex
,
3348 sUNO_service_style_CharacterPropertiesAsian
,
3350 sUNO_service_drawing_ShadowProperties
,
3351 sUNO_service_drawing_RotationDescriptor
};
3352 return aSvxShape_FreeLineServices
;
3358 static const uno::Sequence
<OUString
> aSvxShape_FreeFillServices
3359 = { sUNO_service_drawing_ClosedBezierShape
,
3361 sUNO_service_drawing_Shape
,
3362 sUNO_service_drawing_LineProperties
,
3363 sUNO_service_drawing_FillProperties
,
3365 sUNO_service_drawing_PolyPolygonBezierDescriptor
,
3367 sUNO_service_drawing_Text
,
3368 sUNO_service_drawing_TextProperties
,
3369 sUNO_service_style_ParagraphProperties
,
3370 sUNO_service_style_ParagraphPropertiesComplex
,
3371 sUNO_service_style_ParagraphPropertiesAsian
,
3372 sUNO_service_style_CharacterProperties
,
3373 sUNO_service_style_CharacterPropertiesComplex
,
3374 sUNO_service_style_CharacterPropertiesAsian
,
3376 sUNO_service_drawing_ShadowProperties
,
3377 sUNO_service_drawing_RotationDescriptor
};
3378 return aSvxShape_FreeFillServices
;
3381 case OBJ_OUTLINETEXT
:
3385 static const uno::Sequence
<OUString
> aSvxShape_TextServices
3386 = { sUNO_service_drawing_TextShape
,
3388 sUNO_service_drawing_Shape
,
3389 sUNO_service_drawing_FillProperties
,
3390 sUNO_service_drawing_LineProperties
,
3392 sUNO_service_drawing_Text
,
3393 sUNO_service_drawing_TextProperties
,
3394 sUNO_service_style_ParagraphProperties
,
3395 sUNO_service_style_ParagraphPropertiesComplex
,
3396 sUNO_service_style_ParagraphPropertiesAsian
,
3397 sUNO_service_style_CharacterProperties
,
3398 sUNO_service_style_CharacterPropertiesComplex
,
3399 sUNO_service_style_CharacterPropertiesAsian
,
3401 sUNO_service_drawing_ShadowProperties
,
3402 sUNO_service_drawing_RotationDescriptor
};
3403 return aSvxShape_TextServices
;
3408 static const uno::Sequence
<OUString
> aSvxShape_GrafServices
3409 = { sUNO_service_drawing_GraphicObjectShape
,
3411 sUNO_service_drawing_Shape
,
3413 sUNO_service_drawing_Text
,
3414 sUNO_service_drawing_TextProperties
,
3415 sUNO_service_style_ParagraphProperties
,
3416 sUNO_service_style_ParagraphPropertiesComplex
,
3417 sUNO_service_style_ParagraphPropertiesAsian
,
3418 sUNO_service_style_CharacterProperties
,
3419 sUNO_service_style_CharacterPropertiesComplex
,
3420 sUNO_service_style_CharacterPropertiesAsian
,
3422 sUNO_service_drawing_ShadowProperties
,
3423 sUNO_service_drawing_RotationDescriptor
};
3424 return aSvxShape_GrafServices
;
3429 static const uno::Sequence
<OUString
> aSvxShape_Ole2Services
3430 = { sUNO_service_drawing_OLE2Shape
,
3431 sUNO_service_drawing_Shape
,
3433 // #i118485# Added Text, Shadow and Rotation
3434 sUNO_service_drawing_Text
,
3435 sUNO_service_drawing_TextProperties
,
3436 sUNO_service_style_ParagraphProperties
,
3437 sUNO_service_style_ParagraphPropertiesComplex
,
3438 sUNO_service_style_ParagraphPropertiesAsian
,
3439 sUNO_service_style_CharacterProperties
,
3440 sUNO_service_style_CharacterPropertiesComplex
,
3441 sUNO_service_style_CharacterPropertiesAsian
,
3443 sUNO_service_drawing_ShadowProperties
,
3444 sUNO_service_drawing_RotationDescriptor
};
3445 return aSvxShape_Ole2Services
;
3450 static const uno::Sequence
<OUString
> aSvxShape_CaptionServices
3451 = { sUNO_service_drawing_CaptionShape
,
3453 sUNO_service_drawing_Shape
,
3454 sUNO_service_drawing_FillProperties
,
3455 sUNO_service_drawing_LineProperties
,
3457 sUNO_service_drawing_Text
,
3458 sUNO_service_drawing_TextProperties
,
3459 sUNO_service_style_ParagraphProperties
,
3460 sUNO_service_style_ParagraphPropertiesComplex
,
3461 sUNO_service_style_ParagraphPropertiesAsian
,
3462 sUNO_service_style_CharacterProperties
,
3463 sUNO_service_style_CharacterPropertiesComplex
,
3464 sUNO_service_style_CharacterPropertiesAsian
,
3466 sUNO_service_drawing_ShadowProperties
,
3467 sUNO_service_drawing_RotationDescriptor
};
3468 return aSvxShape_CaptionServices
;
3473 static const uno::Sequence
<OUString
> aSvxShape_PageServices
3474 = { sUNO_service_drawing_PageShape
,
3475 sUNO_service_drawing_Shape
};
3476 return aSvxShape_PageServices
;
3481 static const uno::Sequence
<OUString
> aSvxShape_MeasureServices
3482 = { sUNO_service_drawing_MeasureShape
,
3484 sUNO_service_drawing_MeasureProperties
,
3486 sUNO_service_drawing_Shape
,
3487 sUNO_service_drawing_LineProperties
,
3489 sUNO_service_drawing_Text
,
3490 sUNO_service_drawing_TextProperties
,
3491 sUNO_service_style_ParagraphProperties
,
3492 sUNO_service_style_ParagraphPropertiesComplex
,
3493 sUNO_service_style_ParagraphPropertiesAsian
,
3494 sUNO_service_style_CharacterProperties
,
3495 sUNO_service_style_CharacterPropertiesComplex
,
3496 sUNO_service_style_CharacterPropertiesAsian
,
3498 sUNO_service_drawing_PolyPolygonDescriptor
,
3499 sUNO_service_drawing_ShadowProperties
,
3500 sUNO_service_drawing_RotationDescriptor
};
3501 return aSvxShape_MeasureServices
;
3506 static const uno::Sequence
<OUString
> aSvxShape_FrameServices
3507 = { sUNO_service_drawing_FrameShape
,
3508 sUNO_service_drawing_Shape
};
3509 return aSvxShape_FrameServices
;
3514 static const uno::Sequence
<OUString
> aSvxShape_UnoServices
3515 = { sUNO_service_drawing_ControlShape
,
3516 sUNO_service_drawing_Shape
};
3517 return aSvxShape_UnoServices
;
3522 static const uno::Sequence
<OUString
> aSvxShape_EdgeServices
3523 = { sUNO_service_drawing_ConnectorShape
,
3524 sUNO_service_drawing_ConnectorProperties
,
3526 sUNO_service_drawing_Shape
,
3527 sUNO_service_drawing_LineProperties
,
3529 sUNO_service_drawing_Text
,
3530 sUNO_service_drawing_TextProperties
,
3531 sUNO_service_style_ParagraphProperties
,
3532 sUNO_service_style_ParagraphPropertiesComplex
,
3533 sUNO_service_style_ParagraphPropertiesAsian
,
3534 sUNO_service_style_CharacterProperties
,
3535 sUNO_service_style_CharacterPropertiesComplex
,
3536 sUNO_service_style_CharacterPropertiesAsian
,
3538 sUNO_service_drawing_PolyPolygonDescriptor
,
3539 sUNO_service_drawing_ShadowProperties
,
3540 sUNO_service_drawing_RotationDescriptor
};
3541 return aSvxShape_EdgeServices
;
3545 static const uno::Sequence
<OUString
> aSvxShape_MediaServices
3546 = { sUNO_service_drawing_MediaShape
,
3547 sUNO_service_drawing_Shape
};
3548 return aSvxShape_MediaServices
;
3552 else if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::FmForm
)
3554 #if OSL_DEBUG_LEVEL > 0
3555 const sal_uInt16 nIdent
= GetSdrObject()->GetObjIdentifier();
3556 OSL_ENSURE( nIdent
== OBJ_UNO
, "SvxShape::_getSupportedServiceNames: SdrInventor::FmForm, but no UNO object?" );
3558 static const uno::Sequence
<OUString
> aSvxShape_UnoServices
3559 = { sUNO_service_drawing_ControlShape
,
3560 sUNO_service_drawing_Shape
};
3561 return aSvxShape_UnoServices
;
3563 OSL_FAIL( "SvxShape::_getSupportedServiceNames: could not determine object type!" );
3564 uno::Sequence
< OUString
> aSeq
;
3568 sal_Bool SAL_CALL
SvxShape::supportsService( const OUString
& ServiceName
)
3570 return cppu::supportsService(this, ServiceName
);
3573 // XGluePointsSupplier
3574 uno::Reference
< container::XIndexContainer
> SAL_CALL
SvxShape::getGluePoints()
3576 ::SolarMutexGuard aGuard
;
3577 uno::Reference
< container::XIndexContainer
> xGluePoints( mxGluePoints
);
3579 if( HasSdrObject() && !xGluePoints
.is() )
3581 uno::Reference
< container::XIndexContainer
> xNew( SvxUnoGluePointAccess_createInstance( GetSdrObject() ), uno::UNO_QUERY
);
3582 mxGluePoints
= xGluePoints
= xNew
;
3589 uno::Reference
<uno::XInterface
> SAL_CALL
SvxShape::getParent()
3591 ::SolarMutexGuard aGuard
;
3592 const SdrObject
* pSdrObject(GetSdrObject());
3594 if(nullptr != pSdrObject
)
3596 const SdrObjList
* pParentSdrObjList(GetSdrObject()->getParentSdrObjListFromSdrObject());
3598 if(nullptr != pParentSdrObjList
)
3600 // SdrObject is member of a SdrObjList. That may be a SdrObject
3601 // (SdrObjGroup or E3dScene) or a SdrPage.
3602 // Check for SdrObject first - using getSdrPageFromSdrObjList
3603 // *will* get the SdrPage even when the SdrObject is deep buried
3604 // in a construct of SdrObjGroup.
3605 // We want to ask for the direct parent here...
3606 SdrObject
* pParentSdrObject(pParentSdrObjList
->getSdrObjectFromSdrObjList());
3608 if(nullptr != pParentSdrObject
)
3610 // SdrObject is member of a SdrObject-based Group (SdrObjGroup or E3dScene).
3611 return pParentSdrObject
->getUnoShape();
3615 SdrPage
* pParentSdrPage(pParentSdrObjList
->getSdrPageFromSdrObjList());
3617 if(nullptr != pParentSdrPage
)
3619 // SdrObject is inserted to a SdrPage. Since
3620 // we checked for getSdrObjectFromSdrObjList first,
3621 // we can even say that it is directly member of that
3623 return pParentSdrPage
->getUnoPage();
3627 // not member of any SdrObjList, no parent
3628 OSL_FAIL( "SvxShape::getParent( ): unexpected Parent SdrObjList" );
3632 // no SdrObject, no parent
3633 return uno::Reference
<uno::XInterface
>();
3636 void SAL_CALL
SvxShape::setParent( const css::uno::Reference
< css::uno::XInterface
>& )
3638 throw lang::NoSupportException();
3642 /** called from the XActionLockable interface methods on initial locking */
3643 void SvxShape::lock()
3648 /** called from the XActionLockable interface methods on final unlock */
3649 void SvxShape::unlock()
3655 sal_Bool SAL_CALL
SvxShape::isActionLocked( )
3657 ::SolarMutexGuard aGuard
;
3659 return mnLockCount
!= 0;
3663 void SAL_CALL
SvxShape::addActionLock( )
3665 ::SolarMutexGuard aGuard
;
3667 DBG_ASSERT( mnLockCount
< 0xffff, "lock overflow in SvxShape!" );
3670 if( mnLockCount
== 1 )
3675 void SAL_CALL
SvxShape::removeActionLock( )
3677 ::SolarMutexGuard aGuard
;
3679 DBG_ASSERT( mnLockCount
> 0, "lock underflow in SvxShape!" );
3682 if( mnLockCount
== 0 )
3687 void SAL_CALL
SvxShape::setActionLocks( sal_Int16 nLock
)
3689 ::SolarMutexGuard aGuard
;
3691 if( (mnLockCount
== 0) && (nLock
!= 0) )
3694 if( (mnLockCount
!= 0) && (nLock
== 0) )
3697 mnLockCount
= static_cast<sal_uInt16
>(nLock
);
3701 sal_Int16 SAL_CALL
SvxShape::resetActionLocks( )
3703 ::SolarMutexGuard aGuard
;
3705 if( mnLockCount
!= 0 )
3708 sal_Int16 nOldLocks
= static_cast<sal_Int16
>(mnLockCount
);
3715 /** since polygon shapes can change their kind during editing, we have
3717 Circle shapes also change their kind, but they are all treated equal
3718 so no update is necessary.
3720 void SvxShape::updateShapeKind()
3722 switch( mpImpl
->mnObjId
)
3734 const sal_uInt32 nId
= GetSdrObject()->GetObjIdentifier();
3736 if( nId
!= mpImpl
->mnObjId
)
3738 mpImpl
->mnObjId
= nId
;
3746 SvxShapeText::SvxShapeText(SdrObject
* pObject
)
3747 : SvxShape( pObject
, getSvxMapProvider().GetMap(SVXMAP_TEXT
), getSvxMapProvider().GetPropertySet(SVXMAP_TEXT
, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
3750 SetEditSource( new SvxTextEditSource( pObject
, nullptr ) );
3754 SvxShapeText::SvxShapeText(SdrObject
* pObject
, const SfxItemPropertyMapEntry
* pPropertyMap
, const SvxItemPropertySet
* pPropertySet
)
3755 : SvxShape( pObject
, pPropertyMap
, pPropertySet
), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
3758 SetEditSource( new SvxTextEditSource( pObject
, nullptr ) );
3762 SvxShapeText::~SvxShapeText() throw ()
3764 // check if only this instance is registered at the ranges
3765 DBG_ASSERT( (nullptr == GetEditSource()) || (GetEditSource()->getRanges().size()==1),
3766 "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!");
3769 void SvxShapeText::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
3771 if( pNewObj
&& (nullptr == GetEditSource()))
3772 SetEditSource( new SvxTextEditSource( pNewObj
, nullptr ) );
3773 SvxShape::Create( pNewObj
, pNewPage
);
3778 uno::Any SAL_CALL
SvxShapeText::queryInterface( const uno::Type
& rType
)
3780 return SvxShape::queryInterface( rType
);
3784 uno::Any SAL_CALL
SvxShapeText::queryAggregation( const uno::Type
& rType
)
3786 uno::Any
aAny( SvxShape::queryAggregation( rType
) );
3787 if( aAny
.hasValue() )
3790 return SvxUnoTextBase::queryAggregation( rType
);
3796 OUString SAL_CALL
SvxShapeText::getImplementationName()
3798 return "SvxShapeText";
3802 uno::Sequence
< OUString
> SAL_CALL
SvxShapeText::getSupportedServiceNames()
3804 return SvxShape::getSupportedServiceNames();
3808 sal_Bool SAL_CALL
SvxShapeText::supportsService( const OUString
& ServiceName
)
3810 return cppu::supportsService(static_cast<SvxShape
*>(this), ServiceName
);
3815 uno::Sequence
< uno::Type
> SAL_CALL
SvxShapeText::getTypes()
3817 return SvxShape::getTypes();
3820 sal_Int64 SAL_CALL
SvxShapeText::getSomething( const css::uno::Sequence
< sal_Int8
>& rId
)
3822 const sal_Int64 nReturn
= SvxShape::getSomething( rId
);
3826 return SvxUnoTextBase::getSomething( rId
);
3830 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeText::getImplementationId()
3832 return css::uno::Sequence
<sal_Int8
>();
3836 /** called from the XActionLockable interface methods on initial locking */
3837 void SvxShapeText::lock()
3839 SvxTextEditSource
* pEditSource
= static_cast<SvxTextEditSource
*>(GetEditSource());
3841 pEditSource
->lock();
3845 /** called from the XActionLockable interface methods on final unlock */
3846 void SvxShapeText::unlock()
3848 SvxTextEditSource
* pEditSource
= static_cast<SvxTextEditSource
*>(GetEditSource());
3850 pEditSource
->unlock();
3853 // css::text::XTextRange
3854 uno::Reference
< text::XTextRange
> SAL_CALL
SvxShapeText::getStart()
3856 ::SolarMutexGuard aGuard
;
3857 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : nullptr;
3859 ::GetSelection( maSelection
, pForwarder
);
3860 return SvxUnoTextBase::getStart();
3864 uno::Reference
< text::XTextRange
> SAL_CALL
SvxShapeText::getEnd()
3866 ::SolarMutexGuard aGuard
;
3867 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : nullptr;
3869 ::GetSelection( maSelection
, pForwarder
);
3870 return SvxUnoTextBase::getEnd();
3873 OUString SAL_CALL
SvxShapeText::getString()
3875 ::SolarMutexGuard aGuard
;
3876 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : nullptr;
3878 ::GetSelection( maSelection
, pForwarder
);
3879 return SvxUnoTextBase::getString();
3883 void SAL_CALL
SvxShapeText::setString( const OUString
& aString
)
3885 ::SolarMutexGuard aGuard
;
3886 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : nullptr;
3888 ::GetSelection( maSelection
, pForwarder
);
3889 SvxUnoTextBase::setString( aString
);
3892 // override these for special property handling in subcasses. Return true if property is handled
3893 bool SvxShapeText::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
3896 // since SdrTextObj::SetVerticalWriting exchanges
3897 // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT,
3898 // we have to set the textdirection here
3900 if( pProperty
->nWID
== SDRATTR_TEXTDIRECTION
)
3902 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( GetSdrObject() );
3905 css::text::WritingMode eMode
;
3906 if( rValue
>>= eMode
)
3908 pTextObj
->SetVerticalWriting( eMode
== css::text::WritingMode_TB_RL
);
3913 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
3916 bool SvxShapeText::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, css::uno::Any
& rValue
)
3918 if( pProperty
->nWID
== SDRATTR_TEXTDIRECTION
)
3920 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( GetSdrObject() );
3921 if( pTextObj
&& pTextObj
->IsVerticalWriting() )
3922 rValue
<<= css::text::WritingMode_TB_RL
;
3924 rValue
<<= css::text::WritingMode_LR_TB
;
3928 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
3931 bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertySimpleEntry
* pProperty
, css::beans::PropertyState
& rState
)
3933 return SvxShape::getPropertyStateImpl( pProperty
, rState
);
3936 bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry
* pProperty
)
3938 return SvxShape::setPropertyToDefaultImpl( pProperty
);
3941 SvxShapeRect::SvxShapeRect(SdrObject
* pObj
)
3942 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_SHAPE
), getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE
, SdrObject::GetGlobalDrawObjectItemPool()))
3946 SvxShapeRect::~SvxShapeRect() throw()
3950 uno::Any SAL_CALL
SvxShapeRect::queryInterface( const uno::Type
& rType
)
3952 return SvxShapeText::queryInterface( rType
);
3955 uno::Any SAL_CALL
SvxShapeRect::queryAggregation( const uno::Type
& rType
)
3957 return SvxShapeText::queryAggregation( rType
);
3962 uno::Sequence
< OUString
> SvxShapeRect::getSupportedServiceNames()
3964 return SvxShape::getSupportedServiceNames();
3967 /** returns a StarOffice API wrapper for the given SdrObject */
3968 uno::Reference
< drawing::XShape
> GetXShapeForSdrObject( SdrObject
* pObj
) throw ()
3970 uno::Reference
< drawing::XShape
> xShape( pObj
->getUnoShape(), uno::UNO_QUERY
);
3974 /** returns the SdrObject from the given StarOffice API wrapper */
3975 SdrObject
* GetSdrObjectFromXShape( const uno::Reference
< drawing::XShape
>& xShape
) throw()
3977 SvxShape
* pShape
= comphelper::getUnoTunnelImplementation
<SvxShape
>( xShape
);
3978 return pShape
? pShape
->GetSdrObject() : nullptr;
3982 SdrObject
* SdrObject::getSdrObjectFromXShape( const css::uno::Reference
< css::uno::XInterface
>& xInt
)
3984 SvxShape
* pSvxShape
= comphelper::getUnoTunnelImplementation
<SvxShape
>( xInt
);
3985 return pSvxShape
? pSvxShape
->GetSdrObject() : nullptr;
3988 uno::Any
SvxItemPropertySet_getPropertyValue( const SfxItemPropertySimpleEntry
* pMap
, const SfxItemSet
& rSet
)
3990 if(!pMap
|| !pMap
->nWID
)
3993 // Check is for items that store either metric values if they are positive or percentage if they are negative.
3994 bool bDontConvertNegativeValues
= ( pMap
->nWID
== XATTR_FILLBMP_SIZEX
|| pMap
->nWID
== XATTR_FILLBMP_SIZEY
);
3995 return SvxItemPropertySet::getPropertyValue( pMap
, rSet
, (pMap
->nWID
!= SDRATTR_XMLATTRIBUTES
), bDontConvertNegativeValues
);
3998 void SvxItemPropertySet_setPropertyValue( const SfxItemPropertySimpleEntry
* pMap
, const uno::Any
& rVal
, SfxItemSet
& rSet
)
4000 if(!pMap
|| !pMap
->nWID
)
4003 bool bDontConvertNegativeValues
= ( pMap
->nWID
== XATTR_FILLBMP_SIZEX
|| pMap
->nWID
== XATTR_FILLBMP_SIZEY
);
4004 SvxItemPropertySet::setPropertyValue( pMap
, rVal
, rSet
, bDontConvertNegativeValues
);
4007 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */