1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23 #include <com/sun/star/awt/FontSlant.hpp>
24 #include <com/sun/star/style/VerticalAlignment.hpp>
25 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
26 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
27 #include <com/sun/star/awt/TextAlign.hpp>
28 #include <com/sun/star/style/ParagraphAdjust.hpp>
29 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
30 #include <com/sun/star/drawing/PointSequence.hpp>
31 #include <com/sun/star/drawing/PolygonKind.hpp>
32 #include <com/sun/star/graphic/XGraphic.hpp>
33 #include <com/sun/star/drawing/BarCode.hpp>
34 #include <o3tl/any.hxx>
35 #include <o3tl/safeint.hxx>
36 #include <vcl/svapp.hxx>
37 #include <vcl/wmf.hxx>
38 #include <vcl/cvtgrf.hxx>
39 #include <vcl/graphic/BitmapHelper.hxx>
40 #include <vcl/GraphicLoader.hxx>
42 #include <svx/svdpool.hxx>
44 #include <editeng/unoprnms.hxx>
45 #include <svx/unoshape.hxx>
46 #include <svx/unopage.hxx>
47 #include <svx/svdobj.hxx>
48 #include <svx/svdpage.hxx>
49 #include <svx/svdmodel.hxx>
50 #include <svx/svdouno.hxx>
51 #include "shapeimpl.hxx"
52 #include <svx/unoshprp.hxx>
53 #include <svx/svdoashp.hxx>
54 #include <svx/svdviter.hxx>
55 #include <svx/svdview.hxx>
56 #include <svx/svdopath.hxx>
57 #include <basegfx/matrix/b2dhommatrix.hxx>
58 #include <basegfx/polygon/b2dpolygon.hxx>
59 #include <basegfx/point/b2dpoint.hxx>
60 #include <basegfx/polygon/b2dpolygontools.hxx>
61 #include <basegfx/polygon/b2dpolypolygontools.hxx>
62 #include <com/sun/star/awt/XBitmap.hpp>
63 #include <svx/svdograf.hxx>
64 #include <sal/log.hxx>
65 #include <cppuhelper/queryinterface.hxx>
66 #include <tools/stream.hxx>
71 using namespace ::cppu
;
72 using namespace ::com::sun::star
;
73 using namespace ::com::sun::star::uno
;
74 using namespace ::com::sun::star::lang
;
75 using namespace ::com::sun::star::container
;
77 #define QUERYINT( xint ) \
78 if( rType == cppu::UnoType<xint>::get() ) \
79 aAny <<= Reference< xint >(this)
81 SvxShapeGroup::SvxShapeGroup(SdrObject
* pObj
, SvxDrawPage
* pDrawPage
)
82 : SvxShapeGroupAnyD(pObj
, getSvxMapProvider().GetMap(SVXMAP_GROUP
), getSvxMapProvider().GetPropertySet(SVXMAP_GROUP
, SdrObject::GetGlobalDrawObjectItemPool()))
83 , mxWeakPage(pDrawPage
)
87 SvxShapeGroup::~SvxShapeGroup() noexcept
91 void SvxShapeGroup::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
93 SvxShape::Create( pNewObj
, pNewPage
);
94 mxWeakPage
= pNewPage
;
98 uno::Any SAL_CALL
SvxShapeGroup::queryInterface( const uno::Type
& rType
)
100 return SvxShape::queryInterface( rType
);
103 uno::Any SAL_CALL
SvxShapeGroup::queryAggregation( const uno::Type
& rType
)
107 QUERYINT( drawing::XShapeGroup
);
108 else QUERYINT( drawing::XShapes
);
109 else QUERYINT( drawing::XShapes2
);
110 else QUERYINT( container::XIndexAccess
);
111 else QUERYINT( container::XElementAccess
);
113 return SvxShape::queryAggregation( rType
);
118 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeGroup::getImplementationId()
120 return css::uno::Sequence
<sal_Int8
>();
123 // css::drawing::XShape
126 OUString SAL_CALL
SvxShapeGroup::getShapeType()
128 return SvxShape::getShapeType();
131 awt::Point SAL_CALL
SvxShapeGroup::getPosition()
133 return SvxShape::getPosition();
137 void SAL_CALL
SvxShapeGroup::setPosition( const awt::Point
& Position
)
139 SvxShape::setPosition(Position
);
143 awt::Size SAL_CALL
SvxShapeGroup::getSize()
145 return SvxShape::getSize();
149 void SAL_CALL
SvxShapeGroup::setSize( const awt::Size
& rSize
)
151 SvxShape::setSize( rSize
);
154 // drawing::XShapeGroup
157 void SAL_CALL
SvxShapeGroup::enterGroup( )
160 // pDrView->EnterMarkedGroup();
164 void SAL_CALL
SvxShapeGroup::leaveGroup( )
167 // pDrView->LeaveOneGroup();
170 void SvxShapeGroup::addUnoShape( const uno::Reference
< drawing::XShape
>& xShape
, size_t nPos
)
172 SvxShape
* pShape
= comphelper::getFromUnoTunnel
<SvxShape
>( xShape
);
175 OSL_FAIL("could not add XShape to group shape!");
178 addShape(*pShape
, nPos
);
181 void SvxShapeGroup::addShape( SvxShape
& rShape
)
183 addShape(rShape
, SAL_MAX_SIZE
);
186 void SvxShapeGroup::addShape( SvxShape
& rShape
, size_t nPos
)
188 SdrObject
* pSdrObject
= GetSdrObject();
193 rtl::Reference
<SvxDrawPage
> xPage
= mxWeakPage
.get();
196 OSL_FAIL("could not add XShape to group shape!");
200 rtl::Reference
<SdrObject
> pSdrShape
= rShape
.GetSdrObject();
201 if( pSdrShape
== nullptr )
202 pSdrShape
= xPage
->CreateSdrObject_( &rShape
);
204 if( pSdrShape
->IsInserted() )
205 pSdrShape
->getParentSdrObjListFromSdrObject()->RemoveObject( pSdrShape
->GetOrdNum() );
207 pSdrObject
->GetSubList()->InsertObject(pSdrShape
.get(), nPos
);
208 // TTTT Was created using mpModel in CreateSdrObject_ above
209 // TTTT may be good to add an assertion here for the future
210 // pSdrShape->SetModel(GetSdrObject()->GetModel());
212 // #85922# It makes no sense to set the layer asked
213 // from the group object since this is an iteration
214 // over the contained objects. In consequence, this
215 // statement erases all layer information from the draw
216 // objects. Layers need to be set at draw objects directly
217 // and have nothing to do with grouping at all.
218 // pSdrShape->SetLayer(pObject->GetLayer());
220 // Establish connection between new SdrObject and its wrapper before
221 // inserting the new shape into the group. There a new wrapper
222 // would be created when this connection would not already exist.
223 rShape
.Create( pSdrShape
.get(), xPage
.get() );
225 pSdrObject
->getSdrModelFromSdrObject().SetChanged();
229 void SAL_CALL
SvxShapeGroup::add( const uno::Reference
< drawing::XShape
>& xShape
)
231 ::SolarMutexGuard aGuard
;
233 // Add to the top of the stack (i.e. bottom of the list) by default.
234 addUnoShape(xShape
, SAL_MAX_SIZE
);
238 void SAL_CALL
SvxShapeGroup::remove( const uno::Reference
< drawing::XShape
>& xShape
)
240 ::SolarMutexGuard aGuard
;
242 SdrObject
* pSdrShape
= SdrObject::getSdrObjectFromXShape( xShape
);
244 if( !HasSdrObject() || pSdrShape
== nullptr || pSdrShape
->getParentSdrObjectFromSdrObject() != GetSdrObject() )
245 throw uno::RuntimeException();
247 SdrObjList
& rList
= *pSdrShape
->getParentSdrObjListFromSdrObject();
249 const size_t nObjCount
= rList
.GetObjCount();
251 while( nObjNum
< nObjCount
)
253 if(rList
.GetObj( nObjNum
) == pSdrShape
)
258 if( nObjNum
< nObjCount
)
261 // If the SdrObject which is about to be deleted is in any selection,
262 // deselect it first.
263 SdrViewIter::ForAllViews( pSdrShape
,
264 [&pSdrShape
] (SdrView
* pView
)
266 if(SAL_MAX_SIZE
!= pView
->GetMarkedObjectList().FindObject(pSdrShape
))
268 pView
->MarkObj(pSdrShape
, pView
->GetSdrPageView(), true);
272 rList
.NbcRemoveObject( nObjNum
);
276 SAL_WARN( "svx", "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
279 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
282 void SAL_CALL
SvxShapeGroup::addTop( const uno::Reference
< drawing::XShape
>& xShape
)
284 SolarMutexGuard aGuard
;
286 // Add to the top of the stack (i.e. bottom of the list).
287 addUnoShape(xShape
, SAL_MAX_SIZE
);
290 void SAL_CALL
SvxShapeGroup::addBottom( const uno::Reference
< drawing::XShape
>& xShape
)
292 SolarMutexGuard aGuard
;
294 // Add to the bottom of the stack (i.e. top of the list).
295 addUnoShape(xShape
, 0);
301 sal_Int32 SAL_CALL
SvxShapeGroup::getCount()
303 ::SolarMutexGuard aGuard
;
305 if(!HasSdrObject() || !GetSdrObject()->GetSubList())
306 throw uno::RuntimeException();
308 sal_Int32 nRetval
= GetSdrObject()->GetSubList()->GetObjCount();
313 uno::Any SAL_CALL
SvxShapeGroup::getByIndex( sal_Int32 Index
)
315 ::SolarMutexGuard aGuard
;
317 if( !HasSdrObject() || GetSdrObject()->GetSubList() == nullptr )
318 throw uno::RuntimeException();
320 if( Index
<0 || GetSdrObject()->GetSubList()->GetObjCount() <= o3tl::make_unsigned(Index
) )
321 throw lang::IndexOutOfBoundsException();
323 SdrObject
* pDestObj
= GetSdrObject()->GetSubList()->GetObj( Index
);
325 if(pDestObj
== nullptr)
326 throw lang::IndexOutOfBoundsException();
328 Reference
< drawing::XShape
> xShape( pDestObj
->getUnoShape(), uno::UNO_QUERY
);
329 return uno::Any( xShape
);
332 // css::container::XElementAccess
335 uno::Type SAL_CALL
SvxShapeGroup::getElementType()
337 return cppu::UnoType
<drawing::XShape
>::get();
341 sal_Bool SAL_CALL
SvxShapeGroup::hasElements()
343 ::SolarMutexGuard aGuard
;
345 return HasSdrObject() && GetSdrObject()->GetSubList() && (GetSdrObject()->GetSubList()->GetObjCount() > 0);
348 SvxShapeConnector::SvxShapeConnector(SdrObject
* pObj
)
349 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CONNECTOR
), getSvxMapProvider().GetPropertySet(SVXMAP_CONNECTOR
, SdrObject::GetGlobalDrawObjectItemPool()) )
354 SvxShapeConnector::~SvxShapeConnector() noexcept
359 uno::Any SAL_CALL
SvxShapeConnector::queryInterface( const uno::Type
& rType
)
361 return SvxShapeText::queryInterface( rType
);
364 uno::Any SAL_CALL
SvxShapeConnector::queryAggregation( const uno::Type
& rType
)
368 QUERYINT( drawing::XConnectorShape
);
370 return SvxShapeText::queryAggregation( rType
);
377 uno::Sequence
< uno::Type
> SAL_CALL
SvxShapeConnector::getTypes()
379 return SvxShape::getTypes();
382 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeConnector::getImplementationId()
384 return css::uno::Sequence
<sal_Int8
>();
387 // css::drawing::XShape
390 OUString SAL_CALL
SvxShapeConnector::getShapeType()
392 return SvxShapeText::getShapeType();
395 awt::Point SAL_CALL
SvxShapeConnector::getPosition()
397 return SvxShapeText::getPosition();
401 void SAL_CALL
SvxShapeConnector::setPosition( const awt::Point
& Position
)
403 SvxShapeText::setPosition(Position
);
407 awt::Size SAL_CALL
SvxShapeConnector::getSize()
409 return SvxShapeText::getSize();
413 void SAL_CALL
SvxShapeConnector::setSize( const awt::Size
& rSize
)
415 SvxShapeText::setSize( rSize
);
421 void SAL_CALL
SvxShapeConnector::connectStart( const uno::Reference
< drawing::XConnectableShape
>& xShape
, drawing::ConnectionType
)
423 ::SolarMutexGuard aGuard
;
425 Reference
< drawing::XShape
> xRef( xShape
, UNO_QUERY
);
426 SdrObject
* pSdrObject
= SdrObject::getSdrObjectFromXShape( xRef
);
429 GetSdrObject()->ConnectToNode( true, pSdrObject
);
431 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
435 void SAL_CALL
SvxShapeConnector::connectEnd( const uno::Reference
< drawing::XConnectableShape
>& xShape
, drawing::ConnectionType
)
437 ::SolarMutexGuard aGuard
;
439 Reference
< drawing::XShape
> xRef( xShape
, UNO_QUERY
);
440 SdrObject
* pSdrObject
= SdrObject::getSdrObjectFromXShape( xRef
);
442 if( HasSdrObject() && pSdrObject
)
443 GetSdrObject()->ConnectToNode( false, pSdrObject
);
445 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
449 void SAL_CALL
SvxShapeConnector::disconnectBegin( const uno::Reference
< drawing::XConnectableShape
>& )
451 ::SolarMutexGuard aGuard
;
454 GetSdrObject()->DisconnectFromNode( true );
456 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
460 void SAL_CALL
SvxShapeConnector::disconnectEnd( const uno::Reference
< drawing::XConnectableShape
>& )
462 ::SolarMutexGuard aGuard
;
465 GetSdrObject()->DisconnectFromNode( false );
467 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
470 SvxShapeControl::SvxShapeControl(SdrObject
* pObj
)
471 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CONTROL
), getSvxMapProvider().GetPropertySet(SVXMAP_CONTROL
, SdrObject::GetGlobalDrawObjectItemPool()) )
473 setShapeKind( SdrObjKind::UNO
);
477 SvxShapeControl::~SvxShapeControl() noexcept
482 uno::Any SAL_CALL
SvxShapeControl::queryInterface( const uno::Type
& rType
)
484 return SvxShapeText::queryInterface( rType
);
487 uno::Any SAL_CALL
SvxShapeControl::queryAggregation( const uno::Type
& rType
)
491 QUERYINT( drawing::XControlShape
);
493 return SvxShapeText::queryAggregation( rType
);
500 uno::Sequence
< uno::Type
> SAL_CALL
SvxShapeControl::getTypes()
502 return SvxShape::getTypes();
505 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeControl::getImplementationId()
507 return css::uno::Sequence
<sal_Int8
>();
510 // css::drawing::XShape
513 OUString SAL_CALL
SvxShapeControl::getShapeType()
515 return SvxShapeText::getShapeType();
518 awt::Point SAL_CALL
SvxShapeControl::getPosition()
520 return SvxShapeText::getPosition();
524 void SAL_CALL
SvxShapeControl::setPosition( const awt::Point
& Position
)
526 SvxShapeText::setPosition(Position
);
530 awt::Size SAL_CALL
SvxShapeControl::getSize()
532 return SvxShapeText::getSize();
536 void SAL_CALL
SvxShapeControl::setSize( const awt::Size
& rSize
)
538 SvxShapeText::setSize( rSize
);
544 Reference
< awt::XControlModel
> SAL_CALL
SvxShapeControl::getControl()
546 ::SolarMutexGuard aGuard
;
548 Reference
< awt::XControlModel
> xModel
;
550 SdrUnoObj
* pUnoObj
= dynamic_cast< SdrUnoObj
* >(GetSdrObject());
552 xModel
= pUnoObj
->GetUnoControlModel();
558 void SAL_CALL
SvxShapeControl::setControl( const Reference
< awt::XControlModel
>& xControl
)
560 ::SolarMutexGuard aGuard
;
562 SdrUnoObj
* pUnoObj
= dynamic_cast< SdrUnoObj
* >(GetSdrObject());
564 pUnoObj
->SetUnoControlModel( xControl
);
566 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
574 const SvxShapeControlPropertyMapping
[] =
576 // Warning: The first entry must be FontSlant because the any needs to be converted
577 { UNO_NAME_EDIT_CHAR_POSTURE
, u
"FontSlant"_ustr
}, // const sal_Int16 => css::awt::FontSlant
578 { UNO_NAME_EDIT_CHAR_FONTNAME
, u
"FontName"_ustr
},
579 { UNO_NAME_EDIT_CHAR_FONTSTYLENAME
, u
"FontStyleName"_ustr
},
580 { UNO_NAME_EDIT_CHAR_FONTFAMILY
, u
"FontFamily"_ustr
},
581 { UNO_NAME_EDIT_CHAR_FONTCHARSET
, u
"FontCharset"_ustr
},
582 { UNO_NAME_EDIT_CHAR_HEIGHT
, u
"FontHeight"_ustr
},
583 { UNO_NAME_EDIT_CHAR_FONTPITCH
, u
"FontPitch"_ustr
},
584 { UNO_NAME_EDIT_CHAR_WEIGHT
, u
"FontWeight"_ustr
},
585 { UNO_NAME_EDIT_CHAR_UNDERLINE
, u
"FontUnderline"_ustr
},
586 { UNO_NAME_EDIT_CHAR_STRIKEOUT
, u
"FontStrikeout"_ustr
},
587 { u
"CharKerning"_ustr
, u
"FontKerning"_ustr
},
588 { u
"CharWordMode"_ustr
, u
"FontWordLineMode"_ustr
},
589 { UNO_NAME_EDIT_CHAR_COLOR
, u
"TextColor"_ustr
},
590 { u
"CharBackColor"_ustr
, u
"CharBackColor"_ustr
},
591 { u
"CharBackTransparent"_ustr
, u
"CharBackTransparent"_ustr
},
592 { UNO_NAME_TEXT_CHAINNEXTNAME
, UNO_NAME_TEXT_CHAINNEXTNAME
},
593 { u
"CharRelief"_ustr
, u
"FontRelief"_ustr
},
594 { u
"CharUnderlineColor"_ustr
, u
"TextLineColor"_ustr
},
595 { UNO_NAME_EDIT_PARA_ADJUST
, u
"Align"_ustr
},
596 { u
"TextVerticalAdjust"_ustr
, u
"VerticalAlign"_ustr
},
597 { u
"ControlBackground"_ustr
, u
"BackgroundColor"_ustr
},
598 { u
"ControlSymbolColor"_ustr
, u
"SymbolColor"_ustr
},
599 { u
"ControlBorder"_ustr
, u
"Border"_ustr
},
600 { u
"ControlBorderColor"_ustr
, u
"BorderColor"_ustr
},
601 { u
"ControlTextEmphasis"_ustr
, u
"FontEmphasisMark"_ustr
},
602 { u
"ImageScaleMode"_ustr
, u
"ScaleMode"_ustr
},
603 { u
"ControlWritingMode"_ustr
, u
"WritingMode"_ustr
},
604 //added for exporting OCX control
605 { u
"ControlTypeinMSO"_ustr
, u
"ControlTypeinMSO"_ustr
},
606 { u
"ObjIDinMSO"_ustr
, u
"ObjIDinMSO"_ustr
},
607 { u
"CharCaseMap"_ustr
, u
"CharCaseMap"_ustr
},
608 { u
"CharColorTheme"_ustr
, u
"CharColorTheme"_ustr
},
609 { u
"CharColorTintOrShade"_ustr
, u
"CharColorTintOrShade"_ustr
},
610 { UNO_NAME_EDIT_CHAR_COMPLEX_COLOR
, u
"CharComplexColor"_ustr
},
615 bool lcl_convertPropertyName( std::u16string_view rApiName
, OUString
& rInternalName
)
617 for( const auto & rEntry
: SvxShapeControlPropertyMapping
)
619 if( rApiName
== rEntry
.msAPIName
)
621 rInternalName
= rEntry
.msFormName
;
624 return !rInternalName
.isEmpty();
627 struct EnumConversionMap
629 style::ParagraphAdjust nAPIValue
;
630 sal_Int16 nFormValue
;
633 EnumConversionMap
const aMapAdjustToAlign
[] =
635 // note that order matters:
636 // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
637 // and use the first matching entry
638 {style::ParagraphAdjust_LEFT
, sal_Int16(awt::TextAlign::LEFT
)},
639 {style::ParagraphAdjust_CENTER
, sal_Int16(awt::TextAlign::CENTER
)},
640 {style::ParagraphAdjust_RIGHT
, sal_Int16(awt::TextAlign::RIGHT
)},
641 {style::ParagraphAdjust_BLOCK
, sal_Int16(awt::TextAlign::RIGHT
)},
642 {style::ParagraphAdjust_STRETCH
, sal_Int16(awt::TextAlign::LEFT
)},
643 {style::ParagraphAdjust(-1),-1}
646 void lcl_convertTextAlignmentToParaAdjustment( Any
& _rValue
)
648 sal_Int16 nValue
= sal_Int16();
649 OSL_VERIFY( _rValue
>>= nValue
);
651 for ( auto const & rEntry
: aMapAdjustToAlign
)
652 if ( nValue
== rEntry
.nFormValue
)
654 _rValue
<<= static_cast<sal_uInt16
>(rEntry
.nAPIValue
);
659 void lcl_convertParaAdjustmentToTextAlignment( Any
& _rValue
)
661 sal_Int32 nValue
= 0;
662 OSL_VERIFY( _rValue
>>= nValue
);
664 for ( auto const & rEntry
: aMapAdjustToAlign
)
665 if ( static_cast<style::ParagraphAdjust
>(nValue
) == rEntry
.nAPIValue
)
667 _rValue
<<= rEntry
.nFormValue
;
672 void convertVerticalAdjustToVerticalAlign( Any
& _rValue
)
674 if ( !_rValue
.hasValue() )
677 drawing::TextVerticalAdjust eAdjust
= drawing::TextVerticalAdjust_TOP
;
678 style::VerticalAlignment eAlign
= style::VerticalAlignment_TOP
;
679 if ( !( _rValue
>>= eAdjust
) )
680 throw lang::IllegalArgumentException();
683 case drawing::TextVerticalAdjust_TOP
: eAlign
= style::VerticalAlignment_TOP
; break;
684 case drawing::TextVerticalAdjust_BOTTOM
: eAlign
= style::VerticalAlignment_BOTTOM
; break;
685 default: eAlign
= style::VerticalAlignment_MIDDLE
; break;
690 void convertVerticalAlignToVerticalAdjust( Any
& _rValue
)
692 if ( !_rValue
.hasValue() )
694 style::VerticalAlignment eAlign
= style::VerticalAlignment_TOP
;
695 drawing::TextVerticalAdjust eAdjust
= drawing::TextVerticalAdjust_TOP
;
696 OSL_VERIFY( _rValue
>>= eAlign
);
699 case style::VerticalAlignment_TOP
: eAdjust
= drawing::TextVerticalAdjust_TOP
; break;
700 case style::VerticalAlignment_BOTTOM
: eAdjust
= drawing::TextVerticalAdjust_BOTTOM
; break;
701 default: eAdjust
= drawing::TextVerticalAdjust_CENTER
; break;
707 void SAL_CALL
SvxShapeControl::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
710 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
712 uno::Reference
< beans::XPropertySet
> xControl( getControl(), uno::UNO_QUERY
);
715 uno::Reference
< beans::XPropertySetInfo
> xInfo( xControl
->getPropertySetInfo() );
716 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
718 uno::Any
aConvertedValue( aValue
);
719 if ( aFormsName
== "FontSlant" )
721 awt::FontSlant nSlant
;
722 if( !(aValue
>>= nSlant
) )
723 throw lang::IllegalArgumentException();
724 aConvertedValue
<<= static_cast<sal_Int16
>(nSlant
);
726 else if ( aFormsName
== "Align" )
728 lcl_convertParaAdjustmentToTextAlignment( aConvertedValue
);
730 else if ( aFormsName
== "VerticalAlign" )
732 convertVerticalAdjustToVerticalAlign( aConvertedValue
);
735 xControl
->setPropertyValue( aFormsName
, aConvertedValue
);
741 SvxShape::setPropertyValue( aPropertyName
, aValue
);
745 uno::Any SAL_CALL
SvxShapeControl::getPropertyValue( const OUString
& aPropertyName
)
748 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
750 uno::Reference
< beans::XPropertySet
> xControl( getControl(), uno::UNO_QUERY
);
755 uno::Reference
< beans::XPropertySetInfo
> xInfo( xControl
->getPropertySetInfo() );
756 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
758 aValue
= xControl
->getPropertyValue( aFormsName
);
759 if ( aFormsName
== "FontSlant" )
761 awt::FontSlant eSlant
= awt::FontSlant_NONE
;
762 sal_Int16 nSlant
= sal_Int16();
763 if ( aValue
>>= nSlant
)
765 eSlant
= static_cast<awt::FontSlant
>(nSlant
);
769 OSL_VERIFY( aValue
>>= eSlant
);
773 else if ( aFormsName
== "Align" )
775 lcl_convertTextAlignmentToParaAdjustment( aValue
);
777 else if ( aFormsName
== "VerticalAlign" )
779 convertVerticalAlignToVerticalAdjust( aValue
);
788 return SvxShape::getPropertyValue( aPropertyName
);
794 beans::PropertyState SAL_CALL
SvxShapeControl::getPropertyState( const OUString
& PropertyName
)
797 if ( lcl_convertPropertyName( PropertyName
, aFormsName
) )
799 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
800 uno::Reference
< beans::XPropertySet
> xPropSet( getControl(), uno::UNO_QUERY
);
802 if( xControl
.is() && xPropSet
.is() )
804 uno::Reference
< beans::XPropertySetInfo
> xInfo( xPropSet
->getPropertySetInfo() );
805 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
807 return xControl
->getPropertyState( aFormsName
);
811 return beans::PropertyState_DEFAULT_VALUE
;
815 return SvxShape::getPropertyState( PropertyName
);
819 void SAL_CALL
SvxShapeControl::setPropertyToDefault( const OUString
& PropertyName
)
822 if ( lcl_convertPropertyName( PropertyName
, aFormsName
) )
824 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
825 uno::Reference
< beans::XPropertySet
> xPropSet( getControl(), uno::UNO_QUERY
);
827 if( xControl
.is() && xPropSet
.is() )
829 uno::Reference
< beans::XPropertySetInfo
> xInfo( xPropSet
->getPropertySetInfo() );
830 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
832 xControl
->setPropertyToDefault( aFormsName
);
838 SvxShape::setPropertyToDefault( PropertyName
);
842 uno::Any SAL_CALL
SvxShapeControl::getPropertyDefault( const OUString
& aPropertyName
)
845 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
847 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
851 Any
aDefault( xControl
->getPropertyDefault( aFormsName
) );
852 if ( aFormsName
== "FontSlant" )
854 sal_Int16
nSlant( 0 );
856 aDefault
<<= static_cast<awt::FontSlant
>(nSlant
);
858 else if ( aFormsName
== "Align" )
860 lcl_convertTextAlignmentToParaAdjustment( aDefault
);
862 else if ( aFormsName
== "VerticalAlign" )
864 convertVerticalAlignToVerticalAdjust( aDefault
);
869 throw beans::UnknownPropertyException( aPropertyName
, getXWeak());
873 return SvxShape::getPropertyDefault( aPropertyName
);
877 SvxShapeDimensioning::SvxShapeDimensioning(SdrObject
* pObj
)
878 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_DIMENSIONING
), getSvxMapProvider().GetPropertySet(SVXMAP_DIMENSIONING
, SdrObject::GetGlobalDrawObjectItemPool()) )
882 SvxShapeDimensioning::~SvxShapeDimensioning() noexcept
886 SvxShapeCircle::SvxShapeCircle(SdrObject
* pObj
)
887 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CIRCLE
), getSvxMapProvider().GetPropertySet(SVXMAP_CIRCLE
, SdrObject::GetGlobalDrawObjectItemPool()) )
891 SvxShapeCircle::~SvxShapeCircle() noexcept
895 //////////////////////////////////////////////////////////////////////////////
897 SvxShapePolyPolygon::SvxShapePolyPolygon(
901 getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGON
),
902 getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGON
, SdrObject::GetGlobalDrawObjectItemPool()))
906 SvxShapePolyPolygon::~SvxShapePolyPolygon() noexcept
910 bool SvxShapePolyPolygon::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
912 switch( pProperty
->nWID
)
914 case OWN_ATTR_VALUE_POLYPOLYGONBEZIER
:
916 if( auto s
= o3tl::tryAccess
<drawing::PolyPolygonBezierCoords
>(rValue
) )
918 basegfx::B2DPolyPolygon
aNewPolyPolygon(
919 basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*s
));
921 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
922 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
924 SetPolygon(aNewPolyPolygon
);
929 case OWN_ATTR_VALUE_POLYPOLYGON
:
931 if( auto s
= o3tl::tryAccess
<drawing::PointSequenceSequence
>(rValue
) )
933 basegfx::B2DPolyPolygon
aNewPolyPolygon(
934 basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(*s
));
936 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
937 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
939 SetPolygon(aNewPolyPolygon
);
944 case OWN_ATTR_BASE_GEOMETRY
:
946 drawing::PointSequenceSequence aPointSequenceSequence
;
947 drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords
;
949 if( rValue
>>= aPointSequenceSequence
)
953 basegfx::B2DPolyPolygon aNewPolyPolygon
;
954 basegfx::B2DHomMatrix aNewHomogenMatrix
;
956 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
957 aNewPolyPolygon
= basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(aPointSequenceSequence
);
959 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
960 // Need to adapt aNewPolyPolygon from 100thmm to app-specific
961 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
963 GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
967 else if( rValue
>>= aPolyPolygonBezierCoords
)
971 basegfx::B2DPolyPolygon aNewPolyPolygon
;
972 basegfx::B2DHomMatrix aNewHomogenMatrix
;
974 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
975 aNewPolyPolygon
= basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(aPolyPolygonBezierCoords
);
977 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
978 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
980 GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
986 case OWN_ATTR_VALUE_POLYGON
:
988 if( auto pSequence
= o3tl::tryAccess
<drawing::PointSequence
>(rValue
) )
990 // prepare new polygon
991 basegfx::B2DPolygon aNewPolygon
;
993 // get pointer to arrays
994 const awt::Point
* pArray
= pSequence
->getConstArray();
995 const awt::Point
* pArrayEnd
= pArray
+ pSequence
->getLength();
997 for(;pArray
!= pArrayEnd
;++pArray
)
999 aNewPolygon
.append(basegfx::B2DPoint(pArray
->X
, pArray
->Y
));
1002 // check for closed state flag
1003 basegfx::utils::checkClosed(aNewPolygon
);
1005 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1006 basegfx::B2DPolyPolygon
aNewPolyPolygon(aNewPolygon
);
1007 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
1010 SetPolygon(aNewPolyPolygon
);
1016 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
1019 throw lang::IllegalArgumentException();
1022 bool SvxShapePolyPolygon::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
,
1023 css::uno::Any
& rValue
)
1025 switch( pProperty
->nWID
)
1027 case OWN_ATTR_VALUE_POLYPOLYGONBEZIER
:
1029 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1030 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1032 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1033 ForceMetricTo100th_mm(aPolyPoly
);
1035 drawing::PolyPolygonBezierCoords aRetval
;
1036 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords(aPolyPoly
, aRetval
);
1041 case OWN_ATTR_VALUE_POLYPOLYGON
:
1043 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1044 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1046 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1047 ForceMetricTo100th_mm(aPolyPoly
);
1049 drawing::PointSequenceSequence
aRetval( aPolyPoly
.count() );
1050 basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPoly
, aRetval
);
1055 case OWN_ATTR_BASE_GEOMETRY
:
1057 // pack a tools::PolyPolygon in struct PolyPolygon
1058 basegfx::B2DPolyPolygon aPolyPoly
;
1059 basegfx::B2DHomMatrix aNewHomogenMatrix
;
1063 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aPolyPoly
);
1065 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1066 ForceMetricTo100th_mm(aPolyPoly
);
1069 if(aPolyPoly
.areControlPointsUsed())
1071 drawing::PolyPolygonBezierCoords aRetval
;
1072 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords(aPolyPoly
, aRetval
);
1077 drawing::PointSequenceSequence
aRetval(aPolyPoly
.count());
1078 basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPoly
, aRetval
);
1083 case OWN_ATTR_VALUE_POLYGON
:
1085 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1086 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1088 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1089 ForceMetricTo100th_mm(aPolyPoly
);
1091 const sal_Int32
nCount(0 == aPolyPoly
.count() ? 0 : aPolyPoly
.getB2DPolygon(0).count());
1092 drawing::PointSequence
aRetval( nCount
);
1096 // get single polygon
1097 const basegfx::B2DPolygon
& aPoly(aPolyPoly
.getB2DPolygon(0));
1099 // get pointer to arrays
1100 awt::Point
* pSequence
= aRetval
.getArray();
1102 for(sal_Int32 b
=0;b
<nCount
;b
++)
1104 const basegfx::B2DPoint
aPoint(aPoly
.getB2DPoint(b
));
1105 *pSequence
++ = awt::Point( basegfx::fround(aPoint
.getX()), basegfx::fround(aPoint
.getY()) );
1112 case OWN_ATTR_VALUE_POLYGONKIND
:
1114 rValue
<<= GetPolygonKind();
1118 return SvxShapeText::getPropertyValueImpl( rName
, pProperty
, rValue
);
1124 drawing::PolygonKind
SvxShapePolyPolygon::GetPolygonKind() const
1126 ::SolarMutexGuard aGuard
;
1127 drawing::PolygonKind
aRetval(drawing::PolygonKind_LINE
);
1131 switch(GetSdrObject()->GetObjIdentifier())
1133 case SdrObjKind::Polygon
: aRetval
= drawing::PolygonKind_POLY
; break;
1134 case SdrObjKind::PolyLine
: aRetval
= drawing::PolygonKind_PLIN
; break;
1135 case SdrObjKind::PathLine
: aRetval
= drawing::PolygonKind_PATHLINE
; break;
1136 case SdrObjKind::PathFill
: aRetval
= drawing::PolygonKind_PATHFILL
; break;
1137 case SdrObjKind::FreehandLine
: aRetval
= drawing::PolygonKind_FREELINE
; break;
1138 case SdrObjKind::FreehandFill
: aRetval
= drawing::PolygonKind_FREEFILL
; break;
1146 void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon
& rNew
)
1148 ::SolarMutexGuard aGuard
;
1151 static_cast<SdrPathObj
*>(GetSdrObject())->SetPathPoly(rNew
);
1155 basegfx::B2DPolyPolygon
SvxShapePolyPolygon::GetPolygon() const noexcept
1157 ::SolarMutexGuard aGuard
;
1161 return static_cast<SdrPathObj
*>(GetSdrObject())->GetPathPoly();
1165 return basegfx::B2DPolyPolygon();
1169 //////////////////////////////////////////////////////////////////////////////
1171 SvxGraphicObject::SvxGraphicObject(SdrObject
* pObj
)
1172 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_GRAPHICOBJECT
), getSvxMapProvider().GetPropertySet(SVXMAP_GRAPHICOBJECT
, SdrObject::GetGlobalDrawObjectItemPool()) )
1176 SvxGraphicObject::~SvxGraphicObject() noexcept
1180 bool SvxGraphicObject::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
1183 switch( pProperty
->nWID
)
1185 case OWN_ATTR_VALUE_FILLBITMAP
:
1187 if( auto pSeq
= o3tl::tryAccess
<uno::Sequence
<sal_Int8
>>(rValue
) )
1189 SvMemoryStream aMemStm
;
1192 aMemStm
.SetBuffer( const_cast<css::uno::Sequence
<sal_Int8
> *>(pSeq
)->getArray(), pSeq
->getLength(), pSeq
->getLength() );
1194 if( GraphicConverter::Import( aMemStm
, aGraphic
) == ERRCODE_NONE
)
1196 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1200 else if (uno::Reference
<graphic::XGraphic
> xGraphic
= vcl::GetGraphic(rValue
))
1202 // Handles both graphic::XGraphic and awt::XBitmap
1203 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(Graphic(xGraphic
));
1207 GetSdrObject()->SetEmptyPresObj(false);
1211 case OWN_ATTR_GRAFSTREAMURL
:
1213 OUString aStreamURL
;
1215 if( rValue
>>= aStreamURL
)
1217 if( !aStreamURL
.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX
) )
1220 if( HasSdrObject() )
1222 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGrafStreamURL( aStreamURL
);
1223 GetSdrObject()->SetEmptyPresObj(false);
1230 case OWN_ATTR_GRAPHIC_URL
:
1233 uno::Reference
<awt::XBitmap
> xBitmap
;
1234 if (rValue
>>= aURL
)
1236 Graphic aGraphic
= vcl::graphic::loadFromURL(aURL
);
1237 if (!aGraphic
.IsNone())
1239 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1243 else if (rValue
>>= xBitmap
)
1245 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
1248 Graphic aGraphic
= xGraphic
;
1249 if (!aGraphic
.IsNone())
1251 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1257 GetSdrObject()->SetEmptyPresObj(false);
1261 case OWN_ATTR_VALUE_GRAPHIC
:
1263 Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
1266 static_cast< SdrGrafObj
*>( GetSdrObject() )->SetGraphic( xGraphic
);
1267 GetSdrObject()->SetEmptyPresObj(false);
1273 case OWN_ATTR_IS_SIGNATURELINE
:
1275 bool bIsSignatureLine
;
1276 if (rValue
>>= bIsSignatureLine
)
1278 static_cast<SdrGrafObj
*>(GetSdrObject())->setIsSignatureLine(bIsSignatureLine
);
1284 case OWN_ATTR_SIGNATURELINE_ID
:
1286 OUString aSignatureLineId
;
1287 if (rValue
>>= aSignatureLineId
)
1289 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineId(aSignatureLineId
);
1295 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME
:
1297 OUString aSuggestedSignerName
;
1298 if (rValue
>>= aSuggestedSignerName
)
1300 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerName(aSuggestedSignerName
);
1306 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_TITLE
:
1308 OUString aSuggestedSignerTitle
;
1309 if (rValue
>>= aSuggestedSignerTitle
)
1311 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerTitle(aSuggestedSignerTitle
);
1317 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_EMAIL
:
1319 OUString aSuggestedSignerEmail
;
1320 if (rValue
>>= aSuggestedSignerEmail
)
1322 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerEmail(aSuggestedSignerEmail
);
1328 case OWN_ATTR_SIGNATURELINE_SIGNING_INSTRUCTIONS
:
1330 OUString aSigningInstructions
;
1331 if (rValue
>>= aSigningInstructions
)
1333 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSigningInstructions(aSigningInstructions
);
1339 case OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE
:
1342 if (rValue
>>= bShowSignDate
)
1344 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineShowSignDate(bShowSignDate
);
1350 case OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT
:
1352 bool bCanAddComment
;
1353 if (rValue
>>= bCanAddComment
)
1355 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineCanAddComment(bCanAddComment
);
1361 case OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE
:
1363 Reference
<graphic::XGraphic
> xGraphic(rValue
, uno::UNO_QUERY
);
1366 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineUnsignedGraphic(xGraphic
);
1372 case OWN_ATTR_OBJ_ISEMPTYPRESOBJ
:
1374 bool bIsEmptyPresObj
;
1375 if (rValue
>>= bIsEmptyPresObj
)
1377 GetSdrObject()->SetEmptyPresObj(bIsEmptyPresObj
);
1383 case OWN_ATTR_SIGNATURELINE_IS_SIGNED
:
1386 if (rValue
>>= bIsSigned
)
1388 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineIsSigned(bIsSigned
);
1394 case OWN_ATTR_QRCODE
:
1396 css::drawing::BarCode aBarCode
;
1397 if (rValue
>>= aBarCode
)
1399 static_cast<SdrGrafObj
*>(GetSdrObject())->setQrCode(aBarCode
);
1406 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
1410 throw lang::IllegalArgumentException();
1412 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1417 bool SvxGraphicObject::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
1419 switch( pProperty
->nWID
)
1421 case OWN_ATTR_VALUE_FILLBITMAP
:
1423 const Graphic
& rGraphic
= static_cast<SdrGrafObj
*>(GetSdrObject())->GetGraphic();
1425 if (rGraphic
.GetType() != GraphicType::GdiMetafile
)
1427 uno::Reference
<awt::XBitmap
> xBitmap(rGraphic
.GetXGraphic(), uno::UNO_QUERY
);
1432 SvMemoryStream
aDestStrm( 65535, 65535 );
1434 ConvertGDIMetaFileToWMF( rGraphic
.GetGDIMetaFile(), aDestStrm
, nullptr, false );
1435 const uno::Sequence
<sal_Int8
> aSeq(
1436 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
1437 aDestStrm
.GetEndOfData());
1443 case OWN_ATTR_REPLACEMENT_GRAPHIC
:
1445 const GraphicObject
* pGrafObj
= static_cast< SdrGrafObj
* >(GetSdrObject())->GetReplacementGraphicObject();
1449 rValue
<<= pGrafObj
->GetGraphic().GetXGraphic();
1455 case OWN_ATTR_GRAFSTREAMURL
:
1457 const OUString
aStreamURL( static_cast<SdrGrafObj
*>( GetSdrObject() )->GetGrafStreamURL() );
1458 if( !aStreamURL
.isEmpty() )
1459 rValue
<<= aStreamURL
;
1463 case OWN_ATTR_GRAPHIC_URL
:
1464 case OWN_ATTR_VALUE_GRAPHIC
:
1466 if (pProperty
->nWID
== OWN_ATTR_GRAPHIC_URL
)
1468 SAL_WARN("svx", "Getting Graphic by URL is not supported, getting it by value");
1471 Reference
<graphic::XGraphic
> xGraphic
;
1472 auto pSdrGraphicObject
= static_cast<SdrGrafObj
*>(GetSdrObject());
1473 if (pSdrGraphicObject
1474 && pSdrGraphicObject
->GetGraphicObject().GetType() != GraphicType::NONE
)
1475 xGraphic
= pSdrGraphicObject
->GetGraphic().GetXGraphic();
1476 rValue
<<= xGraphic
;
1480 case OWN_ATTR_GRAPHIC_STREAM
:
1482 rValue
<<= static_cast< SdrGrafObj
* >( GetSdrObject() )->getInputStream();
1486 case OWN_ATTR_IS_SIGNATURELINE
:
1488 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLine();
1492 case OWN_ATTR_SIGNATURELINE_ID
:
1494 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineId();
1498 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME
:
1500 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerName();
1504 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_TITLE
:
1506 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerTitle();
1510 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_EMAIL
:
1512 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerEmail();
1516 case OWN_ATTR_SIGNATURELINE_SIGNING_INSTRUCTIONS
:
1518 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSigningInstructions();
1522 case OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE
:
1524 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineShowSignDate();
1528 case OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT
:
1530 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineCanAddComment();
1534 case OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE
:
1536 Reference
<graphic::XGraphic
> xGraphic(
1537 static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineUnsignedGraphic());
1538 rValue
<<= xGraphic
;
1542 case OWN_ATTR_SIGNATURELINE_IS_SIGNED
:
1544 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineSigned();
1548 case OWN_ATTR_OBJ_ISEMPTYPRESOBJ
:
1550 rValue
<<= GetSdrObject()->IsEmptyPresObj();
1554 case OWN_ATTR_QRCODE
:
1556 css::drawing::BarCode
* ptr
= static_cast<SdrGrafObj
*>(GetSdrObject())->getQrCode();
1565 return SvxShapeText::getPropertyValueImpl(rName
, pProperty
,rValue
);
1572 SvxShapeCaption::SvxShapeCaption(SdrObject
* pObj
)
1573 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CAPTION
), getSvxMapProvider().GetPropertySet(SVXMAP_CAPTION
, SdrObject::GetGlobalDrawObjectItemPool()) )
1577 SvxShapeCaption::~SvxShapeCaption() noexcept
1581 SvxCustomShape::SvxCustomShape(SdrObject
* pObj
)
1582 : SvxShapeText( pObj
, getSvxMapProvider().GetMap( SVXMAP_CUSTOMSHAPE
), getSvxMapProvider().GetPropertySet(SVXMAP_CUSTOMSHAPE
, SdrObject::GetGlobalDrawObjectItemPool()) )
1586 SvxCustomShape::~SvxCustomShape() noexcept
1590 uno::Any SAL_CALL
SvxCustomShape::queryInterface( const uno::Type
& rType
)
1592 return SvxShapeText::queryInterface( rType
);
1595 uno::Any SAL_CALL
SvxCustomShape::queryAggregation( const uno::Type
& rType
)
1597 css::uno::Any aReturn
= SvxShapeText::queryAggregation( rType
);
1598 if ( !aReturn
.hasValue() )
1599 aReturn
= ::cppu::queryInterface(rType
, static_cast<drawing::XEnhancedCustomShapeDefaulter
*>(this) );
1603 uno::Sequence
< sal_Int8
> SAL_CALL
SvxCustomShape::getImplementationId()
1605 return css::uno::Sequence
<sal_Int8
>();
1608 // css::drawing::XShape
1611 awt::Point SAL_CALL
SvxCustomShape::getPosition()
1613 ::SolarMutexGuard aGuard
;
1614 if ( HasSdrObject() )
1616 SdrAShapeObjGeoData aCustomShapeGeoData
;
1617 static_cast<SdrObjCustomShape
*>(GetSdrObject())->SaveGeoData( aCustomShapeGeoData
);
1619 bool bMirroredX
= false;
1620 bool bMirroredY
= false;
1622 if ( HasSdrObject() )
1624 bMirroredX
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->IsMirroredX();
1625 bMirroredY
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->IsMirroredY();
1627 // get aRect, this is the unrotated snaprect
1628 tools::Rectangle
aRect(static_cast<SdrObjCustomShape
*>(GetSdrObject())->GetLogicRect());
1629 tools::Rectangle
aRectangle( aRect
);
1631 if ( bMirroredX
|| bMirroredY
)
1632 { // we have to retrieve the unmirrored rect
1634 GeoStat
aNewGeo(aCustomShapeGeoData
.maGeo
);
1637 tools::Polygon
aPol( Rect2Poly( aRect
, aNewGeo
) );
1638 tools::Rectangle
aBoundRect( aPol
.GetBoundRect() );
1640 Point
aRef1( ( aBoundRect
.Left() + aBoundRect
.Right() ) >> 1, aBoundRect
.Top() );
1641 Point
aRef2( aRef1
.X(), aRef1
.Y() + 1000 );
1643 sal_uInt16 nPointCount
=aPol
.GetSize();
1644 for (i
=0; i
<nPointCount
; i
++)
1646 MirrorPoint(aPol
[i
],aRef1
,aRef2
);
1648 // turn and move polygon
1649 tools::Polygon
aPol0(aPol
);
1655 aRectangle
= svx::polygonToRectangle(aPol
, aNewGeo
);
1659 tools::Polygon
aPol( Rect2Poly( aRectangle
, aNewGeo
) );
1660 tools::Rectangle
aBoundRect( aPol
.GetBoundRect() );
1662 Point
aRef1( aBoundRect
.Left(), ( aBoundRect
.Top() + aBoundRect
.Bottom() ) >> 1 );
1663 Point
aRef2( aRef1
.X() + 1000, aRef1
.Y() );
1665 sal_uInt16 nPointCount
=aPol
.GetSize();
1666 for (i
=0; i
<nPointCount
; i
++)
1668 MirrorPoint(aPol
[i
],aRef1
,aRef2
);
1670 // turn and move polygon
1671 tools::Polygon
aPol0(aPol
);
1677 aRectangle
= svx::polygonToRectangle(aPol
, aNewGeo
);
1680 Point
aPt( aRectangle
.TopLeft() );
1682 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1683 aPt
-= GetSdrObject()->GetAnchorPos();
1685 ForceMetricTo100th_mm(aPt
);
1686 return css::awt::Point( aPt
.X(), aPt
.Y() );
1689 return SvxShape::getPosition();
1693 void SAL_CALL
SvxCustomShape::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
1695 ::SolarMutexGuard aGuard
;
1697 SdrObject
* pObject
= GetSdrObject();
1699 // tdf#98163 Use a custom slot to have filter code flush the UNO
1700 // API implementations of SdrObjCustomShape. Used e.g. by
1701 // ~SdXMLCustomShapeContext, see there for more information
1702 if("FlushCustomShapeUnoApiObjects" == aPropertyName
)
1704 SdrObjCustomShape
* pTarget
= dynamic_cast< SdrObjCustomShape
* >(pObject
);
1707 // Luckily, the object causing problems in tdf#93994 is not the
1708 // UNO API object, but the XCustomShapeEngine involved. This
1709 // object is on-demand replaceable and can be reset here. This
1710 // will free the involved EditEngine and VirtualDevice.
1711 pTarget
->mxCustomShapeEngine
.clear();
1713 // since this case is only for the application cores
1714 // we should return from this function now
1718 bool bCustomShapeGeometry
= pObject
&& aPropertyName
== "CustomShapeGeometry";
1720 bool bMirroredX
= false;
1721 bool bMirroredY
= false;
1723 if ( bCustomShapeGeometry
)
1725 bMirroredX
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredX();
1726 bMirroredY
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredY();
1729 SvxShape::setPropertyValue( aPropertyName
, aValue
);
1731 if ( !bCustomShapeGeometry
)
1734 static_cast<SdrObjCustomShape
*>(pObject
)->MergeDefaultAttributes();
1735 tools::Rectangle
aRect( pObject
->GetSnapRect() );
1738 bool bNeedsMirrorX
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredX() != bMirroredX
;
1739 bool bNeedsMirrorY
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredY() != bMirroredY
;
1741 std::unique_ptr
< SdrGluePointList
> pListCopy
;
1742 if( bNeedsMirrorX
|| bNeedsMirrorY
)
1744 const SdrGluePointList
* pList
= pObject
->GetGluePointList();
1746 pListCopy
.reset( new SdrGluePointList(*pList
) );
1749 if ( bNeedsMirrorX
)
1751 Point
aTop( ( aRect
.Left() + aRect
.Right() ) >> 1, aRect
.Top() );
1752 Point
aBottom( aTop
.X(), aTop
.Y() + 1000 );
1753 pObject
->NbcMirror( aTop
, aBottom
);
1754 // NbcMirroring is flipping the current mirror state,
1755 // so we have to set the correct state again
1756 static_cast<SdrObjCustomShape
*>(pObject
)->SetMirroredX( !bMirroredX
);
1758 if ( bNeedsMirrorY
)
1760 Point
aLeft( aRect
.Left(), ( aRect
.Top() + aRect
.Bottom() ) >> 1 );
1761 Point
aRight( aLeft
.X() + 1000, aLeft
.Y() );
1762 pObject
->NbcMirror( aLeft
, aRight
);
1763 // NbcMirroring is flipping the current mirror state,
1764 // so we have to set the correct state again
1765 static_cast<SdrObjCustomShape
*>(pObject
)->SetMirroredY( !bMirroredY
);
1770 SdrGluePointList
* pNewList
= const_cast< SdrGluePointList
* >( pObject
->GetGluePointList() );
1772 *pNewList
= *pListCopy
;
1776 bool SvxCustomShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
1778 switch( pProperty
->nWID
)
1780 case SDRATTR_ROTATEANGLE
:
1782 double fAngle
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->GetObjectRotation();
1784 rValue
<<= static_cast<sal_Int32
>(fAngle
);
1788 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
1792 void SvxCustomShape::createCustomShapeDefaults( const OUString
& rValueType
)
1794 if (!HasSdrObject())
1796 OSL_FAIL("could not create Custom Shape Defaults!");
1800 static_cast<SdrObjCustomShape
*>(GetSdrObject())->MergeDefaultAttributes( &rValueType
);
1803 SvxShapeGroupAnyD::SvxShapeGroupAnyD( SdrObject
* pObject
, std::span
<const SfxItemPropertyMapEntry
> pEntries
, const SvxItemPropertySet
* pPropertySet
)
1804 : SvxShape(pObject
, pEntries
, pPropertySet
)
1807 SvxShapeGroupAnyD::~SvxShapeGroupAnyD() noexcept
1810 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */