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/interfacecontainer3.hxx>
34 #include <comphelper/scopeguard.hxx>
35 #include <comphelper/servicehelper.hxx>
36 #include <toolkit/helper/vclunohelper.hxx>
37 #include <vcl/gfxlink.hxx>
38 #include <vcl/virdev.hxx>
39 #include <svx/sdangitm.hxx>
40 #include <svx/svdlayer.hxx>
41 #include <svx/svdopage.hxx>
42 #include <svx/xflbstit.hxx>
43 #include <svx/xflbmtit.hxx>
44 #include <svx/xlnstit.hxx>
45 #include <svx/xlnedit.hxx>
46 #include <svx/xlnclit.hxx>
47 #include <svx/svdmodel.hxx>
48 #include <svx/svdobjkind.hxx>
49 #include <svx/unopage.hxx>
50 #include <svx/unoshape.hxx>
51 #include <svx/unoshtxt.hxx>
52 #include <svx/svdpage.hxx>
53 #include <svx/unoshprp.hxx>
54 #include <svx/svdograf.hxx>
55 #include <svx/unoapi.hxx>
56 #include <svx/svdomeas.hxx>
57 #include <svx/svdpool.hxx>
58 #include <comphelper/diagnose_ex.hxx>
59 #include <tools/stream.hxx>
60 #include <tools/gen.hxx>
61 #include <tools/UnitConversion.hxx>
62 #include <svx/svdoedge.hxx>
63 #include <svx/svdocapt.hxx>
64 #include <svx/obj3d.hxx>
65 #include <svx/xflftrit.hxx>
66 #include <svx/xtable.hxx>
67 #include <svx/xbtmpit.hxx>
68 #include <svx/xfillit0.hxx>
69 #include <svx/xflgrit.hxx>
70 #include <svx/xflhtit.hxx>
71 #include <svx/xlineit0.hxx>
72 #include <svx/xlndsit.hxx>
73 #include <svx/unomaster.hxx>
74 #include <basegfx/matrix/b2dhommatrix.hxx>
75 #include <basegfx/matrix/b2dhommatrixtools.hxx>
76 #include <basegfx/polygon/b2dpolypolygontools.hxx>
77 #include "gluepts.hxx"
78 #include "shapeimpl.hxx"
79 #include <sal/log.hxx>
81 #include <svx/lathe3d.hxx>
82 #include <extrud3d.hxx>
83 #include <svx/sdr/contact/viewcontact.hxx>
84 #include <drawinglayer/converters.hxx>
85 #include <drawinglayer/geometry/viewinformation2d.hxx>
86 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
88 #include <vcl/gdimtf.hxx>
89 #include <vcl/wmf.hxx>
90 #include <svx/sdtfsitm.hxx>
91 #include <svx/svdopath.hxx>
92 #include <svx/SvxXTextColumns.hxx>
93 #include <svx/xflclit.hxx>
94 #include <editeng/frmdiritem.hxx>
101 #include <bitmaps.hlst>
103 using namespace ::osl
;
104 using namespace ::cppu
;
105 using namespace ::com::sun::star
;
106 using namespace ::com::sun::star::uno
;
107 using namespace ::com::sun::star::lang
;
108 using namespace ::com::sun::star::container
;
109 using svx::PropertyValueProvider
;
115 std::optional
<SfxItemSet
> mxItemSet
;
117 SvxShapeMaster
* mpMaster
;
120 /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when
121 * a SvxShape::Create() call is executed. It is then set to the created
122 * SdrObject so a multiple call to SvxShape::Create() with same SdrObject
125 ::unotools::WeakReference
< SdrObject
> mxCreatedObj
;
128 ::comphelper::OInterfaceContainerHelper4
<css::lang::XEventListener
> maDisposeListeners
;
129 svx::PropertyChangeNotifier maPropertyNotifier
;
131 SvxShapeImpl( SvxShape
& _rAntiImpl
)
132 :mnObjId( SdrObjKind::NONE
)
134 ,mbDisposing( false )
135 ,maPropertyNotifier( _rAntiImpl
)
142 class ShapePositionProvider
: public PropertyValueProvider
145 static constexpr OUStringLiteral sPosition
= u
"Position";
146 explicit ShapePositionProvider( SvxShape
& _shape
)
147 :PropertyValueProvider( _shape
, sPosition
)
152 virtual void getCurrentValue( Any
& _out_rCurrentValue
) const override
154 _out_rCurrentValue
<<= static_cast< SvxShape
& >( getContext() ).getPosition();
159 class ShapeSizeProvider
: public PropertyValueProvider
162 static constexpr OUStringLiteral sSize
= u
"Size";
163 explicit ShapeSizeProvider( SvxShape
& _shape
)
164 :PropertyValueProvider( _shape
, sSize
)
169 virtual void getCurrentValue( Any
& _out_rCurrentValue
) const override
171 _out_rCurrentValue
<<= static_cast< SvxShape
& >( getContext() ).getSize();
175 /// Calculates what scaling factor will be used for autofit text scaling of this shape.
176 double GetTextFitToSizeScale(SdrObject
* pObject
)
178 SdrTextObj
* pTextObj
= DynCastSdrTextObj(pObject
);
184 const SfxItemSet
& rTextObjSet
= pTextObj
->GetMergedItemSet();
185 if (rTextObjSet
.GetItem
<SdrTextFitToSizeTypeItem
>(SDRATTR_TEXT_FITTOSIZE
)->GetValue()
186 != drawing::TextFitToSizeType_AUTOFIT
)
191 return pTextObj
->GetFontScale();
195 SvxShape::SvxShape( SdrObject
* pObject
)
197 , mpImpl( new SvxShapeImpl( *this ) )
198 , mbIsMultiPropertyCall(false)
199 , mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE
, SdrObject::GetGlobalDrawObjectItemPool()))
200 , maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE
))
201 , mxSdrObject(pObject
)
208 SvxShape::SvxShape( SdrObject
* pObject
, o3tl::span
<const SfxItemPropertyMapEntry
> pEntries
, const SvxItemPropertySet
* pPropertySet
)
210 , mpImpl( new SvxShapeImpl( *this ) )
211 , mbIsMultiPropertyCall(false)
212 , mpPropSet(pPropertySet
)
213 , maPropMapEntries(pEntries
)
214 , mxSdrObject(pObject
)
221 SvxShape::~SvxShape() noexcept
223 ::SolarMutexGuard aGuard
;
225 DBG_ASSERT( mnLockCount
== 0, "Locked shape was disposed!" );
227 if ( mpImpl
->mpMaster
)
228 mpImpl
->mpMaster
->dispose();
232 EndListening(mxSdrObject
->getSdrModelFromSdrObject());
233 mxSdrObject
->setUnoShape(nullptr);
237 EndListeningAll(); // call explicitly within SolarMutexGuard
241 void SvxShape::InvalidateSdrObject()
245 EndListening(mxSdrObject
->getSdrModelFromSdrObject());
250 void SvxShape::setShapeKind( SdrObjKind nKind
)
252 mpImpl
->mnObjId
= nKind
;
256 SdrObjKind
SvxShape::getShapeKind() const
258 return mpImpl
->mnObjId
;
262 void SvxShape::setMaster( SvxShapeMaster
* pMaster
)
264 mpImpl
->mpMaster
= pMaster
;
268 uno::Any SAL_CALL
SvxShape::queryAggregation( const uno::Type
& rType
)
270 if( mpImpl
->mpMaster
)
273 if( mpImpl
->mpMaster
->queryAggregation( rType
, aAny
) )
277 return SvxShape_UnoImplHelper::queryAggregation(rType
);
280 const css::uno::Sequence
< sal_Int8
> & SvxShape::getUnoTunnelId() noexcept
282 static const comphelper::UnoIdInit theSvxShapeUnoTunnelId
;
283 return theSvxShapeUnoTunnelId
.getSeq();
286 sal_Int64 SAL_CALL
SvxShape::getSomething( const css::uno::Sequence
< sal_Int8
>& rId
)
288 return comphelper::getSomethingImpl(rId
, this);
292 void SvxShape::notifyPropertyChange(svx::ShapePropertyProviderId eProp
)
294 std::unique_lock
g(m_aMutex
);
295 mpImpl
->maPropertyNotifier
.notifyPropertyChange(g
, eProp
);
298 void SvxShape::registerProvider(svx::ShapePropertyProviderId eProp
, std::unique_ptr
<svx::PropertyValueProvider
> provider
)
300 mpImpl
->maPropertyNotifier
.registerProvider(eProp
, std::move(provider
));
303 void SvxShape::impl_construct()
305 mpImpl
->maPropertyNotifier
.registerProvider( svx::ShapePropertyProviderId::Position
,
306 std::make_unique
<ShapePositionProvider
>( *this ) );
307 mpImpl
->maPropertyNotifier
.registerProvider( svx::ShapePropertyProviderId::Size
,
308 std::make_unique
<ShapeSizeProvider
>( *this ) );
310 if ( HasSdrObject() )
312 StartListening(GetSdrObject()->getSdrModelFromSdrObject());
313 impl_initFromSdrObject();
318 void SvxShape::impl_initFromSdrObject()
320 DBG_TESTSOLARMUTEX();
321 OSL_PRECOND( HasSdrObject(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
322 if ( !HasSdrObject() )
325 osl_atomic_increment( &m_refCount
);
327 GetSdrObject()->setUnoShape(this);
329 osl_atomic_decrement( &m_refCount
);
332 // Do not simply return when no model but do the type corrections
334 const SdrInventor nInventor
= GetSdrObject()->GetObjInventor();
336 // is it one of ours (svx) ?
337 if( !(nInventor
== SdrInventor::Default
|| nInventor
== SdrInventor::E3d
|| nInventor
== SdrInventor::FmForm
) )
340 if(nInventor
== SdrInventor::FmForm
)
342 mpImpl
->mnObjId
= SdrObjKind::UNO
;
346 mpImpl
->mnObjId
= GetSdrObject()->GetObjIdentifier();
349 switch(mpImpl
->mnObjId
)
351 case SdrObjKind::CircleCut
: // segment of circle
352 case SdrObjKind::CircleArc
: // arc of circle
353 case SdrObjKind::CircleSection
: // sector
354 mpImpl
->mnObjId
= SdrObjKind::CircleOrEllipse
;
361 void SvxShape::Create( SdrObject
* pNewObj
, SvxDrawPage
* /*pNewPage*/ )
363 DBG_TESTSOLARMUTEX();
365 assert( pNewObj
&& "SvxShape::Create: invalid new object!" );
369 rtl::Reference
<SdrObject
> pCreatedObj
= mpImpl
->mxCreatedObj
.get();
370 assert( ( !pCreatedObj
|| ( pCreatedObj
== pNewObj
) ) &&
371 "SvxShape::Create: the same shape used for two different objects?! Strange ..." );
373 // Correct condition (#i52126#)
374 if ( pCreatedObj
== pNewObj
)
377 // Correct condition (#i52126#)
378 mpImpl
->mxCreatedObj
= pNewObj
;
382 EndListening( GetSdrObject()->getSdrModelFromSdrObject() );
385 mxSdrObject
= pNewObj
;
389 StartListening( GetSdrObject()->getSdrModelFromSdrObject() );
392 OSL_ENSURE( !mbIsMultiPropertyCall
, "SvxShape::Create: hmm?" );
393 // this was previously set in impl_initFromSdrObject, but I think it was superfluous
394 // (it definitely was in the other context where it was called, but I strongly suppose
395 // it was also superfluous when called from here)
396 impl_initFromSdrObject();
398 ObtainSettingsFromPropertySet( *mpPropSet
);
401 SdrObjUserCall
* pUser
= GetSdrObject()->GetUserCall();
402 GetSdrObject()->SetUserCall(nullptr);
404 setPosition( maPosition
);
407 // restore user call after we set the initial size
408 GetSdrObject()->SetUserCall( pUser
);
410 // if this shape was already named, use this name
411 if( !maShapeName
.isEmpty() )
413 GetSdrObject()->SetName( maShapeName
);
418 void SvxShape::ForceMetricToItemPoolMetric(Pair
& rPoint
) const noexcept
420 DBG_TESTSOLARMUTEX();
424 MapUnit
eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
425 if(eMapUnit
== MapUnit::Map100thMM
)
428 if (const auto eTo
= MapToO3tlLength(eMapUnit
); eTo
!= o3tl::Length::invalid
)
430 rPoint
.A() = o3tl::convert(rPoint
.A(), o3tl::Length::mm100
, eTo
);
431 rPoint
.B() = o3tl::convert(rPoint
.B(), o3tl::Length::mm100
, eTo
);
435 OSL_FAIL("AW: Missing unit translation to PoolMetric!");
439 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon
& rPolyPolygon
) const noexcept
441 DBG_TESTSOLARMUTEX();
445 GetSdrObject()->ForceMetricToItemPoolMetric(rPolyPolygon
);
448 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DHomMatrix
& rB2DHomMatrix
) const noexcept
450 DBG_TESTSOLARMUTEX();
454 MapUnit
eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
455 if(eMapUnit
== MapUnit::Map100thMM
)
458 if (const auto eTo
= MapToO3tlLength(eMapUnit
); eTo
!= o3tl::Length::invalid
)
460 const double fConvert(o3tl::convert(1.0, o3tl::Length::mm100
, eTo
));
461 const basegfx::utils::B2DHomMatrixBufferedDecompose
aDecomposedTransform(rB2DHomMatrix
);
462 rB2DHomMatrix
= basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
463 aDecomposedTransform
.getScale() * fConvert
,
464 aDecomposedTransform
.getShearX(),
465 aDecomposedTransform
.getRotate(),
466 aDecomposedTransform
.getTranslate() * fConvert
);
470 OSL_FAIL("Missing unit translation to PoolMetric!");
474 void SvxShape::ForceMetricTo100th_mm(Pair
& rPoint
) const noexcept
476 DBG_TESTSOLARMUTEX();
480 MapUnit eMapUnit
= GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
481 if(eMapUnit
== MapUnit::Map100thMM
)
484 if (const auto eFrom
= MapToO3tlLength(eMapUnit
); eFrom
!= o3tl::Length::invalid
)
486 rPoint
.A() = o3tl::convert(rPoint
.A(), eFrom
, o3tl::Length::mm100
);
487 rPoint
.B() = o3tl::convert(rPoint
.B(), eFrom
, o3tl::Length::mm100
);
491 OSL_FAIL("AW: Missing unit translation to 100th mm!");
495 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon
& rPolyPolygon
) const noexcept
497 DBG_TESTSOLARMUTEX();
501 MapUnit eMapUnit
= GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
502 if(eMapUnit
== MapUnit::Map100thMM
)
505 if (const auto eFrom
= MapToO3tlLength(eMapUnit
); eFrom
!= o3tl::Length::invalid
)
507 const double fConvert(o3tl::convert(1.0, eFrom
, o3tl::Length::mm100
));
508 rPolyPolygon
.transform(basegfx::utils::createScaleB2DHomMatrix(fConvert
, fConvert
));
512 OSL_FAIL("Missing unit translation to 100th mm!");
516 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DHomMatrix
& rB2DHomMatrix
) const noexcept
518 DBG_TESTSOLARMUTEX();
522 MapUnit eMapUnit
= GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
523 if(eMapUnit
== MapUnit::Map100thMM
)
526 if (const auto eFrom
= MapToO3tlLength(eMapUnit
); eFrom
!= o3tl::Length::invalid
)
528 const double fConvert(o3tl::convert(1.0, eFrom
, o3tl::Length::mm100
));
529 const basegfx::utils::B2DHomMatrixBufferedDecompose
aDecomposedTransform(rB2DHomMatrix
);
530 rB2DHomMatrix
= basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
531 aDecomposedTransform
.getScale() * fConvert
,
532 aDecomposedTransform
.getShearX(),
533 aDecomposedTransform
.getRotate(),
534 aDecomposedTransform
.getTranslate() * fConvert
);
538 OSL_FAIL("Missing unit translation to 100th mm!");
542 static void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet
& rPropSet
, SvxItemPropertySetUsrAnys
& rAnys
,
543 SfxItemSet
& rSet
, const uno::Reference
< beans::XPropertySet
>& xSet
, const SfxItemPropertyMap
* pMap
)
545 if(!rAnys
.AreThereOwnUsrAnys())
548 const SfxItemPropertyMap
& rSrc
= rPropSet
.getPropertyMap();
550 for(const SfxItemPropertyMapEntry
* pSrcProp
: rSrc
.getPropertyEntries())
552 const sal_uInt16 nWID
= pSrcProp
->nWID
;
553 if(SfxItemPool::IsWhich(nWID
)
554 && (nWID
< OWN_ATTR_VALUE_START
|| nWID
> OWN_ATTR_VALUE_END
)
555 && rAnys
.GetUsrAnyForID(*pSrcProp
))
556 rSet
.Put(rSet
.GetPool()->GetDefaultItem(nWID
));
559 for(const SfxItemPropertyMapEntry
* pSrcProp
: rSrc
.getPropertyEntries())
563 uno::Any
* pUsrAny
= rAnys
.GetUsrAnyForID(*pSrcProp
);
566 // search for equivalent entry in pDst
567 const SfxItemPropertyMapEntry
* pEntry
= pMap
->getByName( pSrcProp
->aName
);
571 if(pEntry
->nWID
>= OWN_ATTR_VALUE_START
&& pEntry
->nWID
<= OWN_ATTR_VALUE_END
)
573 // special ID in PropertySet, can only be set
574 // directly at the object
575 xSet
->setPropertyValue( pSrcProp
->aName
, *pUsrAny
);
579 SvxItemPropertySet_setPropertyValue(pEntry
, *pUsrAny
, rSet
);
585 rAnys
.ClearAllUsrAny();
589 void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet
& rPropSet
)
591 DBG_TESTSOLARMUTEX();
592 if(HasSdrObject() && maUrsAnys
.AreThereOwnUsrAnys())
594 SfxItemSetFixed
<SDRATTR_START
, SDRATTR_END
> aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool() );
595 Reference
< beans::XPropertySet
> xShape(this);
596 SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet
, maUrsAnys
, aSet
, xShape
, &mpPropSet
->getPropertyMap() );
598 GetSdrObject()->SetMergedItemSetAndBroadcast(aSet
);
600 GetSdrObject()->ApplyNotPersistAttr( aSet
);
604 uno::Any
SvxShape::GetBitmap( bool bMetaFile
/* = false */ ) const
606 DBG_TESTSOLARMUTEX();
609 if(!HasSdrObject() || nullptr == GetSdrObject()->getSdrPageFromSdrObject())
614 // tdf#118662 Emulate old behaviour of XclObjComment (see there)
615 const SdrCaptionObj
* pSdrCaptionObj(dynamic_cast<SdrCaptionObj
*>(GetSdrObject()));
616 if(nullptr != pSdrCaptionObj
&& pSdrCaptionObj
->isSuppressGetBitmap())
621 // tdf#119180 If we do not ask for Metafile and we access a SdrGrafObj,
622 // and content exists and is a Bitmap, take the shortcut.
623 // Do *not* do this for Metafile - as can be seen, requested in that case
624 // is a byte-sequence of a saved WMF format file (see below)
627 const SdrGrafObj
* pSdrGrafObj(dynamic_cast<SdrGrafObj
*>(GetSdrObject()));
629 if(nullptr != pSdrGrafObj
)
631 const Graphic
& rGraphic(pSdrGrafObj
->GetGraphic());
633 if(GraphicType::Bitmap
== rGraphic
.GetType())
635 Reference
< awt::XBitmap
> xBmp( rGraphic
.GetXGraphic(), UNO_QUERY
);
643 // tdf#118662 instead of creating an E3dView instance every time to paint
644 // a single SdrObject, use the existing SdrObject::SingleObjectPainter to
645 // use less resources and runtime
648 ScopedVclPtrInstance
< VirtualDevice
> pVDev
;
649 const tools::Rectangle
aBoundRect(GetSdrObject()->GetCurrentBoundRect());
652 pVDev
->SetMapMode(MapMode(MapUnit::Map100thMM
));
653 pVDev
->EnableOutput(false);
655 GetSdrObject()->SingleObjectPainter(*pVDev
);
658 aMtf
.Move(-aBoundRect
.Left(), -aBoundRect
.Top());
659 aMtf
.SetPrefMapMode(MapMode(MapUnit::Map100thMM
));
660 aMtf
.SetPrefSize(aBoundRect
.GetSize());
662 SvMemoryStream
aDestStrm(65535, 65535);
664 ConvertGDIMetaFileToWMF(
670 const uno::Sequence
<sal_Int8
> aSeq(
671 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
672 aDestStrm
.GetEndOfData());
678 drawinglayer::primitive2d::Primitive2DContainer xPrimitives
;
679 GetSdrObject()->GetViewContact().getViewIndependentPrimitive2DContainer(xPrimitives
);
681 if(!xPrimitives
.empty())
683 const drawinglayer::geometry::ViewInformation2D aViewInformation2D
;
684 basegfx::B2DRange
aRange(
685 xPrimitives
.getB2DRange(aViewInformation2D
));
687 if(!aRange
.isEmpty())
689 const MapUnit
aSourceMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetScaleUnit());
691 if(MapUnit::Map100thMM
!= aSourceMapUnit
)
693 // tdf#119180 This is UNO API and thus works in 100th_mm,
694 // so if the MapMode from the used SdrModel is *not* equal
695 // to Map100thMM we need to embed the primitives to an adapting
696 // homogen transformation for correct values
697 const basegfx::B2DHomMatrix
aMapTransform(
698 OutputDevice::LogicToLogic(
699 MapMode(aSourceMapUnit
),
700 MapMode(MapUnit::Map100thMM
)));
702 // Embed primitives to get them in 100th mm
703 drawinglayer::primitive2d::Primitive2DReference
xEmbedRef(
704 new drawinglayer::primitive2d::TransformPrimitive2D(
706 std::move(xPrimitives
)));
708 xPrimitives
= drawinglayer::primitive2d::Primitive2DContainer
{ xEmbedRef
};
710 // Update basegfx::B2DRange aRange, too. Here we have the
711 // choice of transforming the existing value or get newly by
712 // again using 'xPrimitives.getB2DRange(aViewInformation2D)'
713 aRange
.transform(aMapTransform
);
717 drawinglayer::convertPrimitive2DContainerToBitmapEx(
718 std::move(xPrimitives
),
721 Graphic
aGraph(aBmp
);
723 aGraph
.SetPrefSize(aBmp
.GetPrefSize());
724 aGraph
.SetPrefMapMode(aBmp
.GetPrefMapMode());
726 Reference
< awt::XBitmap
> xBmp( aGraph
.GetXGraphic(), UNO_QUERY
);
735 uno::Sequence
< uno::Type
> SAL_CALL
SvxShape::getTypes()
737 if( mpImpl
->mpMaster
)
739 return mpImpl
->mpMaster
->getTypes();
748 uno::Sequence
< uno::Type
> const & SvxShape::_getTypes()
750 switch( mpImpl
->mnObjId
)
752 // shapes without text
753 case SdrObjKind::Page
:
754 case SdrObjKind::OLEPluginFrame
:
755 case SdrObjKind::OLE2Plugin
:
756 case SdrObjKind::OLE2Applet
:
757 case SdrObjKind::E3D_Cube
:
758 case SdrObjKind::E3D_Sphere
:
759 case SdrObjKind::E3D_Lathe
:
760 case SdrObjKind::E3D_Extrusion
:
761 case SdrObjKind::E3D_Polygon
:
762 case SdrObjKind::Media
:
763 case SdrObjKind::Table
:
765 static uno::Sequence
<uno::Type
> aTypeSequence
{
766 cppu::UnoType
<drawing::XShape
>::get(),
767 cppu::UnoType
<lang::XComponent
>::get(),
768 cppu::UnoType
<beans::XPropertySet
>::get(),
769 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
770 cppu::UnoType
<beans::XPropertyState
>::get(),
771 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
772 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
773 cppu::UnoType
<container::XChild
>::get(),
774 cppu::UnoType
<lang::XServiceInfo
>::get(),
775 cppu::UnoType
<lang::XTypeProvider
>::get(),
776 cppu::UnoType
<lang::XUnoTunnel
>::get(),
777 cppu::UnoType
<container::XNamed
>::get(),
780 return aTypeSequence
;
783 case SdrObjKind::Group
:
785 static uno::Sequence
<uno::Type
> aTypeSequence
{
786 cppu::UnoType
<drawing::XShape
>::get(),
787 cppu::UnoType
<lang::XComponent
>::get(),
788 cppu::UnoType
<beans::XPropertySet
>::get(),
789 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
790 cppu::UnoType
<beans::XPropertyState
>::get(),
791 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
792 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
793 cppu::UnoType
<container::XChild
>::get(),
794 cppu::UnoType
<lang::XServiceInfo
>::get(),
795 cppu::UnoType
<lang::XTypeProvider
>::get(),
796 cppu::UnoType
<lang::XUnoTunnel
>::get(),
797 cppu::UnoType
<container::XNamed
>::get(),
798 cppu::UnoType
<drawing::XShapes
>::get(),
799 cppu::UnoType
<drawing::XShapeGroup
>::get(),
802 return aTypeSequence
;
805 case SdrObjKind::Edge
:
807 static uno::Sequence
<uno::Type
> aTypeSequence
{
808 cppu::UnoType
<drawing::XShape
>::get(),
809 cppu::UnoType
<lang::XComponent
>::get(),
810 cppu::UnoType
<beans::XPropertySet
>::get(),
811 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
812 cppu::UnoType
<beans::XPropertyState
>::get(),
813 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
814 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
815 cppu::UnoType
<container::XChild
>::get(),
816 cppu::UnoType
<lang::XServiceInfo
>::get(),
817 cppu::UnoType
<lang::XTypeProvider
>::get(),
818 cppu::UnoType
<lang::XUnoTunnel
>::get(),
819 cppu::UnoType
<container::XNamed
>::get(),
820 cppu::UnoType
<drawing::XConnectorShape
>::get(),
821 // from SvxUnoTextBase::getTypes()
822 cppu::UnoType
<text::XTextAppend
>::get(),
823 cppu::UnoType
<text::XTextCopy
>::get(),
824 cppu::UnoType
<container::XEnumerationAccess
>::get(),
825 cppu::UnoType
<text::XTextRangeMover
>::get(),
828 return aTypeSequence
;
831 case SdrObjKind::UNO
:
833 static uno::Sequence
<uno::Type
> aTypeSequence
{
834 cppu::UnoType
<drawing::XShape
>::get(),
835 cppu::UnoType
<lang::XComponent
>::get(),
836 cppu::UnoType
<beans::XPropertySet
>::get(),
837 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
838 cppu::UnoType
<beans::XPropertyState
>::get(),
839 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
840 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
841 cppu::UnoType
<container::XChild
>::get(),
842 cppu::UnoType
<lang::XServiceInfo
>::get(),
843 cppu::UnoType
<lang::XTypeProvider
>::get(),
844 cppu::UnoType
<lang::XUnoTunnel
>::get(),
845 cppu::UnoType
<container::XNamed
>::get(),
846 cppu::UnoType
<drawing::XControlShape
>::get(),
849 return aTypeSequence
;
852 case SdrObjKind::E3D_Scene
:
854 static uno::Sequence
<uno::Type
> aTypeSequence
{
855 cppu::UnoType
<drawing::XShape
>::get(),
856 cppu::UnoType
<lang::XComponent
>::get(),
857 cppu::UnoType
<beans::XPropertySet
>::get(),
858 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
859 cppu::UnoType
<beans::XPropertyState
>::get(),
860 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
861 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
862 cppu::UnoType
<container::XChild
>::get(),
863 cppu::UnoType
<lang::XServiceInfo
>::get(),
864 cppu::UnoType
<lang::XTypeProvider
>::get(),
865 cppu::UnoType
<lang::XUnoTunnel
>::get(),
866 cppu::UnoType
<container::XNamed
>::get(),
867 cppu::UnoType
<drawing::XShapes
>::get(),
870 return aTypeSequence
;
872 case SdrObjKind::CustomShape
:
874 static uno::Sequence
<uno::Type
> aTypeSequence
{
875 cppu::UnoType
<drawing::XShape
>::get(),
876 cppu::UnoType
<lang::XComponent
>::get(),
877 cppu::UnoType
<beans::XPropertySet
>::get(),
878 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
879 cppu::UnoType
<beans::XPropertyState
>::get(),
880 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
881 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
882 cppu::UnoType
<container::XChild
>::get(),
883 cppu::UnoType
<lang::XServiceInfo
>::get(),
884 cppu::UnoType
<lang::XTypeProvider
>::get(),
885 cppu::UnoType
<lang::XUnoTunnel
>::get(),
886 cppu::UnoType
<container::XNamed
>::get(),
887 // from SvxUnoTextBase::getTypes()
888 cppu::UnoType
<text::XText
>::get(),
889 cppu::UnoType
<container::XEnumerationAccess
>::get(),
890 cppu::UnoType
<text::XTextRangeMover
>::get(),
891 cppu::UnoType
<drawing::XEnhancedCustomShapeDefaulter
>::get(),
894 return aTypeSequence
;
897 case SdrObjKind::Rectangle
:
898 case SdrObjKind::CircleOrEllipse
:
899 case SdrObjKind::Measure
:
900 case SdrObjKind::Line
:
901 case SdrObjKind::Polygon
:
902 case SdrObjKind::PolyLine
:
903 case SdrObjKind::PathLine
:
904 case SdrObjKind::PathFill
:
905 case SdrObjKind::FreehandLine
:
906 case SdrObjKind::FreehandFill
:
907 case SdrObjKind::PathPoly
:
908 case SdrObjKind::PathPolyLine
:
909 case SdrObjKind::Graphic
:
910 case SdrObjKind::Text
:
911 case SdrObjKind::Caption
:
912 case SdrObjKind::OLE2
: // #i118485# Moved to shapes with text
915 static uno::Sequence
<uno::Type
> aTypeSequence
{
916 cppu::UnoType
<drawing::XShape
>::get(),
917 cppu::UnoType
<lang::XComponent
>::get(),
918 cppu::UnoType
<beans::XPropertySet
>::get(),
919 cppu::UnoType
<beans::XMultiPropertySet
>::get(),
920 cppu::UnoType
<beans::XPropertyState
>::get(),
921 cppu::UnoType
<beans::XMultiPropertyStates
>::get(),
922 cppu::UnoType
<drawing::XGluePointsSupplier
>::get(),
923 cppu::UnoType
<container::XChild
>::get(),
924 cppu::UnoType
<lang::XServiceInfo
>::get(),
925 cppu::UnoType
<lang::XTypeProvider
>::get(),
926 cppu::UnoType
<lang::XUnoTunnel
>::get(),
927 cppu::UnoType
<container::XNamed
>::get(),
928 // from SvxUnoTextBase::getTypes()
929 cppu::UnoType
<text::XTextAppend
>::get(),
930 cppu::UnoType
<text::XTextCopy
>::get(),
931 cppu::UnoType
<container::XEnumerationAccess
>::get(),
932 cppu::UnoType
<text::XTextRangeMover
>::get(),
935 return aTypeSequence
;
941 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShape::getImplementationId()
943 return css::uno::Sequence
<sal_Int8
>();
946 void SvxShape::Notify( SfxBroadcaster
&, const SfxHint
& rHint
) noexcept
948 DBG_TESTSOLARMUTEX();
950 // do cheap checks first, this method is hot
951 if (rHint
.GetId() != SfxHintId::ThisIsAnSdrHint
)
955 const SdrHint
* pSdrHint
= static_cast<const SdrHint
*>(&rHint
);
956 // #i55919# SdrHintKind::ObjectChange is only interesting if it's for this object
957 if ((pSdrHint
->GetKind() != SdrHintKind::ModelCleared
) &&
958 (pSdrHint
->GetKind() != SdrHintKind::ObjectChange
|| pSdrHint
->GetObject() != mxSdrObject
.get() ))
961 // prevent object being deleted from under us
962 rtl::Reference
<SdrObject
> xSdrSelf(mxSdrObject
);
963 uno::Reference
< uno::XInterface
> xSelf( mxSdrObject
->getWeakUnoShape() );
966 EndListening(mxSdrObject
->getSdrModelFromSdrObject());
971 if (pSdrHint
->GetKind() == SdrHintKind::ObjectChange
)
975 else // (pSdrHint->GetKind() == SdrHintKind::ModelCleared)
977 EndListening(mxSdrObject
->getSdrModelFromSdrObject());
978 mxSdrObject
->setUnoShape(nullptr);
981 if(!mpImpl
->mbDisposing
)
989 // The "*LogicRectHack" functions also existed in sch, and those
990 // duplicate symbols cause Bad Things To Happen (TM) #i9462#.
991 // Prefixing with 'svx' and marking static to make sure name collisions
994 static bool svx_needLogicRectHack( SdrObject
const * pObj
)
996 if( pObj
->GetObjInventor() == SdrInventor::Default
)
998 switch(pObj
->GetObjIdentifier())
1000 case SdrObjKind::Group
:
1001 case SdrObjKind::Line
:
1002 case SdrObjKind::Polygon
:
1003 case SdrObjKind::PolyLine
:
1004 case SdrObjKind::PathLine
:
1005 case SdrObjKind::PathFill
:
1006 case SdrObjKind::FreehandLine
:
1007 case SdrObjKind::FreehandFill
:
1008 case SdrObjKind::Edge
:
1009 case SdrObjKind::PathPoly
:
1010 case SdrObjKind::PathPolyLine
:
1011 case SdrObjKind::Measure
:
1021 static tools::Rectangle
svx_getLogicRectHack( SdrObject
const * pObj
)
1023 if(svx_needLogicRectHack(pObj
))
1025 return pObj
->GetSnapRect();
1029 return pObj
->GetLogicRect();
1034 static void svx_setLogicRectHack( SdrObject
* pObj
, const tools::Rectangle
& rRect
)
1036 if(svx_needLogicRectHack(pObj
))
1038 pObj
->SetSnapRect( rRect
);
1042 pObj
->SetLogicRect( rRect
);
1047 awt::Point SAL_CALL
SvxShape::getPosition()
1049 ::SolarMutexGuard aGuard
;
1053 tools::Rectangle
aRect( svx_getLogicRectHack(GetSdrObject()) );
1054 Point
aPt( aRect
.Left(), aRect
.Top() );
1056 // Position is relative to anchor, so recalc to absolute position
1057 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1058 aPt
-= GetSdrObject()->GetAnchorPos();
1060 ForceMetricTo100th_mm(aPt
);
1061 return css::awt::Point( aPt
.X(), aPt
.Y() );
1070 void SAL_CALL
SvxShape::setPosition( const awt::Point
& Position
)
1072 ::SolarMutexGuard aGuard
;
1076 // do NOT move 3D objects, this would change the homogen
1077 // transformation matrix
1078 if(dynamic_cast<const E3dCompoundObject
* >(GetSdrObject()) == nullptr)
1080 tools::Rectangle
aRect( svx_getLogicRectHack(GetSdrObject()) );
1081 Point
aLocalPos( Position
.X
, Position
.Y
);
1082 ForceMetricToItemPoolMetric(aLocalPos
);
1084 // Position is absolute, so recalc to position relative to anchor
1085 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1086 aLocalPos
+= GetSdrObject()->GetAnchorPos();
1088 tools::Long nDX
= aLocalPos
.X() - aRect
.Left();
1089 tools::Long nDY
= aLocalPos
.Y() - aRect
.Top();
1091 GetSdrObject()->Move( Size( nDX
, nDY
) );
1092 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1096 maPosition
= Position
;
1100 awt::Size SAL_CALL
SvxShape::getSize()
1102 ::SolarMutexGuard aGuard
;
1106 tools::Rectangle
aRect( svx_getLogicRectHack(GetSdrObject()) );
1107 Size
aObjSize( aRect
.getOpenWidth(), aRect
.getOpenHeight() );
1108 ForceMetricTo100th_mm(aObjSize
);
1109 return css::awt::Size( aObjSize
.getWidth(), aObjSize
.getHeight() );
1116 void SAL_CALL
SvxShape::setSize( const awt::Size
& rSize
)
1118 ::SolarMutexGuard aGuard
;
1122 tools::Rectangle
aRect( svx_getLogicRectHack(GetSdrObject()) );
1123 Size
aLocalSize( rSize
.Width
, rSize
.Height
);
1124 ForceMetricToItemPoolMetric(aLocalSize
);
1126 if(GetSdrObject()->GetObjInventor() == SdrInventor::Default
&& GetSdrObject()->GetObjIdentifier() == SdrObjKind::Measure
)
1128 Fraction
aWdt(aLocalSize
.Width(),aRect
.Right()-aRect
.Left());
1129 Fraction
aHgt(aLocalSize
.Height(),aRect
.Bottom()-aRect
.Top());
1130 Point aPt
= GetSdrObject()->GetSnapRect().TopLeft();
1131 GetSdrObject()->Resize(aPt
,aWdt
,aHgt
);
1135 //aRect.SetSize(aLocalSize); // this call subtract 1 // https://bz.apache.org/ooo/show_bug.cgi?id=83193
1136 if ( !aLocalSize
.Width() )
1138 aRect
.SetWidthEmpty();
1141 aRect
.setWidth(aLocalSize
.Width());
1142 if ( !aLocalSize
.Height() )
1144 aRect
.SetHeightEmpty();
1147 aRect
.setHeight(aLocalSize
.Height());
1149 svx_setLogicRectHack( GetSdrObject(), aRect
);
1152 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1159 OUString SAL_CALL
SvxShape::getName( )
1161 ::SolarMutexGuard aGuard
;
1162 if( HasSdrObject() )
1164 return GetSdrObject()->GetName();
1173 void SAL_CALL
SvxShape::setName( const OUString
& aName
)
1175 ::SolarMutexGuard aGuard
;
1176 if( HasSdrObject() )
1178 GetSdrObject()->SetName( aName
);
1182 maShapeName
= aName
;
1189 OUString SAL_CALL
SvxShape::getShapeType()
1191 if( !maShapeType
.getLength() )
1192 return UHashMap::getNameFromId( mpImpl
->mnObjId
);
1200 void SAL_CALL
SvxShape::dispose()
1202 std::unique_lock
g(m_aMutex
);
1204 if( mpImpl
->mbDisposing
)
1205 return; // caught a recursion
1207 mpImpl
->mbDisposing
= true;
1209 lang::EventObject aEvt
;
1210 aEvt
.Source
= *static_cast<OWeakAggObject
*>(this);
1211 mpImpl
->maDisposeListeners
.disposeAndClear(g
, aEvt
);
1212 mpImpl
->maPropertyNotifier
.disposing(g
);
1214 rtl::Reference
<SdrObject
> pObject
= mxSdrObject
;
1218 EndListening( pObject
->getSdrModelFromSdrObject() );
1220 if ( pObject
->IsInserted() && pObject
->getSdrPageFromSdrObject() )
1222 SdrPage
* pPage
= pObject
->getSdrPageFromSdrObject();
1223 // delete the SdrObject from the page
1224 const size_t nCount
= pPage
->GetObjCount();
1225 for ( size_t nNum
= 0; nNum
< nCount
; ++nNum
)
1227 if ( pPage
->GetObj( nNum
) == pObject
.get() )
1229 OSL_VERIFY( pPage
->RemoveObject( nNum
) == pObject
);
1235 mxSdrObject
.clear();
1236 pObject
->setUnoShape(nullptr);
1240 void SAL_CALL
SvxShape::addEventListener( const Reference
< lang::XEventListener
>& xListener
)
1242 std::unique_lock
g(m_aMutex
);
1243 mpImpl
->maDisposeListeners
.addInterface(g
, xListener
);
1247 void SAL_CALL
SvxShape::removeEventListener( const Reference
< lang::XEventListener
>& aListener
)
1249 std::unique_lock
g(m_aMutex
);
1250 mpImpl
->maDisposeListeners
.removeInterface(g
, aListener
);
1256 Reference
< beans::XPropertySetInfo
> SAL_CALL
1257 SvxShape::getPropertySetInfo()
1259 if( mpImpl
->mpMaster
)
1261 return mpImpl
->mpMaster
->getPropertySetInfo();
1265 return _getPropertySetInfo();
1269 Reference
< beans::XPropertySetInfo
> const &
1270 SvxShape::_getPropertySetInfo()
1272 return mpPropSet
->getPropertySetInfo();
1276 void SAL_CALL
SvxShape::addPropertyChangeListener( const OUString
& _propertyName
, const Reference
< beans::XPropertyChangeListener
>& _listener
)
1278 std::unique_lock
g(m_aMutex
);
1279 mpImpl
->maPropertyNotifier
.addPropertyChangeListener( g
, _propertyName
, _listener
);
1283 void SAL_CALL
SvxShape::removePropertyChangeListener( const OUString
& _propertyName
, const Reference
< beans::XPropertyChangeListener
>& _listener
)
1285 std::unique_lock
g(m_aMutex
);
1286 mpImpl
->maPropertyNotifier
.removePropertyChangeListener( g
, _propertyName
, _listener
);
1290 void SAL_CALL
SvxShape::addVetoableChangeListener( const OUString
& , const Reference
< beans::XVetoableChangeListener
>& )
1292 OSL_FAIL( "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1296 void SAL_CALL
SvxShape::removeVetoableChangeListener( const OUString
& , const Reference
< beans::XVetoableChangeListener
>& )
1298 OSL_FAIL( "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1302 bool SvxShape::SetFillAttribute( sal_uInt16 nWID
, const OUString
& rName
)
1306 SfxItemSet
aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), nWID
, nWID
);
1308 if( SetFillAttribute( nWID
, rName
, aSet
, &GetSdrObject()->getSdrModelFromSdrObject() ) )
1310 //GetSdrObject()->SetItemSetAndBroadcast(aSet);
1311 GetSdrObject()->SetMergedItemSetAndBroadcast(aSet
);
1321 bool SvxShape::SetFillAttribute( sal_uInt16 nWID
, const OUString
& rName
, SfxItemSet
& rSet
, SdrModel
const * pModel
)
1323 // check if an item with the given name and which id is inside the models
1324 // pool or the stylesheet pool, if found it's put in the itemset
1325 if( !SetFillAttribute( nWID
, rName
, rSet
) )
1327 // we did not find such item in one of the pools, so we check
1328 // the property lists that are loaded for the model for items
1329 // that support such.
1330 OUString aStrName
= SvxUnogetInternalNameForItem(nWID
, rName
);
1334 case XATTR_FILLBITMAP
:
1336 XBitmapListRef pBitmapList
= pModel
->GetBitmapList();
1338 if( !pBitmapList
.is() )
1341 tools::Long nPos
= pBitmapList
->GetIndex(aStrName
);
1345 const XBitmapEntry
* pEntry
= pBitmapList
->GetBitmap(nPos
);
1346 XFillBitmapItem
aBmpItem(rName
, pEntry
->GetGraphicObject());
1350 case XATTR_FILLGRADIENT
:
1352 XGradientListRef pGradientList
= pModel
->GetGradientList();
1354 if( !pGradientList
.is() )
1357 tools::Long nPos
= pGradientList
->GetIndex(aStrName
);
1361 const XGradientEntry
* pEntry
= pGradientList
->GetGradient(nPos
);
1362 XFillGradientItem
aGrdItem(rName
, pEntry
->GetGradient());
1363 rSet
.Put( aGrdItem
);
1366 case XATTR_FILLHATCH
:
1368 XHatchListRef pHatchList
= pModel
->GetHatchList();
1370 if( !pHatchList
.is() )
1373 tools::Long nPos
= pHatchList
->GetIndex(aStrName
);
1377 const XHatchEntry
* pEntry
= pHatchList
->GetHatch( nPos
);
1378 XFillHatchItem
aHatchItem(rName
, pEntry
->GetHatch());
1379 rSet
.Put( aHatchItem
);
1383 case XATTR_LINESTART
:
1385 XLineEndListRef pLineEndList
= pModel
->GetLineEndList();
1387 if( !pLineEndList
.is() )
1390 tools::Long nPos
= pLineEndList
->GetIndex(aStrName
);
1394 const XLineEndEntry
* pEntry
= pLineEndList
->GetLineEnd(nPos
);
1395 if( sal_uInt16(XATTR_LINEEND
) == nWID
)
1397 XLineEndItem
aLEItem(rName
, pEntry
->GetLineEnd());
1398 rSet
.Put( aLEItem
);
1402 XLineStartItem
aLSItem(rName
, pEntry
->GetLineEnd());
1403 rSet
.Put( aLSItem
);
1408 case XATTR_LINEDASH
:
1410 XDashListRef pDashList
= pModel
->GetDashList();
1412 if( !pDashList
.is() )
1415 tools::Long nPos
= pDashList
->GetIndex(aStrName
);
1419 const XDashEntry
* pEntry
= pDashList
->GetDash(nPos
);
1420 XLineDashItem
aDashItem(rName
, pEntry
->GetDash());
1421 rSet
.Put( aDashItem
);
1433 bool SvxShape::SetFillAttribute( sal_uInt16 nWID
, const OUString
& rName
, SfxItemSet
& rSet
)
1435 OUString aName
= SvxUnogetInternalNameForItem(nWID
, rName
);
1437 if (aName
.isEmpty())
1442 case XATTR_LINESTART
:
1444 const basegfx::B2DPolyPolygon aEmptyPoly
;
1445 if( nWID
== sal_uInt16(XATTR_LINEEND
) )
1446 rSet
.Put( XLineEndItem( "", aEmptyPoly
) );
1448 rSet
.Put( XLineStartItem( "", aEmptyPoly
) );
1452 case XATTR_FILLFLOATTRANSPARENCE
:
1454 // #85953# Set a disabled XFillFloatTransparenceItem
1455 rSet
.Put(XFillFloatTransparenceItem());
1464 for (const SfxPoolItem
* p
: rSet
.GetPool()->GetItemSurrogates(nWID
))
1466 const NameOrIndex
* pItem
= static_cast<const NameOrIndex
*>(p
);
1467 if( pItem
->GetName() == aName
)
1478 void SAL_CALL
SvxShape::setPropertyValue( const OUString
& rPropertyName
, const uno::Any
& rVal
)
1480 if( mpImpl
->mpMaster
)
1482 mpImpl
->mpMaster
->setPropertyValue( rPropertyName
, rVal
);
1486 _setPropertyValue( rPropertyName
, rVal
);
1490 void SvxShape::_setPropertyValue( const OUString
& rPropertyName
, const uno::Any
& rVal
)
1492 ::SolarMutexGuard aGuard
;
1494 const SfxItemPropertyMapEntry
* pMap
= mpPropSet
->getPropertyMapEntry(rPropertyName
);
1496 if (!HasSdrObject())
1498 // Since we have no actual sdr object right now, remember all
1499 // properties in a list. These properties will be set when the sdr
1500 // object is created.
1502 if (pMap
&& pMap
->nWID
)
1504 // FIXME: We should throw a UnknownPropertyException here.
1505 // But since this class is aggregated from classes that
1506 // support additional properties that we don't know here we
1507 // silently store *all* properties, even if they may be not
1508 // supported after creation.
1509 SvxItemPropertySet::setPropertyValue( pMap
, rVal
, maUrsAnys
);
1515 if (rPropertyName
== "HandlePathObjScale")
1517 auto pPathObj
= dynamic_cast<SdrPathObj
*>(GetSdrObject());
1520 bool bHandleScale
{};
1521 if (rVal
>>= bHandleScale
)
1523 pPathObj
->SetHandleScale(bHandleScale
);
1531 // reduce log noise by ignoring two properties that higher level code queries for on all objects
1532 SAL_WARN_IF(rPropertyName
!= "FromWordArt" && rPropertyName
!= "GraphicColorMode",
1533 "svx.uno", "Unknown Property: " << rPropertyName
);
1534 throw beans::UnknownPropertyException( rPropertyName
, static_cast<cppu::OWeakObject
*>(this));
1537 if ((pMap
->nFlags
& beans::PropertyAttribute::READONLY
) != 0)
1538 throw beans::PropertyVetoException(
1539 "Readonly property can't be set: " + rPropertyName
,
1540 uno::Reference
<drawing::XShape
>(this));
1542 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1544 if (setPropertyValueImpl(rPropertyName
, pMap
, rVal
))
1547 DBG_ASSERT( pMap
->nWID
== SDRATTR_TEXTDIRECTION
|| pMap
->nWID
< SDRATTR_NOTPERSIST_FIRST
|| pMap
->nWID
> SDRATTR_NOTPERSIST_LAST
, "Not persist item not handled!" );
1548 DBG_ASSERT( pMap
->nWID
< OWN_ATTR_VALUE_START
|| pMap
->nWID
> OWN_ATTR_VALUE_END
, "Not item property not handled!" );
1550 bool bIsNotPersist
= pMap
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pMap
->nWID
<= SDRATTR_NOTPERSIST_LAST
&& pMap
->nWID
!= SDRATTR_TEXTDIRECTION
;
1552 if( pMap
->nWID
== SDRATTR_CORNER_RADIUS
)
1554 sal_Int32 nCornerRadius
= 0;
1555 if( !(rVal
>>= nCornerRadius
) || (nCornerRadius
< 0) || (nCornerRadius
> 5000000))
1556 throw IllegalArgumentException();
1559 std::optional
<SfxItemSet
> xLocalSet
;
1561 if( mbIsMultiPropertyCall
&& !bIsNotPersist
)
1563 if( !mpImpl
->mxItemSet
)
1565 mpImpl
->mxItemSet
.emplace( GetSdrObject()->GetProperties().CreateObjectSpecificItemSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool() ) );
1567 pSet
= &*mpImpl
->mxItemSet
;
1571 xLocalSet
.emplace( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), pMap
->nWID
, pMap
->nWID
);
1575 if( pSet
->GetItemState( pMap
->nWID
) != SfxItemState::SET
)
1576 pSet
->Put(GetSdrObject()->GetMergedItem(pMap
->nWID
));
1578 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( pMap
, rVal
, *pSet
))
1580 if( pSet
->GetItemState( pMap
->nWID
) != SfxItemState::SET
)
1584 // not-persistent attribute, get those extra
1585 GetSdrObject()->TakeNotPersistAttr(*pSet
);
1589 if( pSet
->GetItemState( pMap
->nWID
) != SfxItemState::SET
)
1591 // get default from ItemPool
1592 if(SfxItemPool::IsWhich(pMap
->nWID
))
1593 pSet
->Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap
->nWID
));
1596 if( pSet
->GetItemState( pMap
->nWID
) == SfxItemState::SET
)
1598 SvxItemPropertySet_setPropertyValue( pMap
, rVal
, *pSet
);
1604 // set not-persistent attribute extra
1605 GetSdrObject()->ApplyNotPersistAttr( *pSet
);
1609 // if we have a XMultiProperty call then the item set
1610 // will be set in setPropertyValues later
1611 if( !mbIsMultiPropertyCall
)
1612 GetSdrObject()->SetMergedItemSetAndBroadcast( *pSet
);
1617 uno::Any SAL_CALL
SvxShape::getPropertyValue( const OUString
& PropertyName
)
1619 if ( mpImpl
->mpMaster
)
1620 return mpImpl
->mpMaster
->getPropertyValue( PropertyName
);
1622 return _getPropertyValue( PropertyName
);
1626 uno::Any
SvxShape::_getPropertyValue( const OUString
& PropertyName
)
1628 ::SolarMutexGuard aGuard
;
1630 const SfxItemPropertyMapEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1635 if(pMap
== nullptr )
1636 throw beans::UnknownPropertyException( PropertyName
, static_cast<cppu::OWeakObject
*>(this));
1638 if( !getPropertyValueImpl( PropertyName
, pMap
, aAny
) )
1640 DBG_ASSERT( pMap
->nWID
== SDRATTR_TEXTDIRECTION
|| (pMap
->nWID
< SDRATTR_NOTPERSIST_FIRST
|| pMap
->nWID
> SDRATTR_NOTPERSIST_LAST
), "Not persist item not handled!" );
1641 DBG_ASSERT( pMap
->nWID
< OWN_ATTR_VALUE_START
|| pMap
->nWID
> OWN_ATTR_VALUE_END
, "Not item property not handled!" );
1643 SfxItemSet
aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), pMap
->nWID
, pMap
->nWID
);
1644 aSet
.Put(GetSdrObject()->GetMergedItem(pMap
->nWID
));
1646 if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet
, pMap
, aAny
))
1651 if(pMap
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pMap
->nWID
<= SDRATTR_NOTPERSIST_LAST
)
1653 // not-persistent attribute, get those extra
1654 GetSdrObject()->TakeNotPersistAttr(aSet
);
1660 // get default from ItemPool
1661 if(SfxItemPool::IsWhich(pMap
->nWID
))
1662 aSet
.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap
->nWID
));
1666 aAny
= GetAnyForItem( aSet
, pMap
);
1672 // Fixme: we should return default values for OWN_ATTR !
1674 if(pMap
&& pMap
->nWID
)
1675 // FixMe: see setPropertyValue
1676 aAny
= mpPropSet
->getPropertyValue( pMap
, maUrsAnys
);
1683 // XMultiPropertySet
1684 void SAL_CALL
SvxShape::setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
, const css::uno::Sequence
< css::uno::Any
>& aValues
)
1686 ::SolarMutexGuard aSolarGuard
;
1688 const sal_Int32 nCount
= aPropertyNames
.getLength();
1689 if (nCount
!= aValues
.getLength())
1690 throw css::lang::IllegalArgumentException("lengths do not match",
1691 static_cast<cppu::OWeakObject
*>(this), -1);
1693 const OUString
* pNames
= aPropertyNames
.getConstArray();
1694 const uno::Any
* pValues
= aValues
.getConstArray();
1696 // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are
1697 // reset even when an exception is thrown
1698 const ::comphelper::ScopeGuard
aGuard( [this] () { return this->endSetPropertyValues(); } );
1700 mbIsMultiPropertyCall
= true;
1702 if( mpImpl
->mpMaster
)
1704 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pNames
++, pValues
++ )
1708 setPropertyValue( *pNames
, *pValues
);
1710 catch (beans::UnknownPropertyException
&)
1712 DBG_UNHANDLED_EXCEPTION("svx");
1714 catch (uno::Exception
&)
1716 DBG_UNHANDLED_EXCEPTION("svx");
1722 uno::Reference
< beans::XPropertySet
> xSet
;
1723 queryInterface( cppu::UnoType
<beans::XPropertySet
>::get()) >>= xSet
;
1725 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pNames
++, pValues
++ )
1729 xSet
->setPropertyValue( *pNames
, *pValues
);
1731 catch (beans::UnknownPropertyException
&)
1733 DBG_UNHANDLED_EXCEPTION("svx");
1735 catch (uno::Exception
&)
1737 DBG_UNHANDLED_EXCEPTION("svx");
1742 if( mpImpl
->mxItemSet
&& HasSdrObject() )
1743 GetSdrObject()->SetMergedItemSetAndBroadcast( *mpImpl
->mxItemSet
);
1747 void SvxShape::endSetPropertyValues()
1749 mbIsMultiPropertyCall
= false;
1750 mpImpl
->mxItemSet
.reset();
1754 css::uno::Sequence
< css::uno::Any
> SAL_CALL
SvxShape::getPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
)
1756 const sal_Int32 nCount
= aPropertyNames
.getLength();
1757 const OUString
* pNames
= aPropertyNames
.getConstArray();
1759 uno::Sequence
< uno::Any
> aRet( nCount
);
1760 uno::Any
* pValue
= aRet
.getArray();
1762 if( mpImpl
->mpMaster
)
1764 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pValue
++, pNames
++ )
1768 *pValue
= getPropertyValue( *pNames
);
1770 catch( uno::Exception
& )
1772 OSL_FAIL( "SvxShape::getPropertyValues, unknown property asked" );
1778 uno::Reference
< beans::XPropertySet
> xSet
;
1779 queryInterface( cppu::UnoType
<beans::XPropertySet
>::get()) >>= xSet
;
1781 for( sal_Int32 nIdx
= 0; nIdx
< nCount
; nIdx
++, pValue
++, pNames
++ )
1785 *pValue
= xSet
->getPropertyValue( *pNames
);
1787 catch( uno::Exception
& )
1789 OSL_FAIL( "SvxShape::getPropertyValues, unknown property asked" );
1797 void SAL_CALL
SvxShape::addPropertiesChangeListener( const css::uno::Sequence
< OUString
>& , const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& )
1801 void SAL_CALL
SvxShape::removePropertiesChangeListener( const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& )
1805 void SAL_CALL
SvxShape::firePropertiesChangeEvent( const css::uno::Sequence
< OUString
>& , const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& )
1810 uno::Any
SvxShape::GetAnyForItem( SfxItemSet
const & aSet
, const SfxItemPropertyMapEntry
* pMap
) const
1812 DBG_TESTSOLARMUTEX();
1817 case SDRATTR_CIRCSTARTANGLE
:
1819 if(const SdrAngleItem
* pPoolItem
= aSet
.GetItemIfSet(SDRATTR_CIRCSTARTANGLE
,false))
1821 Degree100 nAngle
= pPoolItem
->GetValue();
1822 aAny
<<= nAngle
.get();
1827 case SDRATTR_CIRCENDANGLE
:
1829 if (const SdrAngleItem
* pPoolItem
= aSet
.GetItemIfSet(SDRATTR_CIRCENDANGLE
,false))
1831 Degree100 nAngle
= pPoolItem
->GetValue();
1832 aAny
<<= nAngle
.get();
1837 case SDRATTR_CIRCKIND
:
1839 if( GetSdrObject()->GetObjInventor() == SdrInventor::Default
)
1841 drawing::CircleKind eKind
;
1842 switch(GetSdrObject()->GetObjIdentifier())
1844 case SdrObjKind::CircleOrEllipse
: // circle, ellipse
1845 eKind
= drawing::CircleKind_FULL
;
1847 case SdrObjKind::CircleCut
: // segment of circle
1848 eKind
= drawing::CircleKind_CUT
;
1850 case SdrObjKind::CircleArc
: // arc of circle
1851 eKind
= drawing::CircleKind_ARC
;
1853 case SdrObjKind::CircleSection
: // sector
1854 eKind
= drawing::CircleKind_SECTION
;
1865 // get value from ItemSet
1866 aAny
= SvxItemPropertySet_getPropertyValue( pMap
, aSet
);
1868 if( pMap
->aType
!= aAny
.getValueType() )
1870 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
1871 if( ( pMap
->aType
== ::cppu::UnoType
<sal_Int16
>::get()) && aAny
.getValueType() == ::cppu::UnoType
<sal_Int32
>::get() )
1873 sal_Int32 nValue
= 0;
1875 aAny
<<= static_cast<sal_Int16
>(nValue
);
1879 OSL_FAIL("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" );
1891 beans::PropertyState SAL_CALL
SvxShape::getPropertyState( const OUString
& PropertyName
)
1893 if( mpImpl
->mpMaster
)
1895 return mpImpl
->mpMaster
->getPropertyState( PropertyName
);
1899 return _getPropertyState( PropertyName
);
1903 beans::PropertyState
SvxShape::_getPropertyState( const OUString
& PropertyName
)
1905 ::SolarMutexGuard aGuard
;
1907 const SfxItemPropertyMapEntry
* pMap
= mpPropSet
->getPropertyMapEntry(PropertyName
);
1909 if( !HasSdrObject() || pMap
== nullptr )
1910 throw beans::UnknownPropertyException( PropertyName
, static_cast<cppu::OWeakObject
*>(this));
1912 beans::PropertyState eState
;
1913 if( !getPropertyStateImpl( pMap
, eState
) )
1915 const SfxItemSet
& rSet
= GetSdrObject()->GetMergedItemSet();
1917 switch( rSet
.GetItemState( pMap
->nWID
, false ) )
1919 case SfxItemState::SET
:
1920 eState
= beans::PropertyState_DIRECT_VALUE
;
1922 case SfxItemState::DEFAULT
:
1923 eState
= beans::PropertyState_DEFAULT_VALUE
;
1926 eState
= beans::PropertyState_AMBIGUOUS_VALUE
;
1930 // if an item is set, this doesn't mean we want it :)
1931 if( beans::PropertyState_DIRECT_VALUE
== eState
)
1933 switch( pMap
->nWID
)
1935 // the following items are disabled by changing the
1936 // fill style or the line style. so there is no need
1937 // to export items without names which should be empty
1938 case XATTR_FILLBITMAP
:
1939 case XATTR_FILLGRADIENT
:
1940 case XATTR_FILLHATCH
:
1941 case XATTR_LINEDASH
:
1943 const NameOrIndex
* pItem
= rSet
.GetItem
<NameOrIndex
>(pMap
->nWID
);
1944 if( ( pItem
== nullptr ) || pItem
->GetName().isEmpty() )
1945 eState
= beans::PropertyState_DEFAULT_VALUE
;
1950 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
1951 // may be a hard attribute covering the set LineStart of the parent (Style).
1953 // same is for fill float transparency
1955 case XATTR_LINESTART
:
1956 case XATTR_FILLFLOATTRANSPARENCE
:
1958 const NameOrIndex
* pItem
= rSet
.GetItem
<NameOrIndex
>(pMap
->nWID
);
1959 if ( pItem
== nullptr )
1960 eState
= beans::PropertyState_DEFAULT_VALUE
;
1963 case XATTR_FILLCOLOR
:
1964 if (pMap
->nMemberId
== MID_COLOR_THEME_INDEX
)
1966 const XFillColorItem
* pColor
= rSet
.GetItem
<XFillColorItem
>(pMap
->nWID
);
1967 if (pColor
->getComplexColor().getType() == model::ColorType::Unused
||
1968 pColor
->getComplexColor().getSchemeType() == model::ThemeColorType::Unknown
)
1970 eState
= beans::PropertyState_DEFAULT_VALUE
;
1973 else if (pMap
->nMemberId
== MID_COLOR_LUM_MOD
)
1975 const XFillColorItem
* pColor
= rSet
.GetItem
<XFillColorItem
>(pMap
->nWID
);
1976 sal_Int16 nLumMod
= 10000;
1977 for (auto const& rTransform
: pColor
->getComplexColor().getTransformations())
1979 if (rTransform
.meType
== model::TransformationType::LumMod
)
1980 nLumMod
= rTransform
.mnValue
;
1982 if (nLumMod
== 10000)
1984 eState
= beans::PropertyState_DEFAULT_VALUE
;
1987 else if (pMap
->nMemberId
== MID_COLOR_LUM_OFF
)
1989 const XFillColorItem
* pColor
= rSet
.GetItem
<XFillColorItem
>(pMap
->nWID
);
1990 sal_Int16 nLumOff
= 0;
1991 for (auto const& rTransform
: pColor
->getComplexColor().getTransformations())
1993 if (rTransform
.meType
== model::TransformationType::LumOff
)
1994 nLumOff
= rTransform
.mnValue
;
1998 eState
= beans::PropertyState_DEFAULT_VALUE
;
2001 else if (pMap
->nMemberId
== MID_COMPLEX_COLOR
)
2003 auto const* pColor
= rSet
.GetItem
<XFillColorItem
>(pMap
->nWID
);
2004 if (pColor
->getComplexColor().getType() == model::ColorType::Unused
)
2006 eState
= beans::PropertyState_DEFAULT_VALUE
;
2010 case XATTR_LINECOLOR
:
2011 if (pMap
->nMemberId
== MID_COMPLEX_COLOR
)
2013 auto const* pColor
= rSet
.GetItem
<XLineColorItem
>(pMap
->nWID
);
2014 if (pColor
->getComplexColor().getType() == model::ColorType::Unused
)
2016 eState
= beans::PropertyState_DEFAULT_VALUE
;
2026 bool SvxShape::setPropertyValueImpl( const OUString
&, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
2028 rtl::Reference
<SdrObject
> pSdrObject
= GetSdrObject();
2029 switch( pProperty
->nWID
)
2031 case OWN_ATTR_CAPTION_POINT
:
2034 if( rValue
>>= aPnt
)
2036 Point
aVclPoint( aPnt
.X
, aPnt
.Y
);
2038 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2039 // Need to adapt aVclPoint from 100thmm to app-specific
2040 ForceMetricToItemPoolMetric(aVclPoint
);
2042 // #90763# position is relative to top left, make it absolute
2043 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2044 basegfx::B2DHomMatrix aNewHomogenMatrix
;
2045 pSdrObject
->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2047 aVclPoint
.AdjustX(basegfx::fround(aNewHomogenMatrix
.get(0, 2)) );
2048 aVclPoint
.AdjustY(basegfx::fround(aNewHomogenMatrix
.get(1, 2)) );
2050 // #88491# position relative to anchor
2051 if( pSdrObject
->getSdrModelFromSdrObject().IsWriter() )
2053 aVclPoint
+= pSdrObject
->GetAnchorPos();
2056 static_cast<SdrCaptionObj
*>(pSdrObject
.get())->SetTailPos(aVclPoint
);
2062 case OWN_ATTR_TRANSFORMATION
:
2064 drawing::HomogenMatrix3 aMatrix
;
2065 if(rValue
>>= aMatrix
)
2067 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2068 basegfx::B2DHomMatrix aNewHomogenMatrix
;
2070 // tdf#117145 SdrModel data is app-specific
2071 pSdrObject
->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2073 aNewHomogenMatrix
.set(0, 0, aMatrix
.Line1
.Column1
);
2074 aNewHomogenMatrix
.set(0, 1, aMatrix
.Line1
.Column2
);
2075 aNewHomogenMatrix
.set(0, 2, aMatrix
.Line1
.Column3
);
2076 aNewHomogenMatrix
.set(1, 0, aMatrix
.Line2
.Column1
);
2077 aNewHomogenMatrix
.set(1, 1, aMatrix
.Line2
.Column2
);
2078 aNewHomogenMatrix
.set(1, 2, aMatrix
.Line2
.Column3
);
2079 // For this to be a valid 2D transform matrix, the last row must be [0,0,1]
2080 assert( aMatrix
.Line3
.Column1
== 0 );
2081 assert( aMatrix
.Line3
.Column2
== 0 );
2082 assert( aMatrix
.Line3
.Column3
== 1 );
2084 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2085 // Need to adapt aNewHomogenMatrix from 100thmm to app-specific
2086 ForceMetricToItemPoolMetric(aNewHomogenMatrix
);
2088 pSdrObject
->TRSetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2094 case OWN_ATTR_ZORDER
:
2096 sal_Int32 nNewOrdNum
= 0;
2097 if(rValue
>>= nNewOrdNum
)
2099 SdrObjList
* pObjList
= pSdrObject
->getParentSdrObjListFromSdrObject();
2101 pObjList
->SetExistingObjectOrdNum( pSdrObject
.get(), static_cast<size_t>(nNewOrdNum
) );
2106 case OWN_ATTR_FRAMERECT
:
2108 awt::Rectangle aUnoRect
;
2109 if(rValue
>>= aUnoRect
)
2111 Point
aTopLeft( aUnoRect
.X
, aUnoRect
.Y
);
2112 Size
aObjSize( aUnoRect
.Width
, aUnoRect
.Height
);
2113 ForceMetricToItemPoolMetric(aTopLeft
);
2114 ForceMetricToItemPoolMetric(aObjSize
);
2115 tools::Rectangle aRect
;
2116 aRect
.SetPos(aTopLeft
);
2117 aRect
.SetSize(aObjSize
);
2118 pSdrObject
->SetSnapRect(aRect
);
2123 case OWN_ATTR_MIRRORED
:
2126 if(rValue
>>= bMirror
)
2128 SdrGrafObj
* pObj
= dynamic_cast< SdrGrafObj
* >( pSdrObject
.get() );
2130 pObj
->SetMirrored(bMirror
);
2135 case OWN_ATTR_EDGE_START_OBJ
:
2136 case OWN_ATTR_EDGE_END_OBJ
:
2137 case OWN_ATTR_GLUEID_HEAD
:
2138 case OWN_ATTR_GLUEID_TAIL
:
2139 case OWN_ATTR_EDGE_START_POS
:
2140 case OWN_ATTR_EDGE_END_POS
:
2141 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER
:
2143 SdrEdgeObj
* pEdgeObj
= dynamic_cast< SdrEdgeObj
* >(pSdrObject
.get());
2146 switch(pProperty
->nWID
)
2148 case OWN_ATTR_EDGE_START_OBJ
:
2149 case OWN_ATTR_EDGE_END_OBJ
:
2151 Reference
< drawing::XShape
> xShape
;
2152 if( rValue
>>= xShape
)
2154 SdrObject
* pNode
= SdrObject::getSdrObjectFromXShape(xShape
);
2157 pEdgeObj
->ConnectToNode( pProperty
->nWID
== OWN_ATTR_EDGE_START_OBJ
, pNode
);
2158 pEdgeObj
->setGluePointIndex( pProperty
->nWID
== OWN_ATTR_EDGE_START_OBJ
);
2165 case OWN_ATTR_EDGE_START_POS
:
2166 case OWN_ATTR_EDGE_END_POS
:
2168 awt::Point aUnoPoint
;
2169 if( rValue
>>= aUnoPoint
)
2171 Point
aPoint( aUnoPoint
.X
, aUnoPoint
.Y
);
2173 // Reintroduction of fix for issue i59051 (#i108851#)
2174 // perform metric change before applying anchor position,
2175 // because the anchor position is in pool metric.
2176 ForceMetricToItemPoolMetric( aPoint
);
2177 if( pSdrObject
->getSdrModelFromSdrObject().IsWriter() )
2178 aPoint
+= pSdrObject
->GetAnchorPos();
2180 pEdgeObj
->SetTailPoint( pProperty
->nWID
== OWN_ATTR_EDGE_START_POS
, aPoint
);
2186 case OWN_ATTR_GLUEID_HEAD
:
2187 case OWN_ATTR_GLUEID_TAIL
:
2190 if( rValue
>>= nId
)
2192 pEdgeObj
->setGluePointIndex( pProperty
->nWID
== OWN_ATTR_GLUEID_HEAD
, nId
);
2197 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER
:
2199 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2201 // #123616# be a little bit more flexible regarding the data type used
2202 if( auto s
= o3tl::tryAccess
<drawing::PointSequenceSequence
>(rValue
) )
2204 // get polygpon data from PointSequenceSequence
2205 aNewPolyPolygon
= basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(
2208 else if( auto cs
= o3tl::tryAccess
<drawing::PolyPolygonBezierCoords
>(rValue
) )
2210 // get polygpon data from PolyPolygonBezierCoords
2211 aNewPolyPolygon
= basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
2215 if(aNewPolyPolygon
.count())
2217 // Reintroduction of fix for issue i59051 (#i108851#)
2218 ForceMetricToItemPoolMetric( aNewPolyPolygon
);
2219 if( pSdrObject
->getSdrModelFromSdrObject().IsWriter() )
2221 Point
aPoint( pSdrObject
->GetAnchorPos() );
2222 aNewPolyPolygon
.transform(basegfx::utils::createTranslateB2DHomMatrix(aPoint
.X(), aPoint
.Y()));
2224 pEdgeObj
->SetEdgeTrackPath( aNewPolyPolygon
);
2232 case OWN_ATTR_MEASURE_START_POS
:
2233 case OWN_ATTR_MEASURE_END_POS
:
2235 SdrMeasureObj
* pMeasureObj
= dynamic_cast< SdrMeasureObj
* >(pSdrObject
.get());
2236 awt::Point aUnoPoint
;
2237 if(pMeasureObj
&& ( rValue
>>= aUnoPoint
) )
2239 Point
aPoint( aUnoPoint
.X
, aUnoPoint
.Y
);
2241 // Reintroduction of fix for issue #i59051# (#i108851#)
2242 ForceMetricToItemPoolMetric( aPoint
);
2243 if( pSdrObject
->getSdrModelFromSdrObject().IsWriter() )
2244 aPoint
+= pSdrObject
->GetAnchorPos();
2246 pMeasureObj
->NbcSetPoint( aPoint
, pProperty
->nWID
== OWN_ATTR_MEASURE_START_POS
? 0 : 1 );
2247 pMeasureObj
->SetChanged();
2248 pMeasureObj
->BroadcastObjectChange();
2253 case OWN_ATTR_FILLBMP_MODE
:
2255 drawing::BitmapMode eMode
;
2256 if(!(rValue
>>= eMode
) )
2258 sal_Int32 nMode
= 0;
2259 if(!(rValue
>>= nMode
))
2262 eMode
= static_cast<drawing::BitmapMode
>(nMode
);
2264 pSdrObject
->SetMergedItem( XFillBmpStretchItem( eMode
== drawing::BitmapMode_STRETCH
) );
2265 pSdrObject
->SetMergedItem( XFillBmpTileItem( eMode
== drawing::BitmapMode_REPEAT
) );
2269 case SDRATTR_LAYERID
:
2271 sal_Int16 nLayerId
= sal_Int16();
2272 if( rValue
>>= nLayerId
)
2274 SdrLayer
* pLayer
= pSdrObject
->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId
));
2277 pSdrObject
->SetLayer(SdrLayerID(nLayerId
));
2284 case SDRATTR_LAYERNAME
:
2286 OUString aLayerName
;
2287 if( rValue
>>= aLayerName
)
2289 const SdrLayer
* pLayer
= pSdrObject
->getSdrModelFromSdrObject().GetLayerAdmin().GetLayer(aLayerName
);
2290 if( pLayer
!= nullptr )
2292 pSdrObject
->SetLayer( pLayer
->GetID() );
2298 case SDRATTR_ROTATEANGLE
:
2301 if( rValue
>>= nTmp
)
2303 Degree100
nAngle(nTmp
);
2304 Point
aRef1(pSdrObject
->GetSnapRect().Center());
2305 nAngle
-= pSdrObject
->GetRotateAngle();
2308 double nSin
= sin(toRadians(nAngle
));
2309 double nCos
= cos(toRadians(nAngle
));
2310 pSdrObject
->Rotate(aRef1
,nAngle
,nSin
,nCos
);
2318 case SDRATTR_SHEARANGLE
:
2321 if( rValue
>>= nTmp
)
2323 Degree100
nShear(nTmp
);
2324 nShear
-= pSdrObject
->GetShearAngle();
2327 Point
aRef1(pSdrObject
->GetSnapRect().Center());
2328 double nTan
= tan(toRadians(nShear
));
2329 pSdrObject
->Shear(aRef1
,nShear
,nTan
,false);
2337 case OWN_ATTR_INTEROPGRABBAG
:
2339 pSdrObject
->SetGrabBagItem(rValue
);
2343 case SDRATTR_OBJMOVEPROTECT
:
2346 if( rValue
>>= bMoveProtect
)
2348 pSdrObject
->SetMoveProtect(bMoveProtect
);
2353 case SDRATTR_OBJECTNAME
:
2356 if( rValue
>>= aName
)
2358 pSdrObject
->SetName( aName
);
2364 case OWN_ATTR_TEXTFITTOSIZESCALE
:
2366 double nMaxScale
= 0.0;
2367 if (rValue
>>= nMaxScale
)
2369 SdrTextFitToSizeTypeItem
aItem(pSdrObject
->GetMergedItem(SDRATTR_TEXT_FITTOSIZE
));
2370 aItem
.SetMaxScale(nMaxScale
);
2371 pSdrObject
->SetMergedItem(aItem
);
2378 case OWN_ATTR_MISC_OBJ_TITLE
:
2381 if( rValue
>>= aTitle
)
2383 pSdrObject
->SetTitle( aTitle
);
2388 case OWN_ATTR_MISC_OBJ_DESCRIPTION
:
2390 OUString aDescription
;
2391 if( rValue
>>= aDescription
)
2393 pSdrObject
->SetDescription( aDescription
);
2398 case OWN_ATTR_MISC_OBJ_DECORATIVE
:
2401 if (rValue
>>= isDecorative
)
2403 pSdrObject
->SetDecorative(isDecorative
);
2409 case SDRATTR_OBJPRINTABLE
:
2412 if( rValue
>>= bPrintable
)
2414 pSdrObject
->SetPrintable(bPrintable
);
2419 case SDRATTR_OBJVISIBLE
:
2422 if( rValue
>>= bVisible
)
2424 pSdrObject
->SetVisible(bVisible
);
2429 case SDRATTR_OBJSIZEPROTECT
:
2431 bool bResizeProtect
;
2432 if( rValue
>>= bResizeProtect
)
2434 pSdrObject
->SetResizeProtect(bResizeProtect
);
2439 case OWN_ATTR_PAGE_NUMBER
:
2441 sal_Int32 nPageNum
= 0;
2442 if( (rValue
>>= nPageNum
) && ( nPageNum
>= 0 ) && ( nPageNum
<= 0xffff ) )
2444 SdrPageObj
* pPageObj
= dynamic_cast< SdrPageObj
* >(pSdrObject
.get());
2447 SdrModel
& rModel(pPageObj
->getSdrModelFromSdrObject());
2448 SdrPage
* pNewPage
= nullptr;
2449 const sal_uInt16
nDestinationPageNum(static_cast<sal_uInt16
>((nPageNum
<< 1) - 1));
2451 if(nDestinationPageNum
< rModel
.GetPageCount())
2453 pNewPage
= rModel
.GetPage(nDestinationPageNum
);
2456 pPageObj
->SetReferencedPage(pNewPage
);
2463 case XATTR_FILLBITMAP
:
2464 case XATTR_FILLGRADIENT
:
2465 case XATTR_FILLHATCH
:
2466 case XATTR_FILLFLOATTRANSPARENCE
:
2468 case XATTR_LINESTART
:
2469 case XATTR_LINEDASH
:
2471 if( pProperty
->nMemberId
== MID_NAME
)
2474 if( rValue
>>= aApiName
)
2476 if( SetFillAttribute( pProperty
->nWID
, aApiName
) )
2487 case OWN_ATTR_TEXTCOLUMNS
:
2489 if (auto pTextObj
= DynCastSdrTextObj(pSdrObject
.get()))
2491 css::uno::Reference
<css::text::XTextColumns
> xTextColumns
;
2492 if (rValue
>>= xTextColumns
)
2494 pTextObj
->SetTextColumnsNumber(xTextColumns
->getColumnCount());
2495 if (css::uno::Reference
<css::beans::XPropertySet
> xPropSet
{ xTextColumns
,
2496 css::uno::UNO_QUERY
})
2498 auto aVal
= xPropSet
->getPropertyValue("AutomaticDistance");
2499 if (sal_Int32 nSpacing
; aVal
>>= nSpacing
)
2500 pTextObj
->SetTextColumnsSpacing(nSpacing
);
2507 case OWN_ATTR_HYPERLINK
:
2509 OUString sHyperlink
;
2510 if (rValue
>>= sHyperlink
)
2512 pSdrObject
->setHyperlink(sHyperlink
);
2518 case SDRATTR_WRITINGMODE2
:
2520 SvxFrameDirectionItem
aItem(SvxFrameDirection::Environment
, SDRATTR_WRITINGMODE2
);
2521 aItem
.PutValue(rValue
, 0);
2522 GetSdrObject()->SetMergedItem(aItem
);
2533 OUString
sExceptionMessage(
2534 "IllegalArgumentException in SvxShape::setPropertyValueImpl."
2536 + pProperty
->aType
.getTypeName() + " Property Name: " + pProperty
->aName
2537 + " Property nWID: " + OUString::number(pProperty
->nWID
)
2538 + " Value Type: " + (rValue
.hasValue() ? rValue
.getValueTypeName() : "void (no value)"));
2540 throw lang::IllegalArgumentException(sExceptionMessage
, nullptr, 1);
2544 bool SvxShape::getPropertyValueImpl( const OUString
&, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
2546 switch( pProperty
->nWID
)
2548 case OWN_ATTR_CAPTION_POINT
:
2550 Point aVclPoint
= static_cast<SdrCaptionObj
*>(GetSdrObject())->GetTailPos();
2552 // #88491# make pos relative to anchor
2553 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2555 aVclPoint
-= GetSdrObject()->GetAnchorPos();
2558 // #90763# pos is absolute, make it relative to top left
2559 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2560 basegfx::B2DHomMatrix aNewHomogenMatrix
;
2561 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2563 aVclPoint
.AdjustX( -(basegfx::fround(aNewHomogenMatrix
.get(0, 2))) );
2564 aVclPoint
.AdjustY( -(basegfx::fround(aNewHomogenMatrix
.get(1, 2))) );
2566 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2567 // Need to adapt aVclPoint from app-specific to 100thmm
2568 ForceMetricTo100th_mm(aVclPoint
);
2570 awt::Point
aPnt( aVclPoint
.X(), aVclPoint
.Y() );
2575 case OWN_ATTR_TRANSFORMATION
:
2577 basegfx::B2DPolyPolygon aNewPolyPolygon
;
2578 basegfx::B2DHomMatrix aNewHomogenMatrix
;
2579 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
2580 drawing::HomogenMatrix3 aMatrix
;
2582 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2583 // Need to adapt aNewHomogenMatrix from app-specific to 100thmm
2584 ForceMetricTo100th_mm(aNewHomogenMatrix
);
2586 aMatrix
.Line1
.Column1
= aNewHomogenMatrix
.get(0, 0);
2587 aMatrix
.Line1
.Column2
= aNewHomogenMatrix
.get(0, 1);
2588 aMatrix
.Line1
.Column3
= aNewHomogenMatrix
.get(0, 2);
2589 aMatrix
.Line2
.Column1
= aNewHomogenMatrix
.get(1, 0);
2590 aMatrix
.Line2
.Column2
= aNewHomogenMatrix
.get(1, 1);
2591 aMatrix
.Line2
.Column3
= aNewHomogenMatrix
.get(1, 2);
2592 aMatrix
.Line3
.Column1
= 0;
2593 aMatrix
.Line3
.Column2
= 0;
2594 aMatrix
.Line3
.Column3
= 1;
2601 case OWN_ATTR_ZORDER
:
2603 rValue
<<= static_cast<sal_Int32
>(GetSdrObject()->GetOrdNum());
2607 case OWN_ATTR_BITMAP
:
2609 rValue
= GetBitmap();
2610 if(!rValue
.hasValue())
2611 throw uno::RuntimeException();
2616 case OWN_ATTR_ISFONTWORK
:
2618 bool bIsFontwork
= false;
2619 if (const SdrTextObj
* pTextObj
= DynCastSdrTextObj(GetSdrObject()))
2620 bIsFontwork
= pTextObj
->IsFontwork();
2621 rValue
<<= bIsFontwork
;
2625 case OWN_ATTR_FRAMERECT
:
2627 tools::Rectangle
aRect( GetSdrObject()->GetSnapRect() );
2628 Point
aTopLeft( aRect
.TopLeft() );
2629 Size
aObjSize( aRect
.GetWidth(), aRect
.GetHeight() );
2630 ForceMetricTo100th_mm(aTopLeft
);
2631 ForceMetricTo100th_mm(aObjSize
);
2632 css::awt::Rectangle
aUnoRect(
2633 aTopLeft
.X(), aTopLeft
.Y(),
2634 aObjSize
.getWidth(), aObjSize
.getHeight() );
2635 rValue
<<= aUnoRect
;
2639 case OWN_ATTR_BOUNDRECT
:
2641 tools::Rectangle
aRect( GetSdrObject()->GetCurrentBoundRect() );
2642 Point
aTopLeft( aRect
.TopLeft() );
2643 Size
aObjSize( aRect
.GetWidth(), aRect
.GetHeight() );
2644 ForceMetricTo100th_mm(aTopLeft
);
2645 ForceMetricTo100th_mm(aObjSize
);
2646 css::awt::Rectangle
aUnoRect(
2647 aTopLeft
.X(), aTopLeft
.Y(),
2648 aObjSize
.getWidth(), aObjSize
.getHeight() );
2649 rValue
<<= aUnoRect
;
2653 case OWN_ATTR_LDNAME
:
2655 OUString
aName( GetSdrObject()->GetName() );
2660 case OWN_ATTR_LDBITMAP
:
2663 if( GetSdrObject()->GetObjInventor() == SdrInventor::Default
&& GetSdrObject()->GetObjIdentifier() == SdrObjKind::OLE2
)
2665 sId
= RID_UNODRAW_OLE2
;
2667 else if( GetSdrObject()->GetObjInventor() == SdrInventor::Default
&& GetSdrObject()->GetObjIdentifier() == SdrObjKind::Graphic
)
2669 sId
= RID_UNODRAW_GRAPHICS
;
2673 sId
= RID_UNODRAW_OBJECTS
;
2677 Reference
<awt::XBitmap
> xBmp(VCLUnoHelper::CreateBitmap(aBmp
));
2683 case OWN_ATTR_MIRRORED
:
2685 bool bMirror
= false;
2686 if( HasSdrObject() )
2687 if (auto pGrafObj
= dynamic_cast<SdrGrafObj
*>(GetSdrObject()) )
2688 bMirror
= pGrafObj
->IsMirrored();
2694 case OWN_ATTR_EDGE_START_OBJ
:
2695 case OWN_ATTR_EDGE_START_POS
:
2696 case OWN_ATTR_EDGE_END_POS
:
2697 case OWN_ATTR_EDGE_END_OBJ
:
2698 case OWN_ATTR_GLUEID_HEAD
:
2699 case OWN_ATTR_GLUEID_TAIL
:
2700 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER
:
2702 SdrEdgeObj
* pEdgeObj
= dynamic_cast<SdrEdgeObj
*>(GetSdrObject());
2705 switch(pProperty
->nWID
)
2707 case OWN_ATTR_EDGE_START_OBJ
:
2708 case OWN_ATTR_EDGE_END_OBJ
:
2710 SdrObject
* pNode
= pEdgeObj
->GetConnectedNode(pProperty
->nWID
== OWN_ATTR_EDGE_START_OBJ
);
2713 Reference
< drawing::XShape
> xShape( GetXShapeForSdrObject( pNode
) );
2721 case OWN_ATTR_EDGE_START_POS
:
2722 case OWN_ATTR_EDGE_END_POS
:
2724 Point
aPoint( pEdgeObj
->GetTailPoint( pProperty
->nWID
== OWN_ATTR_EDGE_START_POS
) );
2725 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2726 aPoint
-= GetSdrObject()->GetAnchorPos();
2728 ForceMetricTo100th_mm( aPoint
);
2729 awt::Point
aUnoPoint( aPoint
.X(), aPoint
.Y() );
2731 rValue
<<= aUnoPoint
;
2734 case OWN_ATTR_GLUEID_HEAD
:
2735 case OWN_ATTR_GLUEID_TAIL
:
2737 rValue
<<= pEdgeObj
->getGluePointIndex( pProperty
->nWID
== OWN_ATTR_GLUEID_HEAD
);
2740 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER
:
2742 basegfx::B2DPolyPolygon
aPolyPoly( pEdgeObj
->GetEdgeTrackPath() );
2743 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2745 Point
aPoint( GetSdrObject()->GetAnchorPos() );
2746 aPolyPoly
.transform(basegfx::utils::createTranslateB2DHomMatrix(-aPoint
.X(), -aPoint
.Y()));
2748 // Reintroduction of fix for issue #i59051# (#i108851#)
2749 ForceMetricTo100th_mm( aPolyPoly
);
2750 drawing::PolyPolygonBezierCoords aRetval
;
2751 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPoly
, aRetval
);
2760 case OWN_ATTR_MEASURE_START_POS
:
2761 case OWN_ATTR_MEASURE_END_POS
:
2763 SdrMeasureObj
* pMeasureObj
= dynamic_cast<SdrMeasureObj
*>(GetSdrObject());
2766 Point
aPoint( pMeasureObj
->GetPoint( pProperty
->nWID
== OWN_ATTR_MEASURE_START_POS
? 0 : 1 ) );
2767 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2768 aPoint
-= GetSdrObject()->GetAnchorPos();
2770 // Reintroduction of fix for issue #i59051# (#i108851#)
2771 ForceMetricTo100th_mm( aPoint
);
2772 awt::Point
aUnoPoint( aPoint
.X(), aPoint
.Y() );
2774 rValue
<<= aUnoPoint
;
2780 case OWN_ATTR_FILLBMP_MODE
:
2782 const SfxItemSet
& rObjItemSet
= GetSdrObject()->GetMergedItemSet();
2784 if (rObjItemSet
.Get(XATTR_FILLBMP_TILE
).GetValue())
2786 rValue
<<= drawing::BitmapMode_REPEAT
;
2788 else if (rObjItemSet
.Get(XATTR_FILLBMP_STRETCH
).GetValue())
2790 rValue
<<= drawing::BitmapMode_STRETCH
;
2794 rValue
<<= drawing::BitmapMode_NO_REPEAT
;
2798 case SDRATTR_LAYERID
:
2799 rValue
<<= GetSdrObject()->GetLayer().get();
2802 case SDRATTR_LAYERNAME
:
2804 SdrLayer
* pLayer
= GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(GetSdrObject()->GetLayer());
2807 rValue
<<= pLayer
->GetName();
2812 case SDRATTR_ROTATEANGLE
:
2813 rValue
<<= static_cast<sal_Int32
>(GetSdrObject()->GetRotateAngle());
2816 case SDRATTR_SHEARANGLE
:
2817 rValue
<<= static_cast<sal_Int32
>(GetSdrObject()->GetShearAngle());
2820 case OWN_ATTR_INTEROPGRABBAG
:
2822 GetSdrObject()->GetGrabBagItem(rValue
);
2826 case SDRATTR_OBJMOVEPROTECT
:
2827 rValue
<<= GetSdrObject()->IsMoveProtect();
2830 case SDRATTR_OBJECTNAME
:
2832 OUString
aName( GetSdrObject()->GetName() );
2838 case OWN_ATTR_MISC_OBJ_TITLE
:
2840 OUString
aTitle( GetSdrObject()->GetTitle() );
2845 case OWN_ATTR_MISC_OBJ_DESCRIPTION
:
2847 OUString
aDescription( GetSdrObject()->GetDescription() );
2848 rValue
<<= aDescription
;
2852 case OWN_ATTR_MISC_OBJ_DECORATIVE
:
2854 bool const isDecorative(GetSdrObject()->IsDecorative());
2855 rValue
<<= isDecorative
;
2859 case SDRATTR_OBJPRINTABLE
:
2860 rValue
<<= GetSdrObject()->IsPrintable();
2863 case SDRATTR_OBJVISIBLE
:
2864 rValue
<<= GetSdrObject()->IsVisible();
2867 case SDRATTR_OBJSIZEPROTECT
:
2868 rValue
<<= GetSdrObject()->IsResizeProtect();
2871 case OWN_ATTR_PAGE_NUMBER
:
2873 SdrPageObj
* pPageObj
= dynamic_cast<SdrPageObj
*>(GetSdrObject());
2876 SdrPage
* pPage
= pPageObj
->GetReferencedPage();
2877 sal_Int32 nPageNumber
= pPage
? pPage
->GetPageNum() : 0;
2880 rValue
<<= nPageNumber
;
2885 case OWN_ATTR_UINAME_SINGULAR
:
2887 rValue
<<= GetSdrObject()->TakeObjNameSingul();
2891 case OWN_ATTR_TEXTFITTOSIZESCALE
:
2893 double nScale
= GetTextFitToSizeScale(GetSdrObject());
2898 case OWN_ATTR_UINAME_PLURAL
:
2900 rValue
<<= GetSdrObject()->TakeObjNamePlural();
2903 case OWN_ATTR_METAFILE
:
2905 SdrOle2Obj
* pObj
= dynamic_cast<SdrOle2Obj
*>(GetSdrObject());
2908 const Graphic
* pGraphic
= pObj
->GetGraphic();
2911 bool bIsWMF
= false;
2912 if ( pGraphic
->IsGfxLink() )
2914 GfxLink aLnk
= pGraphic
->GetGfxLink();
2915 if ( aLnk
.GetType() == GfxLinkType::NativeWmf
)
2918 uno::Sequence
<sal_Int8
> aSeq(reinterpret_cast<sal_Int8
const *>(aLnk
.GetData()), static_cast<sal_Int32
>(aLnk
.GetDataSize()));
2924 // #119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically
2925 GDIMetaFile
aMtf(pObj
->GetGraphic()->GetGDIMetaFile());
2926 SvMemoryStream
aDestStrm( 65535, 65535 );
2927 ConvertGDIMetaFileToWMF( aMtf
, aDestStrm
, nullptr, false );
2928 const uno::Sequence
<sal_Int8
> aSeq(
2929 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
2930 aDestStrm
.GetEndOfData());
2937 rValue
= GetBitmap( true );
2942 case OWN_ATTR_TEXTCOLUMNS
:
2944 if (auto pTextObj
= DynCastSdrTextObj(GetSdrObject()))
2946 if (pTextObj
->HasTextColumnsNumber() || pTextObj
->HasTextColumnsSpacing())
2948 auto xIf
= SvxXTextColumns_createInstance();
2949 css::uno::Reference
<css::text::XTextColumns
> xCols(xIf
, css::uno::UNO_QUERY_THROW
);
2950 xCols
->setColumnCount(pTextObj
->GetTextColumnsNumber());
2951 css::uno::Reference
<css::beans::XPropertySet
> xProp(xIf
, css::uno::UNO_QUERY_THROW
);
2952 xProp
->setPropertyValue("AutomaticDistance",
2953 css::uno::Any(pTextObj
->GetTextColumnsSpacing()));
2960 case OWN_ATTR_HYPERLINK
:
2962 rValue
<<= GetSdrObject()->getHyperlink();
2973 bool SvxShape::getPropertyStateImpl( const SfxItemPropertyMapEntry
* pProperty
, css::beans::PropertyState
& rState
)
2975 if( pProperty
->nWID
== OWN_ATTR_FILLBMP_MODE
)
2977 const SfxItemSet
& rSet
= GetSdrObject()->GetMergedItemSet();
2979 if( rSet
.GetItemState( XATTR_FILLBMP_STRETCH
, false ) == SfxItemState::SET
||
2980 rSet
.GetItemState( XATTR_FILLBMP_TILE
, false ) == SfxItemState::SET
)
2982 rState
= beans::PropertyState_DIRECT_VALUE
;
2986 rState
= beans::PropertyState_AMBIGUOUS_VALUE
;
2989 else if((( pProperty
->nWID
>= OWN_ATTR_VALUE_START
&& pProperty
->nWID
<= OWN_ATTR_VALUE_END
) ||
2990 ( pProperty
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pProperty
->nWID
<= SDRATTR_NOTPERSIST_LAST
)) && ( pProperty
->nWID
!= SDRATTR_TEXTDIRECTION
) )
2992 rState
= beans::PropertyState_DIRECT_VALUE
;
3003 bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertyMapEntry
* pProperty
)
3005 if( pProperty
->nWID
== OWN_ATTR_FILLBMP_MODE
)
3007 GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_STRETCH
);
3008 GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_TILE
);
3011 else if((pProperty
->nWID
>= OWN_ATTR_VALUE_START
&& pProperty
->nWID
<= OWN_ATTR_VALUE_END
) ||
3012 ( pProperty
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pProperty
->nWID
<= SDRATTR_NOTPERSIST_LAST
))
3023 uno::Sequence
< beans::PropertyState
> SAL_CALL
SvxShape::getPropertyStates( const uno::Sequence
< OUString
>& aPropertyName
)
3025 const sal_Int32 nCount
= aPropertyName
.getLength();
3026 uno::Sequence
< beans::PropertyState
> aRet( nCount
);
3028 std::transform(aPropertyName
.begin(), aPropertyName
.end(), aRet
.getArray(),
3029 [this](const OUString
& rName
) -> beans::PropertyState
{ return getPropertyState(rName
); });
3035 void SAL_CALL
SvxShape::setPropertyToDefault( const OUString
& PropertyName
)
3037 if( mpImpl
->mpMaster
)
3039 mpImpl
->mpMaster
->setPropertyToDefault( PropertyName
);
3043 _setPropertyToDefault( PropertyName
);
3047 void SvxShape::_setPropertyToDefault( const OUString
& PropertyName
)
3049 ::SolarMutexGuard aGuard
;
3051 const SfxItemPropertyMapEntry
* pProperty
= mpPropSet
->getPropertyMapEntry(PropertyName
);
3053 if( !HasSdrObject() || pProperty
== nullptr )
3054 throw beans::UnknownPropertyException( PropertyName
, static_cast<cppu::OWeakObject
*>(this));
3056 if( !setPropertyToDefaultImpl( pProperty
) )
3058 GetSdrObject()->ClearMergedItem( pProperty
->nWID
);
3061 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
3065 uno::Any SAL_CALL
SvxShape::getPropertyDefault( const OUString
& aPropertyName
)
3067 if( mpImpl
->mpMaster
)
3069 return mpImpl
->mpMaster
->getPropertyDefault( aPropertyName
);
3073 return _getPropertyDefault( aPropertyName
);
3077 uno::Any
SvxShape::_getPropertyDefault( const OUString
& aPropertyName
)
3079 ::SolarMutexGuard aGuard
;
3081 const SfxItemPropertyMapEntry
* pMap
= mpPropSet
->getPropertyMapEntry(aPropertyName
);
3083 if( !HasSdrObject() || pMap
== nullptr )
3084 throw beans::UnknownPropertyException( aPropertyName
, static_cast<cppu::OWeakObject
*>(this));
3086 if(( pMap
->nWID
>= OWN_ATTR_VALUE_START
&& pMap
->nWID
<= OWN_ATTR_VALUE_END
) ||
3087 ( pMap
->nWID
>= SDRATTR_NOTPERSIST_FIRST
&& pMap
->nWID
<= SDRATTR_NOTPERSIST_LAST
))
3089 return getPropertyValue( aPropertyName
);
3092 // get default from ItemPool
3093 if(!SfxItemPool::IsWhich(pMap
->nWID
))
3094 throw beans::UnknownPropertyException( "No WhichID " + OUString::number(pMap
->nWID
) + " for " + aPropertyName
, static_cast<cppu::OWeakObject
*>(this));
3096 SfxItemSet
aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), pMap
->nWID
, pMap
->nWID
);
3097 aSet
.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap
->nWID
));
3099 return GetAnyForItem( aSet
, pMap
);
3102 // XMultiPropertyStates
3103 void SvxShape::setAllPropertiesToDefault()
3105 ::SolarMutexGuard aGuard
;
3107 SdrObject
* pSdrObj
= GetSdrObject();
3109 throw lang::DisposedException();
3110 pSdrObj
->ClearMergedItem(); // nWhich == 0 => all
3112 const SdrObjKind nObjId
= pSdrObj
->GetObjIdentifier();
3113 if(nObjId
== SdrObjKind::Graphic
) // SdrGrafObj
3115 // defaults for graphic objects have changed:
3116 pSdrObj
->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE
) );
3117 pSdrObj
->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE
) );
3120 // #i68523# special handling for Svx3DCharacterModeItem, this is not saved
3121 // but needs to be sal_True in svx, pool default (false) in sch. Since sch
3122 // does not load lathe or extrude objects, it is possible to set the items
3124 // For other solution possibilities, see task description.
3125 if( nObjId
== SdrObjKind::E3D_Lathe
/*E3dLatheObj*/ || nObjId
== SdrObjKind::E3D_Extrusion
/*E3dExtrudeObj*/ )
3127 pSdrObj
->SetMergedItem(Svx3DCharacterModeItem(true));
3130 pSdrObj
->getSdrModelFromSdrObject().SetChanged();
3133 void SvxShape::setPropertiesToDefault(
3134 const uno::Sequence
<OUString
>& aPropertyNames
)
3136 for ( const auto& rPropertyName
: aPropertyNames
)
3137 setPropertyToDefault( rPropertyName
);
3140 uno::Sequence
<uno::Any
> SvxShape::getPropertyDefaults(
3141 const uno::Sequence
<OUString
>& aPropertyNames
)
3143 ::std::vector
<uno::Any
> ret
;
3144 ret
.reserve(aPropertyNames
.getLength());
3145 std::transform(aPropertyNames
.begin(), aPropertyNames
.end(), std::back_inserter(ret
),
3146 [this](const OUString
& rName
) -> uno::Any
{ return getPropertyDefault(rName
); });
3147 return uno::Sequence
<uno::Any
>( ret
.data(), ret
.size() );
3153 OUString SAL_CALL
SvxShape::getImplementationName()
3158 constexpr OUStringLiteral sUNO_service_style_ParagraphProperties
= u
"com.sun.star.style.ParagraphProperties";
3159 constexpr OUStringLiteral sUNO_service_style_ParagraphPropertiesComplex
= u
"com.sun.star.style.ParagraphPropertiesComplex";
3160 constexpr OUStringLiteral sUNO_service_style_ParagraphPropertiesAsian
= u
"com.sun.star.style.ParagraphPropertiesAsian";
3161 constexpr OUStringLiteral sUNO_service_style_CharacterProperties
= u
"com.sun.star.style.CharacterProperties";
3162 constexpr OUStringLiteral sUNO_service_style_CharacterPropertiesComplex
= u
"com.sun.star.style.CharacterPropertiesComplex";
3163 constexpr OUStringLiteral sUNO_service_style_CharacterPropertiesAsian
= u
"com.sun.star.style.CharacterPropertiesAsian";
3165 constexpr OUStringLiteral sUNO_service_drawing_FillProperties
= u
"com.sun.star.drawing.FillProperties";
3166 constexpr OUStringLiteral sUNO_service_drawing_TextProperties
= u
"com.sun.star.drawing.TextProperties";
3167 constexpr OUStringLiteral sUNO_service_drawing_LineProperties
= u
"com.sun.star.drawing.LineProperties";
3168 constexpr OUStringLiteral sUNO_service_drawing_ConnectorProperties
= u
"com.sun.star.drawing.ConnectorProperties";
3169 constexpr OUStringLiteral sUNO_service_drawing_MeasureProperties
= u
"com.sun.star.drawing.MeasureProperties";
3170 constexpr OUStringLiteral sUNO_service_drawing_ShadowProperties
= u
"com.sun.star.drawing.ShadowProperties";
3172 constexpr OUStringLiteral sUNO_service_drawing_RotationDescriptor
= u
"com.sun.star.drawing.RotationDescriptor";
3174 constexpr OUStringLiteral sUNO_service_drawing_Text
= u
"com.sun.star.drawing.Text";
3175 constexpr OUStringLiteral sUNO_service_drawing_GroupShape
= u
"com.sun.star.drawing.GroupShape";
3177 constexpr OUStringLiteral sUNO_service_drawing_CustomShapeProperties
= u
"com.sun.star.drawing.CustomShapeProperties";
3178 constexpr OUStringLiteral sUNO_service_drawing_CustomShape
= u
"com.sun.star.drawing.CustomShape";
3180 constexpr OUStringLiteral sUNO_service_drawing_PolyPolygonDescriptor
= u
"com.sun.star.drawing.PolyPolygonDescriptor";
3181 constexpr OUStringLiteral sUNO_service_drawing_PolyPolygonBezierDescriptor
= u
"com.sun.star.drawing.PolyPolygonBezierDescriptor";
3183 constexpr OUStringLiteral sUNO_service_drawing_LineShape
= u
"com.sun.star.drawing.LineShape";
3184 constexpr OUStringLiteral sUNO_service_drawing_Shape
= u
"com.sun.star.drawing.Shape";
3185 constexpr OUStringLiteral sUNO_service_drawing_RectangleShape
= u
"com.sun.star.drawing.RectangleShape";
3186 constexpr OUStringLiteral sUNO_service_drawing_EllipseShape
= u
"com.sun.star.drawing.EllipseShape";
3187 constexpr OUStringLiteral sUNO_service_drawing_PolyPolygonShape
= u
"com.sun.star.drawing.PolyPolygonShape";
3188 constexpr OUStringLiteral sUNO_service_drawing_PolyLineShape
= u
"com.sun.star.drawing.PolyLineShape";
3189 constexpr OUStringLiteral sUNO_service_drawing_OpenBezierShape
= u
"com.sun.star.drawing.OpenBezierShape";
3190 constexpr OUStringLiteral sUNO_service_drawing_ClosedBezierShape
= u
"com.sun.star.drawing.ClosedBezierShape";
3191 constexpr OUStringLiteral sUNO_service_drawing_TextShape
= u
"com.sun.star.drawing.TextShape";
3192 constexpr OUStringLiteral sUNO_service_drawing_GraphicObjectShape
= u
"com.sun.star.drawing.GraphicObjectShape";
3193 constexpr OUStringLiteral sUNO_service_drawing_OLE2Shape
= u
"com.sun.star.drawing.OLE2Shape";
3194 constexpr OUStringLiteral sUNO_service_drawing_PageShape
= u
"com.sun.star.drawing.PageShape";
3195 constexpr OUStringLiteral sUNO_service_drawing_CaptionShape
= u
"com.sun.star.drawing.CaptionShape";
3196 constexpr OUStringLiteral sUNO_service_drawing_MeasureShape
= u
"com.sun.star.drawing.MeasureShape";
3197 constexpr OUStringLiteral sUNO_service_drawing_FrameShape
= u
"com.sun.star.drawing.FrameShape";
3198 constexpr OUStringLiteral sUNO_service_drawing_ControlShape
= u
"com.sun.star.drawing.ControlShape";
3199 constexpr OUStringLiteral sUNO_service_drawing_ConnectorShape
= u
"com.sun.star.drawing.ConnectorShape";
3200 constexpr OUStringLiteral sUNO_service_drawing_MediaShape
= u
"com.sun.star.drawing.MediaShape";
3203 uno::Sequence
< OUString
> SAL_CALL
SvxShape::getSupportedServiceNames()
3205 if( mpImpl
->mpMaster
)
3207 return mpImpl
->mpMaster
->getSupportedServiceNames();
3211 return _getSupportedServiceNames();
3215 uno::Sequence
< OUString
> SvxShape::_getSupportedServiceNames()
3217 ::SolarMutexGuard aGuard
;
3219 if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::Default
)
3221 const SdrObjKind nIdent
= GetSdrObject()->GetObjIdentifier();
3225 case SdrObjKind::Group
:
3227 static const uno::Sequence
<OUString
> aSvxShape_GroupServices
3228 = { sUNO_service_drawing_GroupShape
,
3229 sUNO_service_drawing_Shape
};
3230 return aSvxShape_GroupServices
;
3232 case SdrObjKind::CustomShape
:
3234 static const uno::Sequence
<OUString
> aSvxShape_CustomShapeServices
3235 = { sUNO_service_drawing_CustomShape
,
3236 sUNO_service_drawing_Shape
,
3237 sUNO_service_drawing_CustomShapeProperties
,
3238 sUNO_service_drawing_FillProperties
,
3239 sUNO_service_drawing_LineProperties
,
3240 sUNO_service_drawing_Text
,
3241 sUNO_service_drawing_TextProperties
,
3242 sUNO_service_style_ParagraphProperties
,
3243 sUNO_service_style_ParagraphPropertiesComplex
,
3244 sUNO_service_style_ParagraphPropertiesAsian
,
3245 sUNO_service_style_CharacterProperties
,
3246 sUNO_service_style_CharacterPropertiesComplex
,
3247 sUNO_service_style_CharacterPropertiesAsian
,
3248 sUNO_service_drawing_ShadowProperties
,
3249 sUNO_service_drawing_RotationDescriptor
};
3250 return aSvxShape_CustomShapeServices
;
3252 case SdrObjKind::Line
:
3254 static const uno::Sequence
<OUString
> aSvxShape_LineServices
3255 = { sUNO_service_drawing_LineShape
,
3257 sUNO_service_drawing_Shape
,
3258 sUNO_service_drawing_LineProperties
,
3260 sUNO_service_drawing_Text
,
3261 sUNO_service_drawing_TextProperties
,
3262 sUNO_service_style_ParagraphProperties
,
3263 sUNO_service_style_ParagraphPropertiesComplex
,
3264 sUNO_service_style_ParagraphPropertiesAsian
,
3265 sUNO_service_style_CharacterProperties
,
3266 sUNO_service_style_CharacterPropertiesComplex
,
3267 sUNO_service_style_CharacterPropertiesAsian
,
3269 sUNO_service_drawing_PolyPolygonDescriptor
,
3270 sUNO_service_drawing_ShadowProperties
,
3271 sUNO_service_drawing_RotationDescriptor
};
3272 return aSvxShape_LineServices
;
3275 case SdrObjKind::Rectangle
:
3277 static const uno::Sequence
<OUString
> aSvxShape_RectServices
3278 = { sUNO_service_drawing_RectangleShape
,
3280 sUNO_service_drawing_Shape
,
3281 sUNO_service_drawing_FillProperties
,
3282 sUNO_service_drawing_LineProperties
,
3283 sUNO_service_drawing_Text
,
3284 sUNO_service_drawing_TextProperties
,
3285 sUNO_service_style_ParagraphProperties
,
3286 sUNO_service_style_ParagraphPropertiesComplex
,
3287 sUNO_service_style_ParagraphPropertiesAsian
,
3288 sUNO_service_style_CharacterProperties
,
3289 sUNO_service_style_CharacterPropertiesComplex
,
3290 sUNO_service_style_CharacterPropertiesAsian
,
3292 sUNO_service_drawing_ShadowProperties
,
3293 sUNO_service_drawing_RotationDescriptor
};
3294 return aSvxShape_RectServices
;
3297 case SdrObjKind::CircleOrEllipse
:
3298 case SdrObjKind::CircleSection
:
3299 case SdrObjKind::CircleArc
:
3300 case SdrObjKind::CircleCut
:
3302 static const uno::Sequence
<OUString
> aSvxShape_CircServices
3303 = { sUNO_service_drawing_EllipseShape
,
3305 sUNO_service_drawing_Shape
,
3306 sUNO_service_drawing_FillProperties
,
3307 sUNO_service_drawing_LineProperties
,
3309 sUNO_service_drawing_Text
,
3310 sUNO_service_drawing_TextProperties
,
3311 sUNO_service_style_ParagraphProperties
,
3312 sUNO_service_style_ParagraphPropertiesComplex
,
3313 sUNO_service_style_ParagraphPropertiesAsian
,
3314 sUNO_service_style_CharacterProperties
,
3315 sUNO_service_style_CharacterPropertiesComplex
,
3316 sUNO_service_style_CharacterPropertiesAsian
,
3318 sUNO_service_drawing_ShadowProperties
,
3319 sUNO_service_drawing_RotationDescriptor
};
3320 return aSvxShape_CircServices
;
3323 case SdrObjKind::PathPolyLine
:
3324 case SdrObjKind::PolyLine
:
3326 static const uno::Sequence
<OUString
> aSvxShape_PathServices
3327 = { sUNO_service_drawing_PolyLineShape
,
3329 sUNO_service_drawing_Shape
,
3330 sUNO_service_drawing_LineProperties
,
3332 sUNO_service_drawing_PolyPolygonDescriptor
,
3334 sUNO_service_drawing_Text
,
3335 sUNO_service_drawing_TextProperties
,
3336 sUNO_service_style_ParagraphProperties
,
3337 sUNO_service_style_ParagraphPropertiesComplex
,
3338 sUNO_service_style_ParagraphPropertiesAsian
,
3339 sUNO_service_style_CharacterProperties
,
3340 sUNO_service_style_CharacterPropertiesComplex
,
3341 sUNO_service_style_CharacterPropertiesAsian
,
3343 sUNO_service_drawing_ShadowProperties
,
3344 sUNO_service_drawing_RotationDescriptor
};
3345 return aSvxShape_PathServices
;
3348 case SdrObjKind::PathPoly
:
3349 case SdrObjKind::Polygon
:
3351 static const uno::Sequence
<OUString
> aSvxShape_PolyServices
3352 = { sUNO_service_drawing_PolyPolygonShape
,
3354 sUNO_service_drawing_Shape
,
3355 sUNO_service_drawing_LineProperties
,
3356 sUNO_service_drawing_FillProperties
,
3358 sUNO_service_drawing_PolyPolygonDescriptor
,
3360 sUNO_service_drawing_Text
,
3361 sUNO_service_drawing_TextProperties
,
3362 sUNO_service_style_ParagraphProperties
,
3363 sUNO_service_style_ParagraphPropertiesComplex
,
3364 sUNO_service_style_ParagraphPropertiesAsian
,
3365 sUNO_service_style_CharacterProperties
,
3366 sUNO_service_style_CharacterPropertiesComplex
,
3367 sUNO_service_style_CharacterPropertiesAsian
,
3369 sUNO_service_drawing_ShadowProperties
,
3370 sUNO_service_drawing_RotationDescriptor
};
3371 return aSvxShape_PolyServices
;
3374 case SdrObjKind::FreehandLine
:
3375 case SdrObjKind::PathLine
:
3377 static const uno::Sequence
<OUString
> aSvxShape_FreeLineServices
3378 = { sUNO_service_drawing_OpenBezierShape
,
3380 sUNO_service_drawing_Shape
,
3381 sUNO_service_drawing_LineProperties
,
3382 sUNO_service_drawing_FillProperties
,
3384 sUNO_service_drawing_PolyPolygonBezierDescriptor
,
3386 sUNO_service_drawing_Text
,
3387 sUNO_service_drawing_TextProperties
,
3388 sUNO_service_style_ParagraphProperties
,
3389 sUNO_service_style_ParagraphPropertiesComplex
,
3390 sUNO_service_style_ParagraphPropertiesAsian
,
3391 sUNO_service_style_CharacterProperties
,
3392 sUNO_service_style_CharacterPropertiesComplex
,
3393 sUNO_service_style_CharacterPropertiesAsian
,
3395 sUNO_service_drawing_ShadowProperties
,
3396 sUNO_service_drawing_RotationDescriptor
};
3397 return aSvxShape_FreeLineServices
;
3400 case SdrObjKind::FreehandFill
:
3401 case SdrObjKind::PathFill
:
3403 static const uno::Sequence
<OUString
> aSvxShape_FreeFillServices
3404 = { sUNO_service_drawing_ClosedBezierShape
,
3406 sUNO_service_drawing_Shape
,
3407 sUNO_service_drawing_LineProperties
,
3408 sUNO_service_drawing_FillProperties
,
3410 sUNO_service_drawing_PolyPolygonBezierDescriptor
,
3412 sUNO_service_drawing_Text
,
3413 sUNO_service_drawing_TextProperties
,
3414 sUNO_service_style_ParagraphProperties
,
3415 sUNO_service_style_ParagraphPropertiesComplex
,
3416 sUNO_service_style_ParagraphPropertiesAsian
,
3417 sUNO_service_style_CharacterProperties
,
3418 sUNO_service_style_CharacterPropertiesComplex
,
3419 sUNO_service_style_CharacterPropertiesAsian
,
3421 sUNO_service_drawing_ShadowProperties
,
3422 sUNO_service_drawing_RotationDescriptor
};
3423 return aSvxShape_FreeFillServices
;
3426 case SdrObjKind::OutlineText
:
3427 case SdrObjKind::TitleText
:
3428 case SdrObjKind::Text
:
3430 static const uno::Sequence
<OUString
> aSvxShape_TextServices
3431 = { sUNO_service_drawing_TextShape
,
3433 sUNO_service_drawing_Shape
,
3434 sUNO_service_drawing_FillProperties
,
3435 sUNO_service_drawing_LineProperties
,
3437 sUNO_service_drawing_Text
,
3438 sUNO_service_drawing_TextProperties
,
3439 sUNO_service_style_ParagraphProperties
,
3440 sUNO_service_style_ParagraphPropertiesComplex
,
3441 sUNO_service_style_ParagraphPropertiesAsian
,
3442 sUNO_service_style_CharacterProperties
,
3443 sUNO_service_style_CharacterPropertiesComplex
,
3444 sUNO_service_style_CharacterPropertiesAsian
,
3446 sUNO_service_drawing_ShadowProperties
,
3447 sUNO_service_drawing_RotationDescriptor
};
3448 return aSvxShape_TextServices
;
3451 case SdrObjKind::Graphic
:
3453 static const uno::Sequence
<OUString
> aSvxShape_GrafServices
3454 = { sUNO_service_drawing_GraphicObjectShape
,
3456 sUNO_service_drawing_Shape
,
3458 sUNO_service_drawing_Text
,
3459 sUNO_service_drawing_TextProperties
,
3460 sUNO_service_style_ParagraphProperties
,
3461 sUNO_service_style_ParagraphPropertiesComplex
,
3462 sUNO_service_style_ParagraphPropertiesAsian
,
3463 sUNO_service_style_CharacterProperties
,
3464 sUNO_service_style_CharacterPropertiesComplex
,
3465 sUNO_service_style_CharacterPropertiesAsian
,
3467 sUNO_service_drawing_ShadowProperties
,
3468 sUNO_service_drawing_RotationDescriptor
};
3469 return aSvxShape_GrafServices
;
3472 case SdrObjKind::OLE2
:
3474 static const uno::Sequence
<OUString
> aSvxShape_Ole2Services
3475 = { sUNO_service_drawing_OLE2Shape
,
3476 sUNO_service_drawing_Shape
,
3478 // #i118485# Added Text, Shadow and Rotation
3479 sUNO_service_drawing_Text
,
3480 sUNO_service_drawing_TextProperties
,
3481 sUNO_service_style_ParagraphProperties
,
3482 sUNO_service_style_ParagraphPropertiesComplex
,
3483 sUNO_service_style_ParagraphPropertiesAsian
,
3484 sUNO_service_style_CharacterProperties
,
3485 sUNO_service_style_CharacterPropertiesComplex
,
3486 sUNO_service_style_CharacterPropertiesAsian
,
3488 sUNO_service_drawing_ShadowProperties
,
3489 sUNO_service_drawing_RotationDescriptor
};
3490 return aSvxShape_Ole2Services
;
3493 case SdrObjKind::Caption
:
3495 static const uno::Sequence
<OUString
> aSvxShape_CaptionServices
3496 = { sUNO_service_drawing_CaptionShape
,
3498 sUNO_service_drawing_Shape
,
3499 sUNO_service_drawing_FillProperties
,
3500 sUNO_service_drawing_LineProperties
,
3502 sUNO_service_drawing_Text
,
3503 sUNO_service_drawing_TextProperties
,
3504 sUNO_service_style_ParagraphProperties
,
3505 sUNO_service_style_ParagraphPropertiesComplex
,
3506 sUNO_service_style_ParagraphPropertiesAsian
,
3507 sUNO_service_style_CharacterProperties
,
3508 sUNO_service_style_CharacterPropertiesComplex
,
3509 sUNO_service_style_CharacterPropertiesAsian
,
3511 sUNO_service_drawing_ShadowProperties
,
3512 sUNO_service_drawing_RotationDescriptor
};
3513 return aSvxShape_CaptionServices
;
3516 case SdrObjKind::Page
:
3518 static const uno::Sequence
<OUString
> aSvxShape_PageServices
3519 = { sUNO_service_drawing_PageShape
,
3520 sUNO_service_drawing_Shape
};
3521 return aSvxShape_PageServices
;
3524 case SdrObjKind::Measure
:
3526 static const uno::Sequence
<OUString
> aSvxShape_MeasureServices
3527 = { sUNO_service_drawing_MeasureShape
,
3529 sUNO_service_drawing_MeasureProperties
,
3531 sUNO_service_drawing_Shape
,
3532 sUNO_service_drawing_LineProperties
,
3534 sUNO_service_drawing_Text
,
3535 sUNO_service_drawing_TextProperties
,
3536 sUNO_service_style_ParagraphProperties
,
3537 sUNO_service_style_ParagraphPropertiesComplex
,
3538 sUNO_service_style_ParagraphPropertiesAsian
,
3539 sUNO_service_style_CharacterProperties
,
3540 sUNO_service_style_CharacterPropertiesComplex
,
3541 sUNO_service_style_CharacterPropertiesAsian
,
3543 sUNO_service_drawing_PolyPolygonDescriptor
,
3544 sUNO_service_drawing_ShadowProperties
,
3545 sUNO_service_drawing_RotationDescriptor
};
3546 return aSvxShape_MeasureServices
;
3549 case SdrObjKind::OLEPluginFrame
:
3551 static const uno::Sequence
<OUString
> aSvxShape_FrameServices
3552 = { sUNO_service_drawing_FrameShape
,
3553 sUNO_service_drawing_Shape
};
3554 return aSvxShape_FrameServices
;
3557 case SdrObjKind::UNO
:
3559 static const uno::Sequence
<OUString
> aSvxShape_UnoServices
3560 = { sUNO_service_drawing_ControlShape
,
3561 sUNO_service_drawing_Shape
};
3562 return aSvxShape_UnoServices
;
3565 case SdrObjKind::Edge
:
3567 static const uno::Sequence
<OUString
> aSvxShape_EdgeServices
3568 = { sUNO_service_drawing_ConnectorShape
,
3569 sUNO_service_drawing_ConnectorProperties
,
3571 sUNO_service_drawing_Shape
,
3572 sUNO_service_drawing_LineProperties
,
3574 sUNO_service_drawing_Text
,
3575 sUNO_service_drawing_TextProperties
,
3576 sUNO_service_style_ParagraphProperties
,
3577 sUNO_service_style_ParagraphPropertiesComplex
,
3578 sUNO_service_style_ParagraphPropertiesAsian
,
3579 sUNO_service_style_CharacterProperties
,
3580 sUNO_service_style_CharacterPropertiesComplex
,
3581 sUNO_service_style_CharacterPropertiesAsian
,
3583 sUNO_service_drawing_PolyPolygonDescriptor
,
3584 sUNO_service_drawing_ShadowProperties
,
3585 sUNO_service_drawing_RotationDescriptor
};
3586 return aSvxShape_EdgeServices
;
3588 case SdrObjKind::Media
:
3590 static const uno::Sequence
<OUString
> aSvxShape_MediaServices
3591 = { sUNO_service_drawing_MediaShape
,
3592 sUNO_service_drawing_Shape
};
3593 return aSvxShape_MediaServices
;
3598 else if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::FmForm
)
3600 #if OSL_DEBUG_LEVEL > 0
3601 const SdrObjKind nIdent
= GetSdrObject()->GetObjIdentifier();
3602 OSL_ENSURE( nIdent
== SdrObjKind::UNO
, "SvxShape::_getSupportedServiceNames: SdrInventor::FmForm, but no UNO object?" );
3604 static const uno::Sequence
<OUString
> aSvxShape_UnoServices
3605 = { sUNO_service_drawing_ControlShape
,
3606 sUNO_service_drawing_Shape
};
3607 return aSvxShape_UnoServices
;
3609 OSL_FAIL( "SvxShape::_getSupportedServiceNames: could not determine object type!" );
3610 uno::Sequence
< OUString
> aSeq
;
3614 sal_Bool SAL_CALL
SvxShape::supportsService( const OUString
& ServiceName
)
3616 return cppu::supportsService(this, ServiceName
);
3619 // XGluePointsSupplier
3620 uno::Reference
< container::XIndexContainer
> SAL_CALL
SvxShape::getGluePoints()
3622 ::SolarMutexGuard aGuard
;
3623 uno::Reference
< container::XIndexContainer
> xGluePoints( mxGluePoints
);
3625 if( HasSdrObject() && !xGluePoints
.is() )
3627 uno::Reference
< container::XIndexContainer
> xNew( SvxUnoGluePointAccess_createInstance( GetSdrObject() ), uno::UNO_QUERY
);
3628 mxGluePoints
= xGluePoints
= xNew
;
3635 uno::Reference
<uno::XInterface
> SAL_CALL
SvxShape::getParent()
3637 ::SolarMutexGuard aGuard
;
3638 const SdrObject
* pSdrObject(GetSdrObject());
3640 if(nullptr != pSdrObject
)
3642 const SdrObjList
* pParentSdrObjList(GetSdrObject()->getParentSdrObjListFromSdrObject());
3644 if(nullptr != pParentSdrObjList
)
3646 // SdrObject is member of a SdrObjList. That may be a SdrObject
3647 // (SdrObjGroup or E3dScene) or a SdrPage.
3648 // Check for SdrObject first - using getSdrPageFromSdrObjList
3649 // *will* get the SdrPage even when the SdrObject is deep buried
3650 // in a construct of SdrObjGroup.
3651 // We want to ask for the direct parent here...
3652 SdrObject
* pParentSdrObject(pParentSdrObjList
->getSdrObjectFromSdrObjList());
3654 if(nullptr != pParentSdrObject
)
3656 // SdrObject is member of a SdrObject-based Group (SdrObjGroup or E3dScene).
3657 return pParentSdrObject
->getUnoShape();
3661 SdrPage
* pParentSdrPage(pParentSdrObjList
->getSdrPageFromSdrObjList());
3663 if(nullptr != pParentSdrPage
)
3665 // SdrObject is inserted to a SdrPage. Since
3666 // we checked for getSdrObjectFromSdrObjList first,
3667 // we can even say that it is directly member of that
3669 return pParentSdrPage
->getUnoPage();
3673 // not member of any SdrObjList, no parent
3674 OSL_FAIL( "SvxShape::getParent( ): unexpected Parent SdrObjList" );
3678 // no SdrObject, no parent
3679 return uno::Reference
<uno::XInterface
>();
3682 void SAL_CALL
SvxShape::setParent( const css::uno::Reference
< css::uno::XInterface
>& )
3684 throw lang::NoSupportException();
3688 /** called from the XActionLockable interface methods on initial locking */
3689 void SvxShape::lock()
3694 /** called from the XActionLockable interface methods on final unlock */
3695 void SvxShape::unlock()
3701 sal_Bool SAL_CALL
SvxShape::isActionLocked( )
3703 ::SolarMutexGuard aGuard
;
3705 return mnLockCount
!= 0;
3709 void SAL_CALL
SvxShape::addActionLock( )
3711 ::SolarMutexGuard aGuard
;
3713 DBG_ASSERT( mnLockCount
< 0xffff, "lock overflow in SvxShape!" );
3716 if( mnLockCount
== 1 )
3721 void SAL_CALL
SvxShape::removeActionLock( )
3723 ::SolarMutexGuard aGuard
;
3725 DBG_ASSERT( mnLockCount
> 0, "lock underflow in SvxShape!" );
3728 if( mnLockCount
== 0 )
3733 void SAL_CALL
SvxShape::setActionLocks( sal_Int16 nLock
)
3735 ::SolarMutexGuard aGuard
;
3737 if( (mnLockCount
== 0) && (nLock
!= 0) )
3740 if( (mnLockCount
!= 0) && (nLock
== 0) )
3743 mnLockCount
= static_cast<sal_uInt16
>(nLock
);
3747 sal_Int16 SAL_CALL
SvxShape::resetActionLocks( )
3749 ::SolarMutexGuard aGuard
;
3751 if( mnLockCount
!= 0 )
3754 sal_Int16 nOldLocks
= static_cast<sal_Int16
>(mnLockCount
);
3761 /** since polygon shapes can change their kind during editing, we have
3763 Circle shapes also change their kind, but they are all treated equal
3764 so no update is necessary.
3766 void SvxShape::updateShapeKind()
3768 switch( mpImpl
->mnObjId
)
3770 case SdrObjKind::Line
:
3771 case SdrObjKind::Polygon
:
3772 case SdrObjKind::PolyLine
:
3773 case SdrObjKind::PathLine
:
3774 case SdrObjKind::PathFill
:
3775 case SdrObjKind::FreehandLine
:
3776 case SdrObjKind::FreehandFill
:
3777 case SdrObjKind::PathPoly
:
3778 case SdrObjKind::PathPolyLine
:
3780 const SdrObjKind nId
= GetSdrObject()->GetObjIdentifier();
3782 if( nId
!= mpImpl
->mnObjId
)
3784 mpImpl
->mnObjId
= nId
;
3793 SvxShapeText::SvxShapeText(SdrObject
* pObject
)
3794 : SvxShape( pObject
, getSvxMapProvider().GetMap(SVXMAP_TEXT
), getSvxMapProvider().GetPropertySet(SVXMAP_TEXT
, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
3797 SetEditSource( new SvxTextEditSource( pObject
, nullptr ) );
3801 SvxShapeText::SvxShapeText(SdrObject
* pObject
, o3tl::span
<const SfxItemPropertyMapEntry
> pPropertyMap
, const SvxItemPropertySet
* pPropertySet
)
3802 : SvxShape( pObject
, pPropertyMap
, pPropertySet
), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
3805 SetEditSource( new SvxTextEditSource( pObject
, nullptr ) );
3809 SvxShapeText::~SvxShapeText() noexcept
3811 // check if only this instance is registered at the ranges
3812 DBG_ASSERT( (nullptr == GetEditSource()) || (GetEditSource()->getRanges().size()==1),
3813 "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!");
3816 void SvxShapeText::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
3818 if( pNewObj
&& (nullptr == GetEditSource()))
3819 SetEditSource( new SvxTextEditSource( pNewObj
, nullptr ) );
3820 SvxShape::Create( pNewObj
, pNewPage
);
3825 uno::Any SAL_CALL
SvxShapeText::queryInterface( const uno::Type
& rType
)
3827 return SvxShape::queryInterface( rType
);
3831 uno::Any SAL_CALL
SvxShapeText::queryAggregation( const uno::Type
& rType
)
3833 uno::Any
aAny( SvxShape::queryAggregation( rType
) );
3834 if( aAny
.hasValue() )
3837 return SvxUnoTextBase::queryAggregation( rType
);
3843 OUString SAL_CALL
SvxShapeText::getImplementationName()
3845 return "SvxShapeText";
3849 uno::Sequence
< OUString
> SAL_CALL
SvxShapeText::getSupportedServiceNames()
3851 return SvxShape::getSupportedServiceNames();
3855 sal_Bool SAL_CALL
SvxShapeText::supportsService( const OUString
& ServiceName
)
3857 return cppu::supportsService(static_cast<SvxShape
*>(this), ServiceName
);
3862 uno::Sequence
< uno::Type
> SAL_CALL
SvxShapeText::getTypes()
3864 return SvxShape::getTypes();
3867 sal_Int64 SAL_CALL
SvxShapeText::getSomething( const css::uno::Sequence
< sal_Int8
>& rId
)
3869 const sal_Int64 nReturn
= SvxShape::getSomething( rId
);
3873 return SvxUnoTextBase::getSomething( rId
);
3877 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeText::getImplementationId()
3879 return css::uno::Sequence
<sal_Int8
>();
3883 /** called from the XActionLockable interface methods on initial locking */
3884 void SvxShapeText::lock()
3886 SvxTextEditSource
* pEditSource
= static_cast<SvxTextEditSource
*>(GetEditSource());
3888 pEditSource
->lock();
3892 /** called from the XActionLockable interface methods on final unlock */
3893 void SvxShapeText::unlock()
3895 SvxTextEditSource
* pEditSource
= static_cast<SvxTextEditSource
*>(GetEditSource());
3897 pEditSource
->unlock();
3900 // css::text::XTextRange
3901 uno::Reference
< text::XTextRange
> SAL_CALL
SvxShapeText::getStart()
3903 ::SolarMutexGuard aGuard
;
3904 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : nullptr;
3906 ::GetSelection( maSelection
, pForwarder
);
3907 return SvxUnoTextBase::getStart();
3911 uno::Reference
< text::XTextRange
> SAL_CALL
SvxShapeText::getEnd()
3913 ::SolarMutexGuard aGuard
;
3914 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : nullptr;
3916 ::GetSelection( maSelection
, pForwarder
);
3917 return SvxUnoTextBase::getEnd();
3920 OUString SAL_CALL
SvxShapeText::getString()
3922 ::SolarMutexGuard aGuard
;
3923 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : nullptr;
3925 ::GetSelection( maSelection
, pForwarder
);
3926 return SvxUnoTextBase::getString();
3930 void SAL_CALL
SvxShapeText::setString( const OUString
& aString
)
3932 ::SolarMutexGuard aGuard
;
3933 SvxTextForwarder
* pForwarder
= mpEditSource
? mpEditSource
->GetTextForwarder() : nullptr;
3935 ::GetSelection( maSelection
, pForwarder
);
3936 SvxUnoTextBase::setString( aString
);
3939 // override these for special property handling in subcasses. Return true if property is handled
3940 bool SvxShapeText::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
3943 // since SdrTextObj::SetVerticalWriting exchanges
3944 // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT,
3945 // we have to set the textdirection here
3947 if( pProperty
->nWID
== SDRATTR_TEXTDIRECTION
)
3949 SdrTextObj
* pTextObj
= DynCastSdrTextObj( GetSdrObject() );
3952 css::text::WritingMode eMode
;
3953 if( rValue
>>= eMode
)
3955 pTextObj
->SetVerticalWriting( eMode
== css::text::WritingMode_TB_RL
);
3960 return SvxShape::setPropertyValueImpl( rName
, pProperty
, rValue
);
3963 bool SvxShapeText::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
3965 if( pProperty
->nWID
== SDRATTR_TEXTDIRECTION
)
3967 SdrTextObj
* pTextObj
= DynCastSdrTextObj( GetSdrObject() );
3968 if( pTextObj
&& pTextObj
->IsVerticalWriting() )
3969 rValue
<<= css::text::WritingMode_TB_RL
;
3971 rValue
<<= css::text::WritingMode_LR_TB
;
3975 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
3978 bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertyMapEntry
* pProperty
, css::beans::PropertyState
& rState
)
3980 return SvxShape::getPropertyStateImpl( pProperty
, rState
);
3983 bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertyMapEntry
* pProperty
)
3985 return SvxShape::setPropertyToDefaultImpl( pProperty
);
3988 SvxShapeRect::SvxShapeRect(SdrObject
* pObj
)
3989 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_SHAPE
), getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE
, SdrObject::GetGlobalDrawObjectItemPool()))
3993 SvxShapeRect::~SvxShapeRect() noexcept
3997 uno::Any SAL_CALL
SvxShapeRect::queryInterface( const uno::Type
& rType
)
3999 return SvxShapeText::queryInterface( rType
);
4002 uno::Any SAL_CALL
SvxShapeRect::queryAggregation( const uno::Type
& rType
)
4004 return SvxShapeText::queryAggregation( rType
);
4009 uno::Sequence
< OUString
> SvxShapeRect::getSupportedServiceNames()
4011 return SvxShape::getSupportedServiceNames();
4014 /** returns a StarOffice API wrapper for the given SdrObject */
4015 uno::Reference
< drawing::XShape
> GetXShapeForSdrObject( SdrObject
* pObj
) noexcept
4017 uno::Reference
< drawing::XShape
> xShape( pObj
->getUnoShape(), uno::UNO_QUERY
);
4022 SdrObject
* SdrObject::getSdrObjectFromXShape( const css::uno::Reference
< css::uno::XInterface
>& xInt
)
4024 SvxShape
* pSvxShape
= comphelper::getFromUnoTunnel
<SvxShape
>( xInt
);
4025 return pSvxShape
? pSvxShape
->GetSdrObject() : nullptr;
4028 uno::Any
SvxItemPropertySet_getPropertyValue( const SfxItemPropertyMapEntry
* pMap
, const SfxItemSet
& rSet
)
4030 if(!pMap
|| !pMap
->nWID
)
4033 // Check is for items that store either metric values if they are positive or percentage if they are negative.
4034 bool bDontConvertNegativeValues
= ( pMap
->nWID
== XATTR_FILLBMP_SIZEX
|| pMap
->nWID
== XATTR_FILLBMP_SIZEY
);
4035 return SvxItemPropertySet::getPropertyValue( pMap
, rSet
, (pMap
->nWID
!= SDRATTR_XMLATTRIBUTES
), bDontConvertNegativeValues
);
4038 void SvxItemPropertySet_setPropertyValue( const SfxItemPropertyMapEntry
* pMap
, const uno::Any
& rVal
, SfxItemSet
& rSet
)
4040 if(!pMap
|| !pMap
->nWID
)
4043 bool bDontConvertNegativeValues
= ( pMap
->nWID
== XATTR_FILLBMP_SIZEX
|| pMap
->nWID
== XATTR_FILLBMP_SIZEY
);
4044 SvxItemPropertySet::setPropertyValue( pMap
, rVal
, rSet
, bDontConvertNegativeValues
);
4047 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */