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/drawing/FlagSequence.hpp>
22 #include <com/sun/star/lang/DisposedException.hpp>
23 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24 #include <com/sun/star/awt/FontSlant.hpp>
25 #include <com/sun/star/style/VerticalAlignment.hpp>
26 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
27 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
28 #include <com/sun/star/awt/TextAlign.hpp>
29 #include <com/sun/star/style/ParagraphAdjust.hpp>
30 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
31 #include <com/sun/star/drawing/PointSequence.hpp>
32 #include <com/sun/star/drawing/PolygonKind.hpp>
33 #include <com/sun/star/graphic/XGraphic.hpp>
34 #include <com/sun/star/drawing/QRCode.hpp>
35 #include <o3tl/any.hxx>
36 #include <tools/urlobj.hxx>
37 #include <vcl/svapp.hxx>
38 #include <osl/file.hxx>
39 #include <vcl/fltcall.hxx>
40 #include <vcl/graphicfilter.hxx>
41 #include <vcl/wmf.hxx>
42 #include <vcl/cvtgrf.hxx>
43 #include <vcl/GraphicLoader.hxx>
45 #include <svx/svdpool.hxx>
47 #include <editeng/unoprnms.hxx>
48 #include <svx/unoshape.hxx>
49 #include <svx/unopage.hxx>
50 #include <svx/svdobj.hxx>
51 #include <svx/svdpage.hxx>
52 #include <svx/svdmodel.hxx>
53 #include <svx/svdouno.hxx>
54 #include "shapeimpl.hxx"
55 #include <svx/unoshprp.hxx>
56 #include <svx/svdoashp.hxx>
57 #include <svx/svdviter.hxx>
58 #include <svx/svdview.hxx>
59 #include <svx/svdopath.hxx>
60 #include <basegfx/matrix/b2dhommatrix.hxx>
61 #include <basegfx/polygon/b2dpolygon.hxx>
62 #include <basegfx/point/b2dpoint.hxx>
63 #include <basegfx/polygon/b2dpolygontools.hxx>
64 #include <basegfx/polygon/b2dpolypolygontools.hxx>
65 #include <com/sun/star/awt/XBitmap.hpp>
66 #include <svx/svdograf.hxx>
67 #include <sfx2/docfile.hxx>
68 #include <sfx2/app.hxx>
69 #include <sfx2/fcontnr.hxx>
70 #include <sal/log.hxx>
71 #include <cppuhelper/queryinterface.hxx>
76 using namespace ::osl
;
77 using namespace ::cppu
;
78 using namespace ::com::sun::star
;
79 using namespace ::com::sun::star::uno
;
80 using namespace ::com::sun::star::lang
;
81 using namespace ::com::sun::star::container
;
83 #define QUERYINT( xint ) \
84 if( rType == cppu::UnoType<xint>::get() ) \
85 aAny <<= Reference< xint >(this)
87 SvxShapeGroup::SvxShapeGroup(SdrObject
* pObj
, SvxDrawPage
* pDrawPage
)
88 : SvxShape(pObj
, getSvxMapProvider().GetMap(SVXMAP_GROUP
), getSvxMapProvider().GetPropertySet(SVXMAP_GROUP
, SdrObject::GetGlobalDrawObjectItemPool()))
93 SvxShapeGroup::~SvxShapeGroup() throw()
97 void SvxShapeGroup::Create( SdrObject
* pNewObj
, SvxDrawPage
* pNewPage
)
99 SvxShape::Create( pNewObj
, pNewPage
);
104 uno::Any SAL_CALL
SvxShapeGroup::queryInterface( const uno::Type
& rType
)
106 return SvxShape::queryInterface( rType
);
109 uno::Any SAL_CALL
SvxShapeGroup::queryAggregation( const uno::Type
& rType
)
113 QUERYINT( drawing::XShapeGroup
);
114 else QUERYINT( drawing::XShapes
);
115 else QUERYINT( drawing::XShapes2
);
116 else QUERYINT( container::XIndexAccess
);
117 else QUERYINT( container::XElementAccess
);
119 return SvxShape::queryAggregation( rType
);
124 void SAL_CALL
SvxShapeGroup::acquire() throw ( )
129 void SAL_CALL
SvxShapeGroup::release() throw ( )
134 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeGroup::getImplementationId()
136 return css::uno::Sequence
<sal_Int8
>();
139 // css::drawing::XShape
142 OUString SAL_CALL
SvxShapeGroup::getShapeType()
144 return SvxShape::getShapeType();
147 awt::Point SAL_CALL
SvxShapeGroup::getPosition()
149 return SvxShape::getPosition();
153 void SAL_CALL
SvxShapeGroup::setPosition( const awt::Point
& Position
)
155 SvxShape::setPosition(Position
);
159 awt::Size SAL_CALL
SvxShapeGroup::getSize()
161 return SvxShape::getSize();
165 void SAL_CALL
SvxShapeGroup::setSize( const awt::Size
& rSize
)
167 SvxShape::setSize( rSize
);
170 // drawing::XShapeGroup
173 void SAL_CALL
SvxShapeGroup::enterGroup( )
176 // pDrView->EnterMarkedGroup();
180 void SAL_CALL
SvxShapeGroup::leaveGroup( )
183 // pDrView->LeaveOneGroup();
186 void SvxShapeGroup::addUnoShape( const uno::Reference
< drawing::XShape
>& xShape
, size_t nPos
)
188 if (!HasSdrObject() || !mxPage
.is())
190 OSL_FAIL("could not add XShape to group shape!");
194 SvxShape
* pShape
= comphelper::getUnoTunnelImplementation
<SvxShape
>( xShape
);
197 OSL_FAIL("could not add XShape to group shape!");
201 SdrObject
* pSdrShape
= pShape
->GetSdrObject();
202 if( pSdrShape
== nullptr )
203 pSdrShape
= mxPage
->CreateSdrObject_( xShape
);
205 if( pSdrShape
->IsInserted() )
206 pSdrShape
->getParentSdrObjListFromSdrObject()->RemoveObject( pSdrShape
->GetOrdNum() );
208 GetSdrObject()->GetSubList()->InsertObject(pSdrShape
, nPos
);
209 // TTTT Was created using mpModel in CreateSdrObject_ above
210 // TTTT may be good to add an assertion here for the future
211 // pSdrShape->SetModel(GetSdrObject()->GetModel());
213 // #85922# It makes no sense to set the layer asked
214 // from the group object since this is an iteration
215 // over the contained objects. In consequence, this
216 // statement erases all layer information from the draw
217 // objects. Layers need to be set at draw objects directly
218 // and have nothing to do with grouping at all.
219 // pSdrShape->SetLayer(pObject->GetLayer());
221 // Establish connection between new SdrObject and its wrapper before
222 // inserting the new shape into the group. There a new wrapper
223 // would be created when this connection would not already exist.
224 pShape
->Create( pSdrShape
, mxPage
.get() );
226 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
230 void SAL_CALL
SvxShapeGroup::add( const uno::Reference
< drawing::XShape
>& xShape
)
232 ::SolarMutexGuard aGuard
;
234 // Add to the top of the stack (i.e. bottom of the list) by default.
235 addUnoShape(xShape
, SAL_MAX_SIZE
);
239 void SAL_CALL
SvxShapeGroup::remove( const uno::Reference
< drawing::XShape
>& xShape
)
241 ::SolarMutexGuard aGuard
;
243 SdrObject
* pSdrShape
= nullptr;
244 SvxShape
* pShape
= comphelper::getUnoTunnelImplementation
<SvxShape
>( xShape
);
247 pSdrShape
= pShape
->GetSdrObject();
249 if( !HasSdrObject() || pSdrShape
== nullptr || pSdrShape
->getParentSdrObjectFromSdrObject() != GetSdrObject() )
250 throw uno::RuntimeException();
252 SdrObjList
& rList
= *pSdrShape
->getParentSdrObjListFromSdrObject();
254 const size_t nObjCount
= rList
.GetObjCount();
256 while( nObjNum
< nObjCount
)
258 if(rList
.GetObj( nObjNum
) == pSdrShape
)
263 if( nObjNum
< nObjCount
)
266 // If the SdrObject which is about to be deleted is in any selection,
267 // deselect it first.
268 SdrViewIter
aIter( pSdrShape
);
270 for ( SdrView
* pView
= aIter
.FirstView(); pView
; pView
= aIter
.NextView() )
272 if(SAL_MAX_SIZE
!= pView
->TryToFindMarkedObject(pSdrShape
))
274 pView
->MarkObj(pSdrShape
, pView
->GetSdrPageView(), true);
278 SdrObject
* pObject
= rList
.NbcRemoveObject( nObjNum
);
279 SdrObject::Free( pObject
);
283 SAL_WARN( "svx", "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
286 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
289 void SAL_CALL
SvxShapeGroup::addTop( const uno::Reference
< drawing::XShape
>& xShape
)
291 SolarMutexGuard aGuard
;
293 // Add to the top of the stack (i.e. bottom of the list).
294 addUnoShape(xShape
, SAL_MAX_SIZE
);
297 void SAL_CALL
SvxShapeGroup::addBottom( const uno::Reference
< drawing::XShape
>& xShape
)
299 SolarMutexGuard aGuard
;
301 // Add to the bottom of the stack (i.e. top of the list).
302 addUnoShape(xShape
, 0);
308 sal_Int32 SAL_CALL
SvxShapeGroup::getCount()
310 ::SolarMutexGuard aGuard
;
312 if(!HasSdrObject() || !GetSdrObject()->GetSubList())
313 throw uno::RuntimeException();
315 sal_Int32 nRetval
= GetSdrObject()->GetSubList()->GetObjCount();
320 uno::Any SAL_CALL
SvxShapeGroup::getByIndex( sal_Int32 Index
)
322 ::SolarMutexGuard aGuard
;
324 if( !HasSdrObject() || GetSdrObject()->GetSubList() == nullptr )
325 throw uno::RuntimeException();
327 if( Index
<0 || GetSdrObject()->GetSubList()->GetObjCount() <= static_cast<size_t>(Index
) )
328 throw lang::IndexOutOfBoundsException();
330 SdrObject
* pDestObj
= GetSdrObject()->GetSubList()->GetObj( Index
);
332 if(pDestObj
== nullptr)
333 throw lang::IndexOutOfBoundsException();
335 Reference
< drawing::XShape
> xShape( pDestObj
->getUnoShape(), uno::UNO_QUERY
);
336 return uno::makeAny( xShape
);
339 // css::container::XElementAccess
342 uno::Type SAL_CALL
SvxShapeGroup::getElementType()
344 return cppu::UnoType
<drawing::XShape
>::get();
348 sal_Bool SAL_CALL
SvxShapeGroup::hasElements()
350 ::SolarMutexGuard aGuard
;
352 return HasSdrObject() && GetSdrObject()->GetSubList() && (GetSdrObject()->GetSubList()->GetObjCount() > 0);
355 SvxShapeConnector::SvxShapeConnector(SdrObject
* pObj
)
356 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CONNECTOR
), getSvxMapProvider().GetPropertySet(SVXMAP_CONNECTOR
, SdrObject::GetGlobalDrawObjectItemPool()) )
361 SvxShapeConnector::~SvxShapeConnector() throw()
366 uno::Any SAL_CALL
SvxShapeConnector::queryInterface( const uno::Type
& rType
)
368 return SvxShapeText::queryInterface( rType
);
371 uno::Any SAL_CALL
SvxShapeConnector::queryAggregation( const uno::Type
& rType
)
375 QUERYINT( drawing::XConnectorShape
);
377 return SvxShapeText::queryAggregation( rType
);
382 void SAL_CALL
SvxShapeConnector::acquire() throw ( )
384 SvxShapeText::acquire();
387 void SAL_CALL
SvxShapeConnector::release() throw ( )
389 SvxShapeText::release();
393 uno::Sequence
< uno::Type
> SAL_CALL
SvxShapeConnector::getTypes()
395 return SvxShape::getTypes();
398 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeConnector::getImplementationId()
400 return css::uno::Sequence
<sal_Int8
>();
403 // css::drawing::XShape
406 OUString SAL_CALL
SvxShapeConnector::getShapeType()
408 return SvxShapeText::getShapeType();
411 awt::Point SAL_CALL
SvxShapeConnector::getPosition()
413 return SvxShapeText::getPosition();
417 void SAL_CALL
SvxShapeConnector::setPosition( const awt::Point
& Position
)
419 SvxShapeText::setPosition(Position
);
423 awt::Size SAL_CALL
SvxShapeConnector::getSize()
425 return SvxShapeText::getSize();
429 void SAL_CALL
SvxShapeConnector::setSize( const awt::Size
& rSize
)
431 SvxShapeText::setSize( rSize
);
437 void SAL_CALL
SvxShapeConnector::connectStart( const uno::Reference
< drawing::XConnectableShape
>& xShape
, drawing::ConnectionType
)
439 ::SolarMutexGuard aGuard
;
441 Reference
< drawing::XShape
> xRef( xShape
, UNO_QUERY
);
442 SvxShape
* pShape
= comphelper::getUnoTunnelImplementation
<SvxShape
>( xRef
);
445 GetSdrObject()->ConnectToNode( true, pShape
->GetSdrObject() );
447 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
451 void SAL_CALL
SvxShapeConnector::connectEnd( const uno::Reference
< drawing::XConnectableShape
>& xShape
, drawing::ConnectionType
)
453 ::SolarMutexGuard aGuard
;
455 Reference
< drawing::XShape
> xRef( xShape
, UNO_QUERY
);
456 SvxShape
* pShape
= comphelper::getUnoTunnelImplementation
<SvxShape
>( xRef
);
458 if( HasSdrObject() && pShape
)
459 GetSdrObject()->ConnectToNode( false, pShape
->GetSdrObject() );
461 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
465 void SAL_CALL
SvxShapeConnector::disconnectBegin( const uno::Reference
< drawing::XConnectableShape
>& )
467 ::SolarMutexGuard aGuard
;
470 GetSdrObject()->DisconnectFromNode( true );
472 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
476 void SAL_CALL
SvxShapeConnector::disconnectEnd( const uno::Reference
< drawing::XConnectableShape
>& )
478 ::SolarMutexGuard aGuard
;
481 GetSdrObject()->DisconnectFromNode( false );
483 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
486 SvxShapeControl::SvxShapeControl(SdrObject
* pObj
)
487 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CONTROL
), getSvxMapProvider().GetPropertySet(SVXMAP_CONTROL
, SdrObject::GetGlobalDrawObjectItemPool()) )
489 setShapeKind( OBJ_UNO
);
493 SvxShapeControl::~SvxShapeControl() throw()
498 uno::Any SAL_CALL
SvxShapeControl::queryInterface( const uno::Type
& rType
)
500 return SvxShapeText::queryInterface( rType
);
503 uno::Any SAL_CALL
SvxShapeControl::queryAggregation( const uno::Type
& rType
)
507 QUERYINT( drawing::XControlShape
);
509 return SvxShapeText::queryAggregation( rType
);
514 void SAL_CALL
SvxShapeControl::acquire() throw ( )
516 SvxShapeText::acquire();
519 void SAL_CALL
SvxShapeControl::release() throw ( )
521 SvxShapeText::release();
525 uno::Sequence
< uno::Type
> SAL_CALL
SvxShapeControl::getTypes()
527 return SvxShape::getTypes();
530 uno::Sequence
< sal_Int8
> SAL_CALL
SvxShapeControl::getImplementationId()
532 return css::uno::Sequence
<sal_Int8
>();
535 // css::drawing::XShape
538 OUString SAL_CALL
SvxShapeControl::getShapeType()
540 return SvxShapeText::getShapeType();
543 awt::Point SAL_CALL
SvxShapeControl::getPosition()
545 return SvxShapeText::getPosition();
549 void SAL_CALL
SvxShapeControl::setPosition( const awt::Point
& Position
)
551 SvxShapeText::setPosition(Position
);
555 awt::Size SAL_CALL
SvxShapeControl::getSize()
557 return SvxShapeText::getSize();
561 void SAL_CALL
SvxShapeControl::setSize( const awt::Size
& rSize
)
563 SvxShapeText::setSize( rSize
);
569 Reference
< awt::XControlModel
> SAL_CALL
SvxShapeControl::getControl()
571 ::SolarMutexGuard aGuard
;
573 Reference
< awt::XControlModel
> xModel
;
575 SdrUnoObj
* pUnoObj
= dynamic_cast< SdrUnoObj
* >(GetSdrObject());
577 xModel
= pUnoObj
->GetUnoControlModel();
583 void SAL_CALL
SvxShapeControl::setControl( const Reference
< awt::XControlModel
>& xControl
)
585 ::SolarMutexGuard aGuard
;
587 SdrUnoObj
* pUnoObj
= dynamic_cast< SdrUnoObj
* >(GetSdrObject());
589 pUnoObj
->SetUnoControlModel( xControl
);
591 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
596 const sal_Char
* mpAPIName
;
597 sal_uInt16
const mnAPINameLen
;
599 const sal_Char
* mpFormName
;
600 sal_uInt16
const mnFormNameLen
;
602 const SvxShapeControlPropertyMapping
[] =
604 // Warning: The first entry must be FontSlant because the any needs to be converted
605 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_POSTURE
), RTL_CONSTASCII_STRINGPARAM("FontSlant") }, // const sal_Int16 => css::awt::FontSlant
606 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_FONTNAME
), RTL_CONSTASCII_STRINGPARAM("FontName") },
607 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_FONTSTYLENAME
), RTL_CONSTASCII_STRINGPARAM("FontStyleName") },
608 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_FONTFAMILY
), RTL_CONSTASCII_STRINGPARAM("FontFamily") },
609 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_FONTCHARSET
), RTL_CONSTASCII_STRINGPARAM("FontCharset") },
610 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_HEIGHT
), RTL_CONSTASCII_STRINGPARAM("FontHeight") },
611 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_FONTPITCH
), RTL_CONSTASCII_STRINGPARAM("FontPitch" ) },
612 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_WEIGHT
), RTL_CONSTASCII_STRINGPARAM("FontWeight" ) },
613 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_UNDERLINE
), RTL_CONSTASCII_STRINGPARAM("FontUnderline") },
614 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_STRIKEOUT
), RTL_CONSTASCII_STRINGPARAM("FontStrikeout") },
615 { RTL_CONSTASCII_STRINGPARAM("CharKerning"), RTL_CONSTASCII_STRINGPARAM("FontKerning") },
616 { RTL_CONSTASCII_STRINGPARAM("CharWordMode"), RTL_CONSTASCII_STRINGPARAM("FontWordLineMode" ) },
617 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_CHAR_COLOR
), RTL_CONSTASCII_STRINGPARAM("TextColor") },
618 { RTL_CONSTASCII_STRINGPARAM("CharBackColor"), RTL_CONSTASCII_STRINGPARAM("CharBackColor") },
619 { RTL_CONSTASCII_STRINGPARAM("CharBackTransparent"), RTL_CONSTASCII_STRINGPARAM("CharBackTransparent") },
620 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_TEXT_CHAINNEXTNAME
), RTL_CONSTASCII_STRINGPARAM(UNO_NAME_TEXT_CHAINNEXTNAME
) },
621 { RTL_CONSTASCII_STRINGPARAM("CharRelief"), RTL_CONSTASCII_STRINGPARAM("FontRelief") },
622 { RTL_CONSTASCII_STRINGPARAM("CharUnderlineColor"), RTL_CONSTASCII_STRINGPARAM("TextLineColor") },
623 { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_PARA_ADJUST
), RTL_CONSTASCII_STRINGPARAM("Align") },
624 { RTL_CONSTASCII_STRINGPARAM("TextVerticalAdjust"), RTL_CONSTASCII_STRINGPARAM("VerticalAlign") },
625 { RTL_CONSTASCII_STRINGPARAM("ControlBackground"), RTL_CONSTASCII_STRINGPARAM("BackgroundColor") },
626 { RTL_CONSTASCII_STRINGPARAM("ControlSymbolColor"), RTL_CONSTASCII_STRINGPARAM("SymbolColor") },
627 { RTL_CONSTASCII_STRINGPARAM("ControlBorder"), RTL_CONSTASCII_STRINGPARAM("Border") },
628 { RTL_CONSTASCII_STRINGPARAM("ControlBorderColor"), RTL_CONSTASCII_STRINGPARAM("BorderColor") },
629 { RTL_CONSTASCII_STRINGPARAM("ControlTextEmphasis"), RTL_CONSTASCII_STRINGPARAM("FontEmphasisMark") },
630 { RTL_CONSTASCII_STRINGPARAM("ImageScaleMode"), RTL_CONSTASCII_STRINGPARAM("ScaleMode") },
631 { RTL_CONSTASCII_STRINGPARAM("ControlWritingMode"), RTL_CONSTASCII_STRINGPARAM("WritingMode") },
632 //added for exporting OCX control
633 { RTL_CONSTASCII_STRINGPARAM("ControlTypeinMSO"), RTL_CONSTASCII_STRINGPARAM("ControlTypeinMSO") },
634 { RTL_CONSTASCII_STRINGPARAM("ObjIDinMSO"), RTL_CONSTASCII_STRINGPARAM("ObjIDinMSO") },
635 { RTL_CONSTASCII_STRINGPARAM("CharCaseMap"), RTL_CONSTASCII_STRINGPARAM("CharCaseMap") },
636 { nullptr,0, nullptr, 0 }
641 bool lcl_convertPropertyName( const OUString
& rApiName
, OUString
& rInternalName
)
644 while( SvxShapeControlPropertyMapping
[i
].mpAPIName
)
646 if( rApiName
.reverseCompareToAsciiL( SvxShapeControlPropertyMapping
[i
].mpAPIName
, SvxShapeControlPropertyMapping
[i
].mnAPINameLen
) == 0 )
648 rInternalName
= OUString( SvxShapeControlPropertyMapping
[i
].mpFormName
, SvxShapeControlPropertyMapping
[i
].mnFormNameLen
, RTL_TEXTENCODING_ASCII_US
);
652 return !rInternalName
.isEmpty();
655 struct EnumConversionMap
657 style::ParagraphAdjust
const nAPIValue
;
658 sal_Int16
const nFormValue
;
661 EnumConversionMap
const aMapAdjustToAlign
[] =
663 // note that order matters:
664 // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
665 // and use the first matching entry
666 {style::ParagraphAdjust_LEFT
, sal_Int16(awt::TextAlign::LEFT
)},
667 {style::ParagraphAdjust_CENTER
, sal_Int16(awt::TextAlign::CENTER
)},
668 {style::ParagraphAdjust_RIGHT
, sal_Int16(awt::TextAlign::RIGHT
)},
669 {style::ParagraphAdjust_BLOCK
, sal_Int16(awt::TextAlign::RIGHT
)},
670 {style::ParagraphAdjust_STRETCH
, sal_Int16(awt::TextAlign::LEFT
)},
671 {style::ParagraphAdjust(-1),-1}
674 void lcl_convertTextAlignmentToParaAdjustment( Any
& _rValue
)
676 sal_Int16 nValue
= sal_Int16();
677 OSL_VERIFY( _rValue
>>= nValue
);
679 for ( auto const & rEntry
: aMapAdjustToAlign
)
680 if ( nValue
== rEntry
.nFormValue
)
682 _rValue
<<= static_cast<sal_uInt16
>(rEntry
.nAPIValue
);
687 void lcl_convertParaAdjustmentToTextAlignment( Any
& _rValue
)
689 sal_Int32 nValue
= 0;
690 OSL_VERIFY( _rValue
>>= nValue
);
692 for ( auto const & rEntry
: aMapAdjustToAlign
)
693 if ( static_cast<style::ParagraphAdjust
>(nValue
) == rEntry
.nAPIValue
)
695 _rValue
<<= rEntry
.nFormValue
;
700 void convertVerticalAdjustToVerticalAlign( Any
& _rValue
)
702 if ( !_rValue
.hasValue() )
705 drawing::TextVerticalAdjust eAdjust
= drawing::TextVerticalAdjust_TOP
;
706 style::VerticalAlignment eAlign
= style::VerticalAlignment_TOP
;
707 if ( !( _rValue
>>= eAdjust
) )
708 throw lang::IllegalArgumentException();
711 case drawing::TextVerticalAdjust_TOP
: eAlign
= style::VerticalAlignment_TOP
; break;
712 case drawing::TextVerticalAdjust_BOTTOM
: eAlign
= style::VerticalAlignment_BOTTOM
; break;
713 default: eAlign
= style::VerticalAlignment_MIDDLE
; break;
718 void convertVerticalAlignToVerticalAdjust( Any
& _rValue
)
720 if ( !_rValue
.hasValue() )
722 style::VerticalAlignment eAlign
= style::VerticalAlignment_TOP
;
723 drawing::TextVerticalAdjust eAdjust
= drawing::TextVerticalAdjust_TOP
;
724 OSL_VERIFY( _rValue
>>= eAlign
);
727 case style::VerticalAlignment_TOP
: eAdjust
= drawing::TextVerticalAdjust_TOP
; break;
728 case style::VerticalAlignment_BOTTOM
: eAdjust
= drawing::TextVerticalAdjust_BOTTOM
; break;
729 default: eAdjust
= drawing::TextVerticalAdjust_CENTER
; break;
735 void SAL_CALL
SvxShapeControl::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
738 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
740 uno::Reference
< beans::XPropertySet
> xControl( getControl(), uno::UNO_QUERY
);
743 uno::Reference
< beans::XPropertySetInfo
> xInfo( xControl
->getPropertySetInfo() );
744 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
746 uno::Any
aConvertedValue( aValue
);
747 if ( aFormsName
== "FontSlant" )
749 awt::FontSlant nSlant
;
750 if( !(aValue
>>= nSlant
) )
751 throw lang::IllegalArgumentException();
752 aConvertedValue
<<= static_cast<sal_Int16
>(nSlant
);
754 else if ( aFormsName
== "Align" )
756 lcl_convertParaAdjustmentToTextAlignment( aConvertedValue
);
758 else if ( aFormsName
== "VerticalAlign" )
760 convertVerticalAdjustToVerticalAlign( aConvertedValue
);
763 xControl
->setPropertyValue( aFormsName
, aConvertedValue
);
769 SvxShape::setPropertyValue( aPropertyName
, aValue
);
773 uno::Any SAL_CALL
SvxShapeControl::getPropertyValue( const OUString
& aPropertyName
)
776 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
778 uno::Reference
< beans::XPropertySet
> xControl( getControl(), uno::UNO_QUERY
);
783 uno::Reference
< beans::XPropertySetInfo
> xInfo( xControl
->getPropertySetInfo() );
784 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
786 aValue
= xControl
->getPropertyValue( aFormsName
);
787 if ( aFormsName
== "FontSlant" )
789 awt::FontSlant eSlant
= awt::FontSlant_NONE
;
790 sal_Int16 nSlant
= sal_Int16();
791 if ( aValue
>>= nSlant
)
793 eSlant
= static_cast<awt::FontSlant
>(nSlant
);
797 OSL_VERIFY( aValue
>>= eSlant
);
801 else if ( aFormsName
== "Align" )
803 lcl_convertTextAlignmentToParaAdjustment( aValue
);
805 else if ( aFormsName
== "VerticalAlign" )
807 convertVerticalAlignToVerticalAdjust( aValue
);
816 return SvxShape::getPropertyValue( aPropertyName
);
822 beans::PropertyState SAL_CALL
SvxShapeControl::getPropertyState( const OUString
& PropertyName
)
825 if ( lcl_convertPropertyName( PropertyName
, aFormsName
) )
827 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
828 uno::Reference
< beans::XPropertySet
> xPropSet( getControl(), uno::UNO_QUERY
);
830 if( xControl
.is() && xPropSet
.is() )
832 uno::Reference
< beans::XPropertySetInfo
> xInfo( xPropSet
->getPropertySetInfo() );
833 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
835 return xControl
->getPropertyState( aFormsName
);
839 return beans::PropertyState_DEFAULT_VALUE
;
843 return SvxShape::getPropertyState( PropertyName
);
847 void SAL_CALL
SvxShapeControl::setPropertyToDefault( const OUString
& PropertyName
)
850 if ( lcl_convertPropertyName( PropertyName
, aFormsName
) )
852 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
853 uno::Reference
< beans::XPropertySet
> xPropSet( getControl(), uno::UNO_QUERY
);
855 if( xControl
.is() && xPropSet
.is() )
857 uno::Reference
< beans::XPropertySetInfo
> xInfo( xPropSet
->getPropertySetInfo() );
858 if( xInfo
.is() && xInfo
->hasPropertyByName( aFormsName
) )
860 xControl
->setPropertyToDefault( aFormsName
);
866 SvxShape::setPropertyToDefault( PropertyName
);
870 uno::Any SAL_CALL
SvxShapeControl::getPropertyDefault( const OUString
& aPropertyName
)
873 if ( lcl_convertPropertyName( aPropertyName
, aFormsName
) )
875 uno::Reference
< beans::XPropertyState
> xControl( getControl(), uno::UNO_QUERY
);
879 Any
aDefault( xControl
->getPropertyDefault( aFormsName
) );
880 if ( aFormsName
== "FontSlant" )
882 sal_Int16
nSlant( 0 );
884 aDefault
<<= static_cast<awt::FontSlant
>(nSlant
);
886 else if ( aFormsName
== "Align" )
888 lcl_convertTextAlignmentToParaAdjustment( aDefault
);
890 else if ( aFormsName
== "VerticalAlign" )
892 convertVerticalAlignToVerticalAdjust( aDefault
);
897 throw beans::UnknownPropertyException( aPropertyName
, static_cast<cppu::OWeakObject
*>(this));
901 return SvxShape::getPropertyDefault( aPropertyName
);
905 SvxShapeDimensioning::SvxShapeDimensioning(SdrObject
* pObj
)
906 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_DIMENSIONING
), getSvxMapProvider().GetPropertySet(SVXMAP_DIMENSIONING
, SdrObject::GetGlobalDrawObjectItemPool()) )
910 SvxShapeDimensioning::~SvxShapeDimensioning() throw()
914 SvxShapeCircle::SvxShapeCircle(SdrObject
* pObj
)
915 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CIRCLE
), getSvxMapProvider().GetPropertySet(SVXMAP_CIRCLE
, SdrObject::GetGlobalDrawObjectItemPool()) )
919 SvxShapeCircle::~SvxShapeCircle() throw()
923 //////////////////////////////////////////////////////////////////////////////
925 SvxShapePolyPolygon::SvxShapePolyPolygon(
929 getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGON
),
930 getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGON
, SdrObject::GetGlobalDrawObjectItemPool()))
934 SvxShapePolyPolygon::~SvxShapePolyPolygon() throw()
938 bool SvxShapePolyPolygon::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
940 switch( pProperty
->nWID
)
942 case OWN_ATTR_VALUE_POLYPOLYGONBEZIER
:
944 if( auto s
= o3tl::tryAccess
<drawing::PolyPolygonBezierCoords
>(rValue
) )
946 basegfx::B2DPolyPolygon
aNewPolyPolygon(
947 basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(*s
));
949 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
950 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
952 SetPolygon(aNewPolyPolygon
);
957 case OWN_ATTR_VALUE_POLYPOLYGON
:
959 if( auto s
= o3tl::tryAccess
<drawing::PointSequenceSequence
>(rValue
) )
961 basegfx::B2DPolyPolygon
aNewPolyPolygon(
962 basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(*s
));
964 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
965 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
967 SetPolygon(aNewPolyPolygon
);
972 case OWN_ATTR_BASE_GEOMETRY
:
974 drawing::PointSequenceSequence aPointSequenceSequence
;
975 drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords
;
977 if( rValue
>>= aPointSequenceSequence
)
981 basegfx::B2DPolyPolygon aNewPolyPolygon
;
982 basegfx::B2DHomMatrix aNewHomogenMatrix
;
984 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
985 aNewPolyPolygon
= basegfx::utils::UnoPointSequenceSequenceToB2DPolyPolygon(aPointSequenceSequence
);
987 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
988 // Need to adapt aNewPolyPolygon from 100thmm to app-specific
989 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
991 GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
995 else if( rValue
>>= aPolyPolygonBezierCoords
)
999 basegfx::B2DPolyPolygon aNewPolyPolygon
;
1000 basegfx::B2DHomMatrix aNewHomogenMatrix
;
1002 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
1003 aNewPolyPolygon
= basegfx::utils::UnoPolyPolygonBezierCoordsToB2DPolyPolygon(aPolyPolygonBezierCoords
);
1005 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1006 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
1008 GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix
, aNewPolyPolygon
);
1014 case OWN_ATTR_VALUE_POLYGON
:
1016 if( auto pSequence
= o3tl::tryAccess
<drawing::PointSequence
>(rValue
) )
1018 // prepare new polygon
1019 basegfx::B2DPolygon aNewPolygon
;
1021 // get pointer to arrays
1022 const awt::Point
* pArray
= pSequence
->getConstArray();
1023 const awt::Point
* pArrayEnd
= pArray
+ pSequence
->getLength();
1025 for(;pArray
!= pArrayEnd
;++pArray
)
1027 aNewPolygon
.append(basegfx::B2DPoint(pArray
->X
, pArray
->Y
));
1030 // check for closed state flag
1031 basegfx::utils::checkClosed(aNewPolygon
);
1033 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1034 basegfx::B2DPolyPolygon
aNewPolyPolygon(aNewPolygon
);
1035 ForceMetricToItemPoolMetric(aNewPolyPolygon
);
1038 SetPolygon(aNewPolyPolygon
);
1044 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
1047 throw lang::IllegalArgumentException();
1050 bool SvxShapePolyPolygon::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
,
1051 css::uno::Any
& rValue
)
1053 switch( pProperty
->nWID
)
1055 case OWN_ATTR_VALUE_POLYPOLYGONBEZIER
:
1057 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1058 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1060 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1061 ForceMetricTo100th_mm(aPolyPoly
);
1063 drawing::PolyPolygonBezierCoords aRetval
;
1064 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords(aPolyPoly
, aRetval
);
1069 case OWN_ATTR_VALUE_POLYPOLYGON
:
1071 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1072 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1074 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1075 ForceMetricTo100th_mm(aPolyPoly
);
1077 drawing::PointSequenceSequence
aRetval( aPolyPoly
.count() );
1078 basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPoly
, aRetval
);
1083 case OWN_ATTR_BASE_GEOMETRY
:
1085 // pack a tools::PolyPolygon in struct PolyPolygon
1086 basegfx::B2DPolyPolygon aPolyPoly
;
1087 basegfx::B2DHomMatrix aNewHomogenMatrix
;
1091 GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix
, aPolyPoly
);
1093 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1094 ForceMetricTo100th_mm(aPolyPoly
);
1097 if(aPolyPoly
.areControlPointsUsed())
1099 drawing::PolyPolygonBezierCoords aRetval
;
1100 basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords(aPolyPoly
, aRetval
);
1105 drawing::PointSequenceSequence
aRetval(aPolyPoly
.count());
1106 basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPoly
, aRetval
);
1111 case OWN_ATTR_VALUE_POLYGON
:
1113 // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1114 basegfx::B2DPolyPolygon
aPolyPoly(GetPolygon());
1116 // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm
1117 ForceMetricTo100th_mm(aPolyPoly
);
1119 const sal_Int32
nCount(0 == aPolyPoly
.count() ? 0 : aPolyPoly
.getB2DPolygon(0).count());
1120 drawing::PointSequence
aRetval( nCount
);
1124 // get single polygon
1125 const basegfx::B2DPolygon
& aPoly(aPolyPoly
.getB2DPolygon(0));
1127 // get pointer to arrays
1128 awt::Point
* pSequence
= aRetval
.getArray();
1130 for(sal_Int32 b
=0;b
<nCount
;b
++)
1132 const basegfx::B2DPoint
aPoint(aPoly
.getB2DPoint(b
));
1133 *pSequence
++ = awt::Point( basegfx::fround(aPoint
.getX()), basegfx::fround(aPoint
.getY()) );
1140 case OWN_ATTR_VALUE_POLYGONKIND
:
1142 rValue
<<= GetPolygonKind();
1146 return SvxShapeText::getPropertyValueImpl( rName
, pProperty
, rValue
);
1152 drawing::PolygonKind
SvxShapePolyPolygon::GetPolygonKind() const
1154 ::SolarMutexGuard aGuard
;
1155 drawing::PolygonKind
aRetval(drawing::PolygonKind_LINE
);
1159 switch(GetSdrObject()->GetObjIdentifier())
1161 case OBJ_POLY
: aRetval
= drawing::PolygonKind_POLY
; break;
1162 case OBJ_PLIN
: aRetval
= drawing::PolygonKind_PLIN
; break;
1164 case OBJ_PATHLINE
: aRetval
= drawing::PolygonKind_PATHLINE
; break;
1166 case OBJ_PATHFILL
: aRetval
= drawing::PolygonKind_PATHFILL
; break;
1167 case OBJ_FREELINE
: aRetval
= drawing::PolygonKind_FREELINE
; break;
1168 case OBJ_FREEFILL
: aRetval
= drawing::PolygonKind_FREEFILL
; break;
1175 void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon
& rNew
)
1177 ::SolarMutexGuard aGuard
;
1180 static_cast<SdrPathObj
*>(GetSdrObject())->SetPathPoly(rNew
);
1184 basegfx::B2DPolyPolygon
SvxShapePolyPolygon::GetPolygon() const throw()
1186 ::SolarMutexGuard aGuard
;
1190 return static_cast<SdrPathObj
*>(GetSdrObject())->GetPathPoly();
1194 return basegfx::B2DPolyPolygon();
1198 //////////////////////////////////////////////////////////////////////////////
1200 SvxGraphicObject::SvxGraphicObject(SdrObject
* pObj
)
1201 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_GRAPHICOBJECT
), getSvxMapProvider().GetPropertySet(SVXMAP_GRAPHICOBJECT
, SdrObject::GetGlobalDrawObjectItemPool()) )
1205 SvxGraphicObject::~SvxGraphicObject() throw()
1209 bool SvxGraphicObject::setPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, const css::uno::Any
& rValue
)
1212 switch( pProperty
->nWID
)
1214 case OWN_ATTR_VALUE_FILLBITMAP
:
1216 if( auto pSeq
= o3tl::tryAccess
<uno::Sequence
<sal_Int8
>>(rValue
) )
1218 SvMemoryStream aMemStm
;
1221 aMemStm
.SetBuffer( const_cast<css::uno::Sequence
<sal_Int8
> *>(pSeq
)->getArray(), pSeq
->getLength(), pSeq
->getLength() );
1223 if( GraphicConverter::Import( aMemStm
, aGraphic
) == ERRCODE_NONE
)
1225 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1229 else if (rValue
.getValueType() == cppu::UnoType
<graphic::XGraphic
>::get())
1231 auto xGraphic
= rValue
.get
<uno::Reference
<graphic::XGraphic
>>();
1234 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(Graphic(xGraphic
));
1238 else if (rValue
.getValueType() == cppu::UnoType
<awt::XBitmap
>::get())
1240 auto xBitmap
= rValue
.get
<uno::Reference
<awt::XBitmap
>>();
1243 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
1244 Graphic
aGraphic(xGraphic
);
1245 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1252 case OWN_ATTR_GRAFSTREAMURL
:
1254 OUString aStreamURL
;
1256 if( rValue
>>= aStreamURL
)
1258 if( !aStreamURL
.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX
) )
1261 if( HasSdrObject() )
1263 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGrafStreamURL( aStreamURL
);
1270 case OWN_ATTR_GRAPHIC_URL
:
1273 uno::Reference
<awt::XBitmap
> xBitmap
;
1274 if (rValue
>>= aURL
)
1276 Graphic aGraphic
= vcl::graphic::loadFromURL(aURL
);
1277 if (!aGraphic
.IsNone())
1279 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1283 else if (rValue
>>= xBitmap
)
1285 uno::Reference
<graphic::XGraphic
> xGraphic(xBitmap
, uno::UNO_QUERY
);
1288 Graphic aGraphic
= xGraphic
;
1289 if (!aGraphic
.IsNone())
1291 static_cast<SdrGrafObj
*>(GetSdrObject())->SetGraphic(aGraphic
);
1299 case OWN_ATTR_VALUE_GRAPHIC
:
1301 Reference
< graphic::XGraphic
> xGraphic( rValue
, uno::UNO_QUERY
);
1304 static_cast< SdrGrafObj
*>( GetSdrObject() )->SetGraphic( xGraphic
);
1310 case OWN_ATTR_IS_SIGNATURELINE
:
1312 bool bIsSignatureLine
;
1313 if (rValue
>>= bIsSignatureLine
)
1315 static_cast<SdrGrafObj
*>(GetSdrObject())->setIsSignatureLine(bIsSignatureLine
);
1321 case OWN_ATTR_SIGNATURELINE_ID
:
1323 OUString aSignatureLineId
;
1324 if (rValue
>>= aSignatureLineId
)
1326 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineId(aSignatureLineId
);
1332 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME
:
1334 OUString aSuggestedSignerName
;
1335 if (rValue
>>= aSuggestedSignerName
)
1337 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerName(aSuggestedSignerName
);
1343 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_TITLE
:
1345 OUString aSuggestedSignerTitle
;
1346 if (rValue
>>= aSuggestedSignerTitle
)
1348 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerTitle(aSuggestedSignerTitle
);
1354 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_EMAIL
:
1356 OUString aSuggestedSignerEmail
;
1357 if (rValue
>>= aSuggestedSignerEmail
)
1359 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSuggestedSignerEmail(aSuggestedSignerEmail
);
1365 case OWN_ATTR_SIGNATURELINE_SIGNING_INSTRUCTIONS
:
1367 OUString aSigningInstructions
;
1368 if (rValue
>>= aSigningInstructions
)
1370 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineSigningInstructions(aSigningInstructions
);
1376 case OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE
:
1379 if (rValue
>>= bShowSignDate
)
1381 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineShowSignDate(bShowSignDate
);
1387 case OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT
:
1389 bool bCanAddComment
;
1390 if (rValue
>>= bCanAddComment
)
1392 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineCanAddComment(bCanAddComment
);
1398 case OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE
:
1400 Reference
<graphic::XGraphic
> xGraphic(rValue
, uno::UNO_QUERY
);
1403 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineUnsignedGraphic(xGraphic
);
1409 case OWN_ATTR_SIGNATURELINE_IS_SIGNED
:
1412 if (rValue
>>= bIsSigned
)
1414 static_cast<SdrGrafObj
*>(GetSdrObject())->setSignatureLineIsSigned(bIsSigned
);
1420 case OWN_ATTR_QRCODE
:
1422 css::drawing::QRCode aQrCode
;
1423 if (rValue
>>= aQrCode
)
1425 static_cast<SdrGrafObj
*>(GetSdrObject())->setQrCode(aQrCode
);
1432 return SvxShapeText::setPropertyValueImpl( rName
, pProperty
, rValue
);
1436 throw lang::IllegalArgumentException();
1438 GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
1443 bool SvxGraphicObject::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, css::uno::Any
& rValue
)
1445 switch( pProperty
->nWID
)
1447 case OWN_ATTR_VALUE_FILLBITMAP
:
1449 const Graphic
& rGraphic
= static_cast<SdrGrafObj
*>(GetSdrObject())->GetGraphic();
1451 if (rGraphic
.GetType() != GraphicType::GdiMetafile
)
1453 uno::Reference
<awt::XBitmap
> xBitmap(rGraphic
.GetXGraphic(), uno::UNO_QUERY
);
1458 SvMemoryStream
aDestStrm( 65535, 65535 );
1460 ConvertGDIMetaFileToWMF( rGraphic
.GetGDIMetaFile(), aDestStrm
, nullptr, false );
1461 const uno::Sequence
<sal_Int8
> aSeq(
1462 static_cast< const sal_Int8
* >(aDestStrm
.GetData()),
1463 aDestStrm
.GetEndOfData());
1469 case OWN_ATTR_REPLACEMENT_GRAPHIC
:
1471 const GraphicObject
* pGrafObj
= static_cast< SdrGrafObj
* >(GetSdrObject())->GetReplacementGraphicObject();
1475 rValue
<<= pGrafObj
->GetGraphic().GetXGraphic();
1481 case OWN_ATTR_GRAFSTREAMURL
:
1483 const OUString
aStreamURL( static_cast<SdrGrafObj
*>( GetSdrObject() )->GetGrafStreamURL() );
1484 if( !aStreamURL
.isEmpty() )
1485 rValue
<<= aStreamURL
;
1489 case OWN_ATTR_GRAPHIC_URL
:
1490 case OWN_ATTR_VALUE_GRAPHIC
:
1492 if (pProperty
->nWID
== OWN_ATTR_GRAPHIC_URL
)
1494 SAL_WARN("svx", "Getting Graphic by URL is not supported, getting it by value");
1497 Reference
<graphic::XGraphic
> xGraphic
;
1498 auto pSdrGraphicObject
= static_cast<SdrGrafObj
*>(GetSdrObject());
1499 if (pSdrGraphicObject
->GetGraphicObject().GetType() != GraphicType::NONE
)
1500 xGraphic
= pSdrGraphicObject
->GetGraphic().GetXGraphic();
1501 rValue
<<= xGraphic
;
1505 case OWN_ATTR_GRAPHIC_STREAM
:
1507 rValue
<<= static_cast< SdrGrafObj
* >( GetSdrObject() )->getInputStream();
1511 case OWN_ATTR_IS_SIGNATURELINE
:
1513 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLine();
1517 case OWN_ATTR_SIGNATURELINE_ID
:
1519 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineId();
1523 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME
:
1525 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerName();
1529 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_TITLE
:
1531 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerTitle();
1535 case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_EMAIL
:
1537 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSuggestedSignerEmail();
1541 case OWN_ATTR_SIGNATURELINE_SIGNING_INSTRUCTIONS
:
1543 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineSigningInstructions();
1547 case OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE
:
1549 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineShowSignDate();
1553 case OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT
:
1555 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineCanAddComment();
1559 case OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE
:
1561 Reference
<graphic::XGraphic
> xGraphic(
1562 static_cast<SdrGrafObj
*>(GetSdrObject())->getSignatureLineUnsignedGraphic());
1563 rValue
<<= xGraphic
;
1567 case OWN_ATTR_SIGNATURELINE_IS_SIGNED
:
1569 rValue
<<= static_cast<SdrGrafObj
*>(GetSdrObject())->isSignatureLineSigned();
1573 case OWN_ATTR_QRCODE
:
1575 css::drawing::QRCode
* ptr
= static_cast<SdrGrafObj
*>(GetSdrObject())->getQrCode();
1584 return SvxShapeText::getPropertyValueImpl(rName
, pProperty
,rValue
);
1591 SvxShapeCaption::SvxShapeCaption(SdrObject
* pObj
)
1592 : SvxShapeText( pObj
, getSvxMapProvider().GetMap(SVXMAP_CAPTION
), getSvxMapProvider().GetPropertySet(SVXMAP_CAPTION
, SdrObject::GetGlobalDrawObjectItemPool()) )
1596 SvxShapeCaption::~SvxShapeCaption() throw()
1600 SvxCustomShape::SvxCustomShape(SdrObject
* pObj
)
1601 : SvxShapeText( pObj
, getSvxMapProvider().GetMap( SVXMAP_CUSTOMSHAPE
), getSvxMapProvider().GetPropertySet(SVXMAP_CUSTOMSHAPE
, SdrObject::GetGlobalDrawObjectItemPool()) )
1605 SvxCustomShape::~SvxCustomShape() throw()
1609 uno::Any SAL_CALL
SvxCustomShape::queryInterface( const uno::Type
& rType
)
1611 return SvxShapeText::queryInterface( rType
);
1614 uno::Any SAL_CALL
SvxCustomShape::queryAggregation( const uno::Type
& rType
)
1616 css::uno::Any aReturn
= SvxShapeText::queryAggregation( rType
);
1617 if ( !aReturn
.hasValue() )
1618 aReturn
= ::cppu::queryInterface(rType
, static_cast<drawing::XEnhancedCustomShapeDefaulter
*>(this) );
1622 void SAL_CALL
SvxCustomShape::acquire() throw ( )
1624 SvxShapeText::acquire();
1627 void SAL_CALL
SvxCustomShape::release() throw ( )
1629 SvxShapeText::release();
1633 uno::Sequence
< uno::Type
> SAL_CALL
SvxCustomShape::getTypes()
1635 return SvxShapeText::getTypes();
1638 uno::Sequence
< sal_Int8
> SAL_CALL
SvxCustomShape::getImplementationId()
1640 return css::uno::Sequence
<sal_Int8
>();
1643 // css::drawing::XShape
1646 awt::Point SAL_CALL
SvxCustomShape::getPosition()
1648 ::SolarMutexGuard aGuard
;
1649 if ( HasSdrObject() )
1651 SdrAShapeObjGeoData aCustomShapeGeoData
;
1652 static_cast<SdrObjCustomShape
*>(GetSdrObject())->SaveGeoData( aCustomShapeGeoData
);
1654 bool bMirroredX
= false;
1655 bool bMirroredY
= false;
1657 if ( HasSdrObject() )
1659 bMirroredX
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->IsMirroredX();
1660 bMirroredY
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->IsMirroredY();
1662 // get aRect, this is the unrotated snaprect
1663 tools::Rectangle
aRect(static_cast<SdrObjCustomShape
*>(GetSdrObject())->GetLogicRect());
1664 tools::Rectangle
aRectangle( aRect
);
1666 if ( bMirroredX
|| bMirroredY
)
1667 { // we have to retrieve the unmirrored rect
1669 GeoStat
aNewGeo( aCustomShapeGeoData
.aGeo
);
1672 tools::Polygon
aPol( Rect2Poly( aRect
, aNewGeo
) );
1673 tools::Rectangle
aBoundRect( aPol
.GetBoundRect() );
1675 Point
aRef1( ( aBoundRect
.Left() + aBoundRect
.Right() ) >> 1, aBoundRect
.Top() );
1676 Point
aRef2( aRef1
.X(), aRef1
.Y() + 1000 );
1678 sal_uInt16 nPointCount
=aPol
.GetSize();
1679 for (i
=0; i
<nPointCount
; i
++)
1681 MirrorPoint(aPol
[i
],aRef1
,aRef2
);
1683 // turn and move polygon
1684 tools::Polygon
aPol0(aPol
);
1690 Poly2Rect(aPol
,aRectangle
,aNewGeo
);
1694 tools::Polygon
aPol( Rect2Poly( aRectangle
, aNewGeo
) );
1695 tools::Rectangle
aBoundRect( aPol
.GetBoundRect() );
1697 Point
aRef1( aBoundRect
.Left(), ( aBoundRect
.Top() + aBoundRect
.Bottom() ) >> 1 );
1698 Point
aRef2( aRef1
.X() + 1000, aRef1
.Y() );
1700 sal_uInt16 nPointCount
=aPol
.GetSize();
1701 for (i
=0; i
<nPointCount
; i
++)
1703 MirrorPoint(aPol
[i
],aRef1
,aRef2
);
1705 // turn and move polygon
1706 tools::Polygon
aPol0(aPol
);
1712 Poly2Rect( aPol
, aRectangle
, aNewGeo
);
1715 Point
aPt( aRectangle
.TopLeft() );
1717 if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
1718 aPt
-= GetSdrObject()->GetAnchorPos();
1720 ForceMetricTo100th_mm(aPt
);
1721 return css::awt::Point( aPt
.X(), aPt
.Y() );
1724 return SvxShape::getPosition();
1728 void SAL_CALL
SvxCustomShape::setPropertyValue( const OUString
& aPropertyName
, const uno::Any
& aValue
)
1730 ::SolarMutexGuard aGuard
;
1732 SdrObject
* pObject
= GetSdrObject();
1734 // tdf#98163 Use a custom slot to have filter code flush the UNO
1735 // API implementations of SdrObjCustomShape. Used e.g. by
1736 // ~SdXMLCustomShapeContext, see there for more information
1737 const OUString
sFlushCustomShapeUnoApiObjects("FlushCustomShapeUnoApiObjects");
1738 if(sFlushCustomShapeUnoApiObjects
== aPropertyName
)
1740 SdrObjCustomShape
* pTarget
= dynamic_cast< SdrObjCustomShape
* >(pObject
);
1743 // Luckily, the object causing problems in tdf#93994 is not the
1744 // UNO API object, but the XCustomShapeEngine involved. This
1745 // object is on-demand replaceable and can be reset here. This
1746 // will free the involved EditEngine and VirtualDevice.
1747 pTarget
->mxCustomShapeEngine
.set(nullptr);
1749 // since this case is only for the application cores
1750 // we should return from this function now
1754 bool bCustomShapeGeometry
= pObject
&& aPropertyName
== "CustomShapeGeometry";
1756 bool bMirroredX
= false;
1757 bool bMirroredY
= false;
1759 if ( bCustomShapeGeometry
)
1761 bMirroredX
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredX();
1762 bMirroredY
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredY();
1765 SvxShape::setPropertyValue( aPropertyName
, aValue
);
1767 if ( bCustomShapeGeometry
)
1769 static_cast<SdrObjCustomShape
*>(pObject
)->MergeDefaultAttributes();
1770 tools::Rectangle
aRect( pObject
->GetSnapRect() );
1773 bool bNeedsMirrorX
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredX() != bMirroredX
;
1774 bool bNeedsMirrorY
= static_cast<SdrObjCustomShape
*>(pObject
)->IsMirroredY() != bMirroredY
;
1776 std::unique_ptr
< SdrGluePointList
> pListCopy
;
1777 if( bNeedsMirrorX
|| bNeedsMirrorY
)
1779 const SdrGluePointList
* pList
= pObject
->GetGluePointList();
1781 pListCopy
.reset( new SdrGluePointList(*pList
) );
1784 if ( bNeedsMirrorX
)
1786 Point
aTop( ( aRect
.Left() + aRect
.Right() ) >> 1, aRect
.Top() );
1787 Point
aBottom( aTop
.X(), aTop
.Y() + 1000 );
1788 pObject
->NbcMirror( aTop
, aBottom
);
1789 // NbcMirroring is flipping the current mirror state,
1790 // so we have to set the correct state again
1791 static_cast<SdrObjCustomShape
*>(pObject
)->SetMirroredX( !bMirroredX
);
1793 if ( bNeedsMirrorY
)
1795 Point
aLeft( aRect
.Left(), ( aRect
.Top() + aRect
.Bottom() ) >> 1 );
1796 Point
aRight( aLeft
.X() + 1000, aLeft
.Y() );
1797 pObject
->NbcMirror( aLeft
, aRight
);
1798 // NbcMirroring is flipping the current mirror state,
1799 // so we have to set the correct state again
1800 static_cast<SdrObjCustomShape
*>(pObject
)->SetMirroredY( !bMirroredY
);
1805 SdrGluePointList
* pNewList
= const_cast< SdrGluePointList
* >( pObject
->GetGluePointList() );
1807 *pNewList
= *pListCopy
;
1812 bool SvxCustomShape::getPropertyValueImpl( const OUString
& rName
, const SfxItemPropertySimpleEntry
* pProperty
, css::uno::Any
& rValue
)
1814 switch( pProperty
->nWID
)
1816 case SDRATTR_ROTATEANGLE
:
1818 double fAngle
= static_cast<SdrObjCustomShape
*>(GetSdrObject())->GetObjectRotation();
1820 rValue
<<= static_cast<sal_Int32
>(fAngle
);
1824 return SvxShape::getPropertyValueImpl( rName
, pProperty
, rValue
);
1828 void SvxCustomShape::createCustomShapeDefaults( const OUString
& rValueType
)
1830 if (!HasSdrObject())
1832 OSL_FAIL("could not create Custom Shape Defaults!");
1836 static_cast<SdrObjCustomShape
*>(GetSdrObject())->MergeDefaultAttributes( &rValueType
);
1839 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */