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/GraphicLoader.hxx>
41 #include <svx/svdpool.hxx>
43 #include <editeng/unoprnms.hxx>
44 #include <svx/unoshape.hxx>
45 #include <svx/unopage.hxx>
46 #include <svx/svdobj.hxx>
47 #include <svx/svdpage.hxx>
48 #include <svx/svdmodel.hxx>
49 #include <svx/svdouno.hxx>
50 #include "shapeimpl.hxx"
51 #include <svx/unoshprp.hxx>
52 #include <svx/svdoashp.hxx>
53 #include <svx/svdviter.hxx>
54 #include <svx/svdview.hxx>
55 #include <svx/svdopath.hxx>
56 #include <basegfx/matrix/b2dhommatrix.hxx>
57 #include <basegfx/polygon/b2dpolygon.hxx>
58 #include <basegfx/point/b2dpoint.hxx>
59 #include <basegfx/polygon/b2dpolygontools.hxx>
60 #include <basegfx/polygon/b2dpolypolygontools.hxx>
61 #include <com/sun/star/awt/XBitmap.hpp>
62 #include <svx/svdograf.hxx>
63 #include <sal/log.hxx>
64 #include <cppuhelper/queryinterface.hxx>
65 #include <tools/stream.hxx>
70 using namespace ::osl
;
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
aIter( pSdrShape
);
265 for ( SdrView
* pView
= aIter
.FirstView(); pView
; pView
= aIter
.NextView() )
267 if(SAL_MAX_SIZE
!= pView
->TryToFindMarkedObject(pSdrShape
))
269 pView
->MarkObj(pSdrShape
, pView
->GetSdrPageView(), true);
273 rList
.NbcRemoveObject( nObjNum
);
277 SAL_WARN( "svx", "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
280 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
283 void SAL_CALL
SvxShapeGroup::addTop( const uno::Reference
< drawing::XShape
>& xShape
)
285 SolarMutexGuard aGuard
;
287 // Add to the top of the stack (i.e. bottom of the list).
288 addUnoShape(xShape
, SAL_MAX_SIZE
);
291 void SAL_CALL
SvxShapeGroup::addBottom( const uno::Reference
< drawing::XShape
>& xShape
)
293 SolarMutexGuard aGuard
;
295 // Add to the bottom of the stack (i.e. top of the list).
296 addUnoShape(xShape
, 0);
302 sal_Int32 SAL_CALL
SvxShapeGroup::getCount()
304 ::SolarMutexGuard aGuard
;
306 if(!HasSdrObject() || !GetSdrObject()->GetSubList())
307 throw uno::RuntimeException();
309 sal_Int32 nRetval
= GetSdrObject()->GetSubList()->GetObjCount();
314 uno::Any SAL_CALL
SvxShapeGroup::getByIndex( sal_Int32 Index
)
316 ::SolarMutexGuard aGuard
;
318 if( !HasSdrObject() || GetSdrObject()->GetSubList() == nullptr )
319 throw uno::RuntimeException();
321 if( Index
<0 || GetSdrObject()->GetSubList()->GetObjCount() <= o3tl::make_unsigned(Index
) )
322 throw lang::IndexOutOfBoundsException();
324 SdrObject
* pDestObj
= GetSdrObject()->GetSubList()->GetObj( Index
);
326 if(pDestObj
== nullptr)
327 throw lang::IndexOutOfBoundsException();
329 Reference
< drawing::XShape
> xShape( pDestObj
->getUnoShape(), uno::UNO_QUERY
);
330 return uno::Any( xShape
);
333 // css::container::XElementAccess
336 uno::Type SAL_CALL
SvxShapeGroup::getElementType()
338 return cppu::UnoType
<drawing::XShape
>::get();
342 sal_Bool SAL_CALL
SvxShapeGroup::hasElements()
344 ::SolarMutexGuard aGuard
;
346 return HasSdrObject() && GetSdrObject()->GetSubList() && (GetSdrObject()->GetSubList()->GetObjCount() > 0);
349 SvxShapeConnector::SvxShapeConnector(SdrObject
* pObj
)
350 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CONNECTOR
), getSvxMapProvider().GetPropertySet(SVXMAP_CONNECTOR
, SdrObject::GetGlobalDrawObjectItemPool()) )
355 SvxShapeConnector::~SvxShapeConnector() noexcept
360 uno::Any SAL_CALL
SvxShapeConnector::queryInterface( const uno::Type
& rType
)
362 return SvxShapeText::queryInterface( rType
);
365 uno::Any SAL_CALL
SvxShapeConnector::queryAggregation( const uno::Type
& rType
)
369 QUERYINT( drawing::XConnectorShape
);
371 return SvxShapeText::queryAggregation( rType
);
378 uno::Sequence
< uno::Type
> SAL_CALL
SvxShapeConnector::getTypes()
380 return SvxShape::getTypes();
383 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeConnector::getImplementationId()
385 return css::uno::Sequence
<sal_Int8
>();
388 // css::drawing::XShape
391 OUString SAL_CALL
SvxShapeConnector::getShapeType()
393 return SvxShapeText::getShapeType();
396 awt::Point SAL_CALL
SvxShapeConnector::getPosition()
398 return SvxShapeText::getPosition();
402 void SAL_CALL
SvxShapeConnector::setPosition( const awt::Point
& Position
)
404 SvxShapeText::setPosition(Position
);
408 awt::Size SAL_CALL
SvxShapeConnector::getSize()
410 return SvxShapeText::getSize();
414 void SAL_CALL
SvxShapeConnector::setSize( const awt::Size
& rSize
)
416 SvxShapeText::setSize( rSize
);
422 void SAL_CALL
SvxShapeConnector::connectStart( const uno::Reference
< drawing::XConnectableShape
>& xShape
, drawing::ConnectionType
)
424 ::SolarMutexGuard aGuard
;
426 Reference
< drawing::XShape
> xRef( xShape
, UNO_QUERY
);
427 SdrObject
* pSdrObject
= SdrObject::getSdrObjectFromXShape( xRef
);
430 GetSdrObject()->ConnectToNode( true, pSdrObject
);
432 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
436 void SAL_CALL
SvxShapeConnector::connectEnd( const uno::Reference
< drawing::XConnectableShape
>& xShape
, drawing::ConnectionType
)
438 ::SolarMutexGuard aGuard
;
440 Reference
< drawing::XShape
> xRef( xShape
, UNO_QUERY
);
441 SdrObject
* pSdrObject
= SdrObject::getSdrObjectFromXShape( xRef
);
443 if( HasSdrObject() && pSdrObject
)
444 GetSdrObject()->ConnectToNode( false, pSdrObject
);
446 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
450 void SAL_CALL
SvxShapeConnector::disconnectBegin( const uno::Reference
< drawing::XConnectableShape
>& )
452 ::SolarMutexGuard aGuard
;
455 GetSdrObject()->DisconnectFromNode( true );
457 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
461 void SAL_CALL
SvxShapeConnector::disconnectEnd( const uno::Reference
< drawing::XConnectableShape
>& )
463 ::SolarMutexGuard aGuard
;
466 GetSdrObject()->DisconnectFromNode( false );
468 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
471 SvxShapeControl::SvxShapeControl(SdrObject
* pObj
)
472 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CONTROL
), getSvxMapProvider().GetPropertySet(SVXMAP_CONTROL
, SdrObject::GetGlobalDrawObjectItemPool()) )
474 setShapeKind( SdrObjKind::UNO
);
478 SvxShapeControl::~SvxShapeControl() noexcept
483 uno::Any SAL_CALL
SvxShapeControl::queryInterface( const uno::Type
& rType
)
485 return SvxShapeText::queryInterface( rType
);
488 uno::Any SAL_CALL
SvxShapeControl::queryAggregation( const uno::Type
& rType
)
492 QUERYINT( drawing::XControlShape
);
494 return SvxShapeText::queryAggregation( rType
);
501 uno::Sequence
< uno::Type
> SAL_CALL
SvxShapeControl::getTypes()
503 return SvxShape::getTypes();
506 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeControl::getImplementationId()
508 return css::uno::Sequence
<sal_Int8
>();
511 // css::drawing::XShape
514 OUString SAL_CALL
SvxShapeControl::getShapeType()
516 return SvxShapeText::getShapeType();
519 awt::Point SAL_CALL
SvxShapeControl::getPosition()
521 return SvxShapeText::getPosition();
525 void SAL_CALL
SvxShapeControl::setPosition( const awt::Point
& Position
)
527 SvxShapeText::setPosition(Position
);
531 awt::Size SAL_CALL
SvxShapeControl::getSize()
533 return SvxShapeText::getSize();
537 void SAL_CALL
SvxShapeControl::setSize( const awt::Size
& rSize
)
539 SvxShapeText::setSize( rSize
);
545 Reference
< awt::XControlModel
> SAL_CALL
SvxShapeControl::getControl()
547 ::SolarMutexGuard aGuard
;
549 Reference
< awt::XControlModel
> xModel
;
551 SdrUnoObj
* pUnoObj
= dynamic_cast< SdrUnoObj
* >(GetSdrObject());
553 xModel
= pUnoObj
->GetUnoControlModel();
559 void SAL_CALL
SvxShapeControl::setControl( const Reference
< awt::XControlModel
>& xControl
)
561 ::SolarMutexGuard aGuard
;
563 SdrUnoObj
* pUnoObj
= dynamic_cast< SdrUnoObj
* >(GetSdrObject());
565 pUnoObj
->SetUnoControlModel( xControl
);
567 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
575 const SvxShapeControlPropertyMapping
[] =
577 // Warning: The first entry must be FontSlant because the any needs to be converted
578 { UNO_NAME_EDIT_CHAR_POSTURE
, "FontSlant" }, // const sal_Int16 => css::awt::FontSlant
579 { UNO_NAME_EDIT_CHAR_FONTNAME
, "FontName" },
580 { UNO_NAME_EDIT_CHAR_FONTSTYLENAME
, "FontStyleName" },
581 { UNO_NAME_EDIT_CHAR_FONTFAMILY
, "FontFamily" },
582 { UNO_NAME_EDIT_CHAR_FONTCHARSET
, "FontCharset" },
583 { UNO_NAME_EDIT_CHAR_HEIGHT
, "FontHeight" },
584 { UNO_NAME_EDIT_CHAR_FONTPITCH
, "FontPitch" },
585 { UNO_NAME_EDIT_CHAR_WEIGHT
, "FontWeight" },
586 { UNO_NAME_EDIT_CHAR_UNDERLINE
, "FontUnderline" },
587 { UNO_NAME_EDIT_CHAR_STRIKEOUT
, "FontStrikeout" },
588 { "CharKerning", "FontKerning" },
589 { "CharWordMode", "FontWordLineMode" },
590 { UNO_NAME_EDIT_CHAR_COLOR
, "TextColor" },
591 { "CharBackColor", "CharBackColor" },
592 { "CharBackTransparent", "CharBackTransparent" },
593 { UNO_NAME_TEXT_CHAINNEXTNAME
, UNO_NAME_TEXT_CHAINNEXTNAME
},
594 { "CharRelief", "FontRelief" },
595 { "CharUnderlineColor", "TextLineColor" },
596 { UNO_NAME_EDIT_PARA_ADJUST
, "Align" },
597 { "TextVerticalAdjust", "VerticalAlign" },
598 { "ControlBackground", "BackgroundColor" },
599 { "ControlSymbolColor", "SymbolColor" },
600 { "ControlBorder", "Border" },
601 { "ControlBorderColor", "BorderColor" },
602 { "ControlTextEmphasis", "FontEmphasisMark" },
603 { "ImageScaleMode", "ScaleMode" },
604 { "ControlWritingMode", "WritingMode" },
605 //added for exporting OCX control
606 { "ControlTypeinMSO", "ControlTypeinMSO" },
607 { "ObjIDinMSO", "ObjIDinMSO" },
608 { "CharCaseMap", "CharCaseMap" },
609 { "CharColorTheme", "CharColorTheme" },
610 { "CharColorTintOrShade", "CharColorTintOrShade" },
611 { UNO_NAME_EDIT_CHAR_COMPLEX_COLOR
, "CharComplexColor" },
616 bool lcl_convertPropertyName( std::u16string_view rApiName
, OUString
& rInternalName
)
618 for( const auto & rEntry
: SvxShapeControlPropertyMapping
)
620 if( rApiName
== rEntry
.msAPIName
)
622 rInternalName
= rEntry
.msFormName
;
625 return !rInternalName
.isEmpty();
628 struct EnumConversionMap
630 style::ParagraphAdjust nAPIValue
;
631 sal_Int16 nFormValue
;
634 EnumConversionMap
const aMapAdjustToAlign
[] =
636 // note that order matters:
637 // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
638 // and use the first matching entry
639 {style::ParagraphAdjust_LEFT
, sal_Int16(awt::TextAlign::LEFT
)},
640 {style::ParagraphAdjust_CENTER
, sal_Int16(awt::TextAlign::CENTER
)},
641 {style::ParagraphAdjust_RIGHT
, sal_Int16(awt::TextAlign::RIGHT
)},
642 {style::ParagraphAdjust_BLOCK
, sal_Int16(awt::TextAlign::RIGHT
)},
643 {style::ParagraphAdjust_STRETCH
, sal_Int16(awt::TextAlign::LEFT
)},
644 {style::ParagraphAdjust(-1),-1}
647 void lcl_convertTextAlignmentToParaAdjustment( Any
& _rValue
)
649 sal_Int16 nValue
= sal_Int16();
650 OSL_VERIFY( _rValue
>>= nValue
);
652 for ( auto const & rEntry
: aMapAdjustToAlign
)
653 if ( nValue
== rEntry
.nFormValue
)
655 _rValue
<<= static_cast<sal_uInt16
>(rEntry
.nAPIValue
);
660 void lcl_convertParaAdjustmentToTextAlignment( Any
& _rValue
)
662 sal_Int32 nValue
= 0;
663 OSL_VERIFY( _rValue
>>= nValue
);
665 for ( auto const & rEntry
: aMapAdjustToAlign
)
666 if ( static_cast<style::ParagraphAdjust
>(nValue
) == rEntry
.nAPIValue
)
668 _rValue
<<= rEntry
.nFormValue
;
673 void convertVerticalAdjustToVerticalAlign( Any
& _rValue
)
675 if ( !_rValue
.hasValue() )
678 drawing::TextVerticalAdjust eAdjust
= drawing::TextVerticalAdjust_TOP
;
679 style::VerticalAlignment eAlign
= style::VerticalAlignment_TOP
;
680 if ( !( _rValue
>>= eAdjust
) )
681 throw lang::IllegalArgumentException();
684 case drawing::TextVerticalAdjust_TOP
: eAlign
= style::VerticalAlignment_TOP
; break;
685 case drawing::TextVerticalAdjust_BOTTOM
: eAlign
= style::VerticalAlignment_BOTTOM
; break;
686 default: eAlign
= style::VerticalAlignment_MIDDLE
; break;
691 void convertVerticalAlignToVerticalAdjust( Any
& _rValue
)
693 if ( !_rValue
.hasValue() )
695 style::VerticalAlignment eAlign
= style::VerticalAlignment_TOP
;
696 drawing::TextVerticalAdjust eAdjust
= drawing::TextVerticalAdjust_TOP
;
697 OSL_VERIFY( _rValue
>>= eAlign
);
700 case style::VerticalAlignment_TOP
: eAdjust
= drawing::TextVerticalAdjust_TOP
; break;
701 case style::VerticalAlignment_BOTTOM
: eAdjust
= drawing::TextVerticalAdjust_BOTTOM
; break;
702 default: eAdjust
= drawing::TextVerticalAdjust_CENTER
; break;
708 void SAL_CALL
SvxShapeControl::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
711 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
713 uno::Reference
< beans::XPropertySet
> xControl( getControl(), uno::UNO_QUERY
);
716 uno::Reference
< beans::XPropertySetInfo
> xInfo( xControl
->getPropertySetInfo() );
717 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
719 uno::Any
aConvertedValue( aValue
);
720 if ( aFormsName
== "FontSlant" )
722 awt::FontSlant nSlant
;
723 if( !(aValue
>>= nSlant
) )
724 throw lang::IllegalArgumentException();
725 aConvertedValue
<<= static_cast<sal_Int16
>(nSlant
);
727 else if ( aFormsName
== "Align" )
729 lcl_convertParaAdjustmentToTextAlignment( aConvertedValue
);
731 else if ( aFormsName
== "VerticalAlign" )
733 convertVerticalAdjustToVerticalAlign( aConvertedValue
);
736 xControl
->setPropertyValue( aFormsName
, aConvertedValue
);
742 SvxShape::setPropertyValue( aPropertyName
, aValue
);
746 uno::Any SAL_CALL
SvxShapeControl::getPropertyValue( const OUString
& aPropertyName
)
749 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
751 uno::Reference
< beans::XPropertySet
> xControl( getControl(), uno::UNO_QUERY
);
756 uno::Reference
< beans::XPropertySetInfo
> xInfo( xControl
->getPropertySetInfo() );
757 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
759 aValue
= xControl
->getPropertyValue( aFormsName
);
760 if ( aFormsName
== "FontSlant" )
762 awt::FontSlant eSlant
= awt::FontSlant_NONE
;
763 sal_Int16 nSlant
= sal_Int16();
764 if ( aValue
>>= nSlant
)
766 eSlant
= static_cast<awt::FontSlant
>(nSlant
);
770 OSL_VERIFY( aValue
>>= eSlant
);
774 else if ( aFormsName
== "Align" )
776 lcl_convertTextAlignmentToParaAdjustment( aValue
);
778 else if ( aFormsName
== "VerticalAlign" )
780 convertVerticalAlignToVerticalAdjust( aValue
);
789 return SvxShape::getPropertyValue( aPropertyName
);
795 beans::PropertyState SAL_CALL
SvxShapeControl::getPropertyState( const OUString
& PropertyName
)
798 if ( lcl_convertPropertyName( PropertyName
, aFormsName
) )
800 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
801 uno::Reference
< beans::XPropertySet
> xPropSet( getControl(), uno::UNO_QUERY
);
803 if( xControl
.is() && xPropSet
.is() )
805 uno::Reference
< beans::XPropertySetInfo
> xInfo( xPropSet
->getPropertySetInfo() );
806 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
808 return xControl
->getPropertyState( aFormsName
);
812 return beans::PropertyState_DEFAULT_VALUE
;
816 return SvxShape::getPropertyState( PropertyName
);
820 void SAL_CALL
SvxShapeControl::setPropertyToDefault( const OUString
& PropertyName
)
823 if ( lcl_convertPropertyName( PropertyName
, aFormsName
) )
825 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
826 uno::Reference
< beans::XPropertySet
> xPropSet( getControl(), uno::UNO_QUERY
);
828 if( xControl
.is() && xPropSet
.is() )
830 uno::Reference
< beans::XPropertySetInfo
> xInfo( xPropSet
->getPropertySetInfo() );
831 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
833 xControl
->setPropertyToDefault( aFormsName
);
839 SvxShape::setPropertyToDefault( PropertyName
);
843 uno::Any SAL_CALL
SvxShapeControl::getPropertyDefault( const OUString
& aPropertyName
)
846 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
848 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
852 Any
aDefault( xControl
->getPropertyDefault( aFormsName
) );
853 if ( aFormsName
== "FontSlant" )
855 sal_Int16
nSlant( 0 );
857 aDefault
<<= static_cast<awt::FontSlant
>(nSlant
);
859 else if ( aFormsName
== "Align" )
861 lcl_convertTextAlignmentToParaAdjustment( aDefault
);
863 else if ( aFormsName
== "VerticalAlign" )
865 convertVerticalAlignToVerticalAdjust( aDefault
);
870 throw beans::UnknownPropertyException( aPropertyName
, static_cast<cppu::OWeakObject
*>(this));
874 return SvxShape::getPropertyDefault( aPropertyName
);
878 SvxShapeDimensioning::SvxShapeDimensioning(SdrObject
* pObj
)
879 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_DIMENSIONING
), getSvxMapProvider().GetPropertySet(SVXMAP_DIMENSIONING
, SdrObject::GetGlobalDrawObjectItemPool()) )
883 SvxShapeDimensioning::~SvxShapeDimensioning() noexcept
887 SvxShapeCircle::SvxShapeCircle(SdrObject
* pObj
)
888 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CIRCLE
), getSvxMapProvider().GetPropertySet(SVXMAP_CIRCLE
, SdrObject::GetGlobalDrawObjectItemPool()) )
892 SvxShapeCircle::~SvxShapeCircle() noexcept
896 //////////////////////////////////////////////////////////////////////////////
898 SvxShapePolyPolygon::SvxShapePolyPolygon(
902 getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGON
),
903 getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGON
, SdrObject::GetGlobalDrawObjectItemPool()))
907 SvxShapePolyPolygon::~SvxShapePolyPolygon() noexcept
911 bool SvxShapePolyPolygon::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
913 switch( pProperty
->nWID
)
915 case OWN_ATTR_VALUE_POLYPOLYGONBEZIER
:
917 if( auto s
= o3tl::tryAccess
<drawing::PolyPolygonBezierCoords
>(rValue
) )
919 basegfx::B2DPolyPolygon
aNewPolyPolygon(
920 basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*s
));
922 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
923 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
925 SetPolygon(aNewPolyPolygon
);
930 case OWN_ATTR_VALUE_POLYPOLYGON
:
932 if( auto s
= o3tl::tryAccess
<drawing::PointSequenceSequence
>(rValue
) )
934 basegfx::B2DPolyPolygon
aNewPolyPolygon(
935 basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(*s
));
937 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
938 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
940 SetPolygon(aNewPolyPolygon
);
945 case OWN_ATTR_BASE_GEOMETRY
:
947 drawing::PointSequenceSequence aPointSequenceSequence
;
948 drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords
;
950 if( rValue
>>= aPointSequenceSequence
)
954 basegfx::B2DPolyPolygon aNewPolyPolygon
;
955 basegfx::B2DHomMatrix aNewHomogenMatrix
;
957 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
958 aNewPolyPolygon
= basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(aPointSequenceSequence
);
960 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
961 // Need to adapt aNewPolyPolygon from 100thmm to app-specific
962 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
964 GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
968 else if( rValue
>>= aPolyPolygonBezierCoords
)
972 basegfx::B2DPolyPolygon aNewPolyPolygon
;
973 basegfx::B2DHomMatrix aNewHomogenMatrix
;
975 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
976 aNewPolyPolygon
= basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(aPolyPolygonBezierCoords
);
978 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
979 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
981 GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
987 case OWN_ATTR_VALUE_POLYGON
:
989 if( auto pSequence
= o3tl::tryAccess
<drawing::PointSequence
>(rValue
) )
991 // prepare new polygon
992 basegfx::B2DPolygon aNewPolygon
;
994 // get pointer to arrays
995 const awt::Point
* pArray
= pSequence
->getConstArray();
996 const awt::Point
* pArrayEnd
= pArray
+ pSequence
->getLength();
998 for(;pArray
!= pArrayEnd
;++pArray
)
1000 aNewPolygon
.append(basegfx::B2DPoint(pArray
->X
, pArray
->Y
));
1003 // check for closed state flag
1004 basegfx::utils::checkClosed(aNewPolygon
);
1006 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1007 basegfx::B2DPolyPolygon
aNewPolyPolygon(aNewPolygon
);
1008 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
1011 SetPolygon(aNewPolyPolygon
);
1017 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
1020 throw lang::IllegalArgumentException();
1023 bool SvxShapePolyPolygon::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
,
1024 css::uno::Any
& rValue
)
1026 switch( pProperty
->nWID
)
1028 case OWN_ATTR_VALUE_POLYPOLYGONBEZIER
:
1030 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1031 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1033 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1034 ForceMetricTo100th_mm(aPolyPoly
);
1036 drawing::PolyPolygonBezierCoords aRetval
;
1037 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords(aPolyPoly
, aRetval
);
1042 case OWN_ATTR_VALUE_POLYPOLYGON
:
1044 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1045 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1047 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1048 ForceMetricTo100th_mm(aPolyPoly
);
1050 drawing::PointSequenceSequence
aRetval( aPolyPoly
.count() );
1051 basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPoly
, aRetval
);
1056 case OWN_ATTR_BASE_GEOMETRY
:
1058 // pack a tools::PolyPolygon in struct PolyPolygon
1059 basegfx::B2DPolyPolygon aPolyPoly
;
1060 basegfx::B2DHomMatrix aNewHomogenMatrix
;
1064 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aPolyPoly
);
1066 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1067 ForceMetricTo100th_mm(aPolyPoly
);
1070 if(aPolyPoly
.areControlPointsUsed())
1072 drawing::PolyPolygonBezierCoords aRetval
;
1073 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords(aPolyPoly
, aRetval
);
1078 drawing::PointSequenceSequence
aRetval(aPolyPoly
.count());
1079 basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPoly
, aRetval
);
1084 case OWN_ATTR_VALUE_POLYGON
:
1086 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1087 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1089 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1090 ForceMetricTo100th_mm(aPolyPoly
);
1092 const sal_Int32
nCount(0 == aPolyPoly
.count() ? 0 : aPolyPoly
.getB2DPolygon(0).count());
1093 drawing::PointSequence
aRetval( nCount
);
1097 // get single polygon
1098 const basegfx::B2DPolygon
& aPoly(aPolyPoly
.getB2DPolygon(0));
1100 // get pointer to arrays
1101 awt::Point
* pSequence
= aRetval
.getArray();
1103 for(sal_Int32 b
=0;b
<nCount
;b
++)
1105 const basegfx::B2DPoint
aPoint(aPoly
.getB2DPoint(b
));
1106 *pSequence
++ = awt::Point( basegfx::fround(aPoint
.getX()), basegfx::fround(aPoint
.getY()) );
1113 case OWN_ATTR_VALUE_POLYGONKIND
:
1115 rValue
<<= GetPolygonKind();
1119 return SvxShapeText::getPropertyValueImpl( rName
, pProperty
, rValue
);
1125 drawing::PolygonKind
SvxShapePolyPolygon::GetPolygonKind() const
1127 ::SolarMutexGuard aGuard
;
1128 drawing::PolygonKind
aRetval(drawing::PolygonKind_LINE
);
1132 switch(GetSdrObject()->GetObjIdentifier())
1134 case SdrObjKind::Polygon
: aRetval
= drawing::PolygonKind_POLY
; break;
1135 case SdrObjKind::PolyLine
: aRetval
= drawing::PolygonKind_PLIN
; break;
1136 case SdrObjKind::PathLine
: aRetval
= drawing::PolygonKind_PATHLINE
; break;
1137 case SdrObjKind::PathFill
: aRetval
= drawing::PolygonKind_PATHFILL
; break;
1138 case SdrObjKind::FreehandLine
: aRetval
= drawing::PolygonKind_FREELINE
; break;
1139 case SdrObjKind::FreehandFill
: aRetval
= drawing::PolygonKind_FREEFILL
; break;
1147 void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon
& rNew
)
1149 ::SolarMutexGuard aGuard
;
1152 static_cast<SdrPathObj
*>(GetSdrObject())->SetPathPoly(rNew
);
1156 basegfx::B2DPolyPolygon
SvxShapePolyPolygon::GetPolygon() const noexcept
1158 ::SolarMutexGuard aGuard
;
1162 return static_cast<SdrPathObj
*>(GetSdrObject())->GetPathPoly();
1166 return basegfx::B2DPolyPolygon();
1170 //////////////////////////////////////////////////////////////////////////////
1172 SvxGraphicObject::SvxGraphicObject(SdrObject
* pObj
)
1173 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_GRAPHICOBJECT
), getSvxMapProvider().GetPropertySet(SVXMAP_GRAPHICOBJECT
, SdrObject::GetGlobalDrawObjectItemPool()) )
1177 SvxGraphicObject::~SvxGraphicObject() noexcept
1181 bool SvxGraphicObject::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, const css::uno::Any
& rValue
)
1184 switch( pProperty
->nWID
)
1186 case OWN_ATTR_VALUE_FILLBITMAP
:
1188 if( auto pSeq
= o3tl::tryAccess
<uno::Sequence
<sal_Int8
>>(rValue
) )
1190 SvMemoryStream aMemStm
;
1193 aMemStm
.SetBuffer( const_cast<css::uno::Sequence
<sal_Int8
> *>(pSeq
)->getArray(), pSeq
->getLength(), pSeq
->getLength() );
1195 if( GraphicConverter::Import( aMemStm
, aGraphic
) == ERRCODE_NONE
)
1197 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1201 else if (rValue
.getValueType() == cppu::UnoType
<graphic::XGraphic
>::get())
1203 auto xGraphic
= rValue
.get
<uno::Reference
<graphic::XGraphic
>>();
1206 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(Graphic(xGraphic
));
1210 else if (rValue
.getValueType() == cppu::UnoType
<awt::XBitmap
>::get())
1212 auto xBitmap
= rValue
.get
<uno::Reference
<awt::XBitmap
>>();
1215 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
1216 Graphic
aGraphic(xGraphic
);
1217 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1224 case OWN_ATTR_GRAFSTREAMURL
:
1226 OUString aStreamURL
;
1228 if( rValue
>>= aStreamURL
)
1230 if( !aStreamURL
.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX
) )
1233 if( HasSdrObject() )
1235 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGrafStreamURL( aStreamURL
);
1242 case OWN_ATTR_GRAPHIC_URL
:
1245 uno::Reference
<awt::XBitmap
> xBitmap
;
1246 if (rValue
>>= aURL
)
1248 Graphic aGraphic
= vcl::graphic::loadFromURL(aURL
);
1249 if (!aGraphic
.IsNone())
1251 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1255 else if (rValue
>>= xBitmap
)
1257 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
1260 Graphic aGraphic
= xGraphic
;
1261 if (!aGraphic
.IsNone())
1263 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1271 case OWN_ATTR_VALUE_GRAPHIC
:
1273 Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
1276 static_cast< SdrGrafObj
*>( GetSdrObject() )->SetGraphic( xGraphic
);
1282 case OWN_ATTR_IS_SIGNATURELINE
:
1284 bool bIsSignatureLine
;
1285 if (rValue
>>= bIsSignatureLine
)
1287 static_cast<SdrGrafObj
*>(GetSdrObject())->setIsSignatureLine(bIsSignatureLine
);
1293 case OWN_ATTR_SIGNATURELINE_ID
:
1295 OUString aSignatureLineId
;
1296 if (rValue
>>= aSignatureLineId
)
1298 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineId(aSignatureLineId
);
1304 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME
:
1306 OUString aSuggestedSignerName
;
1307 if (rValue
>>= aSuggestedSignerName
)
1309 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerName(aSuggestedSignerName
);
1315 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_TITLE
:
1317 OUString aSuggestedSignerTitle
;
1318 if (rValue
>>= aSuggestedSignerTitle
)
1320 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerTitle(aSuggestedSignerTitle
);
1326 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_EMAIL
:
1328 OUString aSuggestedSignerEmail
;
1329 if (rValue
>>= aSuggestedSignerEmail
)
1331 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerEmail(aSuggestedSignerEmail
);
1337 case OWN_ATTR_SIGNATURELINE_SIGNING_INSTRUCTIONS
:
1339 OUString aSigningInstructions
;
1340 if (rValue
>>= aSigningInstructions
)
1342 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSigningInstructions(aSigningInstructions
);
1348 case OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE
:
1351 if (rValue
>>= bShowSignDate
)
1353 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineShowSignDate(bShowSignDate
);
1359 case OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT
:
1361 bool bCanAddComment
;
1362 if (rValue
>>= bCanAddComment
)
1364 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineCanAddComment(bCanAddComment
);
1370 case OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE
:
1372 Reference
<graphic::XGraphic
> xGraphic(rValue
, uno::UNO_QUERY
);
1375 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineUnsignedGraphic(xGraphic
);
1381 case OWN_ATTR_SIGNATURELINE_IS_SIGNED
:
1384 if (rValue
>>= bIsSigned
)
1386 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineIsSigned(bIsSigned
);
1392 case OWN_ATTR_QRCODE
:
1394 css::drawing::BarCode aBarCode
;
1395 if (rValue
>>= aBarCode
)
1397 static_cast<SdrGrafObj
*>(GetSdrObject())->setQrCode(aBarCode
);
1404 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
1408 throw lang::IllegalArgumentException();
1410 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1415 bool SvxGraphicObject::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
1417 switch( pProperty
->nWID
)
1419 case OWN_ATTR_VALUE_FILLBITMAP
:
1421 const Graphic
& rGraphic
= static_cast<SdrGrafObj
*>(GetSdrObject())->GetGraphic();
1423 if (rGraphic
.GetType() != GraphicType::GdiMetafile
)
1425 uno::Reference
<awt::XBitmap
> xBitmap(rGraphic
.GetXGraphic(), uno::UNO_QUERY
);
1430 SvMemoryStream
aDestStrm( 65535, 65535 );
1432 ConvertGDIMetaFileToWMF( rGraphic
.GetGDIMetaFile(), aDestStrm
, nullptr, false );
1433 const uno::Sequence
<sal_Int8
> aSeq(
1434 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
1435 aDestStrm
.GetEndOfData());
1441 case OWN_ATTR_REPLACEMENT_GRAPHIC
:
1443 const GraphicObject
* pGrafObj
= static_cast< SdrGrafObj
* >(GetSdrObject())->GetReplacementGraphicObject();
1447 rValue
<<= pGrafObj
->GetGraphic().GetXGraphic();
1453 case OWN_ATTR_GRAFSTREAMURL
:
1455 const OUString
aStreamURL( static_cast<SdrGrafObj
*>( GetSdrObject() )->GetGrafStreamURL() );
1456 if( !aStreamURL
.isEmpty() )
1457 rValue
<<= aStreamURL
;
1461 case OWN_ATTR_GRAPHIC_URL
:
1462 case OWN_ATTR_VALUE_GRAPHIC
:
1464 if (pProperty
->nWID
== OWN_ATTR_GRAPHIC_URL
)
1466 SAL_WARN("svx", "Getting Graphic by URL is not supported, getting it by value");
1469 Reference
<graphic::XGraphic
> xGraphic
;
1470 auto pSdrGraphicObject
= static_cast<SdrGrafObj
*>(GetSdrObject());
1471 if (pSdrGraphicObject
1472 && pSdrGraphicObject
->GetGraphicObject().GetType() != GraphicType::NONE
)
1473 xGraphic
= pSdrGraphicObject
->GetGraphic().GetXGraphic();
1474 rValue
<<= xGraphic
;
1478 case OWN_ATTR_GRAPHIC_STREAM
:
1480 rValue
<<= static_cast< SdrGrafObj
* >( GetSdrObject() )->getInputStream();
1484 case OWN_ATTR_IS_SIGNATURELINE
:
1486 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLine();
1490 case OWN_ATTR_SIGNATURELINE_ID
:
1492 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineId();
1496 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME
:
1498 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerName();
1502 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_TITLE
:
1504 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerTitle();
1508 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_EMAIL
:
1510 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerEmail();
1514 case OWN_ATTR_SIGNATURELINE_SIGNING_INSTRUCTIONS
:
1516 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSigningInstructions();
1520 case OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE
:
1522 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineShowSignDate();
1526 case OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT
:
1528 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineCanAddComment();
1532 case OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE
:
1534 Reference
<graphic::XGraphic
> xGraphic(
1535 static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineUnsignedGraphic());
1536 rValue
<<= xGraphic
;
1540 case OWN_ATTR_SIGNATURELINE_IS_SIGNED
:
1542 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineSigned();
1546 case OWN_ATTR_QRCODE
:
1548 css::drawing::BarCode
* ptr
= static_cast<SdrGrafObj
*>(GetSdrObject())->getQrCode();
1557 return SvxShapeText::getPropertyValueImpl(rName
, pProperty
,rValue
);
1564 SvxShapeCaption::SvxShapeCaption(SdrObject
* pObj
)
1565 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CAPTION
), getSvxMapProvider().GetPropertySet(SVXMAP_CAPTION
, SdrObject::GetGlobalDrawObjectItemPool()) )
1569 SvxShapeCaption::~SvxShapeCaption() noexcept
1573 SvxCustomShape::SvxCustomShape(SdrObject
* pObj
)
1574 : SvxShapeText( pObj
, getSvxMapProvider().GetMap( SVXMAP_CUSTOMSHAPE
), getSvxMapProvider().GetPropertySet(SVXMAP_CUSTOMSHAPE
, SdrObject::GetGlobalDrawObjectItemPool()) )
1578 SvxCustomShape::~SvxCustomShape() noexcept
1582 uno::Any SAL_CALL
SvxCustomShape::queryInterface( const uno::Type
& rType
)
1584 return SvxShapeText::queryInterface( rType
);
1587 uno::Any SAL_CALL
SvxCustomShape::queryAggregation( const uno::Type
& rType
)
1589 css::uno::Any aReturn
= SvxShapeText::queryAggregation( rType
);
1590 if ( !aReturn
.hasValue() )
1591 aReturn
= ::cppu::queryInterface(rType
, static_cast<drawing::XEnhancedCustomShapeDefaulter
*>(this) );
1595 uno::Sequence
< sal_Int8
> SAL_CALL
SvxCustomShape::getImplementationId()
1597 return css::uno::Sequence
<sal_Int8
>();
1600 // css::drawing::XShape
1603 awt::Point SAL_CALL
SvxCustomShape::getPosition()
1605 ::SolarMutexGuard aGuard
;
1606 if ( HasSdrObject() )
1608 SdrAShapeObjGeoData aCustomShapeGeoData
;
1609 static_cast<SdrObjCustomShape
*>(GetSdrObject())->SaveGeoData( aCustomShapeGeoData
);
1611 bool bMirroredX
= false;
1612 bool bMirroredY
= false;
1614 if ( HasSdrObject() )
1616 bMirroredX
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->IsMirroredX();
1617 bMirroredY
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->IsMirroredY();
1619 // get aRect, this is the unrotated snaprect
1620 tools::Rectangle
aRect(static_cast<SdrObjCustomShape
*>(GetSdrObject())->GetLogicRect());
1621 tools::Rectangle
aRectangle( aRect
);
1623 if ( bMirroredX
|| bMirroredY
)
1624 { // we have to retrieve the unmirrored rect
1626 GeoStat
aNewGeo(aCustomShapeGeoData
.maGeo
);
1629 tools::Polygon
aPol( Rect2Poly( aRect
, aNewGeo
) );
1630 tools::Rectangle
aBoundRect( aPol
.GetBoundRect() );
1632 Point
aRef1( ( aBoundRect
.Left() + aBoundRect
.Right() ) >> 1, aBoundRect
.Top() );
1633 Point
aRef2( aRef1
.X(), aRef1
.Y() + 1000 );
1635 sal_uInt16 nPointCount
=aPol
.GetSize();
1636 for (i
=0; i
<nPointCount
; i
++)
1638 MirrorPoint(aPol
[i
],aRef1
,aRef2
);
1640 // turn and move polygon
1641 tools::Polygon
aPol0(aPol
);
1647 aRectangle
= svx::polygonToRectangle(aPol
, aNewGeo
);
1651 tools::Polygon
aPol( Rect2Poly( aRectangle
, aNewGeo
) );
1652 tools::Rectangle
aBoundRect( aPol
.GetBoundRect() );
1654 Point
aRef1( aBoundRect
.Left(), ( aBoundRect
.Top() + aBoundRect
.Bottom() ) >> 1 );
1655 Point
aRef2( aRef1
.X() + 1000, aRef1
.Y() );
1657 sal_uInt16 nPointCount
=aPol
.GetSize();
1658 for (i
=0; i
<nPointCount
; i
++)
1660 MirrorPoint(aPol
[i
],aRef1
,aRef2
);
1662 // turn and move polygon
1663 tools::Polygon
aPol0(aPol
);
1669 aRectangle
= svx::polygonToRectangle(aPol
, aNewGeo
);
1672 Point
aPt( aRectangle
.TopLeft() );
1674 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1675 aPt
-= GetSdrObject()->GetAnchorPos();
1677 ForceMetricTo100th_mm(aPt
);
1678 return css::awt::Point( aPt
.X(), aPt
.Y() );
1681 return SvxShape::getPosition();
1685 void SAL_CALL
SvxCustomShape::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
1687 ::SolarMutexGuard aGuard
;
1689 SdrObject
* pObject
= GetSdrObject();
1691 // tdf#98163 Use a custom slot to have filter code flush the UNO
1692 // API implementations of SdrObjCustomShape. Used e.g. by
1693 // ~SdXMLCustomShapeContext, see there for more information
1694 if("FlushCustomShapeUnoApiObjects" == aPropertyName
)
1696 SdrObjCustomShape
* pTarget
= dynamic_cast< SdrObjCustomShape
* >(pObject
);
1699 // Luckily, the object causing problems in tdf#93994 is not the
1700 // UNO API object, but the XCustomShapeEngine involved. This
1701 // object is on-demand replaceable and can be reset here. This
1702 // will free the involved EditEngine and VirtualDevice.
1703 pTarget
->mxCustomShapeEngine
.set(nullptr);
1705 // since this case is only for the application cores
1706 // we should return from this function now
1710 bool bCustomShapeGeometry
= pObject
&& aPropertyName
== "CustomShapeGeometry";
1712 bool bMirroredX
= false;
1713 bool bMirroredY
= false;
1715 if ( bCustomShapeGeometry
)
1717 bMirroredX
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredX();
1718 bMirroredY
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredY();
1721 SvxShape::setPropertyValue( aPropertyName
, aValue
);
1723 if ( !bCustomShapeGeometry
)
1726 static_cast<SdrObjCustomShape
*>(pObject
)->MergeDefaultAttributes();
1727 tools::Rectangle
aRect( pObject
->GetSnapRect() );
1730 bool bNeedsMirrorX
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredX() != bMirroredX
;
1731 bool bNeedsMirrorY
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredY() != bMirroredY
;
1733 std::unique_ptr
< SdrGluePointList
> pListCopy
;
1734 if( bNeedsMirrorX
|| bNeedsMirrorY
)
1736 const SdrGluePointList
* pList
= pObject
->GetGluePointList();
1738 pListCopy
.reset( new SdrGluePointList(*pList
) );
1741 if ( bNeedsMirrorX
)
1743 Point
aTop( ( aRect
.Left() + aRect
.Right() ) >> 1, aRect
.Top() );
1744 Point
aBottom( aTop
.X(), aTop
.Y() + 1000 );
1745 pObject
->NbcMirror( aTop
, aBottom
);
1746 // NbcMirroring is flipping the current mirror state,
1747 // so we have to set the correct state again
1748 static_cast<SdrObjCustomShape
*>(pObject
)->SetMirroredX( !bMirroredX
);
1750 if ( bNeedsMirrorY
)
1752 Point
aLeft( aRect
.Left(), ( aRect
.Top() + aRect
.Bottom() ) >> 1 );
1753 Point
aRight( aLeft
.X() + 1000, aLeft
.Y() );
1754 pObject
->NbcMirror( aLeft
, aRight
);
1755 // NbcMirroring is flipping the current mirror state,
1756 // so we have to set the correct state again
1757 static_cast<SdrObjCustomShape
*>(pObject
)->SetMirroredY( !bMirroredY
);
1762 SdrGluePointList
* pNewList
= const_cast< SdrGluePointList
* >( pObject
->GetGluePointList() );
1764 *pNewList
= *pListCopy
;
1768 bool SvxCustomShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertyMapEntry
* pProperty
, css::uno::Any
& rValue
)
1770 switch( pProperty
->nWID
)
1772 case SDRATTR_ROTATEANGLE
:
1774 double fAngle
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->GetObjectRotation();
1776 rValue
<<= static_cast<sal_Int32
>(fAngle
);
1780 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
1784 void SvxCustomShape::createCustomShapeDefaults( const OUString
& rValueType
)
1786 if (!HasSdrObject())
1788 OSL_FAIL("could not create Custom Shape Defaults!");
1792 static_cast<SdrObjCustomShape
*>(GetSdrObject())->MergeDefaultAttributes( &rValueType
);
1795 SvxShapeGroupAnyD::SvxShapeGroupAnyD( SdrObject
* pObject
, o3tl::span
<const SfxItemPropertyMapEntry
> pEntries
, const SvxItemPropertySet
* pPropertySet
)
1796 : SvxShape(pObject
, pEntries
, pPropertySet
)
1799 SvxShapeGroupAnyD::~SvxShapeGroupAnyD() noexcept
1802 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */