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>
35#include <osl/diagnose.h>
47using namespace css::uno;
48using namespace css::lang;
49using namespace css::container;
50using namespace css::beans;
51using namespace css::document;
52using namespace css::drawing;
68 public XEventsSupplier,
77 std::unique_ptr<IMapObject> createIMapObject()
const;
88 virtual void SAL_CALL
acquire()
noexcept override;
89 virtual void SAL_CALL
release()
noexcept override;
92 virtual Sequence< Type > SAL_CALL getTypes( )
override;
93 virtual Sequence< sal_Int8 > SAL_CALL getImplementationId( )
override;
96 virtual Reference< css::container::XNameReplace > SAL_CALL getEvents( )
override;
115 awt::Rectangle maBoundary;
127 case IMapObjectType::Polygon:
142 case IMapObjectType::Circle:
158 case IMapObjectType::Rectangle:
188 mnType( rMapObject.GetType() )
201 case IMapObjectType::Rectangle:
204 maBoundary.X = aRect.Left();
205 maBoundary.Y = aRect.Top();
206 maBoundary.Width = aRect.GetWidth();
207 maBoundary.Height = aRect.GetHeight();
210 case IMapObjectType::Circle:
212 mnRadius =
static_cast<const IMapCircleObject*
>(&rMapObject)->GetRadius(
false);
215 maCenter.X = aPoint.X();
216 maCenter.Y = aPoint.Y();
219 case IMapObjectType::Polygon:
224 const sal_uInt16
nCount = aPoly.GetSize();
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();
242std::unique_ptr<IMapObject> SvUnoImageMapObject::createIMapObject()
const
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;
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 ));
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 ));
268 case IMapObjectType::Polygon:
271 const sal_uInt16
nCount =
static_cast<sal_uInt16
>(
maPolygon.getLength());
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 ));
287 mxEvents->copyMacrosIntoTable(aMacroTable);
288 pNewIMapObject->SetMacroTable( aMacroTable );
290 return pNewIMapObject;
295Any SAL_CALL SvUnoImageMapObject::queryInterface(
const Type & rType )
297 return OWeakAggObject::queryInterface( rType );
300Any SAL_CALL SvUnoImageMapObject::queryAggregation(
const Type & rType )
305 aAny <<= Reference< XServiceInfo >(
this);
307 aAny <<= Reference< XTypeProvider >(
this);
309 aAny <<= Reference< XPropertySet >(
this);
311 aAny <<= Reference< XEventsSupplier >(
this);
313 aAny <<= Reference< XMultiPropertySet >(
this);
315 aAny = OWeakAggObject::queryAggregation( rType );
320void SAL_CALL SvUnoImageMapObject::acquire() noexcept
322 OWeakAggObject::acquire();
325void SAL_CALL SvUnoImageMapObject::release() noexcept
327 OWeakAggObject::release();
330uno::Sequence< uno::Type > SAL_CALL SvUnoImageMapObject::getTypes()
332 static const uno::Sequence< uno::Type >
aTypes {
342uno::Sequence< sal_Int8 > SAL_CALL SvUnoImageMapObject::getImplementationId()
344 return css::uno::Sequence<sal_Int8>();
348sal_Bool SAL_CALL SvUnoImageMapObject::supportsService(
const OUString& ServiceName )
353Sequence< OUString > SAL_CALL SvUnoImageMapObject::getSupportedServiceNames()
355 Sequence< OUString > aSNS( 2 );
356 aSNS.getArray()[0] =
"com.sun.star.image.ImageMapObject";
359 case IMapObjectType::Polygon:
361 aSNS.getArray()[1] =
"com.sun.star.image.ImageMapPolygonObject";
363 case IMapObjectType::Rectangle:
364 aSNS.getArray()[1] =
"com.sun.star.image.ImageMapRectangleObject";
366 case IMapObjectType::Circle:
367 aSNS.getArray()[1] =
"com.sun.star.image.ImageMapCircleObject";
373OUString SAL_CALL SvUnoImageMapObject::getImplementationName()
377 case IMapObjectType::Polygon:
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";
388void SvUnoImageMapObject::_setPropertyValues(
const PropertyMapEntry** ppEntries,
const Any* pValues )
394 switch( (*ppEntries)->mnHandle )
427 OSL_FAIL(
"SvUnoImageMapObject::_setPropertyValues: unexpected property handle" );
432 throw IllegalArgumentException();
439void SvUnoImageMapObject::_getPropertyValues(
const PropertyMapEntry** ppEntries, Any* pValues )
443 switch( (*ppEntries)->mnHandle )
476 OSL_FAIL(
"SvUnoImageMapObject::_getPropertyValues: unexpected property handle" );
486Reference< XNameReplace > SAL_CALL SvUnoImageMapObject::getEvents()
493class SvUnoImageMap :
public WeakImplHelper< XIndexContainer, XServiceInfo >
496 explicit SvUnoImageMap();
499 void fillImageMap(
ImageMap& rMap )
const;
501 static SvUnoImageMapObject* getObject(
const Any& aElement );
504 virtual void SAL_CALL insertByIndex( sal_Int32
Index,
const Any& Element )
override;
505 virtual void SAL_CALL removeByIndex( sal_Int32
Index )
override;
508 virtual void SAL_CALL replaceByIndex( sal_Int32
Index,
const Any& Element )
override;
511 virtual sal_Int32 SAL_CALL getCount( )
override;
512 virtual Any SAL_CALL getByIndex( sal_Int32
Index )
override;
515 virtual Type SAL_CALL getElementType( )
override;
516 virtual sal_Bool SAL_CALL hasElements( )
override;
526 std::vector< rtl::Reference<SvUnoImageMapObject> > maObjectList;
531SvUnoImageMap::SvUnoImageMap()
544 maObjectList.push_back( xUnoObj );
548SvUnoImageMapObject* SvUnoImageMap::getObject(
const Any& aElement )
550 Reference< XInterface > xObject;
551 aElement >>= xObject;
553 SvUnoImageMapObject*
pObject =
dynamic_cast<SvUnoImageMapObject*
>( xObject.get() );
555 throw IllegalArgumentException();
561void 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 );
572 auto aIter = maObjectList.begin();
573 std::advance(aIter, nIndex);
574 maObjectList.insert( aIter,
pObject );
578void 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();
590 auto aIter = maObjectList.begin();
591 std::advance(aIter, nIndex);
592 maObjectList.erase( aIter );
597void 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);
610sal_Int32 SAL_CALL SvUnoImageMap::getCount( )
612 return maObjectList.size();
615Any 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 );
629Type SAL_CALL SvUnoImageMap::getElementType( )
634sal_Bool SAL_CALL SvUnoImageMap::hasElements( )
636 return (!maObjectList.empty());
640OUString SAL_CALL SvUnoImageMap::getImplementationName( )
642 return "org.openoffice.comp.svt.SvUnoImageMap";
645sal_Bool SAL_CALL SvUnoImageMap::supportsService(
const OUString& ServiceName )
650Sequence< OUString > SAL_CALL SvUnoImageMap::getSupportedServiceNames( )
652 return {
"com.sun.star.image.ImageMap" };
655void SvUnoImageMap::fillImageMap(
ImageMap& rMap )
const
661 for (
auto const& elem : maObjectList)
663 std::unique_ptr<IMapObject> pNewMapObject = elem->createIMapObject();
674 return getXWeak(
new SvUnoImageMapObject( IMapObjectType::Rectangle, pSupportedMacroItems ));
679 return getXWeak(
new SvUnoImageMapObject( IMapObjectType::Circle, pSupportedMacroItems ));
684 return getXWeak(
new SvUnoImageMapObject( IMapObjectType::Polygon, pSupportedMacroItems ));
689 return getXWeak(
new SvUnoImageMap);
694 return getXWeak(
new SvUnoImageMap( rMap, pSupportedMacroItems ));
699 SvUnoImageMap* pUnoImageMap =
dynamic_cast<SvUnoImageMap*
>( xImageMap.get() );
700 if(
nullptr == pUnoImageMap )
703 pUnoImageMap->fillImageMap( rMap );
const PropertyValue * pValues
const OUString & GetAltText() const
const OUString & GetName() const
const OUString & GetURL() const
const SvxMacroTableDtor & GetMacroTable() const
const OUString & GetTarget() const
const OUString & GetDesc() const
void SetName(const OUString &rName)
const OUString & GetName() const
void InsertIMapObject(const IMapObject &rIMapObject)
IMapObject * GetIMapObject(size_t nPos) const
size_t GetIMapObjectCount() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
virtual void _getPropertyValues(const comphelper::PropertyMapEntry **ppEntries, css::uno::Any *pValue)=0
virtual void _setPropertyValues(const comphelper::PropertyMapEntry **ppEntries, const css::uno::Any *pValues)=0
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
css::uno::Type const & get()
EmbeddedObjectRef * pObject
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SvEventDescription: Description of a single event.
Reference< XInterface > SvUnoImageMap_createInstance()
Reference< XInterface > SvUnoImageMapRectangleObject_createInstance(const SvEventDescription *pSupportedMacroItems)
const sal_Int32 HANDLE_NAME
const sal_Int32 HANDLE_BOUNDARY
Reference< XInterface > SvUnoImageMapPolygonObject_createInstance(const SvEventDescription *pSupportedMacroItems)
const sal_Int32 HANDLE_DESCRIPTION
const sal_Int32 HANDLE_TARGET
const sal_Int32 HANDLE_ISACTIVE
const sal_Int32 HANDLE_POLYGON
const sal_Int32 HANDLE_CENTER
const sal_Int32 HANDLE_URL
const sal_Int32 HANDLE_RADIUS
const sal_Int32 HANDLE_TITLE
bool SvUnoImageMap_fillImageMap(const Reference< XInterface > &xImageMap, ImageMap &rMap)
Reference< XInterface > SvUnoImageMapCircleObject_createInstance(const SvEventDescription *pSupportedMacroItems)