tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / svx / source / unodraw / unoshape.cxx
blob9ae9b9d69e09274e129dfef29621185a6be41a00
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <cppuhelper/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 <comphelper/scopeguard.hxx>
33 #include <comphelper/servicehelper.hxx>
34 #include <comphelper/multiinterfacecontainer4.hxx>
35 #include <toolkit/helper/vclunohelper.hxx>
36 #include <vcl/gfxlink.hxx>
37 #include <vcl/virdev.hxx>
38 #include <svx/sdangitm.hxx>
39 #include <svx/svdlayer.hxx>
40 #include <svx/svdopage.hxx>
41 #include <svx/svx3ditems.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/sdr/contact/viewcontact.hxx>
82 #include <drawinglayer/converters.hxx>
83 #include <drawinglayer/geometry/viewinformation2d.hxx>
84 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
86 #include <vcl/gdimtf.hxx>
87 #include <vcl/wmf.hxx>
88 #include <svx/sdtfsitm.hxx>
89 #include <svx/svdopath.hxx>
90 #include <svx/SvxXTextColumns.hxx>
91 #include <svx/xflclit.hxx>
92 #include <editeng/frmdiritem.hxx>
94 #include <memory>
95 #include <optional>
96 #include <vector>
97 #include <iostream>
99 #include <bitmaps.hlst>
101 using namespace ::cppu;
102 using namespace ::com::sun::star;
103 using namespace ::com::sun::star::uno;
104 using namespace ::com::sun::star::lang;
105 using namespace ::com::sun::star::container;
107 class GDIMetaFile;
109 struct SvxShapeImpl
111 std::optional<SfxItemSet> moItemSet;
112 SdrObjKind mnObjId;
113 SvxShapeMaster* mpMaster;
114 bool mbDisposing;
116 /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when
117 * a SvxShape::Create() call is executed. It is then set to the created
118 * SdrObject so a multiple call to SvxShape::Create() with same SdrObject
119 * is prohibited.
121 ::unotools::WeakReference< SdrObject > mxCreatedObj;
123 // for xComponent
124 ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> maDisposeListeners;
125 ::comphelper::OMultiTypeInterfaceContainerHelperVar4<OUString, css::beans::XPropertyChangeListener> maPropertyChangeListeners;
127 SvxShapeImpl()
128 :mnObjId( SdrObjKind::NONE )
129 ,mpMaster( nullptr )
130 ,mbDisposing( false )
135 namespace {
138 /// Calculates what scaling factor will be used for autofit text scaling of this shape.
139 SdrTextObj* getTextObjectWithFitToSize(SdrObject* pObject)
141 SdrTextObj* pTextObj = DynCastSdrTextObj(pObject);
142 if (!pTextObj)
144 return nullptr;
147 const SfxItemSet& rTextObjSet = pTextObj->GetMergedItemSet();
148 if (rTextObjSet.GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE)->GetValue()
149 != drawing::TextFitToSizeType_AUTOFIT)
151 return nullptr;
154 return pTextObj;
158 SvxShape::SvxShape( SdrObject* pObject )
159 : maSize(100,100)
160 , mpImpl( new SvxShapeImpl )
161 , mbIsMultiPropertyCall(false)
162 , mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
163 , maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
164 , mxSdrObject(pObject)
165 , mnLockCount(0)
167 impl_construct();
171 SvxShape::SvxShape( SdrObject* pObject, std::span<const SfxItemPropertyMapEntry> pEntries, const SvxItemPropertySet* pPropertySet )
172 : maSize(100,100)
173 , mpImpl( new SvxShapeImpl )
174 , mbIsMultiPropertyCall(false)
175 , mpPropSet(pPropertySet)
176 , maPropMapEntries(pEntries)
177 , mxSdrObject(pObject)
178 , mnLockCount(0)
180 impl_construct();
184 SvxShape::~SvxShape() noexcept
186 ::SolarMutexGuard aGuard;
188 DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" );
190 if ( mpImpl->mpMaster )
191 mpImpl->mpMaster->dispose();
193 if ( mxSdrObject )
195 mxSdrObject->RemoveListener(*this);
196 mxSdrObject->setUnoShape(nullptr);
197 mxSdrObject.clear();
200 EndListeningAll(); // call explicitly within SolarMutexGuard
204 void SvxShape::InvalidateSdrObject()
206 if(mxSdrObject)
208 mxSdrObject->RemoveListener(*this);
209 mxSdrObject.clear();
213 void SvxShape::setShapeKind( SdrObjKind nKind )
215 mpImpl->mnObjId = nKind;
219 SdrObjKind SvxShape::getShapeKind() const
221 return mpImpl->mnObjId;
225 void SvxShape::setMaster( SvxShapeMaster* pMaster )
227 mpImpl->mpMaster = pMaster;
231 uno::Any SAL_CALL SvxShape::queryAggregation( const uno::Type& rType )
233 if( mpImpl->mpMaster )
235 uno::Any aAny;
236 if( mpImpl->mpMaster->queryAggregation( rType, aAny ) )
237 return aAny;
240 return SvxShape_UnoImplHelper::queryAggregation(rType);
243 const css::uno::Sequence< sal_Int8 > & SvxShape::getUnoTunnelId() noexcept
245 static const comphelper::UnoIdInit theSvxShapeUnoTunnelId;
246 return theSvxShapeUnoTunnelId.getSeq();
249 sal_Int64 SAL_CALL SvxShape::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
251 return comphelper::getSomethingImpl(rId, this);
255 void SvxShape::notifyPropertyChange(const OUString& rPropName)
257 std::unique_lock g(m_aMutex);
258 comphelper::OInterfaceContainerHelper4<beans::XPropertyChangeListener>* pPropListeners =
259 mpImpl->maPropertyChangeListeners.getContainer( g, rPropName );
260 comphelper::OInterfaceContainerHelper4<beans::XPropertyChangeListener>* pAllListeners =
261 mpImpl->maPropertyChangeListeners.getContainer( g, OUString() );
262 if (pPropListeners || pAllListeners)
266 // Handle/OldValue not supported
267 beans::PropertyChangeEvent aEvt;
268 aEvt.Source = static_cast<cppu::OWeakObject*>(this);
269 aEvt.PropertyName = rPropName;
270 aEvt.NewValue = getPropertyValue(rPropName);
271 if (pPropListeners)
272 pPropListeners->notifyEach( g, &beans::XPropertyChangeListener::propertyChange, aEvt );
273 if (pAllListeners)
274 pAllListeners->notifyEach( g, &beans::XPropertyChangeListener::propertyChange, aEvt );
276 catch( const Exception& )
278 DBG_UNHANDLED_EXCEPTION("svx");
284 void SvxShape::impl_construct()
286 if ( HasSdrObject() )
288 GetSdrObject()->AddListener(*this);
289 impl_initFromSdrObject();
294 void SvxShape::impl_initFromSdrObject()
296 DBG_TESTSOLARMUTEX();
297 OSL_PRECOND( HasSdrObject(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
298 if ( !HasSdrObject() )
299 return;
301 osl_atomic_increment( &m_refCount );
303 GetSdrObject()->setUnoShape(this);
305 osl_atomic_decrement( &m_refCount );
307 // #i40944#
308 // Do not simply return when no model but do the type corrections
309 // following below.
310 const SdrInventor nInventor = GetSdrObject()->GetObjInventor();
312 // is it one of ours (svx) ?
313 if( !(nInventor == SdrInventor::Default || nInventor == SdrInventor::E3d || nInventor == SdrInventor::FmForm) )
314 return;
316 if(nInventor == SdrInventor::FmForm)
318 mpImpl->mnObjId = SdrObjKind::UNO;
320 else
322 mpImpl->mnObjId = GetSdrObject()->GetObjIdentifier();
325 switch(mpImpl->mnObjId)
327 case SdrObjKind::CircleCut: // segment of circle
328 case SdrObjKind::CircleArc: // arc of circle
329 case SdrObjKind::CircleSection: // sector
330 mpImpl->mnObjId = SdrObjKind::CircleOrEllipse;
331 break;
332 default: ;
337 void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
339 DBG_TESTSOLARMUTEX();
341 assert( pNewObj && "SvxShape::Create: invalid new object!" );
342 if ( !pNewObj )
343 return;
345 rtl::Reference<SdrObject> pCreatedObj = mpImpl->mxCreatedObj.get();
346 assert( ( !pCreatedObj || ( pCreatedObj == pNewObj ) ) &&
347 "SvxShape::Create: the same shape used for two different objects?! Strange ..." );
349 // Correct condition (#i52126#)
350 if ( pCreatedObj == pNewObj )
351 return;
353 // Correct condition (#i52126#)
354 mpImpl->mxCreatedObj = pNewObj;
356 if( HasSdrObject() )
358 GetSdrObject()->RemoveListener( *this );
361 mxSdrObject = pNewObj;
363 if( HasSdrObject() )
365 GetSdrObject()->AddListener( *this );
368 OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" );
369 // this was previously set in impl_initFromSdrObject, but I think it was superfluous
370 // (it definitely was in the other context where it was called, but I strongly suppose
371 // it was also superfluous when called from here)
372 impl_initFromSdrObject();
374 ObtainSettingsFromPropertySet( *mpPropSet );
376 // save user call
377 SdrObjUserCall* pUser = GetSdrObject()->GetUserCall();
378 GetSdrObject()->SetUserCall(nullptr);
380 setPosition( maPosition );
381 setSize( maSize );
383 // restore user call after we set the initial size
384 GetSdrObject()->SetUserCall( pUser );
386 // if this shape was already named, use this name
387 if( !maShapeName.isEmpty() )
389 GetSdrObject()->SetName( maShapeName );
390 maShapeName.clear();
394 void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const noexcept
396 DBG_TESTSOLARMUTEX();
397 if(!HasSdrObject())
398 return;
400 MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
401 if(eMapUnit == MapUnit::Map100thMM)
402 return;
404 if (const auto eTo = MapToO3tlLength(eMapUnit); eTo != o3tl::Length::invalid)
406 rPoint.A() = o3tl::convert(rPoint.A(), o3tl::Length::mm100, eTo);
407 rPoint.B() = o3tl::convert(rPoint.B(), o3tl::Length::mm100, eTo);
409 else
411 OSL_FAIL("AW: Missing unit translation to PoolMetric!");
415 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const noexcept
417 DBG_TESTSOLARMUTEX();
418 if(!HasSdrObject())
419 return;
421 GetSdrObject()->ForceMetricToItemPoolMetric(rPolyPolygon);
424 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DHomMatrix& rB2DHomMatrix) const noexcept
426 DBG_TESTSOLARMUTEX();
427 if(!HasSdrObject())
428 return;
430 MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
431 if(eMapUnit == MapUnit::Map100thMM)
432 return;
434 if (const auto eTo = MapToO3tlLength(eMapUnit); eTo != o3tl::Length::invalid)
436 const double fConvert(o3tl::convert(1.0, o3tl::Length::mm100, eTo));
437 const basegfx::utils::B2DHomMatrixBufferedDecompose aDecomposedTransform(rB2DHomMatrix);
438 rB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
439 aDecomposedTransform.getScale() * fConvert,
440 aDecomposedTransform.getShearX(),
441 aDecomposedTransform.getRotate(),
442 aDecomposedTransform.getTranslate() * fConvert);
444 else
446 OSL_FAIL("Missing unit translation to PoolMetric!");
450 void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const noexcept
452 DBG_TESTSOLARMUTEX();
453 if(!HasSdrObject())
454 return;
456 MapUnit eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
457 if(eMapUnit == MapUnit::Map100thMM)
458 return;
460 if (const auto eFrom = MapToO3tlLength(eMapUnit); eFrom != o3tl::Length::invalid)
462 rPoint.A() = o3tl::convert(rPoint.A(), eFrom, o3tl::Length::mm100);
463 rPoint.B() = o3tl::convert(rPoint.B(), eFrom, o3tl::Length::mm100);
465 else
467 OSL_FAIL("AW: Missing unit translation to 100th mm!");
471 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const noexcept
473 DBG_TESTSOLARMUTEX();
474 if(!HasSdrObject())
475 return;
477 MapUnit eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
478 if(eMapUnit == MapUnit::Map100thMM)
479 return;
481 if (const auto eFrom = MapToO3tlLength(eMapUnit); eFrom != o3tl::Length::invalid)
483 const double fConvert(o3tl::convert(1.0, eFrom, o3tl::Length::mm100));
484 rPolyPolygon.transform(basegfx::utils::createScaleB2DHomMatrix(fConvert, fConvert));
486 else
488 OSL_FAIL("Missing unit translation to 100th mm!");
492 void SvxShape::ForceMetricTo100th_mm(basegfx::B2DHomMatrix& rB2DHomMatrix) const noexcept
494 DBG_TESTSOLARMUTEX();
495 if(!HasSdrObject())
496 return;
498 MapUnit eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
499 if(eMapUnit == MapUnit::Map100thMM)
500 return;
502 if (const auto eFrom = MapToO3tlLength(eMapUnit); eFrom != o3tl::Length::invalid)
504 const double fConvert(o3tl::convert(1.0, eFrom, o3tl::Length::mm100));
505 const basegfx::utils::B2DHomMatrixBufferedDecompose aDecomposedTransform(rB2DHomMatrix);
506 rB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
507 aDecomposedTransform.getScale() * fConvert,
508 aDecomposedTransform.getShearX(),
509 aDecomposedTransform.getRotate(),
510 aDecomposedTransform.getTranslate() * fConvert);
512 else
514 OSL_FAIL("Missing unit translation to 100th mm!");
518 static void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet, SvxItemPropertySetUsrAnys& rAnys,
519 SfxItemSet& rSet, const uno::Reference< beans::XPropertySet >& xSet, const SfxItemPropertyMap* pMap )
521 if(!rAnys.AreThereOwnUsrAnys())
522 return;
524 const SfxItemPropertyMap& rSrc = rPropSet.getPropertyMap();
526 for(const auto & rPair : rSrc.getPropertyEntries())
528 const SfxItemPropertyMapEntry* pSrcProp = rPair.second;
529 const sal_uInt16 nWID = pSrcProp->nWID;
530 if(SfxItemPool::IsWhich(nWID)
531 && (nWID < OWN_ATTR_VALUE_START || nWID > OWN_ATTR_VALUE_END)
532 && rAnys.GetUsrAnyForID(*pSrcProp))
533 rSet.Put(rSet.GetPool()->GetUserOrPoolDefaultItem(nWID));
536 for(const auto & rPair : rSrc.getPropertyEntries())
538 const SfxItemPropertyMapEntry* pSrcProp = rPair.second;
539 if(pSrcProp->nWID)
541 uno::Any* pUsrAny = rAnys.GetUsrAnyForID(*pSrcProp);
542 if(pUsrAny)
544 // search for equivalent entry in pDst
545 const SfxItemPropertyMapEntry* pEntry = pMap->getByName( pSrcProp->aName );
546 if(pEntry)
548 // entry found
549 if(pEntry->nWID >= OWN_ATTR_VALUE_START && pEntry->nWID <= OWN_ATTR_VALUE_END)
551 // special ID in PropertySet, can only be set
552 // directly at the object
553 xSet->setPropertyValue( pSrcProp->aName, *pUsrAny);
555 else
557 SvxItemPropertySet_setPropertyValue(pEntry, *pUsrAny, rSet);
563 rAnys.ClearAllUsrAny();
567 void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet)
569 DBG_TESTSOLARMUTEX();
570 if(HasSdrObject() && maUrsAnys.AreThereOwnUsrAnys())
572 SfxItemSetFixed<SDRATTR_START, SDRATTR_END> aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool() );
573 Reference< beans::XPropertySet > xShape(this);
574 SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet, maUrsAnys, aSet, xShape, &mpPropSet->getPropertyMap() );
576 GetSdrObject()->SetMergedItemSetAndBroadcast(aSet);
578 GetSdrObject()->ApplyNotPersistAttr( aSet );
582 uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
584 DBG_TESTSOLARMUTEX();
585 uno::Any aAny;
587 if(!HasSdrObject() || nullptr == GetSdrObject()->getSdrPageFromSdrObject())
589 return aAny;
592 // tdf#118662 Emulate old behaviour of XclObjComment (see there)
593 const SdrCaptionObj* pSdrCaptionObj(dynamic_cast<SdrCaptionObj*>(GetSdrObject()));
594 if(nullptr != pSdrCaptionObj && pSdrCaptionObj->isSuppressGetBitmap())
596 return aAny;
599 // tdf#119180 If we do not ask for Metafile and we access a SdrGrafObj,
600 // and content exists and is a Bitmap, take the shortcut.
601 // Do *not* do this for Metafile - as can be seen, requested in that case
602 // is a byte-sequence of a saved WMF format file (see below)
603 if(!bMetaFile)
605 const SdrGrafObj* pSdrGrafObj(dynamic_cast<SdrGrafObj*>(GetSdrObject()));
607 if(nullptr != pSdrGrafObj)
609 const Graphic& rGraphic(pSdrGrafObj->GetGraphic());
611 if(GraphicType::Bitmap == rGraphic.GetType())
613 Reference< awt::XBitmap > xBmp( rGraphic.GetXGraphic(), UNO_QUERY );
614 aAny <<= xBmp;
616 return aAny;
621 // tdf#118662 instead of creating an E3dView instance every time to paint
622 // a single SdrObject, use the existing SdrObject::SingleObjectPainter to
623 // use less resources and runtime
624 if(bMetaFile)
626 ScopedVclPtrInstance< VirtualDevice > pVDev;
627 const tools::Rectangle aBoundRect(GetSdrObject()->GetCurrentBoundRect());
628 GDIMetaFile aMtf;
630 pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
631 pVDev->EnableOutput(false);
632 aMtf.Record(pVDev);
633 GetSdrObject()->SingleObjectPainter(*pVDev);
634 aMtf.Stop();
635 aMtf.WindStart();
636 aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
637 aMtf.SetPrefMapMode(MapMode(MapUnit::Map100thMM));
638 aMtf.SetPrefSize(aBoundRect.GetSize());
640 SvMemoryStream aDestStrm(65535, 65535);
642 ConvertGDIMetaFileToWMF(
643 aMtf,
644 aDestStrm,
645 nullptr,
646 false);
648 const uno::Sequence<sal_Int8> aSeq(
649 static_cast< const sal_Int8* >(aDestStrm.GetData()),
650 aDestStrm.GetEndOfData());
652 aAny <<= aSeq;
654 else
656 drawinglayer::primitive2d::Primitive2DContainer xPrimitives;
657 GetSdrObject()->GetViewContact().getViewIndependentPrimitive2DContainer(xPrimitives);
659 if(!xPrimitives.empty())
661 const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
662 basegfx::B2DRange aRange(
663 xPrimitives.getB2DRange(aViewInformation2D));
665 if(!aRange.isEmpty())
667 const MapUnit aSourceMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetScaleUnit());
669 if(MapUnit::Map100thMM != aSourceMapUnit)
671 // tdf#119180 This is UNO API and thus works in 100th_mm,
672 // so if the MapMode from the used SdrModel is *not* equal
673 // to Map100thMM we need to embed the primitives to an adapting
674 // homogen transformation for correct values
675 const basegfx::B2DHomMatrix aMapTransform(
676 OutputDevice::LogicToLogic(
677 MapMode(aSourceMapUnit),
678 MapMode(MapUnit::Map100thMM)));
680 // Embed primitives to get them in 100th mm
681 xPrimitives = drawinglayer::primitive2d::Primitive2DContainer {
682 new drawinglayer::primitive2d::TransformPrimitive2D(
683 aMapTransform,
684 std::move(xPrimitives))
687 // Update basegfx::B2DRange aRange, too. Here we have the
688 // choice of transforming the existing value or get newly by
689 // again using 'xPrimitives.getB2DRange(aViewInformation2D)'
690 aRange.transform(aMapTransform);
693 const BitmapEx aBmp(
694 drawinglayer::convertPrimitive2DContainerToBitmapEx(
695 std::move(xPrimitives),
696 aRange));
698 Graphic aGraph(aBmp);
700 aGraph.SetPrefSize(aBmp.GetPrefSize());
701 aGraph.SetPrefMapMode(aBmp.GetPrefMapMode());
703 Reference< awt::XBitmap > xBmp( aGraph.GetXGraphic(), UNO_QUERY );
704 aAny <<= xBmp;
709 return aAny;
712 uno::Sequence< uno::Type > SAL_CALL SvxShape::getTypes()
714 if( mpImpl->mpMaster )
716 return mpImpl->mpMaster->getTypes();
718 else
720 return _getTypes();
725 uno::Sequence< uno::Type > const & SvxShape::_getTypes()
727 switch( mpImpl->mnObjId )
729 // shapes without text
730 case SdrObjKind::Page:
731 case SdrObjKind::OLEPluginFrame:
732 case SdrObjKind::OLE2Plugin:
733 case SdrObjKind::OLE2Applet:
734 case SdrObjKind::E3D_Cube:
735 case SdrObjKind::E3D_Sphere:
736 case SdrObjKind::E3D_Lathe:
737 case SdrObjKind::E3D_Extrusion:
738 case SdrObjKind::E3D_Polygon:
739 case SdrObjKind::Media:
740 case SdrObjKind::Table:
742 static uno::Sequence<uno::Type> aTypeSequence{
743 cppu::UnoType<drawing::XShape>::get(),
744 cppu::UnoType<lang::XComponent>::get(),
745 cppu::UnoType<beans::XPropertySet>::get(),
746 cppu::UnoType<beans::XMultiPropertySet>::get(),
747 cppu::UnoType<beans::XPropertyState>::get(),
748 cppu::UnoType<beans::XMultiPropertyStates>::get(),
749 cppu::UnoType<drawing::XGluePointsSupplier>::get(),
750 cppu::UnoType<container::XChild>::get(),
751 cppu::UnoType<lang::XServiceInfo>::get(),
752 cppu::UnoType<lang::XTypeProvider>::get(),
753 cppu::UnoType<lang::XUnoTunnel>::get(),
754 cppu::UnoType<container::XNamed>::get(),
757 return aTypeSequence;
759 // group shape
760 case SdrObjKind::Group:
762 static uno::Sequence<uno::Type> aTypeSequence{
763 cppu::UnoType<drawing::XShape>::get(),
764 cppu::UnoType<lang::XComponent>::get(),
765 cppu::UnoType<beans::XPropertySet>::get(),
766 cppu::UnoType<beans::XMultiPropertySet>::get(),
767 cppu::UnoType<beans::XPropertyState>::get(),
768 cppu::UnoType<beans::XMultiPropertyStates>::get(),
769 cppu::UnoType<drawing::XGluePointsSupplier>::get(),
770 cppu::UnoType<container::XChild>::get(),
771 cppu::UnoType<lang::XServiceInfo>::get(),
772 cppu::UnoType<lang::XTypeProvider>::get(),
773 cppu::UnoType<lang::XUnoTunnel>::get(),
774 cppu::UnoType<container::XNamed>::get(),
775 cppu::UnoType<drawing::XShapes>::get(),
776 cppu::UnoType<drawing::XShapeGroup>::get(),
779 return aTypeSequence;
781 // connector shape
782 case SdrObjKind::Edge:
784 static uno::Sequence<uno::Type> aTypeSequence{
785 cppu::UnoType<drawing::XShape>::get(),
786 cppu::UnoType<lang::XComponent>::get(),
787 cppu::UnoType<beans::XPropertySet>::get(),
788 cppu::UnoType<beans::XMultiPropertySet>::get(),
789 cppu::UnoType<beans::XPropertyState>::get(),
790 cppu::UnoType<beans::XMultiPropertyStates>::get(),
791 cppu::UnoType<drawing::XGluePointsSupplier>::get(),
792 cppu::UnoType<container::XChild>::get(),
793 cppu::UnoType<lang::XServiceInfo>::get(),
794 cppu::UnoType<lang::XTypeProvider>::get(),
795 cppu::UnoType<lang::XUnoTunnel>::get(),
796 cppu::UnoType<container::XNamed>::get(),
797 cppu::UnoType<drawing::XConnectorShape>::get(),
798 // from SvxUnoTextBase::getTypes()
799 cppu::UnoType<text::XTextAppend>::get(),
800 cppu::UnoType<text::XTextCopy>::get(),
801 cppu::UnoType<container::XEnumerationAccess>::get(),
802 cppu::UnoType<text::XTextRangeMover>::get(),
805 return aTypeSequence;
807 // control shape
808 case SdrObjKind::UNO:
810 static uno::Sequence<uno::Type> aTypeSequence{
811 cppu::UnoType<drawing::XShape>::get(),
812 cppu::UnoType<lang::XComponent>::get(),
813 cppu::UnoType<beans::XPropertySet>::get(),
814 cppu::UnoType<beans::XMultiPropertySet>::get(),
815 cppu::UnoType<beans::XPropertyState>::get(),
816 cppu::UnoType<beans::XMultiPropertyStates>::get(),
817 cppu::UnoType<drawing::XGluePointsSupplier>::get(),
818 cppu::UnoType<container::XChild>::get(),
819 cppu::UnoType<lang::XServiceInfo>::get(),
820 cppu::UnoType<lang::XTypeProvider>::get(),
821 cppu::UnoType<lang::XUnoTunnel>::get(),
822 cppu::UnoType<container::XNamed>::get(),
823 cppu::UnoType<drawing::XControlShape>::get(),
826 return aTypeSequence;
828 // 3d scene shape
829 case SdrObjKind::E3D_Scene:
831 static uno::Sequence<uno::Type> aTypeSequence{
832 cppu::UnoType<drawing::XShape>::get(),
833 cppu::UnoType<lang::XComponent>::get(),
834 cppu::UnoType<beans::XPropertySet>::get(),
835 cppu::UnoType<beans::XMultiPropertySet>::get(),
836 cppu::UnoType<beans::XPropertyState>::get(),
837 cppu::UnoType<beans::XMultiPropertyStates>::get(),
838 cppu::UnoType<drawing::XGluePointsSupplier>::get(),
839 cppu::UnoType<container::XChild>::get(),
840 cppu::UnoType<lang::XServiceInfo>::get(),
841 cppu::UnoType<lang::XTypeProvider>::get(),
842 cppu::UnoType<lang::XUnoTunnel>::get(),
843 cppu::UnoType<container::XNamed>::get(),
844 cppu::UnoType<drawing::XShapes>::get(),
847 return aTypeSequence;
849 case SdrObjKind::CustomShape:
851 static uno::Sequence<uno::Type> aTypeSequence{
852 cppu::UnoType<drawing::XShape>::get(),
853 cppu::UnoType<lang::XComponent>::get(),
854 cppu::UnoType<beans::XPropertySet>::get(),
855 cppu::UnoType<beans::XMultiPropertySet>::get(),
856 cppu::UnoType<beans::XPropertyState>::get(),
857 cppu::UnoType<beans::XMultiPropertyStates>::get(),
858 cppu::UnoType<drawing::XGluePointsSupplier>::get(),
859 cppu::UnoType<container::XChild>::get(),
860 cppu::UnoType<lang::XServiceInfo>::get(),
861 cppu::UnoType<lang::XTypeProvider>::get(),
862 cppu::UnoType<lang::XUnoTunnel>::get(),
863 cppu::UnoType<container::XNamed>::get(),
864 // from SvxUnoTextBase::getTypes()
865 cppu::UnoType<text::XText>::get(),
866 cppu::UnoType<container::XEnumerationAccess>::get(),
867 cppu::UnoType<text::XTextRangeMover>::get(),
868 cppu::UnoType<drawing::XEnhancedCustomShapeDefaulter>::get(),
871 return aTypeSequence;
873 // shapes with text
874 case SdrObjKind::Rectangle:
875 case SdrObjKind::CircleOrEllipse:
876 case SdrObjKind::Measure:
877 case SdrObjKind::Line:
878 case SdrObjKind::Polygon:
879 case SdrObjKind::PolyLine:
880 case SdrObjKind::PathLine:
881 case SdrObjKind::PathFill:
882 case SdrObjKind::FreehandLine:
883 case SdrObjKind::FreehandFill:
884 case SdrObjKind::PathPoly:
885 case SdrObjKind::PathPolyLine:
886 case SdrObjKind::Graphic:
887 case SdrObjKind::Text:
888 case SdrObjKind::Caption:
889 case SdrObjKind::OLE2: // #i118485# Moved to shapes with text
890 default:
892 static uno::Sequence<uno::Type> aTypeSequence{
893 cppu::UnoType<drawing::XShape>::get(),
894 cppu::UnoType<lang::XComponent>::get(),
895 cppu::UnoType<beans::XPropertySet>::get(),
896 cppu::UnoType<beans::XMultiPropertySet>::get(),
897 cppu::UnoType<beans::XPropertyState>::get(),
898 cppu::UnoType<beans::XMultiPropertyStates>::get(),
899 cppu::UnoType<drawing::XGluePointsSupplier>::get(),
900 cppu::UnoType<container::XChild>::get(),
901 cppu::UnoType<lang::XServiceInfo>::get(),
902 cppu::UnoType<lang::XTypeProvider>::get(),
903 cppu::UnoType<lang::XUnoTunnel>::get(),
904 cppu::UnoType<container::XNamed>::get(),
905 // from SvxUnoTextBase::getTypes()
906 cppu::UnoType<text::XTextAppend>::get(),
907 cppu::UnoType<text::XTextCopy>::get(),
908 cppu::UnoType<container::XEnumerationAccess>::get(),
909 cppu::UnoType<text::XTextRangeMover>::get(),
912 return aTypeSequence;
918 uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId()
920 return css::uno::Sequence<sal_Int8>();
923 void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) noexcept
925 DBG_TESTSOLARMUTEX();
927 // do cheap checks first, this method is hot
928 if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint)
929 return;
930 if( !mxSdrObject )
931 return;
932 const SdrHint* pSdrHint = static_cast<const SdrHint*>(&rHint);
933 // #i55919# SdrHintKind::ObjectChange is only interesting if it's for this object
934 if (pSdrHint->GetKind() != SdrHintKind::ObjectChange || pSdrHint->GetObject() != mxSdrObject.get())
935 return;
937 // prevent object being deleted from under us
938 rtl::Reference<SdrObject> xSdrSelf(mxSdrObject);
939 uno::Reference< uno::XInterface > xSelf( mxSdrObject->getWeakUnoShape() );
940 if( !xSelf.is() )
942 mxSdrObject->RemoveListener(*this);
943 mxSdrObject.clear();
944 return;
947 updateShapeKind();
950 // XShape
953 // The "*LogicRectHack" functions also existed in sch, and those
954 // duplicate symbols cause Bad Things To Happen (TM) #i9462#.
955 // Prefixing with 'svx' and marking static to make sure name collisions
956 // do not occur.
958 static bool svx_needLogicRectHack( SdrObject const * pObj )
960 if( pObj->GetObjInventor() == SdrInventor::Default)
962 switch(pObj->GetObjIdentifier())
964 case SdrObjKind::Group:
965 case SdrObjKind::Line:
966 case SdrObjKind::Polygon:
967 case SdrObjKind::PolyLine:
968 case SdrObjKind::PathLine:
969 case SdrObjKind::PathFill:
970 case SdrObjKind::FreehandLine:
971 case SdrObjKind::FreehandFill:
972 case SdrObjKind::Edge:
973 case SdrObjKind::PathPoly:
974 case SdrObjKind::PathPolyLine:
975 case SdrObjKind::Measure:
976 return true;
977 default:
978 break;
981 return false;
985 static tools::Rectangle svx_getLogicRectHack( SdrObject const * pObj )
987 if(svx_needLogicRectHack(pObj))
989 return pObj->GetSnapRect();
991 else
993 return pObj->GetLogicRect();
998 static void svx_setLogicRectHack( SdrObject* pObj, const tools::Rectangle& rRect )
1000 if(svx_needLogicRectHack(pObj))
1002 pObj->SetSnapRect( rRect );
1004 else
1006 pObj->SetLogicRect( rRect );
1011 awt::Point SAL_CALL SvxShape::getPosition()
1013 ::SolarMutexGuard aGuard;
1015 if(HasSdrObject())
1017 tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
1018 Point aPt( aRect.Left(), aRect.Top() );
1020 // Position is relative to anchor, so recalc to absolute position
1021 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1022 aPt -= GetSdrObject()->GetAnchorPos();
1024 ForceMetricTo100th_mm(aPt);
1025 return css::awt::Point( aPt.X(), aPt.Y() );
1027 else
1029 return maPosition;
1034 void SAL_CALL SvxShape::setPosition( const awt::Point& Position )
1036 ::SolarMutexGuard aGuard;
1038 if(HasSdrObject())
1040 // do NOT move 3D objects, this would change the homogen
1041 // transformation matrix
1042 if(dynamic_cast<const E3dCompoundObject* >(GetSdrObject()) == nullptr)
1044 tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
1045 Point aLocalPos( Position.X, Position.Y );
1046 ForceMetricToItemPoolMetric(aLocalPos);
1048 // Position is absolute, so recalc to position relative to anchor
1049 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1050 aLocalPos += GetSdrObject()->GetAnchorPos();
1052 tools::Long nDX = aLocalPos.X() - aRect.Left();
1053 tools::Long nDY = aLocalPos.Y() - aRect.Top();
1055 GetSdrObject()->Move( Size( nDX, nDY ) );
1056 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1060 maPosition = Position;
1064 awt::Size SAL_CALL SvxShape::getSize()
1066 ::SolarMutexGuard aGuard;
1068 if(HasSdrObject())
1070 tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
1071 Size aObjSize( aRect.getOpenWidth(), aRect.getOpenHeight() );
1072 ForceMetricTo100th_mm(aObjSize);
1073 return css::awt::Size( aObjSize.getWidth(), aObjSize.getHeight() );
1075 else
1076 return maSize;
1080 void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
1082 ::SolarMutexGuard aGuard;
1084 if(HasSdrObject())
1086 tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
1087 Size aLocalSize( rSize.Width, rSize.Height );
1088 ForceMetricToItemPoolMetric(aLocalSize);
1090 if(GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == SdrObjKind::Measure )
1092 Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left());
1093 Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top());
1094 Point aPt = GetSdrObject()->GetSnapRect().TopLeft();
1095 GetSdrObject()->Resize(aPt,aWdt,aHgt);
1097 else
1099 //aRect.SetSize(aLocalSize); // this call subtract 1 // https://bz.apache.org/ooo/show_bug.cgi?id=83193
1100 if ( !aLocalSize.Width() )
1102 aRect.SetWidthEmpty();
1104 else
1105 aRect.setWidth(aLocalSize.Width());
1106 if ( !aLocalSize.Height() )
1108 aRect.SetHeightEmpty();
1110 else
1111 aRect.setHeight(aLocalSize.Height());
1113 svx_setLogicRectHack( GetSdrObject(), aRect );
1116 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1118 maSize = rSize;
1122 // XNamed
1123 OUString SAL_CALL SvxShape::getName( )
1125 ::SolarMutexGuard aGuard;
1126 if( HasSdrObject() )
1128 return GetSdrObject()->GetName();
1130 else
1132 return maShapeName;
1137 void SAL_CALL SvxShape::setName( const OUString& aName )
1139 ::SolarMutexGuard aGuard;
1140 if( HasSdrObject() )
1142 GetSdrObject()->SetName( aName );
1144 else
1146 maShapeName = aName;
1150 // XShapeDescriptor
1153 OUString SAL_CALL SvxShape::getShapeType()
1155 if( !maShapeType.getLength() )
1156 return UHashMap::getNameFromId( mpImpl->mnObjId );
1157 else
1158 return maShapeType;
1161 // XComponent
1164 void SAL_CALL SvxShape::dispose()
1166 std::unique_lock g(m_aMutex);
1168 if( mpImpl->mbDisposing )
1169 return; // caught a recursion
1171 mpImpl->mbDisposing = true;
1173 lang::EventObject aEvt;
1174 aEvt.Source = *static_cast<OWeakAggObject*>(this);
1175 mpImpl->maDisposeListeners.disposeAndClear(g, aEvt);
1176 mpImpl->maPropertyChangeListeners.disposeAndClear(g, aEvt);
1178 rtl::Reference<SdrObject> pObject = mxSdrObject;
1179 if (!pObject)
1180 return;
1182 pObject->RemoveListener( *this );
1184 if ( pObject->IsInserted() && pObject->getSdrPageFromSdrObject() )
1186 SdrPage* pPage = pObject->getSdrPageFromSdrObject();
1187 // delete the SdrObject from the page
1188 const size_t nCount = pPage->GetObjCount();
1189 for ( size_t nNum = 0; nNum < nCount; ++nNum )
1191 if ( pPage->GetObj( nNum ) == pObject.get() )
1193 OSL_VERIFY( pPage->RemoveObject( nNum ) == pObject );
1194 break;
1199 mxSdrObject.clear();
1200 pObject->setUnoShape(nullptr);
1204 void SAL_CALL SvxShape::addEventListener( const Reference< lang::XEventListener >& xListener )
1206 std::unique_lock g(m_aMutex);
1207 mpImpl->maDisposeListeners.addInterface(g, xListener);
1211 void SAL_CALL SvxShape::removeEventListener( const Reference< lang::XEventListener >& aListener )
1213 std::unique_lock g(m_aMutex);
1214 mpImpl->maDisposeListeners.removeInterface(g, aListener);
1217 // XPropertySet
1220 Reference< beans::XPropertySetInfo > SAL_CALL
1221 SvxShape::getPropertySetInfo()
1223 if( mpImpl->mpMaster )
1225 return mpImpl->mpMaster->getPropertySetInfo();
1227 else
1229 return _getPropertySetInfo();
1233 rtl::Reference< SfxItemPropertySetInfo > const &
1234 SvxShape::_getPropertySetInfo()
1236 return mpPropSet->getPropertySetInfo();
1240 void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener )
1242 std::unique_lock g(m_aMutex);
1243 mpImpl->maPropertyChangeListeners.addInterface( g, _propertyName, _listener );
1247 void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener )
1249 std::unique_lock g(m_aMutex);
1250 mpImpl->maPropertyChangeListeners.removeInterface( g, _propertyName, _listener );
1254 void SAL_CALL SvxShape::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& )
1256 OSL_FAIL( "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1260 void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& )
1262 OSL_FAIL( "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" );
1266 bool SvxShape::SetFillAttribute( sal_uInt16 nWID, const OUString& rName )
1268 if(HasSdrObject())
1270 SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), nWID, nWID );
1272 if( SetFillAttribute( nWID, rName, aSet, &GetSdrObject()->getSdrModelFromSdrObject() ) )
1274 //GetSdrObject()->SetItemSetAndBroadcast(aSet);
1275 GetSdrObject()->SetMergedItemSetAndBroadcast(aSet);
1277 return true;
1281 return false;
1285 bool SvxShape::SetFillAttribute( sal_uInt16 nWID, const OUString& rName, SfxItemSet& rSet, SdrModel const * pModel )
1287 // check if an item with the given name and which id is inside the models
1288 // pool or the stylesheet pool, if found it's put in the itemset
1289 if( !SetFillAttribute( nWID, rName, rSet ) )
1291 // we did not find such item in one of the pools, so we check
1292 // the property lists that are loaded for the model for items
1293 // that support such.
1294 OUString aStrName = SvxUnogetInternalNameForItem(nWID, rName);
1296 switch( nWID )
1298 case XATTR_FILLBITMAP:
1300 XBitmapListRef pBitmapList = pModel->GetBitmapList();
1302 if( !pBitmapList.is() )
1303 return false;
1305 tools::Long nPos = pBitmapList->GetIndex(aStrName);
1306 if( nPos == -1 )
1307 return false;
1309 const XBitmapEntry* pEntry = pBitmapList->GetBitmap(nPos);
1310 XFillBitmapItem aBmpItem(rName, pEntry->GetGraphicObject());
1311 rSet.Put(aBmpItem);
1312 break;
1314 case XATTR_FILLGRADIENT:
1316 XGradientListRef pGradientList = pModel->GetGradientList();
1318 if( !pGradientList.is() )
1319 return false;
1321 tools::Long nPos = pGradientList->GetIndex(aStrName);
1322 if( nPos == -1 )
1323 return false;
1325 const XGradientEntry* pEntry = pGradientList->GetGradient(nPos);
1326 XFillGradientItem aGrdItem(rName, pEntry->GetGradient());
1327 rSet.Put( aGrdItem );
1328 break;
1330 case XATTR_FILLHATCH:
1332 XHatchListRef pHatchList = pModel->GetHatchList();
1334 if( !pHatchList.is() )
1335 return false;
1337 tools::Long nPos = pHatchList->GetIndex(aStrName);
1338 if( nPos == -1 )
1339 return false;
1341 const XHatchEntry* pEntry = pHatchList->GetHatch( nPos );
1342 XFillHatchItem aHatchItem(rName, pEntry->GetHatch());
1343 rSet.Put( aHatchItem );
1344 break;
1346 case XATTR_LINEEND:
1347 case XATTR_LINESTART:
1349 XLineEndListRef pLineEndList = pModel->GetLineEndList();
1351 if( !pLineEndList.is() )
1352 return false;
1354 tools::Long nPos = pLineEndList->GetIndex(aStrName);
1355 if( nPos == -1 )
1356 return false;
1358 const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos);
1359 if( sal_uInt16(XATTR_LINEEND) == nWID )
1361 XLineEndItem aLEItem(rName, pEntry->GetLineEnd());
1362 rSet.Put( aLEItem );
1364 else
1366 XLineStartItem aLSItem(rName, pEntry->GetLineEnd());
1367 rSet.Put( aLSItem );
1370 break;
1372 case XATTR_LINEDASH:
1374 XDashListRef pDashList = pModel->GetDashList();
1376 if( !pDashList.is() )
1377 return false;
1379 tools::Long nPos = pDashList->GetIndex(aStrName);
1380 if( nPos == -1 )
1381 return false;
1383 const XDashEntry* pEntry = pDashList->GetDash(nPos);
1384 XLineDashItem aDashItem(rName, pEntry->GetDash());
1385 rSet.Put( aDashItem );
1386 break;
1388 default:
1389 return false;
1393 return true;
1397 bool SvxShape::SetFillAttribute( sal_uInt16 nWID, const OUString& rName, SfxItemSet& rSet )
1399 OUString aName = SvxUnogetInternalNameForItem(nWID, rName);
1401 if (aName.isEmpty())
1403 switch( nWID )
1405 case XATTR_LINEEND:
1406 case XATTR_LINESTART:
1408 const basegfx::B2DPolyPolygon aEmptyPoly;
1409 if( nWID == sal_uInt16(XATTR_LINEEND) )
1410 rSet.Put( XLineEndItem( u""_ustr, aEmptyPoly ) );
1411 else
1412 rSet.Put( XLineStartItem( u""_ustr, aEmptyPoly ) );
1414 return true;
1416 case XATTR_FILLFLOATTRANSPARENCE:
1418 // #85953# Set a disabled XFillFloatTransparenceItem
1419 rSet.Put(XFillFloatTransparenceItem());
1421 return true;
1425 return false;
1428 SfxItemType eItemType;
1429 switch (nWID)
1431 case XATTR_FILLBITMAP: eItemType = SfxItemType::XFillBitmapItemType; break;
1432 case XATTR_FILLGRADIENT: eItemType = SfxItemType::XFillGradientItemType; break;
1433 case XATTR_FILLHATCH: eItemType = SfxItemType::XFillHatchItemType; break;
1434 case XATTR_FILLFLOATTRANSPARENCE: eItemType = SfxItemType::XFillFloatTransparenceItemType; break;
1435 case XATTR_LINEEND: eItemType = SfxItemType::XLineEndItemType; break;
1436 case XATTR_LINESTART: eItemType = SfxItemType::XLineStartItemType; break;
1437 case XATTR_LINEDASH: eItemType = SfxItemType::XLineDashItemType; break;
1438 default: assert(false); abort();
1440 ItemSurrogates aSurrogates;
1441 rSet.GetPool()->GetItemSurrogatesForItem(aSurrogates, eItemType);
1442 for (const SfxPoolItem* p : aSurrogates)
1444 const NameOrIndex* pItem = static_cast<const NameOrIndex*>(p);
1445 if( pItem->GetName() == aName )
1447 rSet.Put( *pItem );
1448 return true;
1452 return false;
1456 void SAL_CALL SvxShape::setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal )
1458 if( mpImpl->mpMaster )
1460 mpImpl->mpMaster->setPropertyValue( rPropertyName, rVal );
1462 else
1464 _setPropertyValue( rPropertyName, rVal );
1468 void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal )
1470 ::SolarMutexGuard aGuard;
1472 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
1474 if (!HasSdrObject())
1476 // Since we have no actual sdr object right now, remember all
1477 // properties in a list. These properties will be set when the sdr
1478 // object is created.
1480 if (pMap && pMap->nWID)
1482 // FIXME: We should throw a UnknownPropertyException here.
1483 // But since this class is aggregated from classes that
1484 // support additional properties that we don't know here we
1485 // silently store *all* properties, even if they may be not
1486 // supported after creation.
1487 SvxItemPropertySet::setPropertyValue( pMap, rVal, maUrsAnys );
1490 return;
1493 if (rPropertyName == "HandlePathObjScale")
1495 auto pPathObj = dynamic_cast<SdrPathObj*>(GetSdrObject());
1496 if (pPathObj)
1498 bool bHandleScale{};
1499 if (rVal >>= bHandleScale)
1501 pPathObj->SetHandleScale(bHandleScale);
1504 return;
1507 // A hack to avoid taking incomplete OLE object's size into account when loading
1508 // see SdXMLObjectShapeContext::createFastChildContext
1509 if (rPropertyName == "IgnoreOLEObjectScale")
1511 if (auto pOleObj = DynCastSdrOle2Obj(GetSdrObject()))
1512 if (bool bVal; rVal >>= bVal)
1513 pOleObj->SetIgnoreOLEObjectScale(bVal);
1514 return;
1517 if (!pMap)
1518 throw beans::UnknownPropertyException( rPropertyName, getXWeak());
1520 if ((pMap->nFlags & beans::PropertyAttribute::READONLY) != 0)
1521 throw beans::PropertyVetoException(
1522 "Readonly property can't be set: " + rPropertyName,
1523 uno::Reference<drawing::XShape>(this));
1525 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1527 if (setPropertyValueImpl(rPropertyName, pMap, rVal))
1528 return;
1530 DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST, "Not persist item not handled!" );
1531 DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
1533 bool bIsNotPersist = pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST && pMap->nWID != SDRATTR_TEXTDIRECTION;
1535 if( pMap->nWID == SDRATTR_CORNER_RADIUS )
1537 sal_Int32 nCornerRadius = 0;
1538 if( !(rVal >>= nCornerRadius) || (nCornerRadius < 0) || (nCornerRadius > 5000000))
1539 throw IllegalArgumentException();
1542 std::optional<SfxItemSet> xLocalSet;
1543 SfxItemSet* pSet;
1544 if( mbIsMultiPropertyCall && !bIsNotPersist )
1546 if( !mpImpl->moItemSet )
1548 mpImpl->moItemSet.emplace( GetSdrObject()->GetProperties().CreateObjectSpecificItemSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool() ) );
1550 pSet = &*mpImpl->moItemSet;
1552 else
1554 xLocalSet.emplace( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), pMap->nWID, pMap->nWID);
1555 pSet = &*xLocalSet;
1558 if( pSet->GetItemState( pMap->nWID ) != SfxItemState::SET )
1559 pSet->Put(GetSdrObject()->GetMergedItem(pMap->nWID));
1561 if( !SvxUnoTextRangeBase::SetPropertyValueHelper( pMap, rVal, *pSet ))
1563 if( pSet->GetItemState( pMap->nWID ) != SfxItemState::SET )
1565 if(bIsNotPersist)
1567 // not-persistent attribute, get those extra
1568 GetSdrObject()->TakeNotPersistAttr(*pSet);
1572 if( pSet->GetItemState( pMap->nWID ) != SfxItemState::SET )
1574 // get default from ItemPool
1575 if(SfxItemPool::IsWhich(pMap->nWID))
1576 pSet->Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetUserOrPoolDefaultItem(pMap->nWID));
1579 if( pSet->GetItemState( pMap->nWID ) == SfxItemState::SET )
1581 SvxItemPropertySet_setPropertyValue( pMap, rVal, *pSet );
1585 if(bIsNotPersist)
1587 // set not-persistent attribute extra
1588 GetSdrObject()->ApplyNotPersistAttr( *pSet );
1590 else
1592 // if we have a XMultiProperty call then the item set
1593 // will be set in setPropertyValues later
1594 if( !mbIsMultiPropertyCall )
1595 GetSdrObject()->SetMergedItemSetAndBroadcast( *pSet );
1600 uno::Any SAL_CALL SvxShape::getPropertyValue( const OUString& PropertyName )
1602 if ( mpImpl->mpMaster )
1603 return mpImpl->mpMaster->getPropertyValue( PropertyName );
1604 else
1605 return _getPropertyValue( PropertyName );
1609 uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
1611 ::SolarMutexGuard aGuard;
1613 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1615 uno::Any aAny;
1616 if(HasSdrObject())
1618 if(pMap == nullptr )
1619 throw beans::UnknownPropertyException( PropertyName, getXWeak());
1621 if( !getPropertyValueImpl( PropertyName, pMap, aAny ) )
1623 DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || (pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST), "Not persist item not handled!" );
1624 DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
1626 SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), pMap->nWID, pMap->nWID );
1627 aSet.Put(GetSdrObject()->GetMergedItem(pMap->nWID));
1629 if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
1630 return aAny;
1632 if(!aSet.Count())
1634 if(pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST)
1636 // not-persistent attribute, get those extra
1637 GetSdrObject()->TakeNotPersistAttr(aSet);
1641 if(!aSet.Count())
1643 // get default from ItemPool
1644 if(SfxItemPool::IsWhich(pMap->nWID))
1645 aSet.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetUserOrPoolDefaultItem(pMap->nWID));
1648 if(aSet.Count())
1649 aAny = GetAnyForItem( aSet, pMap );
1652 else
1655 // Fixme: we should return default values for OWN_ATTR !
1657 if(pMap && pMap->nWID)
1658 // FixMe: see setPropertyValue
1659 aAny = mpPropSet->getPropertyValue( pMap, maUrsAnys );
1662 return aAny;
1666 // XMultiPropertySet
1667 void SAL_CALL SvxShape::setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues )
1669 ::SolarMutexGuard aSolarGuard;
1671 const sal_Int32 nCount = aPropertyNames.getLength();
1672 if (nCount != aValues.getLength())
1673 throw css::lang::IllegalArgumentException(u"lengths do not match"_ustr,
1674 getXWeak(), -1);
1676 const OUString* pNames = aPropertyNames.getConstArray();
1677 const uno::Any* pValues = aValues.getConstArray();
1679 // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are
1680 // reset even when an exception is thrown
1681 const ::comphelper::ScopeGuard aGuard( [this] () { return this->endSetPropertyValues(); } );
1683 mbIsMultiPropertyCall = true;
1685 if( mpImpl->mpMaster )
1687 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1691 setPropertyValue( *pNames, *pValues );
1693 catch (beans::UnknownPropertyException&)
1695 // ignore, various code likes to opportunistically set properties on objects that don't support those properties
1697 catch (uno::Exception&)
1699 DBG_UNHANDLED_EXCEPTION("svx");
1703 else
1705 uno::Reference< beans::XPropertySet > xSet;
1706 queryInterface( cppu::UnoType<beans::XPropertySet>::get()) >>= xSet;
1708 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
1712 xSet->setPropertyValue( *pNames, *pValues );
1714 catch (beans::UnknownPropertyException&)
1716 DBG_UNHANDLED_EXCEPTION("svx");
1718 catch (uno::Exception&)
1720 DBG_UNHANDLED_EXCEPTION("svx");
1725 if( mpImpl->moItemSet && HasSdrObject() )
1726 GetSdrObject()->SetMergedItemSetAndBroadcast( *mpImpl->moItemSet );
1730 void SvxShape::endSetPropertyValues()
1732 mbIsMultiPropertyCall = false;
1733 mpImpl->moItemSet.reset();
1737 css::uno::Sequence< css::uno::Any > SAL_CALL SvxShape::getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames )
1739 const sal_Int32 nCount = aPropertyNames.getLength();
1740 const OUString* pNames = aPropertyNames.getConstArray();
1742 uno::Sequence< uno::Any > aRet( nCount );
1743 uno::Any* pValue = aRet.getArray();
1745 if( mpImpl->mpMaster )
1747 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
1751 *pValue = getPropertyValue( *pNames );
1753 catch( uno::Exception& )
1755 OSL_FAIL( "SvxShape::getPropertyValues, unknown property asked" );
1759 else
1761 uno::Reference< beans::XPropertySet > xSet;
1762 queryInterface( cppu::UnoType<beans::XPropertySet>::get()) >>= xSet;
1764 for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
1768 *pValue = xSet->getPropertyValue( *pNames );
1770 catch( uno::Exception& )
1772 OSL_FAIL( "SvxShape::getPropertyValues, unknown property asked" );
1777 return aRet;
1780 void SAL_CALL SvxShape::addPropertiesChangeListener( const css::uno::Sequence< OUString >& , const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
1784 void SAL_CALL SvxShape::removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
1788 void SAL_CALL SvxShape::firePropertiesChangeEvent( const css::uno::Sequence< OUString >& , const css::uno::Reference< css::beans::XPropertiesChangeListener >& )
1793 uno::Any SvxShape::GetAnyForItem( SfxItemSet const & aSet, const SfxItemPropertyMapEntry* pMap ) const
1795 DBG_TESTSOLARMUTEX();
1796 uno::Any aAny;
1798 switch(pMap->nWID)
1800 case SDRATTR_CIRCSTARTANGLE:
1802 if(const SdrAngleItem* pPoolItem = aSet.GetItemIfSet(SDRATTR_CIRCSTARTANGLE,false))
1804 Degree100 nAngle = pPoolItem->GetValue();
1805 aAny <<= nAngle.get();
1807 break;
1810 case SDRATTR_CIRCENDANGLE:
1812 if (const SdrAngleItem* pPoolItem = aSet.GetItemIfSet(SDRATTR_CIRCENDANGLE,false))
1814 Degree100 nAngle = pPoolItem->GetValue();
1815 aAny <<= nAngle.get();
1817 break;
1820 case SDRATTR_CIRCKIND:
1822 if( GetSdrObject()->GetObjInventor() == SdrInventor::Default)
1824 drawing::CircleKind eKind;
1825 switch(GetSdrObject()->GetObjIdentifier())
1827 case SdrObjKind::CircleOrEllipse: // circle, ellipse
1828 eKind = drawing::CircleKind_FULL;
1829 break;
1830 case SdrObjKind::CircleCut: // segment of circle
1831 eKind = drawing::CircleKind_CUT;
1832 break;
1833 case SdrObjKind::CircleArc: // arc of circle
1834 eKind = drawing::CircleKind_ARC;
1835 break;
1836 case SdrObjKind::CircleSection: // sector
1837 eKind = drawing::CircleKind_SECTION;
1838 break;
1839 default:
1840 break;
1842 aAny <<= eKind;
1844 break;
1846 default:
1848 // get value from ItemSet
1849 aAny = SvxItemPropertySet_getPropertyValue( pMap, aSet );
1851 if( pMap->aType != aAny.getValueType() )
1853 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
1854 if( ( pMap->aType == ::cppu::UnoType<sal_Int16>::get()) && aAny.getValueType() == ::cppu::UnoType<sal_Int32>::get() )
1856 sal_Int32 nValue = 0;
1857 aAny >>= nValue;
1858 aAny <<= static_cast<sal_Int16>(nValue);
1860 else
1862 SAL_WARN("svx", "SvxShape::GetAnyForItem() Return value has wrong Type, " << pMap->aType << " != " << aAny.getValueType());
1869 return aAny;
1873 // XPropertyState
1874 beans::PropertyState SAL_CALL SvxShape::getPropertyState( const OUString& PropertyName )
1876 if( mpImpl->mpMaster )
1878 return mpImpl->mpMaster->getPropertyState( PropertyName );
1880 else
1882 return _getPropertyState( PropertyName );
1886 beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName )
1888 ::SolarMutexGuard aGuard;
1890 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
1892 if( !HasSdrObject() || pMap == nullptr )
1893 throw beans::UnknownPropertyException( PropertyName, getXWeak());
1895 beans::PropertyState eState;
1896 if( !getPropertyStateImpl( pMap, eState ) )
1898 const SfxItemSet& rSet = GetSdrObject()->GetMergedItemSet();
1900 switch( rSet.GetItemState( pMap->nWID, false ) )
1902 case SfxItemState::SET:
1903 eState = beans::PropertyState_DIRECT_VALUE;
1904 break;
1905 case SfxItemState::DEFAULT:
1906 eState = beans::PropertyState_DEFAULT_VALUE;
1907 break;
1908 default:
1909 eState = beans::PropertyState_AMBIGUOUS_VALUE;
1910 break;
1913 // if an item is set, this doesn't mean we want it :)
1914 if( beans::PropertyState_DIRECT_VALUE == eState )
1916 switch( pMap->nWID )
1918 // the following items are disabled by changing the
1919 // fill style or the line style. so there is no need
1920 // to export items without names which should be empty
1921 case XATTR_FILLBITMAP:
1922 case XATTR_FILLGRADIENT:
1923 case XATTR_FILLHATCH:
1924 case XATTR_LINEDASH:
1926 const NameOrIndex* pItem = rSet.GetItem<NameOrIndex>(pMap->nWID);
1927 if( ( pItem == nullptr ) || pItem->GetName().isEmpty() )
1928 eState = beans::PropertyState_DEFAULT_VALUE;
1930 break;
1932 // #i36115#
1933 // If e.g. the LineStart is on NONE and thus the string has length 0, it still
1934 // may be a hard attribute covering the set LineStart of the parent (Style).
1935 // #i37644#
1936 // same is for fill float transparency
1937 case XATTR_LINEEND:
1938 case XATTR_LINESTART:
1939 case XATTR_FILLFLOATTRANSPARENCE:
1941 const NameOrIndex* pItem = rSet.GetItem<NameOrIndex>(pMap->nWID);
1942 if ( pItem == nullptr )
1943 eState = beans::PropertyState_DEFAULT_VALUE;
1945 break;
1946 case XATTR_FILLCOLOR:
1947 if (pMap->nMemberId == MID_COLOR_THEME_INDEX)
1949 const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID);
1950 if (!pColor->getComplexColor().isValidThemeType())
1952 eState = beans::PropertyState_DEFAULT_VALUE;
1955 else if (pMap->nMemberId == MID_COLOR_LUM_MOD)
1957 const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID);
1958 sal_Int16 nLumMod = 10000;
1959 for (auto const& rTransform : pColor->getComplexColor().getTransformations())
1961 if (rTransform.meType == model::TransformationType::LumMod)
1962 nLumMod = rTransform.mnValue;
1964 if (nLumMod == 10000)
1966 eState = beans::PropertyState_DEFAULT_VALUE;
1969 else if (pMap->nMemberId == MID_COLOR_LUM_OFF)
1971 const XFillColorItem* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID);
1972 sal_Int16 nLumOff = 0;
1973 for (auto const& rTransform : pColor->getComplexColor().getTransformations())
1975 if (rTransform.meType == model::TransformationType::LumOff)
1976 nLumOff = rTransform.mnValue;
1978 if (nLumOff == 0)
1980 eState = beans::PropertyState_DEFAULT_VALUE;
1983 else if (pMap->nMemberId == MID_COMPLEX_COLOR)
1985 auto const* pColor = rSet.GetItem<XFillColorItem>(pMap->nWID);
1986 if (pColor->getComplexColor().getType() == model::ColorType::Unused)
1988 eState = beans::PropertyState_DEFAULT_VALUE;
1991 break;
1992 case XATTR_LINECOLOR:
1993 if (pMap->nMemberId == MID_COMPLEX_COLOR)
1995 auto const* pColor = rSet.GetItem<XLineColorItem>(pMap->nWID);
1996 if (pColor->getComplexColor().getType() == model::ColorType::Unused)
1998 eState = beans::PropertyState_DEFAULT_VALUE;
2001 break;
2005 return eState;
2008 bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue )
2010 rtl::Reference<SdrObject> pSdrObject = GetSdrObject();
2011 switch( pProperty->nWID )
2013 case OWN_ATTR_CAPTION_POINT:
2015 awt::Point aPnt;
2016 if( rValue >>= aPnt )
2018 Point aVclPoint( aPnt.X, aPnt.Y );
2020 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2021 // Need to adapt aVclPoint from 100thmm to app-specific
2022 ForceMetricToItemPoolMetric(aVclPoint);
2024 // #90763# position is relative to top left, make it absolute
2025 basegfx::B2DPolyPolygon aNewPolyPolygon;
2026 basegfx::B2DHomMatrix aNewHomogenMatrix;
2027 pSdrObject->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2029 aVclPoint.AdjustX(basegfx::fround<tools::Long>(aNewHomogenMatrix.get(0, 2)) );
2030 aVclPoint.AdjustY(basegfx::fround<tools::Long>(aNewHomogenMatrix.get(1, 2)) );
2032 // #88491# position relative to anchor
2033 if( pSdrObject->getSdrModelFromSdrObject().IsWriter() )
2035 aVclPoint += pSdrObject->GetAnchorPos();
2038 static_cast<SdrCaptionObj*>(pSdrObject.get())->SetTailPos(aVclPoint);
2040 return true;
2042 break;
2044 case OWN_ATTR_TRANSFORMATION:
2046 drawing::HomogenMatrix3 aMatrix;
2047 if(rValue >>= aMatrix)
2049 basegfx::B2DPolyPolygon aNewPolyPolygon;
2050 basegfx::B2DHomMatrix aNewHomogenMatrix;
2052 // tdf#117145 SdrModel data is app-specific
2053 pSdrObject->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2055 aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1);
2056 aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2);
2057 aNewHomogenMatrix.set(0, 2, aMatrix.Line1.Column3);
2058 aNewHomogenMatrix.set(1, 0, aMatrix.Line2.Column1);
2059 aNewHomogenMatrix.set(1, 1, aMatrix.Line2.Column2);
2060 aNewHomogenMatrix.set(1, 2, aMatrix.Line2.Column3);
2061 // For this to be a valid 2D transform matrix, the last row must be [0,0,1]
2062 assert( aMatrix.Line3.Column1 == 0 );
2063 assert( aMatrix.Line3.Column2 == 0 );
2064 assert( aMatrix.Line3.Column3 == 1 );
2066 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2067 // Need to adapt aNewHomogenMatrix from 100thmm to app-specific
2068 ForceMetricToItemPoolMetric(aNewHomogenMatrix);
2070 pSdrObject->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2071 return true;
2073 break;
2076 case OWN_ATTR_ZORDER:
2078 sal_Int32 nNewOrdNum = 0;
2079 if(rValue >>= nNewOrdNum)
2081 SdrObjList* pObjList = pSdrObject->getParentSdrObjListFromSdrObject();
2082 if( pObjList )
2083 pObjList->SetExistingObjectOrdNum( pSdrObject.get(), static_cast<size_t>(nNewOrdNum) );
2084 return true;
2086 break;
2088 case OWN_ATTR_FRAMERECT:
2090 awt::Rectangle aUnoRect;
2091 if(rValue >>= aUnoRect)
2093 Point aTopLeft( aUnoRect.X, aUnoRect.Y );
2094 Size aObjSize( aUnoRect.Width, aUnoRect.Height );
2095 ForceMetricToItemPoolMetric(aTopLeft);
2096 ForceMetricToItemPoolMetric(aObjSize);
2097 tools::Rectangle aRect(aTopLeft, aObjSize);
2098 pSdrObject->SetSnapRect(aRect);
2099 return true;
2101 break;
2103 case OWN_ATTR_MIRRORED:
2105 bool bMirror;
2106 if(rValue >>= bMirror )
2108 SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( pSdrObject.get() );
2109 if( pObj )
2110 pObj->SetMirrored(bMirror);
2111 return true;
2113 break;
2115 case OWN_ATTR_EDGE_START_OBJ:
2116 case OWN_ATTR_EDGE_END_OBJ:
2117 case OWN_ATTR_GLUEID_HEAD:
2118 case OWN_ATTR_GLUEID_TAIL:
2119 case OWN_ATTR_EDGE_START_POS:
2120 case OWN_ATTR_EDGE_END_POS:
2121 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2123 SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(pSdrObject.get());
2124 if(pEdgeObj)
2126 switch(pProperty->nWID)
2128 case OWN_ATTR_EDGE_START_OBJ:
2129 case OWN_ATTR_EDGE_END_OBJ:
2131 Reference< drawing::XShape > xShape;
2132 if( rValue >>= xShape )
2134 SdrObject* pNode = SdrObject::getSdrObjectFromXShape(xShape);
2135 if( pNode )
2137 pEdgeObj->ConnectToNode( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, pNode );
2138 pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ );
2139 return true;
2142 break;
2145 case OWN_ATTR_EDGE_START_POS:
2146 case OWN_ATTR_EDGE_END_POS:
2148 awt::Point aUnoPoint;
2149 if( rValue >>= aUnoPoint )
2151 Point aPoint( aUnoPoint.X, aUnoPoint.Y );
2153 // Reintroduction of fix for issue i59051 (#i108851#)
2154 // perform metric change before applying anchor position,
2155 // because the anchor position is in pool metric.
2156 ForceMetricToItemPoolMetric( aPoint );
2157 if( pSdrObject->getSdrModelFromSdrObject().IsWriter() )
2158 aPoint += pSdrObject->GetAnchorPos();
2160 pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint );
2161 return true;
2163 break;
2166 case OWN_ATTR_GLUEID_HEAD:
2167 case OWN_ATTR_GLUEID_TAIL:
2169 sal_Int32 nId = 0;
2170 if( rValue >>= nId )
2172 pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD, nId );
2173 return true;
2175 break;
2177 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2179 basegfx::B2DPolyPolygon aNewPolyPolygon;
2181 // #123616# be a little bit more flexible regarding the data type used
2182 if( auto s = o3tl::tryAccess<drawing::PointSequenceSequence>(rValue) )
2184 // get polygpon data from PointSequenceSequence
2185 aNewPolyPolygon = basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(
2186 *s);
2188 else if( auto cs = o3tl::tryAccess<drawing::PolyPolygonBezierCoords>(rValue) )
2190 // get polygpon data from PolyPolygonBezierCoords
2191 aNewPolyPolygon = basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(
2192 *cs);
2195 if(aNewPolyPolygon.count())
2197 // Reintroduction of fix for issue i59051 (#i108851#)
2198 ForceMetricToItemPoolMetric( aNewPolyPolygon );
2199 if( pSdrObject->getSdrModelFromSdrObject().IsWriter() )
2201 Point aPoint( pSdrObject->GetAnchorPos() );
2202 aNewPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y()));
2204 pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon );
2205 return true;
2210 break;
2212 case OWN_ATTR_MEASURE_START_POS:
2213 case OWN_ATTR_MEASURE_END_POS:
2215 SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(pSdrObject.get());
2216 awt::Point aUnoPoint;
2217 if(pMeasureObj && ( rValue >>= aUnoPoint ) )
2219 Point aPoint( aUnoPoint.X, aUnoPoint.Y );
2221 // Reintroduction of fix for issue #i59051# (#i108851#)
2222 ForceMetricToItemPoolMetric( aPoint );
2223 if( pSdrObject->getSdrModelFromSdrObject().IsWriter() )
2224 aPoint += pSdrObject->GetAnchorPos();
2226 pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 );
2227 pMeasureObj->SetChanged();
2228 pMeasureObj->BroadcastObjectChange();
2229 return true;
2231 break;
2233 case OWN_ATTR_FILLBMP_MODE:
2235 drawing::BitmapMode eMode;
2236 if(!(rValue >>= eMode) )
2238 sal_Int32 nMode = 0;
2239 if(!(rValue >>= nMode))
2240 break;
2242 eMode = static_cast<drawing::BitmapMode>(nMode);
2244 pSdrObject->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
2245 pSdrObject->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
2246 return true;
2249 case SDRATTR_LAYERID:
2251 sal_Int16 nLayerId = sal_Int16();
2252 if( rValue >>= nLayerId )
2254 SdrLayer* pLayer = pSdrObject->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId));
2255 if( pLayer )
2257 pSdrObject->SetLayer(SdrLayerID(nLayerId));
2258 return true;
2261 break;
2264 case SDRATTR_LAYERNAME:
2266 OUString aLayerName;
2267 if( rValue >>= aLayerName )
2269 const SdrLayer* pLayer = pSdrObject->getSdrModelFromSdrObject().GetLayerAdmin().GetLayer(aLayerName);
2270 if( pLayer != nullptr )
2272 pSdrObject->SetLayer( pLayer->GetID() );
2273 return true;
2276 break;
2278 case SDRATTR_ROTATEANGLE:
2280 sal_Int32 nTmp = 0;
2281 if( rValue >>= nTmp )
2283 Degree100 nAngle(nTmp);
2284 Point aRef1(pSdrObject->GetSnapRect().Center());
2285 nAngle -= pSdrObject->GetRotateAngle();
2286 if (nAngle)
2288 double nSin = sin(toRadians(nAngle));
2289 double nCos = cos(toRadians(nAngle));
2290 pSdrObject->Rotate(aRef1,nAngle,nSin,nCos);
2292 return true;
2295 break;
2298 case SDRATTR_SHEARANGLE:
2300 sal_Int32 nTmp = 0;
2301 if( rValue >>= nTmp )
2303 Degree100 nShear(nTmp);
2304 nShear -= pSdrObject->GetShearAngle();
2305 if(nShear)
2307 Point aRef1(pSdrObject->GetSnapRect().Center());
2308 double nTan = tan(toRadians(nShear));
2309 pSdrObject->Shear(aRef1,nShear,nTan,false);
2310 return true;
2314 break;
2317 case OWN_ATTR_INTEROPGRABBAG:
2319 pSdrObject->SetGrabBagItem(rValue);
2320 return true;
2323 case SDRATTR_OBJMOVEPROTECT:
2325 bool bMoveProtect;
2326 if( rValue >>= bMoveProtect )
2328 pSdrObject->SetMoveProtect(bMoveProtect);
2329 return true;
2331 break;
2333 case SDRATTR_OBJECTNAME:
2335 OUString aName;
2336 if( rValue >>= aName )
2338 pSdrObject->SetName( aName );
2339 return true;
2341 break;
2344 case OWN_ATTR_TEXTFITTOSIZE_FONT_SCALE:
2346 double fScale = 0.0;
2347 if (rValue >>= fScale)
2349 SdrTextFitToSizeTypeItem aItem(pSdrObject->GetMergedItem(SDRATTR_TEXT_FITTOSIZE));
2350 aItem.setFontScale(fScale / 100.0);
2351 pSdrObject->SetMergedItem(aItem);
2352 return true;
2354 break;
2357 case OWN_ATTR_TEXTFITTOSIZE_SPACING_SCALE:
2359 double fScale = 0.0;
2360 if (rValue >>= fScale)
2362 SdrTextFitToSizeTypeItem aItem(pSdrObject->GetMergedItem(SDRATTR_TEXT_FITTOSIZE));
2363 aItem.setSpacingScale(fScale / 100.0);
2364 pSdrObject->SetMergedItem(aItem);
2365 return true;
2367 break;
2370 // #i68101#
2371 case OWN_ATTR_MISC_OBJ_TITLE:
2373 OUString aTitle;
2374 if( rValue >>= aTitle )
2376 pSdrObject->SetTitle( aTitle );
2377 return true;
2379 break;
2381 case OWN_ATTR_MISC_OBJ_DESCRIPTION:
2383 OUString aDescription;
2384 if( rValue >>= aDescription )
2386 pSdrObject->SetDescription( aDescription );
2387 return true;
2389 break;
2391 case OWN_ATTR_MISC_OBJ_DECORATIVE:
2393 bool isDecorative;
2394 if (rValue >>= isDecorative)
2396 pSdrObject->SetDecorative(isDecorative);
2397 return true;
2399 break;
2402 case SDRATTR_OBJPRINTABLE:
2404 bool bPrintable;
2405 if( rValue >>= bPrintable )
2407 pSdrObject->SetPrintable(bPrintable);
2408 return true;
2410 break;
2412 case SDRATTR_OBJVISIBLE:
2414 bool bVisible;
2415 if( rValue >>= bVisible )
2417 pSdrObject->SetVisible(bVisible);
2418 return true;
2420 break;
2422 case SDRATTR_OBJSIZEPROTECT:
2424 bool bResizeProtect;
2425 if( rValue >>= bResizeProtect )
2427 pSdrObject->SetResizeProtect(bResizeProtect);
2428 return true;
2430 break;
2432 case OWN_ATTR_PAGE_NUMBER:
2434 sal_Int32 nPageNum = 0;
2435 if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) )
2437 SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(pSdrObject.get());
2438 if( pPageObj )
2440 SdrModel& rModel(pPageObj->getSdrModelFromSdrObject());
2441 SdrPage* pNewPage = nullptr;
2442 const sal_uInt16 nDestinationPageNum(static_cast<sal_uInt16>((nPageNum << 1) - 1));
2444 if(nDestinationPageNum < rModel.GetPageCount())
2446 pNewPage = rModel.GetPage(nDestinationPageNum);
2449 pPageObj->SetReferencedPage(pNewPage);
2452 return true;
2454 break;
2456 case XATTR_FILLBITMAP:
2457 case XATTR_FILLGRADIENT:
2458 case XATTR_FILLHATCH:
2459 case XATTR_FILLFLOATTRANSPARENCE:
2460 case XATTR_LINEEND:
2461 case XATTR_LINESTART:
2462 case XATTR_LINEDASH:
2464 if( pProperty->nMemberId == MID_NAME )
2466 OUString aApiName;
2467 if( rValue >>= aApiName )
2469 if( SetFillAttribute( pProperty->nWID, aApiName ) )
2470 return true;
2472 break;
2474 else
2476 return false;
2480 case OWN_ATTR_TEXTCOLUMNS:
2482 if (auto pTextObj = DynCastSdrTextObj(pSdrObject.get()))
2484 css::uno::Reference<css::text::XTextColumns> xTextColumns;
2485 if (rValue >>= xTextColumns)
2487 pTextObj->SetTextColumnsNumber(xTextColumns->getColumnCount());
2488 if (css::uno::Reference<css::beans::XPropertySet> xPropSet{ xTextColumns,
2489 css::uno::UNO_QUERY })
2491 auto aVal = xPropSet->getPropertyValue(u"AutomaticDistance"_ustr);
2492 if (sal_Int32 nSpacing; aVal >>= nSpacing)
2493 pTextObj->SetTextColumnsSpacing(nSpacing);
2497 return true;
2500 case OWN_ATTR_HYPERLINK:
2502 OUString sHyperlink;
2503 if (rValue >>= sHyperlink)
2505 pSdrObject->setHyperlink(sHyperlink);
2506 return true;
2508 break;
2511 case SDRATTR_WRITINGMODE2:
2513 SvxFrameDirectionItem aItem(SvxFrameDirection::Environment, SDRATTR_WRITINGMODE2);
2514 aItem.PutValue(rValue, 0);
2515 GetSdrObject()->SetMergedItem(aItem);
2516 return true;
2517 break;
2520 default:
2522 return false;
2526 OUString sExceptionMessage(
2527 "IllegalArgumentException in SvxShape::setPropertyValueImpl."
2528 " Property Type: "
2529 + pProperty->aType.getTypeName() + " Property Name: " + pProperty->aName
2530 + " Property nWID: " + OUString::number(pProperty->nWID)
2531 + " Value Type: " + (rValue.hasValue() ? rValue.getValueTypeName() : u"void (no value)"_ustr));
2533 throw lang::IllegalArgumentException(sExceptionMessage, nullptr, 1);
2537 bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue )
2539 switch( pProperty->nWID )
2541 case OWN_ATTR_CAPTION_POINT:
2543 Point aVclPoint = static_cast<SdrCaptionObj*>(GetSdrObject())->GetTailPos();
2545 // #88491# make pos relative to anchor
2546 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2548 aVclPoint -= GetSdrObject()->GetAnchorPos();
2551 // #90763# pos is absolute, make it relative to top left
2552 basegfx::B2DPolyPolygon aNewPolyPolygon;
2553 basegfx::B2DHomMatrix aNewHomogenMatrix;
2554 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2556 aVclPoint.AdjustX( -(basegfx::fround<tools::Long>(aNewHomogenMatrix.get(0, 2))) );
2557 aVclPoint.AdjustY( -(basegfx::fround<tools::Long>(aNewHomogenMatrix.get(1, 2))) );
2559 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2560 // Need to adapt aVclPoint from app-specific to 100thmm
2561 ForceMetricTo100th_mm(aVclPoint);
2563 awt::Point aPnt( aVclPoint.X(), aVclPoint.Y() );
2564 rValue <<= aPnt;
2565 break;
2568 case OWN_ATTR_TRANSFORMATION:
2570 basegfx::B2DPolyPolygon aNewPolyPolygon;
2571 basegfx::B2DHomMatrix aNewHomogenMatrix;
2572 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
2573 drawing::HomogenMatrix3 aMatrix;
2575 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
2576 // Need to adapt aNewHomogenMatrix from app-specific to 100thmm
2577 ForceMetricTo100th_mm(aNewHomogenMatrix);
2579 aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0);
2580 aMatrix.Line1.Column2 = aNewHomogenMatrix.get(0, 1);
2581 aMatrix.Line1.Column3 = aNewHomogenMatrix.get(0, 2);
2582 aMatrix.Line2.Column1 = aNewHomogenMatrix.get(1, 0);
2583 aMatrix.Line2.Column2 = aNewHomogenMatrix.get(1, 1);
2584 aMatrix.Line2.Column3 = aNewHomogenMatrix.get(1, 2);
2585 aMatrix.Line3.Column1 = 0;
2586 aMatrix.Line3.Column2 = 0;
2587 aMatrix.Line3.Column3 = 1;
2589 rValue <<= aMatrix;
2591 break;
2594 case OWN_ATTR_ZORDER:
2596 rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetOrdNum());
2597 break;
2600 case OWN_ATTR_BITMAP:
2602 rValue = GetBitmap();
2603 if(!rValue.hasValue())
2604 throw uno::RuntimeException();
2606 break;
2609 case OWN_ATTR_ISFONTWORK:
2611 bool bIsFontwork = false;
2612 if (const SdrTextObj* pTextObj = DynCastSdrTextObj(GetSdrObject()))
2613 bIsFontwork = pTextObj->IsFontwork();
2614 rValue <<= bIsFontwork;
2615 break;
2618 case OWN_ATTR_FRAMERECT:
2620 tools::Rectangle aRect( GetSdrObject()->GetSnapRect() );
2621 Point aTopLeft( aRect.TopLeft() );
2622 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
2623 ForceMetricTo100th_mm(aTopLeft);
2624 ForceMetricTo100th_mm(aObjSize);
2625 css::awt::Rectangle aUnoRect(
2626 aTopLeft.X(), aTopLeft.Y(),
2627 aObjSize.getWidth(), aObjSize.getHeight() );
2628 rValue <<= aUnoRect;
2629 break;
2632 case OWN_ATTR_BOUNDRECT:
2634 tools::Rectangle aRect( GetSdrObject()->GetCurrentBoundRect() );
2635 Point aTopLeft( aRect.TopLeft() );
2636 Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
2637 ForceMetricTo100th_mm(aTopLeft);
2638 ForceMetricTo100th_mm(aObjSize);
2639 css::awt::Rectangle aUnoRect(
2640 aTopLeft.X(), aTopLeft.Y(),
2641 aObjSize.getWidth(), aObjSize.getHeight() );
2642 rValue <<= aUnoRect;
2643 break;
2646 case OWN_ATTR_LDNAME:
2648 OUString aName( GetSdrObject()->GetName() );
2649 rValue <<= aName;
2650 break;
2653 case OWN_ATTR_LDBITMAP:
2655 OUString sId;
2656 if( GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == SdrObjKind::OLE2 )
2658 sId = RID_UNODRAW_OLE2;
2660 else if( GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == SdrObjKind::Graphic )
2662 sId = RID_UNODRAW_GRAPHICS;
2664 else
2666 sId = RID_UNODRAW_OBJECTS;
2669 BitmapEx aBmp(sId);
2670 Reference<awt::XBitmap> xBmp(VCLUnoHelper::CreateBitmap(aBmp));
2672 rValue <<= xBmp;
2673 break;
2676 case OWN_ATTR_MIRRORED:
2678 bool bMirror = false;
2679 if( HasSdrObject() )
2680 if (auto pGrafObj = dynamic_cast<SdrGrafObj*>(GetSdrObject()) )
2681 bMirror = pGrafObj->IsMirrored();
2683 rValue <<= bMirror;
2684 break;
2687 case OWN_ATTR_EDGE_START_OBJ:
2688 case OWN_ATTR_EDGE_START_POS:
2689 case OWN_ATTR_EDGE_END_POS:
2690 case OWN_ATTR_EDGE_END_OBJ:
2691 case OWN_ATTR_GLUEID_HEAD:
2692 case OWN_ATTR_GLUEID_TAIL:
2693 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2695 SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(GetSdrObject());
2696 if(pEdgeObj)
2698 switch(pProperty->nWID)
2700 case OWN_ATTR_EDGE_START_OBJ:
2701 case OWN_ATTR_EDGE_END_OBJ:
2703 SdrObject* pNode = pEdgeObj->GetConnectedNode(pProperty->nWID == OWN_ATTR_EDGE_START_OBJ);
2704 if(pNode)
2706 Reference< drawing::XShape > xShape( GetXShapeForSdrObject( pNode ) );
2707 if(xShape.is())
2708 rValue <<= xShape;
2711 break;
2714 case OWN_ATTR_EDGE_START_POS:
2715 case OWN_ATTR_EDGE_END_POS:
2717 Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) );
2718 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2719 aPoint -= GetSdrObject()->GetAnchorPos();
2721 ForceMetricTo100th_mm( aPoint );
2722 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
2724 rValue <<= aUnoPoint;
2725 break;
2727 case OWN_ATTR_GLUEID_HEAD:
2728 case OWN_ATTR_GLUEID_TAIL:
2730 rValue <<= pEdgeObj->getGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD );
2731 break;
2733 case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
2735 basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() );
2736 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2738 Point aPoint( GetSdrObject()->GetAnchorPos() );
2739 aPolyPoly.transform(basegfx::utils::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y()));
2741 // Reintroduction of fix for issue #i59051# (#i108851#)
2742 ForceMetricTo100th_mm( aPolyPoly );
2743 drawing::PolyPolygonBezierCoords aRetval;
2744 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPoly, aRetval);
2745 rValue <<= aRetval;
2746 break;
2750 break;
2753 case OWN_ATTR_MEASURE_START_POS:
2754 case OWN_ATTR_MEASURE_END_POS:
2756 SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(GetSdrObject());
2757 if(pMeasureObj)
2759 Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) );
2760 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
2761 aPoint -= GetSdrObject()->GetAnchorPos();
2763 // Reintroduction of fix for issue #i59051# (#i108851#)
2764 ForceMetricTo100th_mm( aPoint );
2765 awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
2767 rValue <<= aUnoPoint;
2768 break;
2770 break;
2773 case OWN_ATTR_FILLBMP_MODE:
2775 const SfxItemSet& rObjItemSet = GetSdrObject()->GetMergedItemSet();
2777 if (rObjItemSet.Get(XATTR_FILLBMP_TILE).GetValue())
2779 rValue <<= drawing::BitmapMode_REPEAT;
2781 else if (rObjItemSet.Get(XATTR_FILLBMP_STRETCH).GetValue())
2783 rValue <<= drawing::BitmapMode_STRETCH;
2785 else
2787 rValue <<= drawing::BitmapMode_NO_REPEAT;
2789 break;
2791 case SDRATTR_LAYERID:
2792 rValue <<= GetSdrObject()->GetLayer().get();
2793 break;
2795 case SDRATTR_LAYERNAME:
2797 SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(GetSdrObject()->GetLayer());
2798 if( pLayer )
2800 rValue <<= pLayer->GetName();
2802 break;
2805 case SDRATTR_ROTATEANGLE:
2806 rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetRotateAngle());
2807 break;
2809 case SDRATTR_SHEARANGLE:
2810 rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetShearAngle());
2811 break;
2813 case OWN_ATTR_INTEROPGRABBAG:
2815 GetSdrObject()->GetGrabBagItem(rValue);
2816 break;
2819 case SDRATTR_OBJMOVEPROTECT:
2820 rValue <<= GetSdrObject()->IsMoveProtect();
2821 break;
2823 case SDRATTR_OBJECTNAME:
2825 OUString aName( GetSdrObject()->GetName() );
2826 rValue <<= aName;
2827 break;
2830 // #i68101#
2831 case OWN_ATTR_MISC_OBJ_TITLE:
2833 OUString aTitle( GetSdrObject()->GetTitle() );
2834 rValue <<= aTitle;
2835 break;
2838 case OWN_ATTR_MISC_OBJ_DESCRIPTION:
2840 OUString aDescription( GetSdrObject()->GetDescription() );
2841 rValue <<= aDescription;
2842 break;
2845 case OWN_ATTR_MISC_OBJ_DECORATIVE:
2847 bool const isDecorative(GetSdrObject()->IsDecorative());
2848 rValue <<= isDecorative;
2849 break;
2852 case SDRATTR_OBJPRINTABLE:
2853 rValue <<= GetSdrObject()->IsPrintable();
2854 break;
2856 case SDRATTR_OBJVISIBLE:
2857 rValue <<= GetSdrObject()->IsVisible();
2858 break;
2860 case SDRATTR_OBJSIZEPROTECT:
2861 rValue <<= GetSdrObject()->IsResizeProtect();
2862 break;
2864 case OWN_ATTR_PAGE_NUMBER:
2866 SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(GetSdrObject());
2867 if(pPageObj)
2869 SdrPage* pPage = pPageObj->GetReferencedPage();
2870 sal_Int32 nPageNumber = pPage ? pPage->GetPageNum() : 0;
2871 nPageNumber++;
2872 nPageNumber >>= 1;
2873 rValue <<= nPageNumber;
2875 break;
2878 case OWN_ATTR_UINAME_SINGULAR:
2880 rValue <<= GetSdrObject()->TakeObjNameSingul();
2881 break;
2884 case OWN_ATTR_TEXTFITTOSIZE_FONT_SCALE:
2886 auto* pTextObject = getTextObjectWithFitToSize(GetSdrObject());
2887 if (pTextObject)
2889 rValue <<= pTextObject->GetFontScale() * 100.0;
2891 break;
2894 case OWN_ATTR_TEXTFITTOSIZE_SPACING_SCALE:
2896 auto* pTextObject = getTextObjectWithFitToSize(GetSdrObject());
2897 if (pTextObject)
2899 rValue <<= pTextObject->GetSpacingScale() * 100.0;
2901 break;
2904 case OWN_ATTR_UINAME_PLURAL:
2906 rValue <<= GetSdrObject()->TakeObjNamePlural();
2907 break;
2909 case OWN_ATTR_METAFILE:
2911 SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(GetSdrObject());
2912 if( pObj )
2914 const Graphic* pGraphic = pObj->GetGraphic();
2915 if( pGraphic )
2917 bool bIsWMF = false;
2918 if ( pGraphic->IsGfxLink() )
2920 GfxLink aLnk = pGraphic->GetGfxLink();
2921 if ( aLnk.GetType() == GfxLinkType::NativeWmf )
2923 bIsWMF = true;
2924 uno::Sequence<sal_Int8> aSeq(reinterpret_cast<sal_Int8 const *>(aLnk.GetData()), static_cast<sal_Int32>(aLnk.GetDataSize()));
2925 rValue <<= aSeq;
2928 if ( !bIsWMF )
2930 // #119735# just use GetGDIMetaFile, it will create a buffered version of contained bitmap now automatically
2931 GDIMetaFile aMtf(pGraphic->GetGDIMetaFile());
2932 SvMemoryStream aDestStrm( 65535, 65535 );
2933 ConvertGDIMetaFileToWMF( aMtf, aDestStrm, nullptr, false );
2934 const uno::Sequence<sal_Int8> aSeq(
2935 static_cast< const sal_Int8* >(aDestStrm.GetData()),
2936 aDestStrm.GetEndOfData());
2937 rValue <<= aSeq;
2941 else
2943 rValue = GetBitmap( true );
2945 break;
2948 case OWN_ATTR_TEXTCOLUMNS:
2950 if (auto pTextObj = DynCastSdrTextObj(GetSdrObject()))
2952 if (pTextObj->HasTextColumnsNumber() || pTextObj->HasTextColumnsSpacing())
2954 auto xIf = SvxXTextColumns_createInstance();
2955 css::uno::Reference<css::text::XTextColumns> xCols(xIf, css::uno::UNO_QUERY_THROW);
2956 xCols->setColumnCount(pTextObj->GetTextColumnsNumber());
2957 css::uno::Reference<css::beans::XPropertySet> xProp(xIf, css::uno::UNO_QUERY_THROW);
2958 xProp->setPropertyValue(u"AutomaticDistance"_ustr,
2959 css::uno::Any(pTextObj->GetTextColumnsSpacing()));
2960 rValue <<= xIf;
2963 break;
2966 case OWN_ATTR_HYPERLINK:
2968 rValue <<= GetSdrObject()->getHyperlink();
2969 break;
2972 default:
2973 return false;
2975 return true;
2979 bool SvxShape::getPropertyStateImpl( const SfxItemPropertyMapEntry* pProperty, css::beans::PropertyState& rState )
2981 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
2983 const SfxItemSet& rSet = GetSdrObject()->GetMergedItemSet();
2985 if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SfxItemState::SET ||
2986 rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SfxItemState::SET )
2988 rState = beans::PropertyState_DIRECT_VALUE;
2990 else
2992 rState = beans::PropertyState_AMBIGUOUS_VALUE;
2995 else if((( pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
2996 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) && ( pProperty->nWID != SDRATTR_TEXTDIRECTION ) )
2998 rState = beans::PropertyState_DIRECT_VALUE;
3000 else
3002 return false;
3005 return true;
3009 bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertyMapEntry* pProperty )
3011 if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
3013 GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_STRETCH );
3014 GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_TILE );
3015 return true;
3017 else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
3018 ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST ))
3020 return true;
3022 else
3024 return false;
3029 uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
3031 const sal_Int32 nCount = aPropertyName.getLength();
3032 uno::Sequence< beans::PropertyState > aRet( nCount );
3034 std::transform(aPropertyName.begin(), aPropertyName.end(), aRet.getArray(),
3035 [this](const OUString& rName) -> beans::PropertyState { return getPropertyState(rName); });
3037 return aRet;
3041 void SAL_CALL SvxShape::setPropertyToDefault( const OUString& PropertyName )
3043 if( mpImpl->mpMaster )
3045 mpImpl->mpMaster->setPropertyToDefault( PropertyName );
3047 else
3049 _setPropertyToDefault( PropertyName );
3053 void SvxShape::_setPropertyToDefault( const OUString& PropertyName )
3055 ::SolarMutexGuard aGuard;
3057 const SfxItemPropertyMapEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName);
3059 if( !HasSdrObject() || pProperty == nullptr )
3060 throw beans::UnknownPropertyException( PropertyName, getXWeak());
3062 if( !setPropertyToDefaultImpl( pProperty ) )
3064 GetSdrObject()->ClearMergedItem( pProperty->nWID );
3067 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
3071 uno::Any SAL_CALL SvxShape::getPropertyDefault( const OUString& aPropertyName )
3073 if( mpImpl->mpMaster )
3075 return mpImpl->mpMaster->getPropertyDefault( aPropertyName );
3077 else
3079 return _getPropertyDefault( aPropertyName );
3083 uno::Any SvxShape::_getPropertyDefault( const OUString& aPropertyName )
3085 ::SolarMutexGuard aGuard;
3087 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
3089 if( !HasSdrObject() || pMap == nullptr )
3090 throw beans::UnknownPropertyException( aPropertyName, getXWeak());
3092 if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) ||
3093 ( pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST ))
3095 return getPropertyValue( aPropertyName );
3098 // get default from ItemPool
3099 if(!SfxItemPool::IsWhich(pMap->nWID))
3100 throw beans::UnknownPropertyException( "No WhichID " + OUString::number(pMap->nWID) + " for " + aPropertyName, getXWeak());
3102 SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), pMap->nWID, pMap->nWID );
3103 aSet.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetUserOrPoolDefaultItem(pMap->nWID));
3105 return GetAnyForItem( aSet, pMap );
3108 // XMultiPropertyStates
3109 void SvxShape::setAllPropertiesToDefault()
3111 ::SolarMutexGuard aGuard;
3113 SdrObject* pSdrObj = GetSdrObject();
3114 if( !pSdrObj )
3115 throw lang::DisposedException();
3116 pSdrObj->ClearMergedItem(); // nWhich == 0 => all
3118 const SdrObjKind nObjId = pSdrObj->GetObjIdentifier();
3119 if(nObjId == SdrObjKind::Graphic) // SdrGrafObj
3121 // defaults for graphic objects have changed:
3122 pSdrObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
3123 pSdrObj->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) );
3126 // #i68523# special handling for Svx3DCharacterModeItem, this is not saved
3127 // but needs to be sal_True in svx, pool default (false) in sch. Since sch
3128 // does not load lathe or extrude objects, it is possible to set the items
3129 // here.
3130 // For other solution possibilities, see task description.
3131 if( nObjId == SdrObjKind::E3D_Lathe /*E3dLatheObj*/ || nObjId == SdrObjKind::E3D_Extrusion /*E3dExtrudeObj*/ )
3133 pSdrObj->SetMergedItem(Svx3DCharacterModeItem(true));
3136 pSdrObj->getSdrModelFromSdrObject().SetChanged();
3139 void SvxShape::setPropertiesToDefault(
3140 const uno::Sequence<OUString>& aPropertyNames )
3142 for ( const auto& rPropertyName : aPropertyNames )
3143 setPropertyToDefault( rPropertyName );
3146 uno::Sequence<uno::Any> SvxShape::getPropertyDefaults(
3147 const uno::Sequence<OUString>& aPropertyNames )
3149 ::std::vector<uno::Any> ret;
3150 ret.reserve(aPropertyNames.getLength());
3151 std::transform(aPropertyNames.begin(), aPropertyNames.end(), std::back_inserter(ret),
3152 [this](const OUString& rName) -> uno::Any { return getPropertyDefault(rName); });
3153 return uno::Sequence<uno::Any>( ret.data(), ret.size() );
3157 // XServiceInfo
3159 OUString SAL_CALL SvxShape::getImplementationName()
3161 return u"SvxShape"_ustr;
3164 constexpr OUString sUNO_service_style_ParagraphProperties = u"com.sun.star.style.ParagraphProperties"_ustr;
3165 constexpr OUString sUNO_service_style_ParagraphPropertiesComplex = u"com.sun.star.style.ParagraphPropertiesComplex"_ustr;
3166 constexpr OUString sUNO_service_style_ParagraphPropertiesAsian = u"com.sun.star.style.ParagraphPropertiesAsian"_ustr;
3167 constexpr OUString sUNO_service_style_CharacterProperties = u"com.sun.star.style.CharacterProperties"_ustr;
3168 constexpr OUString sUNO_service_style_CharacterPropertiesComplex = u"com.sun.star.style.CharacterPropertiesComplex"_ustr;
3169 constexpr OUString sUNO_service_style_CharacterPropertiesAsian = u"com.sun.star.style.CharacterPropertiesAsian"_ustr;
3171 constexpr OUString sUNO_service_drawing_FillProperties = u"com.sun.star.drawing.FillProperties"_ustr;
3172 constexpr OUString sUNO_service_drawing_TextProperties = u"com.sun.star.drawing.TextProperties"_ustr;
3173 constexpr OUString sUNO_service_drawing_LineProperties = u"com.sun.star.drawing.LineProperties"_ustr;
3174 constexpr OUString sUNO_service_drawing_ConnectorProperties = u"com.sun.star.drawing.ConnectorProperties"_ustr;
3175 constexpr OUString sUNO_service_drawing_MeasureProperties = u"com.sun.star.drawing.MeasureProperties"_ustr;
3176 constexpr OUString sUNO_service_drawing_ShadowProperties = u"com.sun.star.drawing.ShadowProperties"_ustr;
3178 constexpr OUString sUNO_service_drawing_RotationDescriptor = u"com.sun.star.drawing.RotationDescriptor"_ustr;
3180 constexpr OUString sUNO_service_drawing_Text = u"com.sun.star.drawing.Text"_ustr;
3181 constexpr OUString sUNO_service_drawing_GroupShape = u"com.sun.star.drawing.GroupShape"_ustr;
3183 constexpr OUString sUNO_service_drawing_CustomShapeProperties = u"com.sun.star.drawing.CustomShapeProperties"_ustr;
3184 constexpr OUString sUNO_service_drawing_CustomShape = u"com.sun.star.drawing.CustomShape"_ustr;
3186 constexpr OUString sUNO_service_drawing_PolyPolygonDescriptor = u"com.sun.star.drawing.PolyPolygonDescriptor"_ustr;
3187 constexpr OUString sUNO_service_drawing_PolyPolygonBezierDescriptor= u"com.sun.star.drawing.PolyPolygonBezierDescriptor"_ustr;
3189 constexpr OUString sUNO_service_drawing_LineShape = u"com.sun.star.drawing.LineShape"_ustr;
3190 constexpr OUString sUNO_service_drawing_Shape = u"com.sun.star.drawing.Shape"_ustr;
3191 constexpr OUString sUNO_service_drawing_RectangleShape = u"com.sun.star.drawing.RectangleShape"_ustr;
3192 constexpr OUString sUNO_service_drawing_EllipseShape = u"com.sun.star.drawing.EllipseShape"_ustr;
3193 constexpr OUString sUNO_service_drawing_PolyPolygonShape = u"com.sun.star.drawing.PolyPolygonShape"_ustr;
3194 constexpr OUString sUNO_service_drawing_PolyLineShape = u"com.sun.star.drawing.PolyLineShape"_ustr;
3195 constexpr OUString sUNO_service_drawing_OpenBezierShape = u"com.sun.star.drawing.OpenBezierShape"_ustr;
3196 constexpr OUString sUNO_service_drawing_ClosedBezierShape = u"com.sun.star.drawing.ClosedBezierShape"_ustr;
3197 constexpr OUString sUNO_service_drawing_TextShape = u"com.sun.star.drawing.TextShape"_ustr;
3198 constexpr OUString sUNO_service_drawing_AnnotationShape = u"com.sun.star.drawing.AnnotationShape"_ustr;
3199 constexpr OUString sUNO_service_drawing_GraphicObjectShape = u"com.sun.star.drawing.GraphicObjectShape"_ustr;
3200 constexpr OUString sUNO_service_drawing_OLE2Shape = u"com.sun.star.drawing.OLE2Shape"_ustr;
3201 constexpr OUString sUNO_service_drawing_PageShape = u"com.sun.star.drawing.PageShape"_ustr;
3202 constexpr OUString sUNO_service_drawing_CaptionShape = u"com.sun.star.drawing.CaptionShape"_ustr;
3203 constexpr OUString sUNO_service_drawing_MeasureShape = u"com.sun.star.drawing.MeasureShape"_ustr;
3204 constexpr OUString sUNO_service_drawing_FrameShape = u"com.sun.star.drawing.FrameShape"_ustr;
3205 constexpr OUString sUNO_service_drawing_ControlShape = u"com.sun.star.drawing.ControlShape"_ustr;
3206 constexpr OUString sUNO_service_drawing_ConnectorShape = u"com.sun.star.drawing.ConnectorShape"_ustr;
3207 constexpr OUString sUNO_service_drawing_MediaShape = u"com.sun.star.drawing.MediaShape"_ustr;
3210 uno::Sequence< OUString > SAL_CALL SvxShape::getSupportedServiceNames()
3212 if( mpImpl->mpMaster )
3214 return mpImpl->mpMaster->getSupportedServiceNames();
3216 else
3218 return _getSupportedServiceNames();
3222 uno::Sequence< OUString > SvxShape::_getSupportedServiceNames()
3224 ::SolarMutexGuard aGuard;
3226 if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::Default)
3228 const SdrObjKind nIdent = GetSdrObject()->GetObjIdentifier();
3230 switch(nIdent)
3232 case SdrObjKind::Group:
3234 static const uno::Sequence<OUString> aSvxShape_GroupServices
3235 = { sUNO_service_drawing_GroupShape,
3236 sUNO_service_drawing_Shape };
3237 return aSvxShape_GroupServices;
3239 case SdrObjKind::CustomShape:
3241 static const uno::Sequence<OUString> aSvxShape_CustomShapeServices
3242 = { sUNO_service_drawing_CustomShape,
3243 sUNO_service_drawing_Shape,
3244 sUNO_service_drawing_CustomShapeProperties,
3245 sUNO_service_drawing_FillProperties,
3246 sUNO_service_drawing_LineProperties,
3247 sUNO_service_drawing_Text,
3248 sUNO_service_drawing_TextProperties,
3249 sUNO_service_style_ParagraphProperties,
3250 sUNO_service_style_ParagraphPropertiesComplex,
3251 sUNO_service_style_ParagraphPropertiesAsian,
3252 sUNO_service_style_CharacterProperties,
3253 sUNO_service_style_CharacterPropertiesComplex,
3254 sUNO_service_style_CharacterPropertiesAsian,
3255 sUNO_service_drawing_ShadowProperties,
3256 sUNO_service_drawing_RotationDescriptor };
3257 return aSvxShape_CustomShapeServices;
3259 case SdrObjKind::Line:
3261 static const uno::Sequence<OUString> aSvxShape_LineServices
3262 = { sUNO_service_drawing_LineShape,
3264 sUNO_service_drawing_Shape,
3265 sUNO_service_drawing_LineProperties,
3267 sUNO_service_drawing_Text,
3268 sUNO_service_drawing_TextProperties,
3269 sUNO_service_style_ParagraphProperties,
3270 sUNO_service_style_ParagraphPropertiesComplex,
3271 sUNO_service_style_ParagraphPropertiesAsian,
3272 sUNO_service_style_CharacterProperties,
3273 sUNO_service_style_CharacterPropertiesComplex,
3274 sUNO_service_style_CharacterPropertiesAsian,
3276 sUNO_service_drawing_PolyPolygonDescriptor,
3277 sUNO_service_drawing_ShadowProperties,
3278 sUNO_service_drawing_RotationDescriptor };
3279 return aSvxShape_LineServices;
3282 case SdrObjKind::Rectangle:
3284 static const uno::Sequence<OUString> aSvxShape_RectServices
3285 = { sUNO_service_drawing_RectangleShape,
3287 sUNO_service_drawing_Shape,
3288 sUNO_service_drawing_FillProperties,
3289 sUNO_service_drawing_LineProperties,
3290 sUNO_service_drawing_Text,
3291 sUNO_service_drawing_TextProperties,
3292 sUNO_service_style_ParagraphProperties,
3293 sUNO_service_style_ParagraphPropertiesComplex,
3294 sUNO_service_style_ParagraphPropertiesAsian,
3295 sUNO_service_style_CharacterProperties,
3296 sUNO_service_style_CharacterPropertiesComplex,
3297 sUNO_service_style_CharacterPropertiesAsian,
3299 sUNO_service_drawing_ShadowProperties,
3300 sUNO_service_drawing_RotationDescriptor };
3301 return aSvxShape_RectServices;
3304 case SdrObjKind::CircleOrEllipse:
3305 case SdrObjKind::CircleSection:
3306 case SdrObjKind::CircleArc:
3307 case SdrObjKind::CircleCut:
3309 static const uno::Sequence<OUString> aSvxShape_CircServices
3310 = { sUNO_service_drawing_EllipseShape,
3312 sUNO_service_drawing_Shape,
3313 sUNO_service_drawing_FillProperties,
3314 sUNO_service_drawing_LineProperties,
3316 sUNO_service_drawing_Text,
3317 sUNO_service_drawing_TextProperties,
3318 sUNO_service_style_ParagraphProperties,
3319 sUNO_service_style_ParagraphPropertiesComplex,
3320 sUNO_service_style_ParagraphPropertiesAsian,
3321 sUNO_service_style_CharacterProperties,
3322 sUNO_service_style_CharacterPropertiesComplex,
3323 sUNO_service_style_CharacterPropertiesAsian,
3325 sUNO_service_drawing_ShadowProperties,
3326 sUNO_service_drawing_RotationDescriptor };
3327 return aSvxShape_CircServices;
3330 case SdrObjKind::PathPolyLine:
3331 case SdrObjKind::PolyLine:
3333 static const uno::Sequence<OUString> aSvxShape_PathServices
3334 = { sUNO_service_drawing_PolyLineShape,
3336 sUNO_service_drawing_Shape,
3337 sUNO_service_drawing_LineProperties,
3339 sUNO_service_drawing_PolyPolygonDescriptor,
3341 sUNO_service_drawing_Text,
3342 sUNO_service_drawing_TextProperties,
3343 sUNO_service_style_ParagraphProperties,
3344 sUNO_service_style_ParagraphPropertiesComplex,
3345 sUNO_service_style_ParagraphPropertiesAsian,
3346 sUNO_service_style_CharacterProperties,
3347 sUNO_service_style_CharacterPropertiesComplex,
3348 sUNO_service_style_CharacterPropertiesAsian,
3350 sUNO_service_drawing_ShadowProperties,
3351 sUNO_service_drawing_RotationDescriptor };
3352 return aSvxShape_PathServices;
3355 case SdrObjKind::PathPoly:
3356 case SdrObjKind::Polygon:
3358 static const uno::Sequence<OUString> aSvxShape_PolyServices
3359 = { sUNO_service_drawing_PolyPolygonShape,
3361 sUNO_service_drawing_Shape,
3362 sUNO_service_drawing_LineProperties,
3363 sUNO_service_drawing_FillProperties,
3365 sUNO_service_drawing_PolyPolygonDescriptor,
3367 sUNO_service_drawing_Text,
3368 sUNO_service_drawing_TextProperties,
3369 sUNO_service_style_ParagraphProperties,
3370 sUNO_service_style_ParagraphPropertiesComplex,
3371 sUNO_service_style_ParagraphPropertiesAsian,
3372 sUNO_service_style_CharacterProperties,
3373 sUNO_service_style_CharacterPropertiesComplex,
3374 sUNO_service_style_CharacterPropertiesAsian,
3376 sUNO_service_drawing_ShadowProperties,
3377 sUNO_service_drawing_RotationDescriptor };
3378 return aSvxShape_PolyServices;
3381 case SdrObjKind::FreehandLine:
3382 case SdrObjKind::PathLine:
3384 static const uno::Sequence<OUString> aSvxShape_FreeLineServices
3385 = { sUNO_service_drawing_OpenBezierShape,
3387 sUNO_service_drawing_Shape,
3388 sUNO_service_drawing_LineProperties,
3389 sUNO_service_drawing_FillProperties,
3391 sUNO_service_drawing_PolyPolygonBezierDescriptor,
3393 sUNO_service_drawing_Text,
3394 sUNO_service_drawing_TextProperties,
3395 sUNO_service_style_ParagraphProperties,
3396 sUNO_service_style_ParagraphPropertiesComplex,
3397 sUNO_service_style_ParagraphPropertiesAsian,
3398 sUNO_service_style_CharacterProperties,
3399 sUNO_service_style_CharacterPropertiesComplex,
3400 sUNO_service_style_CharacterPropertiesAsian,
3402 sUNO_service_drawing_ShadowProperties,
3403 sUNO_service_drawing_RotationDescriptor };
3404 return aSvxShape_FreeLineServices;
3407 case SdrObjKind::FreehandFill:
3408 case SdrObjKind::PathFill:
3410 static const uno::Sequence<OUString> aSvxShape_FreeFillServices
3411 = { sUNO_service_drawing_ClosedBezierShape,
3413 sUNO_service_drawing_Shape,
3414 sUNO_service_drawing_LineProperties,
3415 sUNO_service_drawing_FillProperties,
3417 sUNO_service_drawing_PolyPolygonBezierDescriptor,
3419 sUNO_service_drawing_Text,
3420 sUNO_service_drawing_TextProperties,
3421 sUNO_service_style_ParagraphProperties,
3422 sUNO_service_style_ParagraphPropertiesComplex,
3423 sUNO_service_style_ParagraphPropertiesAsian,
3424 sUNO_service_style_CharacterProperties,
3425 sUNO_service_style_CharacterPropertiesComplex,
3426 sUNO_service_style_CharacterPropertiesAsian,
3428 sUNO_service_drawing_ShadowProperties,
3429 sUNO_service_drawing_RotationDescriptor };
3430 return aSvxShape_FreeFillServices;
3433 case SdrObjKind::OutlineText:
3434 case SdrObjKind::TitleText:
3435 case SdrObjKind::Text:
3437 static const uno::Sequence<OUString> aSvxShape_TextServices
3438 = { sUNO_service_drawing_TextShape,
3440 sUNO_service_drawing_Shape,
3441 sUNO_service_drawing_FillProperties,
3442 sUNO_service_drawing_LineProperties,
3444 sUNO_service_drawing_Text,
3445 sUNO_service_drawing_TextProperties,
3446 sUNO_service_style_ParagraphProperties,
3447 sUNO_service_style_ParagraphPropertiesComplex,
3448 sUNO_service_style_ParagraphPropertiesAsian,
3449 sUNO_service_style_CharacterProperties,
3450 sUNO_service_style_CharacterPropertiesComplex,
3451 sUNO_service_style_CharacterPropertiesAsian,
3453 sUNO_service_drawing_ShadowProperties,
3454 sUNO_service_drawing_RotationDescriptor };
3455 return aSvxShape_TextServices;
3457 case SdrObjKind::Annotation:
3459 static const uno::Sequence<OUString> aSvxShape_AnnotationServices = {
3460 sUNO_service_drawing_AnnotationShape,
3462 sUNO_service_drawing_Shape,
3463 sUNO_service_drawing_FillProperties,
3464 sUNO_service_drawing_LineProperties,
3466 sUNO_service_drawing_Text,
3467 sUNO_service_drawing_TextProperties,
3468 sUNO_service_style_ParagraphProperties,
3469 sUNO_service_style_ParagraphPropertiesComplex,
3470 sUNO_service_style_ParagraphPropertiesAsian,
3471 sUNO_service_style_CharacterProperties,
3472 sUNO_service_style_CharacterPropertiesComplex,
3473 sUNO_service_style_CharacterPropertiesAsian,
3475 sUNO_service_drawing_ShadowProperties,
3476 sUNO_service_drawing_RotationDescriptor
3478 return aSvxShape_AnnotationServices;
3481 case SdrObjKind::Graphic:
3483 static const uno::Sequence<OUString> aSvxShape_GrafServices
3484 = { sUNO_service_drawing_GraphicObjectShape,
3486 sUNO_service_drawing_Shape,
3488 sUNO_service_drawing_Text,
3489 sUNO_service_drawing_TextProperties,
3490 sUNO_service_style_ParagraphProperties,
3491 sUNO_service_style_ParagraphPropertiesComplex,
3492 sUNO_service_style_ParagraphPropertiesAsian,
3493 sUNO_service_style_CharacterProperties,
3494 sUNO_service_style_CharacterPropertiesComplex,
3495 sUNO_service_style_CharacterPropertiesAsian,
3497 sUNO_service_drawing_ShadowProperties,
3498 sUNO_service_drawing_RotationDescriptor};
3499 return aSvxShape_GrafServices;
3502 case SdrObjKind::OLE2:
3504 static const uno::Sequence<OUString> aSvxShape_Ole2Services
3505 = { sUNO_service_drawing_OLE2Shape,
3506 sUNO_service_drawing_Shape,
3508 // #i118485# Added Text, Shadow and Rotation
3509 sUNO_service_drawing_Text,
3510 sUNO_service_drawing_TextProperties,
3511 sUNO_service_style_ParagraphProperties,
3512 sUNO_service_style_ParagraphPropertiesComplex,
3513 sUNO_service_style_ParagraphPropertiesAsian,
3514 sUNO_service_style_CharacterProperties,
3515 sUNO_service_style_CharacterPropertiesComplex,
3516 sUNO_service_style_CharacterPropertiesAsian,
3518 sUNO_service_drawing_ShadowProperties,
3519 sUNO_service_drawing_RotationDescriptor };
3520 return aSvxShape_Ole2Services;
3523 case SdrObjKind::Caption:
3525 static const uno::Sequence<OUString> aSvxShape_CaptionServices
3526 = { sUNO_service_drawing_CaptionShape,
3528 sUNO_service_drawing_Shape,
3529 sUNO_service_drawing_FillProperties,
3530 sUNO_service_drawing_LineProperties,
3532 sUNO_service_drawing_Text,
3533 sUNO_service_drawing_TextProperties,
3534 sUNO_service_style_ParagraphProperties,
3535 sUNO_service_style_ParagraphPropertiesComplex,
3536 sUNO_service_style_ParagraphPropertiesAsian,
3537 sUNO_service_style_CharacterProperties,
3538 sUNO_service_style_CharacterPropertiesComplex,
3539 sUNO_service_style_CharacterPropertiesAsian,
3541 sUNO_service_drawing_ShadowProperties,
3542 sUNO_service_drawing_RotationDescriptor };
3543 return aSvxShape_CaptionServices;
3546 case SdrObjKind::Page:
3548 static const uno::Sequence<OUString> aSvxShape_PageServices
3549 = { sUNO_service_drawing_PageShape,
3550 sUNO_service_drawing_Shape };
3551 return aSvxShape_PageServices;
3554 case SdrObjKind::Measure:
3556 static const uno::Sequence<OUString> aSvxShape_MeasureServices
3557 = { sUNO_service_drawing_MeasureShape,
3559 sUNO_service_drawing_MeasureProperties,
3561 sUNO_service_drawing_Shape,
3562 sUNO_service_drawing_LineProperties,
3564 sUNO_service_drawing_Text,
3565 sUNO_service_drawing_TextProperties,
3566 sUNO_service_style_ParagraphProperties,
3567 sUNO_service_style_ParagraphPropertiesComplex,
3568 sUNO_service_style_ParagraphPropertiesAsian,
3569 sUNO_service_style_CharacterProperties,
3570 sUNO_service_style_CharacterPropertiesComplex,
3571 sUNO_service_style_CharacterPropertiesAsian,
3573 sUNO_service_drawing_PolyPolygonDescriptor,
3574 sUNO_service_drawing_ShadowProperties,
3575 sUNO_service_drawing_RotationDescriptor };
3576 return aSvxShape_MeasureServices;
3579 case SdrObjKind::OLEPluginFrame:
3581 static const uno::Sequence<OUString> aSvxShape_FrameServices
3582 = { sUNO_service_drawing_FrameShape,
3583 sUNO_service_drawing_Shape };
3584 return aSvxShape_FrameServices;
3587 case SdrObjKind::UNO:
3589 static const uno::Sequence<OUString> aSvxShape_UnoServices
3590 = { sUNO_service_drawing_ControlShape,
3591 sUNO_service_drawing_Shape };
3592 return aSvxShape_UnoServices;
3595 case SdrObjKind::Edge:
3597 static const uno::Sequence<OUString> aSvxShape_EdgeServices
3598 = { sUNO_service_drawing_ConnectorShape,
3599 sUNO_service_drawing_ConnectorProperties,
3601 sUNO_service_drawing_Shape,
3602 sUNO_service_drawing_LineProperties,
3604 sUNO_service_drawing_Text,
3605 sUNO_service_drawing_TextProperties,
3606 sUNO_service_style_ParagraphProperties,
3607 sUNO_service_style_ParagraphPropertiesComplex,
3608 sUNO_service_style_ParagraphPropertiesAsian,
3609 sUNO_service_style_CharacterProperties,
3610 sUNO_service_style_CharacterPropertiesComplex,
3611 sUNO_service_style_CharacterPropertiesAsian,
3613 sUNO_service_drawing_PolyPolygonDescriptor,
3614 sUNO_service_drawing_ShadowProperties,
3615 sUNO_service_drawing_RotationDescriptor };
3616 return aSvxShape_EdgeServices;
3618 case SdrObjKind::Media:
3620 static const uno::Sequence<OUString> aSvxShape_MediaServices
3621 = { sUNO_service_drawing_MediaShape,
3622 sUNO_service_drawing_Shape };
3623 return aSvxShape_MediaServices;
3625 default: ;
3628 else if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::FmForm)
3630 #if OSL_DEBUG_LEVEL > 0
3631 const SdrObjKind nIdent = GetSdrObject()->GetObjIdentifier();
3632 OSL_ENSURE( nIdent == SdrObjKind::UNO, "SvxShape::_getSupportedServiceNames: SdrInventor::FmForm, but no UNO object?" );
3633 #endif
3634 static const uno::Sequence<OUString> aSvxShape_UnoServices
3635 = { sUNO_service_drawing_ControlShape,
3636 sUNO_service_drawing_Shape };
3637 return aSvxShape_UnoServices;
3639 OSL_FAIL( "SvxShape::_getSupportedServiceNames: could not determine object type!" );
3640 uno::Sequence< OUString > aSeq;
3641 return aSeq;
3644 sal_Bool SAL_CALL SvxShape::supportsService( const OUString& ServiceName )
3646 return cppu::supportsService(this, ServiceName);
3649 // XGluePointsSupplier
3650 uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints()
3652 ::SolarMutexGuard aGuard;
3653 uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints );
3655 if( HasSdrObject() && !xGluePoints.is() )
3657 xGluePoints.set(SvxUnoGluePointAccess_createInstance(GetSdrObject()), uno::UNO_QUERY);
3658 mxGluePoints = xGluePoints;
3661 return xGluePoints;
3664 // XChild
3665 uno::Reference<uno::XInterface> SAL_CALL SvxShape::getParent()
3667 ::SolarMutexGuard aGuard;
3668 const SdrObject* pSdrObject(GetSdrObject());
3670 if(nullptr != pSdrObject)
3672 const SdrObjList* pParentSdrObjList(GetSdrObject()->getParentSdrObjListFromSdrObject());
3674 if(nullptr != pParentSdrObjList)
3676 // SdrObject is member of a SdrObjList. That may be a SdrObject
3677 // (SdrObjGroup or E3dScene) or a SdrPage.
3678 // Check for SdrObject first - using getSdrPageFromSdrObjList
3679 // *will* get the SdrPage even when the SdrObject is deep buried
3680 // in a construct of SdrObjGroup.
3681 // We want to ask for the direct parent here...
3682 SdrObject* pParentSdrObject(pParentSdrObjList->getSdrObjectFromSdrObjList());
3684 if(nullptr != pParentSdrObject)
3686 // SdrObject is member of a SdrObject-based Group (SdrObjGroup or E3dScene).
3687 return pParentSdrObject->getUnoShape();
3689 else
3691 SdrPage* pParentSdrPage(pParentSdrObjList->getSdrPageFromSdrObjList());
3693 if(nullptr != pParentSdrPage)
3695 // SdrObject is inserted to a SdrPage. Since
3696 // we checked for getSdrObjectFromSdrObjList first,
3697 // we can even say that it is directly member of that
3698 // SdrPage.
3699 return pParentSdrPage->getUnoPage();
3703 // not member of any SdrObjList, no parent
3704 OSL_FAIL( "SvxShape::getParent( ): unexpected Parent SdrObjList" );
3708 // no SdrObject, no parent
3709 return uno::Reference<uno::XInterface>();
3712 void SAL_CALL SvxShape::setParent( const css::uno::Reference< css::uno::XInterface >& )
3714 throw lang::NoSupportException();
3718 /** called from the XActionLockable interface methods on initial locking */
3719 void SvxShape::lock()
3724 /** called from the XActionLockable interface methods on final unlock */
3725 void SvxShape::unlock()
3730 // XActionLockable
3731 sal_Bool SAL_CALL SvxShape::isActionLocked( )
3733 ::SolarMutexGuard aGuard;
3735 return mnLockCount != 0;
3739 void SAL_CALL SvxShape::addActionLock( )
3741 ::SolarMutexGuard aGuard;
3743 DBG_ASSERT( mnLockCount < 0xffff, "lock overflow in SvxShape!" );
3744 mnLockCount++;
3746 if( mnLockCount == 1 )
3747 lock();
3751 void SAL_CALL SvxShape::removeActionLock( )
3753 ::SolarMutexGuard aGuard;
3755 DBG_ASSERT( mnLockCount > 0, "lock underflow in SvxShape!" );
3756 mnLockCount--;
3758 if( mnLockCount == 0 )
3759 unlock();
3763 void SAL_CALL SvxShape::setActionLocks( sal_Int16 nLock )
3765 ::SolarMutexGuard aGuard;
3767 if( (mnLockCount == 0) && (nLock != 0) )
3768 unlock();
3770 if( (mnLockCount != 0) && (nLock == 0) )
3771 lock();
3773 mnLockCount = static_cast<sal_uInt16>(nLock);
3777 sal_Int16 SAL_CALL SvxShape::resetActionLocks( )
3779 ::SolarMutexGuard aGuard;
3781 if( mnLockCount != 0 )
3782 unlock();
3784 sal_Int16 nOldLocks = static_cast<sal_Int16>(mnLockCount);
3785 mnLockCount = 0;
3787 return nOldLocks;
3791 /** since polygon shapes can change their kind during editing, we have
3792 to recheck it here.
3793 Circle shapes also change their kind, but they are all treated equal
3794 so no update is necessary.
3796 void SvxShape::updateShapeKind()
3798 switch( mpImpl->mnObjId )
3800 case SdrObjKind::Line:
3801 case SdrObjKind::Polygon:
3802 case SdrObjKind::PolyLine:
3803 case SdrObjKind::PathLine:
3804 case SdrObjKind::PathFill:
3805 case SdrObjKind::FreehandLine:
3806 case SdrObjKind::FreehandFill:
3807 case SdrObjKind::PathPoly:
3808 case SdrObjKind::PathPolyLine:
3810 const SdrObjKind nId = GetSdrObject()->GetObjIdentifier();
3812 if( nId != mpImpl->mnObjId )
3814 mpImpl->mnObjId = nId;
3817 break;
3819 default: ;
3823 SvxShapeText::SvxShapeText(SdrObject* pObject)
3824 : SvxShape( pObject, getSvxMapProvider().GetMap(SVXMAP_TEXT), getSvxMapProvider().GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
3826 if( pObject )
3827 SetEditSource( new SvxTextEditSource( pObject, nullptr ) );
3831 SvxShapeText::SvxShapeText(SdrObject* pObject, std::span<const SfxItemPropertyMapEntry> pPropertyMap, const SvxItemPropertySet* pPropertySet)
3832 : SvxShape( pObject, pPropertyMap, pPropertySet ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
3834 if( pObject )
3835 SetEditSource( new SvxTextEditSource( pObject, nullptr ) );
3839 SvxShapeText::~SvxShapeText() noexcept
3841 // check if only this instance is registered at the ranges
3842 DBG_ASSERT( (nullptr == GetEditSource()) || (GetEditSource()->getRanges().size()==1),
3843 "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!");
3846 void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
3848 if( pNewObj && (nullptr == GetEditSource()))
3849 SetEditSource( new SvxTextEditSource( pNewObj, nullptr ) );
3850 SvxShape::Create( pNewObj, pNewPage );
3853 // XInterface
3855 uno::Any SAL_CALL SvxShapeText::queryInterface( const uno::Type & rType )
3857 return SvxShape::queryInterface( rType );
3861 uno::Any SAL_CALL SvxShapeText::queryAggregation( const uno::Type & rType )
3863 uno::Any aAny( SvxShape::queryAggregation( rType ) );
3864 if( aAny.hasValue() )
3865 return aAny;
3867 return SvxUnoTextBase::queryAggregation( rType );
3871 // XServiceInfo
3873 OUString SAL_CALL SvxShapeText::getImplementationName()
3875 return u"SvxShapeText"_ustr;
3879 uno::Sequence< OUString > SAL_CALL SvxShapeText::getSupportedServiceNames()
3881 return SvxShape::getSupportedServiceNames();
3885 sal_Bool SAL_CALL SvxShapeText::supportsService( const OUString& ServiceName )
3887 return cppu::supportsService(static_cast<SvxShape*>(this), ServiceName);
3890 // XTypeProvider
3892 uno::Sequence< uno::Type > SAL_CALL SvxShapeText::getTypes()
3894 return SvxShape::getTypes();
3897 sal_Int64 SAL_CALL SvxShapeText::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
3899 const sal_Int64 nReturn = SvxShape::getSomething( rId );
3900 if( nReturn )
3901 return nReturn;
3903 return SvxUnoTextBase::getSomething( rId );
3907 uno::Sequence< sal_Int8 > SAL_CALL SvxShapeText::getImplementationId()
3909 return css::uno::Sequence<sal_Int8>();
3913 /** called from the XActionLockable interface methods on initial locking */
3914 void SvxShapeText::lock()
3916 SvxTextEditSource* pEditSource = static_cast<SvxTextEditSource*>(GetEditSource());
3917 if( pEditSource )
3918 pEditSource->lock();
3922 /** called from the XActionLockable interface methods on final unlock */
3923 void SvxShapeText::unlock()
3925 SvxTextEditSource* pEditSource = static_cast<SvxTextEditSource*>(GetEditSource());
3926 if( pEditSource )
3927 pEditSource->unlock();
3930 // css::text::XTextRange
3931 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getStart()
3933 ::SolarMutexGuard aGuard;
3934 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
3935 if( pForwarder )
3936 ::GetSelection( maSelection, pForwarder );
3937 return SvxUnoTextBase::getStart();
3941 uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getEnd()
3943 ::SolarMutexGuard aGuard;
3944 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
3945 if( pForwarder )
3946 ::GetSelection( maSelection, pForwarder );
3947 return SvxUnoTextBase::getEnd();
3950 OUString SAL_CALL SvxShapeText::getString()
3952 ::SolarMutexGuard aGuard;
3953 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
3954 if( pForwarder )
3955 ::GetSelection( maSelection, pForwarder );
3956 return SvxUnoTextBase::getString();
3960 void SAL_CALL SvxShapeText::setString( const OUString& aString )
3962 ::SolarMutexGuard aGuard;
3963 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
3964 if( pForwarder )
3965 ::GetSelection( maSelection, pForwarder );
3966 SvxUnoTextBase::setString( aString );
3969 // override these for special property handling in subcasses. Return true if property is handled
3970 bool SvxShapeText::setPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue )
3972 // HACK-fix #99090#
3973 // since SdrTextObj::SetVerticalWriting exchanges
3974 // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT,
3975 // we have to set the textdirection here
3977 if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
3979 SdrTextObj* pTextObj = DynCastSdrTextObj( GetSdrObject() );
3980 if( pTextObj )
3982 css::text::WritingMode eMode;
3983 if( rValue >>= eMode )
3985 pTextObj->SetVerticalWriting( eMode == css::text::WritingMode_TB_RL );
3988 return true;
3990 return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
3993 bool SvxShapeText::getPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue )
3995 if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
3997 SdrTextObj* pTextObj = DynCastSdrTextObj( GetSdrObject() );
3998 if( pTextObj && pTextObj->IsVerticalWriting() )
3999 rValue <<= css::text::WritingMode_TB_RL;
4000 else
4001 rValue <<= css::text::WritingMode_LR_TB;
4002 return true;
4005 return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
4008 bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertyMapEntry* pProperty, css::beans::PropertyState& rState )
4010 return SvxShape::getPropertyStateImpl( pProperty, rState );
4013 bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertyMapEntry* pProperty )
4015 return SvxShape::setPropertyToDefaultImpl( pProperty );
4018 SvxShapeRect::SvxShapeRect(SdrObject* pObj)
4019 : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_SHAPE), getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
4023 SvxShapeRect::~SvxShapeRect() noexcept
4027 uno::Any SAL_CALL SvxShapeRect::queryInterface( const uno::Type & rType )
4029 return SvxShapeText::queryInterface( rType );
4032 uno::Any SAL_CALL SvxShapeRect::queryAggregation( const uno::Type & rType )
4034 return SvxShapeText::queryAggregation( rType );
4037 // XServiceInfo
4039 uno::Sequence< OUString > SvxShapeRect::getSupportedServiceNames()
4041 return SvxShape::getSupportedServiceNames();
4044 /** returns a StarOffice API wrapper for the given SdrObject */
4045 uno::Reference< drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) noexcept
4047 uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
4048 return xShape;
4052 SdrObject* SdrObject::getSdrObjectFromXShape( const css::uno::Reference< css::uno::XInterface >& xInt )
4054 SvxShape* pSvxShape = comphelper::getFromUnoTunnel<SvxShape>( xInt );
4055 return pSvxShape ? pSvxShape->GetSdrObject() : nullptr;
4058 uno::Any SvxItemPropertySet_getPropertyValue( const SfxItemPropertyMapEntry* pMap, const SfxItemSet& rSet )
4060 if(!pMap || !pMap->nWID)
4061 return uno::Any();
4063 // Check is for items that store either metric values if they are positive or percentage if they are negative.
4064 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
4065 return SvxItemPropertySet::getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES), bDontConvertNegativeValues );
4068 void SvxItemPropertySet_setPropertyValue( const SfxItemPropertyMapEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet )
4070 if(!pMap || !pMap->nWID)
4071 return;
4073 bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
4074 SvxItemPropertySet::setPropertyValue( pMap, rVal, rSet, bDontConvertNegativeValues );
4077 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */