20#include <com/sun/star/container/NoSuchElementException.hpp>
21#include <com/sun/star/container/XIdentifierContainer.hpp>
22#include <com/sun/star/container/XIndexContainer.hpp>
23#include <com/sun/star/drawing/GluePoint2.hpp>
24#include <com/sun/star/lang/IllegalArgumentException.hpp>
25#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
36using namespace ::
cppu;
42class SvxUnoGluePointAccess :
public WeakImplHelper< container::XIndexContainer, container::XIdentifierContainer >
51 virtual sal_Int32 SAL_CALL insert(
const uno::Any& aElement )
override;
52 virtual void SAL_CALL removeByIdentifier( sal_Int32
Identifier )
override;
55 virtual void SAL_CALL replaceByIdentifer( sal_Int32
Identifier,
const uno::Any& aElement )
override;
59 virtual uno::Sequence< sal_Int32 > SAL_CALL getIdentifiers( )
override;
63 virtual void SAL_CALL insertByIndex( sal_Int32
Index,
const uno::Any& Element )
override;
64 virtual void SAL_CALL removeByIndex( sal_Int32
Index )
override;
68 virtual void SAL_CALL replaceByIndex( sal_Int32
Index,
const uno::Any& Element )
override;
72 virtual sal_Int32 SAL_CALL getCount( )
override;
73 virtual uno::Any SAL_CALL getByIndex( sal_Int32
Index )
override;
76 virtual uno::Type SAL_CALL getElementType( )
override;
77 virtual sal_Bool SAL_CALL hasElements( )
override;
84 rUnoGlue.Position.X = rSdrGlue.GetPos().X();
85 rUnoGlue.Position.Y = rSdrGlue.GetPos().Y();
86 rUnoGlue.IsRelative = rSdrGlue.IsPercent();
88 SdrAlign eAlign = rSdrGlue.GetAlign();
90 rUnoGlue.PositionAlignment = drawing::Alignment_TOP_LEFT;
92 rUnoGlue.PositionAlignment = drawing::Alignment_TOP;
94 rUnoGlue.PositionAlignment = drawing::Alignment_TOP_RIGHT;
96 rUnoGlue.PositionAlignment = drawing::Alignment_CENTER;
98 rUnoGlue.PositionAlignment = drawing::Alignment_RIGHT;
100 rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_LEFT;
102 rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM;
104 rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_RIGHT;
106 rUnoGlue.PositionAlignment = drawing::Alignment_LEFT;
109 switch( rSdrGlue.GetEscDir() )
112 rUnoGlue.Escape = drawing::EscapeDirection_LEFT;
115 rUnoGlue.Escape = drawing::EscapeDirection_RIGHT;
118 rUnoGlue.Escape = drawing::EscapeDirection_UP;
121 rUnoGlue.Escape = drawing::EscapeDirection_DOWN;
124 rUnoGlue.Escape = drawing::EscapeDirection_HORIZONTAL;
127 rUnoGlue.Escape = drawing::EscapeDirection_VERTICAL;
131 rUnoGlue.Escape = drawing::EscapeDirection_SMART;
138 rSdrGlue.SetPos(
Point( rUnoGlue.Position.X, rUnoGlue.Position.Y ) );
139 rSdrGlue.SetPercent( rUnoGlue.IsRelative );
141 switch( rUnoGlue.PositionAlignment )
143 case drawing::Alignment_TOP_LEFT:
146 case drawing::Alignment_TOP:
149 case drawing::Alignment_TOP_RIGHT:
152 case drawing::Alignment_CENTER:
155 case drawing::Alignment_RIGHT:
158 case drawing::Alignment_BOTTOM_LEFT:
161 case drawing::Alignment_BOTTOM:
164 case drawing::Alignment_BOTTOM_RIGHT:
172 switch( rUnoGlue.Escape )
174 case drawing::EscapeDirection_LEFT:
177 case drawing::EscapeDirection_RIGHT:
180 case drawing::EscapeDirection_UP:
183 case drawing::EscapeDirection_DOWN:
186 case drawing::EscapeDirection_HORIZONTAL:
189 case drawing::EscapeDirection_VERTICAL:
199SvxUnoGluePointAccess::SvxUnoGluePointAccess(
SdrObject* pObject ) noexcept
205sal_Int32 SAL_CALL SvxUnoGluePointAccess::insert(
const uno::Any& aElement )
213 drawing::GluePoint2 aUnoGlue;
215 if( aElement >>= aUnoGlue )
219 sal_uInt16
nId = pList->
Insert( aSdrGlue );
228 throw lang::IllegalArgumentException();
235void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier )
248 if( (*pList)[
i].GetId() ==
nId )
261 throw container::NoSuchElementException();
265void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier,
const uno::Any& aElement )
271 struct drawing::GluePoint2 aGluePoint;
273 throw lang::IllegalArgumentException();
282 if( (*pList)[
i].GetId() ==
nId )
286 convert( aGluePoint, rTempPoint );
296 throw container::NoSuchElementException();
300uno::Any SAL_CALL SvxUnoGluePointAccess::getByIdentifier( sal_Int32 Identifier )
305 struct drawing::GluePoint2 aGluePoint;
309 SdrGluePoint aTempPoint =
pObject->GetVertexGluePoint(
static_cast<sal_uInt16
>(Identifier) );
310 aGluePoint.IsUserDefined =
false;
311 convert( aTempPoint, aGluePoint );
320 for( sal_uInt16 i = 0;
i <
nCount;
i++ )
331 convert( rTempPoint, aGluePoint );
338 throw container::NoSuchElementException();
341uno::Sequence< sal_Int32 > SAL_CALL SvxUnoGluePointAccess::getIdentifiers()
352 sal_Int32 *pIdentifier = aIdSequence.getArray();
355 *pIdentifier++ =
static_cast<sal_Int32
>(i);
364 uno::Sequence< sal_Int32 > aEmpty;
372void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32,
const uno::Any& Element )
380 drawing::GluePoint2 aUnoGlue;
382 if( Element >>= aUnoGlue )
386 pList->
Insert( aSdrGlue );
395 throw lang::IllegalArgumentException();
399 throw lang::IndexOutOfBoundsException();
402void SAL_CALL SvxUnoGluePointAccess::removeByIndex( sal_Int32
Index )
424 throw lang::IndexOutOfBoundsException();
428void SAL_CALL SvxUnoGluePointAccess::replaceByIndex( sal_Int32
Index,
const uno::Any& Element )
430 drawing::GluePoint2 aUnoGlue;
431 if(!(Element >>= aUnoGlue))
432 throw lang::IllegalArgumentException();
436 if( pObject &&
Index >= 0 )
450 throw lang::IndexOutOfBoundsException();
454sal_Int32 SAL_CALL SvxUnoGluePointAccess::getCount()
472uno::Any SAL_CALL SvxUnoGluePointAccess::getByIndex( sal_Int32
Index )
475 if(
Index >= 0 && pObject )
477 struct drawing::GluePoint2 aGluePoint;
482 aGluePoint.IsUserDefined =
false;
483 convert( aTempPoint, aGluePoint );
494 convert( rTempPoint, aGluePoint );
500 throw lang::IndexOutOfBoundsException();
504uno::Type SAL_CALL SvxUnoGluePointAccess::getElementType()
509sal_Bool SAL_CALL SvxUnoGluePointAccess::hasElements()
519 return *
new SvxUnoGluePointAccess(
pObject);
sal_uInt16 Insert(const SdrGluePoint &rGP)
void Delete(sal_uInt16 nPos)
sal_uInt16 GetCount() const
bool IsUserDefined() const
css::uno::Type const & get()
virtual sal_uInt32 GetId() const override
EmbeddedObjectRef * pObject
const sal_uInt16 NON_USER_DEFINED_GLUE_POINTS
uno::Reference< uno::XInterface > SvxUnoGluePointAccess_createInstance(SdrObject *pObject)
Create a SvxUnoGluePointAccess.
static void convert(const SdrGluePoint &rSdrGlue, drawing::GluePoint2 &rUnoGlue) noexcept