android: Update app-specific/MIME type icons
[LibreOffice.git] / svtools / source / uno / unoimap.cxx
blob210e580818c0d9d8ee8dd4e6befb27bcf82558d7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/container/XIndexContainer.hpp>
21 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/document/XEventsSupplier.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/awt/Rectangle.hpp>
26 #include <com/sun/star/awt/Point.hpp>
27 #include <com/sun/star/drawing/PointSequence.hpp>
28 #include <comphelper/servicehelper.hxx>
29 #include <comphelper/propertysethelper.hxx>
30 #include <comphelper/propertysetinfo.hxx>
31 #include <cppuhelper/weakagg.hxx>
32 #include <cppuhelper/implbase.hxx>
33 #include <cppuhelper/supportsservice.hxx>
34 #include <algorithm>
35 #include <osl/diagnose.h>
36 #include <rtl/ref.hxx>
37 #include <svtools/unoevent.hxx>
38 #include <svtools/unoimap.hxx>
39 #include <vcl/imap.hxx>
40 #include <vcl/imapcirc.hxx>
41 #include <vcl/imaprect.hxx>
42 #include <vcl/imappoly.hxx>
44 using namespace comphelper;
45 using namespace cppu;
46 using namespace com::sun::star;
47 using namespace css::uno;
48 using namespace css::lang;
49 using namespace css::container;
50 using namespace css::beans;
51 using namespace css::document;
52 using namespace css::drawing;
54 const sal_Int32 HANDLE_URL = 1;
55 const sal_Int32 HANDLE_DESCRIPTION = 2;
56 const sal_Int32 HANDLE_TARGET = 3;
57 const sal_Int32 HANDLE_NAME = 4;
58 const sal_Int32 HANDLE_ISACTIVE = 5;
59 const sal_Int32 HANDLE_POLYGON = 6;
60 const sal_Int32 HANDLE_CENTER = 7;
61 const sal_Int32 HANDLE_RADIUS = 8;
62 const sal_Int32 HANDLE_BOUNDARY = 9;
63 const sal_Int32 HANDLE_TITLE = 10;
65 namespace {
67 class SvUnoImageMapObject : public OWeakAggObject,
68 public XEventsSupplier,
69 public XServiceInfo,
70 public PropertySetHelper,
71 public XTypeProvider
73 public:
74 SvUnoImageMapObject( IMapObjectType nType, const SvEventDescription* pSupportedMacroItems );
75 SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems );
77 std::unique_ptr<IMapObject> createIMapObject() const;
79 rtl::Reference<SvMacroTableEventDescriptor> mxEvents;
81 // overridden helpers from PropertySetHelper
82 virtual void _setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) override;
83 virtual void _getPropertyValues( const PropertyMapEntry** ppEntries, Any* pValue ) override;
85 // XInterface
86 virtual Any SAL_CALL queryAggregation( const Type & rType ) override;
87 virtual Any SAL_CALL queryInterface( const Type & rType ) override;
88 virtual void SAL_CALL acquire() noexcept override;
89 virtual void SAL_CALL release() noexcept override;
91 // XTypeProvider
92 virtual Sequence< Type > SAL_CALL getTypes( ) override;
93 virtual Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
95 // XEventsSupplier
96 virtual Reference< css::container::XNameReplace > SAL_CALL getEvents( ) override;
98 // XServiceInfo
99 virtual OUString SAL_CALL getImplementationName( ) override;
100 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
101 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
103 private:
104 static rtl::Reference<PropertySetInfo> createPropertySetInfo( IMapObjectType nType );
107 IMapObjectType mnType;
109 OUString maURL;
110 OUString maAltText;
111 OUString maDesc;
112 OUString maTarget;
113 OUString maName;
114 bool mbIsActive;
115 awt::Rectangle maBoundary;
116 awt::Point maCenter;
117 sal_Int32 mnRadius;
118 PointSequence maPolygon;
123 rtl::Reference<PropertySetInfo> SvUnoImageMapObject::createPropertySetInfo( IMapObjectType nType )
125 switch( nType )
127 case IMapObjectType::Polygon:
129 static PropertyMapEntry const aPolygonObj_Impl[] =
131 { OUString("URL"), HANDLE_URL, cppu::UnoType<OUString>::get(), 0, 0 },
132 { OUString("Title"), HANDLE_TITLE, cppu::UnoType<OUString>::get(), 0, 0 },
133 { OUString("Description"), HANDLE_DESCRIPTION, cppu::UnoType<OUString>::get(), 0, 0 },
134 { OUString("Target"), HANDLE_TARGET, cppu::UnoType<OUString>::get(), 0, 0 },
135 { OUString("Name"), HANDLE_NAME, cppu::UnoType<OUString>::get(), 0, 0 },
136 { OUString("IsActive"), HANDLE_ISACTIVE, cppu::UnoType<bool>::get(), 0, 0 },
137 { OUString("Polygon"), HANDLE_POLYGON, cppu::UnoType<PointSequence>::get(), 0, 0 },
140 return rtl::Reference<PropertySetInfo>(new PropertySetInfo( aPolygonObj_Impl ));
142 case IMapObjectType::Circle:
144 static PropertyMapEntry const aCircleObj_Impl[] =
146 { OUString("URL"), HANDLE_URL, cppu::UnoType<OUString>::get(), 0, 0 },
147 { OUString("Title"), HANDLE_TITLE, cppu::UnoType<OUString>::get(), 0, 0 },
148 { OUString("Description"), HANDLE_DESCRIPTION, cppu::UnoType<OUString>::get(), 0, 0 },
149 { OUString("Target"), HANDLE_TARGET, cppu::UnoType<OUString>::get(), 0, 0 },
150 { OUString("Name"), HANDLE_NAME, cppu::UnoType<OUString>::get(), 0, 0 },
151 { OUString("IsActive"), HANDLE_ISACTIVE, cppu::UnoType<bool>::get(), 0, 0 },
152 { OUString("Center"), HANDLE_CENTER, cppu::UnoType<awt::Point>::get(), 0, 0 },
153 { OUString("Radius"), HANDLE_RADIUS, cppu::UnoType<sal_Int32>::get(), 0, 0 },
156 return rtl::Reference<PropertySetInfo>(new PropertySetInfo( aCircleObj_Impl ));
158 case IMapObjectType::Rectangle:
159 default:
161 static PropertyMapEntry const aRectangleObj_Impl[] =
163 { OUString("URL"), HANDLE_URL, cppu::UnoType<OUString>::get(), 0, 0 },
164 { OUString("Title"), HANDLE_TITLE, cppu::UnoType<OUString>::get(), 0, 0 },
165 { OUString("Description"), HANDLE_DESCRIPTION, cppu::UnoType<OUString>::get(), 0, 0 },
166 { OUString("Target"), HANDLE_TARGET, cppu::UnoType<OUString>::get(), 0, 0 },
167 { OUString("Name"), HANDLE_NAME, cppu::UnoType<OUString>::get(), 0, 0 },
168 { OUString("IsActive"), HANDLE_ISACTIVE, cppu::UnoType<bool>::get(), 0, 0 },
169 { OUString("Boundary"), HANDLE_BOUNDARY, cppu::UnoType<awt::Rectangle>::get(), 0, 0 },
172 return rtl::Reference<PropertySetInfo>(new PropertySetInfo( aRectangleObj_Impl ));
177 SvUnoImageMapObject::SvUnoImageMapObject( IMapObjectType nType, const SvEventDescription* pSupportedMacroItems )
178 : PropertySetHelper( createPropertySetInfo( nType ) ),
179 mnType( nType )
180 , mbIsActive( true )
181 , mnRadius( 0 )
183 mxEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems );
186 SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems )
187 : PropertySetHelper( createPropertySetInfo( rMapObject.GetType() ) ),
188 mnType( rMapObject.GetType() )
189 , mbIsActive( true )
190 , mnRadius( 0 )
192 maURL = rMapObject.GetURL();
193 maAltText = rMapObject.GetAltText();
194 maDesc = rMapObject.GetDesc();
195 maTarget = rMapObject.GetTarget();
196 maName = rMapObject.GetName();
197 mbIsActive = rMapObject.IsActive();
199 switch( mnType )
201 case IMapObjectType::Rectangle:
203 const tools::Rectangle aRect( static_cast<const IMapRectangleObject*>(&rMapObject)->GetRectangle(false) );
204 maBoundary.X = aRect.Left();
205 maBoundary.Y = aRect.Top();
206 maBoundary.Width = aRect.GetWidth();
207 maBoundary.Height = aRect.GetHeight();
209 break;
210 case IMapObjectType::Circle:
212 mnRadius = static_cast<const IMapCircleObject*>(&rMapObject)->GetRadius(false);
213 const Point aPoint( static_cast<const IMapCircleObject*>(&rMapObject)->GetCenter(false) );
215 maCenter.X = aPoint.X();
216 maCenter.Y = aPoint.Y();
218 break;
219 case IMapObjectType::Polygon:
220 default:
222 const tools::Polygon aPoly( static_cast<const IMapPolygonObject*>(&rMapObject)->GetPolygon(false) );
224 const sal_uInt16 nCount = aPoly.GetSize();
225 maPolygon.realloc( nCount );
226 awt::Point* pPoints = maPolygon.getArray();
228 for( sal_uInt16 nPoint = 0; nPoint < nCount; nPoint++ )
230 const Point& rPoint = aPoly.GetPoint( nPoint );
231 pPoints->X = rPoint.X();
232 pPoints->Y = rPoint.Y();
234 pPoints++;
239 mxEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems );
242 std::unique_ptr<IMapObject> SvUnoImageMapObject::createIMapObject() const
244 const OUString aURL( maURL );
245 const OUString aAltText( maAltText );
246 const OUString aDesc( maDesc );
247 const OUString aTarget( maTarget );
248 const OUString aName( maName );
250 std::unique_ptr<IMapObject> pNewIMapObject;
252 switch( mnType )
254 case IMapObjectType::Rectangle:
256 const tools::Rectangle aRect( maBoundary.X, maBoundary.Y, maBoundary.X + maBoundary.Width - 1, maBoundary.Y + maBoundary.Height - 1 );
257 pNewIMapObject.reset(new IMapRectangleObject( aRect, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false ));
259 break;
261 case IMapObjectType::Circle:
263 const Point aCenter( maCenter.X, maCenter.Y );
264 pNewIMapObject.reset(new IMapCircleObject( aCenter, mnRadius, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false ));
266 break;
268 case IMapObjectType::Polygon:
269 default:
271 const sal_uInt16 nCount = static_cast<sal_uInt16>(maPolygon.getLength());
273 tools::Polygon aPoly( nCount );
274 for( sal_uInt16 nPoint = 0; nPoint < nCount; nPoint++ )
276 Point aPoint( maPolygon[nPoint].X, maPolygon[nPoint].Y );
277 aPoly.SetPoint( aPoint, nPoint );
280 aPoly.Optimize( PolyOptimizeFlags::CLOSE );
281 pNewIMapObject.reset(new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, false ));
283 break;
286 SvxMacroTableDtor aMacroTable;
287 mxEvents->copyMacrosIntoTable(aMacroTable);
288 pNewIMapObject->SetMacroTable( aMacroTable );
290 return pNewIMapObject;
293 // XInterface
295 Any SAL_CALL SvUnoImageMapObject::queryInterface( const Type & rType )
297 return OWeakAggObject::queryInterface( rType );
300 Any SAL_CALL SvUnoImageMapObject::queryAggregation( const Type & rType )
302 Any aAny;
304 if( rType == cppu::UnoType<XServiceInfo>::get())
305 aAny <<= Reference< XServiceInfo >(this);
306 else if( rType == cppu::UnoType<XTypeProvider>::get())
307 aAny <<= Reference< XTypeProvider >(this);
308 else if( rType == cppu::UnoType<XPropertySet>::get())
309 aAny <<= Reference< XPropertySet >(this);
310 else if( rType == cppu::UnoType<XEventsSupplier>::get())
311 aAny <<= Reference< XEventsSupplier >(this);
312 else if( rType == cppu::UnoType<XMultiPropertySet>::get())
313 aAny <<= Reference< XMultiPropertySet >(this);
314 else
315 aAny = OWeakAggObject::queryAggregation( rType );
317 return aAny;
320 void SAL_CALL SvUnoImageMapObject::acquire() noexcept
322 OWeakAggObject::acquire();
325 void SAL_CALL SvUnoImageMapObject::release() noexcept
327 OWeakAggObject::release();
330 uno::Sequence< uno::Type > SAL_CALL SvUnoImageMapObject::getTypes()
332 static const uno::Sequence< uno::Type > aTypes {
333 cppu::UnoType<XAggregation>::get(),
334 cppu::UnoType<XEventsSupplier>::get(),
335 cppu::UnoType<XServiceInfo>::get(),
336 cppu::UnoType<XPropertySet>::get(),
337 cppu::UnoType<XMultiPropertySet>::get(),
338 cppu::UnoType<XTypeProvider>::get() };
339 return aTypes;
342 uno::Sequence< sal_Int8 > SAL_CALL SvUnoImageMapObject::getImplementationId()
344 return css::uno::Sequence<sal_Int8>();
347 // XServiceInfo
348 sal_Bool SAL_CALL SvUnoImageMapObject::supportsService( const OUString& ServiceName )
350 return cppu::supportsService(this, ServiceName);
353 Sequence< OUString > SAL_CALL SvUnoImageMapObject::getSupportedServiceNames()
355 Sequence< OUString > aSNS( 2 );
356 aSNS.getArray()[0] = "com.sun.star.image.ImageMapObject";
357 switch( mnType )
359 case IMapObjectType::Polygon:
360 default:
361 aSNS.getArray()[1] = "com.sun.star.image.ImageMapPolygonObject";
362 break;
363 case IMapObjectType::Rectangle:
364 aSNS.getArray()[1] = "com.sun.star.image.ImageMapRectangleObject";
365 break;
366 case IMapObjectType::Circle:
367 aSNS.getArray()[1] = "com.sun.star.image.ImageMapCircleObject";
368 break;
370 return aSNS;
373 OUString SAL_CALL SvUnoImageMapObject::getImplementationName()
375 switch( mnType )
377 case IMapObjectType::Polygon:
378 default:
379 return "org.openoffice.comp.svt.ImageMapPolygonObject";
380 case IMapObjectType::Circle:
381 return "org.openoffice.comp.svt.ImageMapCircleObject";
382 case IMapObjectType::Rectangle:
383 return "org.openoffice.comp.svt.ImageMapRectangleObject";
387 // overridden helpers from PropertySetHelper
388 void SvUnoImageMapObject::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues )
390 bool bOk = false;
392 while( *ppEntries )
394 switch( (*ppEntries)->mnHandle )
396 case HANDLE_URL:
397 bOk = *pValues >>= maURL;
398 break;
399 case HANDLE_TITLE:
400 bOk = *pValues >>= maAltText;
401 break;
402 case HANDLE_DESCRIPTION:
403 bOk = *pValues >>= maDesc;
404 break;
405 case HANDLE_TARGET:
406 bOk = *pValues >>= maTarget;
407 break;
408 case HANDLE_NAME:
409 bOk = *pValues >>= maName;
410 break;
411 case HANDLE_ISACTIVE:
412 bOk = *pValues >>= mbIsActive;
413 break;
414 case HANDLE_BOUNDARY:
415 bOk = *pValues >>= maBoundary;
416 break;
417 case HANDLE_CENTER:
418 bOk = *pValues >>= maCenter;
419 break;
420 case HANDLE_RADIUS:
421 bOk = *pValues >>= mnRadius;
422 break;
423 case HANDLE_POLYGON:
424 bOk = *pValues >>= maPolygon;
425 break;
426 default:
427 OSL_FAIL( "SvUnoImageMapObject::_setPropertyValues: unexpected property handle" );
428 break;
431 if( !bOk )
432 throw IllegalArgumentException();
434 ppEntries++;
435 pValues++;
439 void SvUnoImageMapObject::_getPropertyValues( const PropertyMapEntry** ppEntries, Any* pValues )
441 while( *ppEntries )
443 switch( (*ppEntries)->mnHandle )
445 case HANDLE_URL:
446 *pValues <<= maURL;
447 break;
448 case HANDLE_TITLE:
449 *pValues <<= maAltText;
450 break;
451 case HANDLE_DESCRIPTION:
452 *pValues <<= maDesc;
453 break;
454 case HANDLE_TARGET:
455 *pValues <<= maTarget;
456 break;
457 case HANDLE_NAME:
458 *pValues <<= maName;
459 break;
460 case HANDLE_ISACTIVE:
461 *pValues <<= mbIsActive;
462 break;
463 case HANDLE_BOUNDARY:
464 *pValues <<= maBoundary;
465 break;
466 case HANDLE_CENTER:
467 *pValues <<= maCenter;
468 break;
469 case HANDLE_RADIUS:
470 *pValues <<= mnRadius;
471 break;
472 case HANDLE_POLYGON:
473 *pValues <<= maPolygon;
474 break;
475 default:
476 OSL_FAIL( "SvUnoImageMapObject::_getPropertyValues: unexpected property handle" );
477 break;
480 ppEntries++;
481 pValues++;
486 Reference< XNameReplace > SAL_CALL SvUnoImageMapObject::getEvents()
488 return mxEvents;
491 namespace {
493 class SvUnoImageMap : public WeakImplHelper< XIndexContainer, XServiceInfo >
495 public:
496 explicit SvUnoImageMap();
497 SvUnoImageMap( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems );
499 void fillImageMap( ImageMap& rMap ) const;
500 /// @throws IllegalArgumentException
501 static SvUnoImageMapObject* getObject( const Any& aElement );
503 // XIndexContainer
504 virtual void SAL_CALL insertByIndex( sal_Int32 Index, const Any& Element ) override;
505 virtual void SAL_CALL removeByIndex( sal_Int32 Index ) override;
507 // XIndexReplace
508 virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const Any& Element ) override;
510 // XIndexAccess
511 virtual sal_Int32 SAL_CALL getCount( ) override;
512 virtual Any SAL_CALL getByIndex( sal_Int32 Index ) override;
514 // XElementAccess
515 virtual Type SAL_CALL getElementType( ) override;
516 virtual sal_Bool SAL_CALL hasElements( ) override;
518 // XServiceInfo
519 virtual OUString SAL_CALL getImplementationName( ) override;
520 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
521 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
523 private:
524 OUString maName;
526 std::vector< rtl::Reference<SvUnoImageMapObject> > maObjectList;
531 SvUnoImageMap::SvUnoImageMap()
535 SvUnoImageMap::SvUnoImageMap( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems )
537 maName = rMap.GetName();
539 const std::size_t nCount = rMap.GetIMapObjectCount();
540 for( std::size_t nPos = 0; nPos < nCount; nPos++ )
542 IMapObject* pMapObject = rMap.GetIMapObject( nPos );
543 rtl::Reference<SvUnoImageMapObject> xUnoObj = new SvUnoImageMapObject( *pMapObject, pSupportedMacroItems );
544 maObjectList.push_back( xUnoObj );
548 SvUnoImageMapObject* SvUnoImageMap::getObject( const Any& aElement )
550 Reference< XInterface > xObject;
551 aElement >>= xObject;
553 SvUnoImageMapObject* pObject = dynamic_cast<SvUnoImageMapObject*>( xObject.get() );
554 if( nullptr == pObject )
555 throw IllegalArgumentException();
557 return pObject;
560 // XIndexContainer
561 void SAL_CALL SvUnoImageMap::insertByIndex( sal_Int32 nIndex, const Any& Element )
563 SvUnoImageMapObject* pObject = getObject( Element );
564 const sal_Int32 nCount = maObjectList.size();
565 if( nullptr == pObject || nIndex > nCount )
566 throw IndexOutOfBoundsException();
568 if( nIndex == nCount )
569 maObjectList.emplace_back(pObject );
570 else
572 auto aIter = maObjectList.begin();
573 std::advance(aIter, nIndex);
574 maObjectList.insert( aIter, pObject );
578 void SAL_CALL SvUnoImageMap::removeByIndex( sal_Int32 nIndex )
580 const sal_Int32 nCount = maObjectList.size();
581 if( nIndex >= nCount )
582 throw IndexOutOfBoundsException();
584 if( nCount - 1 == nIndex )
586 maObjectList.pop_back();
588 else
590 auto aIter = maObjectList.begin();
591 std::advance(aIter, nIndex);
592 maObjectList.erase( aIter );
596 // XIndexReplace
597 void SAL_CALL SvUnoImageMap::replaceByIndex( sal_Int32 nIndex, const Any& Element )
599 SvUnoImageMapObject* pObject = getObject( Element );
600 const sal_Int32 nCount = maObjectList.size();
601 if( nullptr == pObject || nIndex >= nCount )
602 throw IndexOutOfBoundsException();
604 auto aIter = maObjectList.begin();
605 std::advance(aIter, nIndex);
606 *aIter = pObject;
609 // XIndexAccess
610 sal_Int32 SAL_CALL SvUnoImageMap::getCount( )
612 return maObjectList.size();
615 Any SAL_CALL SvUnoImageMap::getByIndex( sal_Int32 nIndex )
617 const sal_Int32 nCount = maObjectList.size();
618 if( nIndex >= nCount )
619 throw IndexOutOfBoundsException();
621 auto aIter = maObjectList.begin();
622 std::advance(aIter, nIndex);
624 Reference< XPropertySet > xObj( *aIter );
625 return Any( xObj );
628 // XElementAccess
629 Type SAL_CALL SvUnoImageMap::getElementType( )
631 return cppu::UnoType<XPropertySet>::get();
634 sal_Bool SAL_CALL SvUnoImageMap::hasElements( )
636 return (!maObjectList.empty());
639 // XServiceInfo
640 OUString SAL_CALL SvUnoImageMap::getImplementationName( )
642 return "org.openoffice.comp.svt.SvUnoImageMap";
645 sal_Bool SAL_CALL SvUnoImageMap::supportsService( const OUString& ServiceName )
647 return cppu::supportsService(this, ServiceName);
650 Sequence< OUString > SAL_CALL SvUnoImageMap::getSupportedServiceNames( )
652 return { "com.sun.star.image.ImageMap" };
655 void SvUnoImageMap::fillImageMap( ImageMap& rMap ) const
657 rMap.ClearImageMap();
659 rMap.SetName( maName );
661 for (auto const& elem : maObjectList)
663 std::unique_ptr<IMapObject> pNewMapObject = elem->createIMapObject();
664 rMap.InsertIMapObject( std::move(pNewMapObject) );
669 // factory helper methods
672 Reference< XInterface > SvUnoImageMapRectangleObject_createInstance( const SvEventDescription* pSupportedMacroItems )
674 return getXWeak(new SvUnoImageMapObject( IMapObjectType::Rectangle, pSupportedMacroItems ));
677 Reference< XInterface > SvUnoImageMapCircleObject_createInstance( const SvEventDescription* pSupportedMacroItems )
679 return getXWeak(new SvUnoImageMapObject( IMapObjectType::Circle, pSupportedMacroItems ));
682 Reference< XInterface > SvUnoImageMapPolygonObject_createInstance( const SvEventDescription* pSupportedMacroItems )
684 return getXWeak(new SvUnoImageMapObject( IMapObjectType::Polygon, pSupportedMacroItems ));
687 Reference< XInterface > SvUnoImageMap_createInstance()
689 return getXWeak(new SvUnoImageMap);
692 Reference< XInterface > SvUnoImageMap_createInstance( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems )
694 return getXWeak(new SvUnoImageMap( rMap, pSupportedMacroItems ));
697 bool SvUnoImageMap_fillImageMap( const Reference< XInterface >& xImageMap, ImageMap& rMap )
699 SvUnoImageMap* pUnoImageMap = dynamic_cast<SvUnoImageMap*>( xImageMap.get() );
700 if( nullptr == pUnoImageMap )
701 return false;
703 pUnoImageMap->fillImageMap( rMap );
704 return true;
707 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */