1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svtools.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequence.hpp> 39*cdf0e10cSrcweir #include <comphelper/servicehelper.hxx> 40*cdf0e10cSrcweir #include <comphelper/propertysethelper.hxx> 41*cdf0e10cSrcweir #include <comphelper/propertysetinfo.hxx> 42*cdf0e10cSrcweir #include <cppuhelper/weakagg.hxx> 43*cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 44*cdf0e10cSrcweir #include <list> 45*cdf0e10cSrcweir #include <rtl/uuid.h> 46*cdf0e10cSrcweir #include <vos/mutex.hxx> 47*cdf0e10cSrcweir #include <vcl/svapp.hxx> 48*cdf0e10cSrcweir #include <svtools/unoevent.hxx> 49*cdf0e10cSrcweir #include <svtools/unoimap.hxx> 50*cdf0e10cSrcweir #include <svtools/imap.hxx> 51*cdf0e10cSrcweir #include <svtools/imapcirc.hxx> 52*cdf0e10cSrcweir #include <svtools/imaprect.hxx> 53*cdf0e10cSrcweir #include <svtools/imappoly.hxx> 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #ifndef SEQTYPE 56*cdf0e10cSrcweir #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500) 57*cdf0e10cSrcweir #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x )) 58*cdf0e10cSrcweir #else 59*cdf0e10cSrcweir #define SEQTYPE(x) &(x) 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir #endif 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #define MAP_LEN(x) x, sizeof(x)-1 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir using namespace comphelper; 67*cdf0e10cSrcweir using namespace cppu; 68*cdf0e10cSrcweir using namespace com::sun::star; 69*cdf0e10cSrcweir using namespace com::sun::star::uno; 70*cdf0e10cSrcweir using namespace com::sun::star::lang; 71*cdf0e10cSrcweir using namespace com::sun::star::container; 72*cdf0e10cSrcweir using namespace com::sun::star::beans; 73*cdf0e10cSrcweir using namespace com::sun::star::document; 74*cdf0e10cSrcweir using namespace com::sun::star::drawing; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir const sal_Int32 HANDLE_URL = 1; 77*cdf0e10cSrcweir const sal_Int32 HANDLE_DESCRIPTION = 2; 78*cdf0e10cSrcweir const sal_Int32 HANDLE_TARGET = 3; 79*cdf0e10cSrcweir const sal_Int32 HANDLE_NAME = 4; 80*cdf0e10cSrcweir const sal_Int32 HANDLE_ISACTIVE = 5; 81*cdf0e10cSrcweir const sal_Int32 HANDLE_POLYGON = 6; 82*cdf0e10cSrcweir const sal_Int32 HANDLE_CENTER = 7; 83*cdf0e10cSrcweir const sal_Int32 HANDLE_RADIUS = 8; 84*cdf0e10cSrcweir const sal_Int32 HANDLE_BOUNDARY = 9; 85*cdf0e10cSrcweir const sal_Int32 HANDLE_TITLE = 10; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir class SvUnoImageMapObject : public OWeakAggObject, 88*cdf0e10cSrcweir public XEventsSupplier, 89*cdf0e10cSrcweir public XServiceInfo, 90*cdf0e10cSrcweir public PropertySetHelper, 91*cdf0e10cSrcweir public XTypeProvider, 92*cdf0e10cSrcweir public XUnoTunnel 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir public: 95*cdf0e10cSrcweir SvUnoImageMapObject( sal_uInt16 nType, const SvEventDescription* pSupportedMacroItems ); 96*cdf0e10cSrcweir SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems ); 97*cdf0e10cSrcweir virtual ~SvUnoImageMapObject() throw(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_DECL( SvUnoImageMapObject ) 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir IMapObject* createIMapObject() const; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir SvMacroTableEventDescriptor* mpEvents; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir // overiden helpers from PropertySetHelper 106*cdf0e10cSrcweir virtual void _setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException ); 107*cdf0e10cSrcweir virtual void _getPropertyValues( const PropertyMapEntry** ppEntries, Any* pValue ) throw(UnknownPropertyException, WrappedTargetException ); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir // XInterface 110*cdf0e10cSrcweir virtual Any SAL_CALL queryAggregation( const Type & rType ) throw(RuntimeException); 111*cdf0e10cSrcweir virtual Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException); 112*cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 113*cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir // XTypeProvider 116*cdf0e10cSrcweir virtual Sequence< Type > SAL_CALL getTypes( ) throw(RuntimeException); 117*cdf0e10cSrcweir virtual Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(RuntimeException); 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir // XEventsSupplier 120*cdf0e10cSrcweir virtual Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(RuntimeException); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir // XServiceInfo 123*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw( RuntimeException ); 124*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( RuntimeException ); 125*cdf0e10cSrcweir virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw( RuntimeException ); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir private: 128*cdf0e10cSrcweir static PropertySetInfo* createPropertySetInfo( sal_uInt16 nType ); 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir sal_uInt16 mnType; 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir ::rtl::OUString maURL; 134*cdf0e10cSrcweir ::rtl::OUString maAltText; 135*cdf0e10cSrcweir ::rtl::OUString maDesc; 136*cdf0e10cSrcweir ::rtl::OUString maTarget; 137*cdf0e10cSrcweir ::rtl::OUString maName; 138*cdf0e10cSrcweir sal_Bool mbIsActive; 139*cdf0e10cSrcweir awt::Rectangle maBoundary; 140*cdf0e10cSrcweir awt::Point maCenter; 141*cdf0e10cSrcweir sal_Int32 mnRadius; 142*cdf0e10cSrcweir PointSequence maPolygon; 143*cdf0e10cSrcweir }; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SvUnoImageMapObject ); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir PropertySetInfo* SvUnoImageMapObject::createPropertySetInfo( sal_uInt16 nType ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir switch( nType ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir case IMAP_OBJ_POLYGON: 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir static PropertyMapEntry aPolygonObj_Impl[] = 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir { MAP_LEN( "URL" ), HANDLE_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 156*cdf0e10cSrcweir { MAP_LEN( "Title" ), HANDLE_TITLE, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 157*cdf0e10cSrcweir { MAP_LEN( "Description" ), HANDLE_DESCRIPTION, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 158*cdf0e10cSrcweir { MAP_LEN( "Target" ), HANDLE_TARGET, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 159*cdf0e10cSrcweir { MAP_LEN( "Name" ), HANDLE_NAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 160*cdf0e10cSrcweir { MAP_LEN( "IsActive" ), HANDLE_ISACTIVE, &::getBooleanCppuType(), 0, 0 }, 161*cdf0e10cSrcweir { MAP_LEN( "Polygon" ), HANDLE_POLYGON, SEQTYPE(::getCppuType((const PointSequence*)0)), 0, 0 }, 162*cdf0e10cSrcweir {0,0,0,0,0,0} 163*cdf0e10cSrcweir }; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir return new PropertySetInfo( aPolygonObj_Impl ); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir case IMAP_OBJ_CIRCLE: 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir static PropertyMapEntry aCircleObj_Impl[] = 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir { MAP_LEN( "URL" ), HANDLE_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 172*cdf0e10cSrcweir { MAP_LEN( "Title" ), HANDLE_TITLE, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 173*cdf0e10cSrcweir { MAP_LEN( "Description" ), HANDLE_DESCRIPTION, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 174*cdf0e10cSrcweir { MAP_LEN( "Target" ), HANDLE_TARGET, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 175*cdf0e10cSrcweir { MAP_LEN( "Name" ), HANDLE_NAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 176*cdf0e10cSrcweir { MAP_LEN( "IsActive" ), HANDLE_ISACTIVE, &::getBooleanCppuType(), 0, 0 }, 177*cdf0e10cSrcweir { MAP_LEN( "Center" ), HANDLE_CENTER, &::getCppuType((const awt::Point*)0), 0, 0 }, 178*cdf0e10cSrcweir { MAP_LEN( "Radius" ), HANDLE_RADIUS, &::getCppuType((const sal_Int32*)0), 0, 0 }, 179*cdf0e10cSrcweir {0,0,0,0,0,0} 180*cdf0e10cSrcweir }; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir return new PropertySetInfo( aCircleObj_Impl ); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir case IMAP_OBJ_RECTANGLE: 185*cdf0e10cSrcweir default: 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir static PropertyMapEntry aRectangleObj_Impl[] = 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir { MAP_LEN( "URL" ), HANDLE_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 190*cdf0e10cSrcweir { MAP_LEN( "Title" ), HANDLE_TITLE, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 191*cdf0e10cSrcweir { MAP_LEN( "Description" ), HANDLE_DESCRIPTION, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 192*cdf0e10cSrcweir { MAP_LEN( "Target" ), HANDLE_TARGET, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 193*cdf0e10cSrcweir { MAP_LEN( "Name" ), HANDLE_NAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0 }, 194*cdf0e10cSrcweir { MAP_LEN( "IsActive" ), HANDLE_ISACTIVE, &::getBooleanCppuType(), 0, 0 }, 195*cdf0e10cSrcweir { MAP_LEN( "Boundary" ), HANDLE_BOUNDARY, &::getCppuType((const awt::Rectangle*)0), 0, 0 }, 196*cdf0e10cSrcweir {0,0,0,0,0,0} 197*cdf0e10cSrcweir }; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir return new PropertySetInfo( aRectangleObj_Impl ); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir SvUnoImageMapObject::SvUnoImageMapObject( sal_uInt16 nType, const SvEventDescription* pSupportedMacroItems ) 205*cdf0e10cSrcweir : PropertySetHelper( createPropertySetInfo( nType ) ), 206*cdf0e10cSrcweir mnType( nType ) 207*cdf0e10cSrcweir , mbIsActive( true ) 208*cdf0e10cSrcweir , mnRadius( 0 ) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir mpEvents = new SvMacroTableEventDescriptor( pSupportedMacroItems ); 211*cdf0e10cSrcweir mpEvents->acquire(); 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir SvUnoImageMapObject::SvUnoImageMapObject( const IMapObject& rMapObject, const SvEventDescription* pSupportedMacroItems ) 215*cdf0e10cSrcweir : PropertySetHelper( createPropertySetInfo( rMapObject.GetType() ) ), 216*cdf0e10cSrcweir mnType( rMapObject.GetType() ) 217*cdf0e10cSrcweir , mbIsActive( true ) 218*cdf0e10cSrcweir , mnRadius( 0 ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir maURL = rMapObject.GetURL(); 221*cdf0e10cSrcweir maAltText = rMapObject.GetAltText(); 222*cdf0e10cSrcweir maDesc = rMapObject.GetDesc(); 223*cdf0e10cSrcweir maTarget = rMapObject.GetTarget(); 224*cdf0e10cSrcweir maName = rMapObject.GetName(); 225*cdf0e10cSrcweir mbIsActive = rMapObject.IsActive(); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir switch( mnType ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir case IMAP_OBJ_RECTANGLE: 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir const Rectangle aRect( ((IMapRectangleObject*)&rMapObject)->GetRectangle(sal_False) ); 232*cdf0e10cSrcweir maBoundary.X = aRect.Left(); 233*cdf0e10cSrcweir maBoundary.Y = aRect.Top(); 234*cdf0e10cSrcweir maBoundary.Width = aRect.GetWidth(); 235*cdf0e10cSrcweir maBoundary.Height = aRect.GetHeight(); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir break; 238*cdf0e10cSrcweir case IMAP_OBJ_CIRCLE: 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir mnRadius = (sal_Int32)((IMapCircleObject*)&rMapObject)->GetRadius(sal_False); 241*cdf0e10cSrcweir const Point aPoint( ((IMapCircleObject*)&rMapObject)->GetCenter(sal_False) ); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir maCenter.X = aPoint.X(); 244*cdf0e10cSrcweir maCenter.Y = aPoint.Y(); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir break; 247*cdf0e10cSrcweir case IMAP_OBJ_POLYGON: 248*cdf0e10cSrcweir default: 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir const Polygon aPoly( ((IMapPolygonObject*)&rMapObject)->GetPolygon(sal_False) ); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir const sal_uInt16 nCount = aPoly.GetSize(); 253*cdf0e10cSrcweir maPolygon.realloc( nCount ); 254*cdf0e10cSrcweir awt::Point* pPoints = maPolygon.getArray(); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir for( sal_uInt16 nPoint = 0; nPoint < nCount; nPoint++ ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir const Point& rPoint = aPoly.GetPoint( nPoint ); 259*cdf0e10cSrcweir pPoints->X = rPoint.X(); 260*cdf0e10cSrcweir pPoints->Y = rPoint.Y(); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir pPoints++; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir mpEvents = new SvMacroTableEventDescriptor( rMapObject.GetMacroTable(), pSupportedMacroItems ); 268*cdf0e10cSrcweir mpEvents->acquire(); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir SvUnoImageMapObject::~SvUnoImageMapObject() throw() 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir mpEvents->release(); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir IMapObject* SvUnoImageMapObject::createIMapObject() const 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir const String aURL( maURL ); 279*cdf0e10cSrcweir const String aAltText( maAltText ); 280*cdf0e10cSrcweir const String aDesc( maDesc ); 281*cdf0e10cSrcweir const String aTarget( maTarget ); 282*cdf0e10cSrcweir const String aName( maName ); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir IMapObject* pNewIMapObject; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir switch( mnType ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir case IMAP_OBJ_RECTANGLE: 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir const Rectangle aRect( maBoundary.X, maBoundary.Y, maBoundary.X + maBoundary.Width - 1, maBoundary.Y + maBoundary.Height - 1 ); 291*cdf0e10cSrcweir pNewIMapObject = new IMapRectangleObject( aRect, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, sal_False ); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir break; 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir case IMAP_OBJ_CIRCLE: 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir const Point aCenter( maCenter.X, maCenter.Y ); 298*cdf0e10cSrcweir pNewIMapObject = new IMapCircleObject( aCenter, mnRadius, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, sal_False ); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir break; 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir case IMAP_OBJ_POLYGON: 303*cdf0e10cSrcweir default: 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir const sal_uInt16 nCount = (sal_uInt16)maPolygon.getLength(); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir Polygon aPoly( nCount ); 308*cdf0e10cSrcweir for( sal_uInt16 nPoint = 0; nPoint < nCount; nPoint++ ) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir Point aPoint( maPolygon[nPoint].X, maPolygon[nPoint].Y ); 311*cdf0e10cSrcweir aPoly.SetPoint( aPoint, nPoint ); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir aPoly.Optimize( POLY_OPTIMIZE_CLOSE ); 315*cdf0e10cSrcweir pNewIMapObject = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, aName, mbIsActive, sal_False ); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir break; 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir SvxMacroTableDtor aMacroTable; 321*cdf0e10cSrcweir mpEvents->copyMacrosIntoTable(aMacroTable); 322*cdf0e10cSrcweir pNewIMapObject->SetMacroTable( aMacroTable ); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir return pNewIMapObject; 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir // XInterface 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir Any SAL_CALL SvUnoImageMapObject::queryInterface( const Type & rType ) 330*cdf0e10cSrcweir throw( RuntimeException ) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir return OWeakAggObject::queryInterface( rType ); 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir Any SAL_CALL SvUnoImageMapObject::queryAggregation( const Type & rType ) 336*cdf0e10cSrcweir throw(RuntimeException) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir Any aAny; 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir if( rType == ::getCppuType((const Reference< XServiceInfo >*)0) ) 341*cdf0e10cSrcweir aAny <<= Reference< XServiceInfo >(this); 342*cdf0e10cSrcweir else if( rType == ::getCppuType((const Reference< XTypeProvider >*)0) ) 343*cdf0e10cSrcweir aAny <<= Reference< XTypeProvider >(this); 344*cdf0e10cSrcweir else if( rType == ::getCppuType((const Reference< XPropertySet >*)0) ) 345*cdf0e10cSrcweir aAny <<= Reference< XPropertySet >(this); 346*cdf0e10cSrcweir else if( rType == ::getCppuType((const Reference< XEventsSupplier >*)0) ) 347*cdf0e10cSrcweir aAny <<= Reference< XEventsSupplier >(this); 348*cdf0e10cSrcweir else if( rType == ::getCppuType((const Reference< XMultiPropertySet >*)0) ) 349*cdf0e10cSrcweir aAny <<= Reference< XMultiPropertySet >(this); 350*cdf0e10cSrcweir else if( rType == ::getCppuType((const Reference< XUnoTunnel >*)0) ) 351*cdf0e10cSrcweir aAny <<= Reference< XUnoTunnel >(this); 352*cdf0e10cSrcweir else 353*cdf0e10cSrcweir aAny <<= OWeakAggObject::queryAggregation( rType ); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir return aAny; 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir void SAL_CALL SvUnoImageMapObject::acquire() throw() 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir OWeakAggObject::acquire(); 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir void SAL_CALL SvUnoImageMapObject::release() throw() 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir OWeakAggObject::release(); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SvUnoImageMapObject::getTypes() 369*cdf0e10cSrcweir throw (uno::RuntimeException) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir uno::Sequence< uno::Type > aTypes( 7 ); 372*cdf0e10cSrcweir uno::Type* pTypes = aTypes.getArray(); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< XAggregation>*)0); 375*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< XEventsSupplier>*)0); 376*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< XServiceInfo>*)0); 377*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< XPropertySet>*)0); 378*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< XMultiPropertySet>*)0); 379*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< XTypeProvider>*)0); 380*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< XUnoTunnel>*)0); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir return aTypes; 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SvUnoImageMapObject::getImplementationId() 386*cdf0e10cSrcweir throw (uno::RuntimeException) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId; 391*cdf0e10cSrcweir if( aId.getLength() == 0 ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir aId.realloc( 16 ); 394*cdf0e10cSrcweir rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir return aId; 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir // XServiceInfo 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir sal_Bool SAL_CALL SvUnoImageMapObject::supportsService( const ::rtl::OUString& ServiceName ) throw(RuntimeException) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir const Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); 404*cdf0e10cSrcweir const ::rtl::OUString * pArray = aSNL.getConstArray(); 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir const sal_Int32 nCount = aSNL.getLength(); 407*cdf0e10cSrcweir for( sal_Int32 i = 0; i < nCount; i++ ) 408*cdf0e10cSrcweir if( pArray[i] == ServiceName ) 409*cdf0e10cSrcweir return sal_True; 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir return sal_False; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SvUnoImageMapObject::getSupportedServiceNames() 415*cdf0e10cSrcweir throw(RuntimeException) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSNS( 2 ); 418*cdf0e10cSrcweir aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapObject" )); 419*cdf0e10cSrcweir switch( mnType ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir case IMAP_OBJ_POLYGON: 422*cdf0e10cSrcweir default: 423*cdf0e10cSrcweir aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapPolygonObject" )); 424*cdf0e10cSrcweir break; 425*cdf0e10cSrcweir case IMAP_OBJ_RECTANGLE: 426*cdf0e10cSrcweir aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapRectangleObject" )); 427*cdf0e10cSrcweir break; 428*cdf0e10cSrcweir case IMAP_OBJ_CIRCLE: 429*cdf0e10cSrcweir aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapCircleObject" )); 430*cdf0e10cSrcweir break; 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir return aSNS; 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvUnoImageMapObject::getImplementationName() throw(RuntimeException) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir switch( mnType ) 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir case IMAP_OBJ_POLYGON: 440*cdf0e10cSrcweir default: 441*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.svt.ImageMapPolygonObject") ); 442*cdf0e10cSrcweir case IMAP_OBJ_CIRCLE: 443*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.svt.ImageMapCircleObject") ); 444*cdf0e10cSrcweir case IMAP_OBJ_RECTANGLE: 445*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.svt.ImageMapRectangleObject") ); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir // overiden helpers from PropertySetHelper 450*cdf0e10cSrcweir void SvUnoImageMapObject::_setPropertyValues( const PropertyMapEntry** ppEntries, const Any* pValues ) 451*cdf0e10cSrcweir throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir sal_Bool bOk = sal_False; 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir while( *ppEntries ) 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir switch( (*ppEntries)->mnHandle ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir case HANDLE_URL: 460*cdf0e10cSrcweir bOk = *pValues >>= maURL; 461*cdf0e10cSrcweir break; 462*cdf0e10cSrcweir case HANDLE_TITLE: 463*cdf0e10cSrcweir bOk = *pValues >>= maAltText; 464*cdf0e10cSrcweir break; 465*cdf0e10cSrcweir case HANDLE_DESCRIPTION: 466*cdf0e10cSrcweir bOk = *pValues >>= maDesc; 467*cdf0e10cSrcweir break; 468*cdf0e10cSrcweir case HANDLE_TARGET: 469*cdf0e10cSrcweir bOk = *pValues >>= maTarget; 470*cdf0e10cSrcweir break; 471*cdf0e10cSrcweir case HANDLE_NAME: 472*cdf0e10cSrcweir bOk = *pValues >>= maName; 473*cdf0e10cSrcweir break; 474*cdf0e10cSrcweir case HANDLE_ISACTIVE: 475*cdf0e10cSrcweir bOk = *pValues >>= mbIsActive; 476*cdf0e10cSrcweir break; 477*cdf0e10cSrcweir case HANDLE_BOUNDARY: 478*cdf0e10cSrcweir bOk = *pValues >>= maBoundary; 479*cdf0e10cSrcweir break; 480*cdf0e10cSrcweir case HANDLE_CENTER: 481*cdf0e10cSrcweir bOk = *pValues >>= maCenter; 482*cdf0e10cSrcweir break; 483*cdf0e10cSrcweir case HANDLE_RADIUS: 484*cdf0e10cSrcweir bOk = *pValues >>= mnRadius; 485*cdf0e10cSrcweir break; 486*cdf0e10cSrcweir case HANDLE_POLYGON: 487*cdf0e10cSrcweir bOk = *pValues >>= maPolygon; 488*cdf0e10cSrcweir break; 489*cdf0e10cSrcweir default: 490*cdf0e10cSrcweir DBG_ERROR( "SvUnoImageMapObject::_setPropertyValues: unexpected property handle" ); 491*cdf0e10cSrcweir break; 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir if( !bOk ) 495*cdf0e10cSrcweir throw IllegalArgumentException(); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir ppEntries++; 498*cdf0e10cSrcweir pValues++; 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir void SvUnoImageMapObject::_getPropertyValues( const PropertyMapEntry** ppEntries, Any* pValues ) 503*cdf0e10cSrcweir throw(UnknownPropertyException, WrappedTargetException ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir while( *ppEntries ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir switch( (*ppEntries)->mnHandle ) 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir case HANDLE_URL: 510*cdf0e10cSrcweir *pValues <<= maURL; 511*cdf0e10cSrcweir break; 512*cdf0e10cSrcweir case HANDLE_TITLE: 513*cdf0e10cSrcweir *pValues <<= maAltText; 514*cdf0e10cSrcweir break; 515*cdf0e10cSrcweir case HANDLE_DESCRIPTION: 516*cdf0e10cSrcweir *pValues <<= maDesc; 517*cdf0e10cSrcweir break; 518*cdf0e10cSrcweir case HANDLE_TARGET: 519*cdf0e10cSrcweir *pValues <<= maTarget; 520*cdf0e10cSrcweir break; 521*cdf0e10cSrcweir case HANDLE_NAME: 522*cdf0e10cSrcweir *pValues <<= maName; 523*cdf0e10cSrcweir break; 524*cdf0e10cSrcweir case HANDLE_ISACTIVE: 525*cdf0e10cSrcweir *pValues <<= mbIsActive; 526*cdf0e10cSrcweir break; 527*cdf0e10cSrcweir case HANDLE_BOUNDARY: 528*cdf0e10cSrcweir *pValues <<= maBoundary; 529*cdf0e10cSrcweir break; 530*cdf0e10cSrcweir case HANDLE_CENTER: 531*cdf0e10cSrcweir *pValues <<= maCenter; 532*cdf0e10cSrcweir break; 533*cdf0e10cSrcweir case HANDLE_RADIUS: 534*cdf0e10cSrcweir *pValues <<= mnRadius; 535*cdf0e10cSrcweir break; 536*cdf0e10cSrcweir case HANDLE_POLYGON: 537*cdf0e10cSrcweir *pValues <<= maPolygon; 538*cdf0e10cSrcweir break; 539*cdf0e10cSrcweir default: 540*cdf0e10cSrcweir DBG_ERROR( "SvUnoImageMapObject::_getPropertyValues: unexpected property handle" ); 541*cdf0e10cSrcweir break; 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir ppEntries++; 545*cdf0e10cSrcweir pValues++; 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir Reference< XNameReplace > SAL_CALL SvUnoImageMapObject::getEvents() 551*cdf0e10cSrcweir throw( RuntimeException ) 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir // try weak reference first 554*cdf0e10cSrcweir Reference< XNameReplace > xEvents( mpEvents ); 555*cdf0e10cSrcweir return xEvents; 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir class SvUnoImageMap : public WeakImplHelper3< XIndexContainer, XServiceInfo, XUnoTunnel > 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir public: 563*cdf0e10cSrcweir SvUnoImageMap( const SvEventDescription* pSupportedMacroItems ); 564*cdf0e10cSrcweir SvUnoImageMap( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems ); 565*cdf0e10cSrcweir virtual ~SvUnoImageMap(); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir sal_Bool fillImageMap( ImageMap& rMap ) const; 568*cdf0e10cSrcweir SvUnoImageMapObject* getObject( const Any& aElement ) const throw( IllegalArgumentException ); 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_DECL( SvUnoImageMap ) 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir // XIndexContainer 573*cdf0e10cSrcweir virtual void SAL_CALL insertByIndex( sal_Int32 Index, const Any& Element ) throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); 574*cdf0e10cSrcweir virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir // XIndexReplace 577*cdf0e10cSrcweir virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const Any& Element ) throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir // XIndexAccess 580*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getCount( ) throw( RuntimeException ); 581*cdf0e10cSrcweir virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ); 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir // XElementAccess 584*cdf0e10cSrcweir virtual Type SAL_CALL getElementType( ) throw( RuntimeException ); 585*cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements( ) throw( RuntimeException ); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir // XSerivceInfo 588*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw( RuntimeException ); 589*cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( RuntimeException ); 590*cdf0e10cSrcweir virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw( RuntimeException ); 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir private: 593*cdf0e10cSrcweir ::rtl::OUString maName; 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir std::list< SvUnoImageMapObject* > maObjectList; 596*cdf0e10cSrcweir }; 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SvUnoImageMap ); 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir SvUnoImageMap::SvUnoImageMap( const SvEventDescription* ) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir SvUnoImageMap::SvUnoImageMap( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir maName = rMap.GetName(); 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir const sal_uInt16 nCount = rMap.GetIMapObjectCount(); 609*cdf0e10cSrcweir for( sal_uInt16 nPos = 0; nPos < nCount; nPos++ ) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir IMapObject* pMapObject = rMap.GetIMapObject( nPos ); 612*cdf0e10cSrcweir SvUnoImageMapObject* pUnoObj = new SvUnoImageMapObject( *pMapObject, pSupportedMacroItems ); 613*cdf0e10cSrcweir pUnoObj->acquire(); 614*cdf0e10cSrcweir maObjectList.push_back( pUnoObj ); 615*cdf0e10cSrcweir } 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir SvUnoImageMap::~SvUnoImageMap() 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin(); 621*cdf0e10cSrcweir const std::list< SvUnoImageMapObject* >::iterator aEnd = maObjectList.end(); 622*cdf0e10cSrcweir while( aIter != aEnd ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir (*aIter++)->release(); 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir SvUnoImageMapObject* SvUnoImageMap::getObject( const Any& aElement ) const 629*cdf0e10cSrcweir throw( IllegalArgumentException ) 630*cdf0e10cSrcweir { 631*cdf0e10cSrcweir Reference< XInterface > xObject; 632*cdf0e10cSrcweir aElement >>= xObject; 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir SvUnoImageMapObject* pObject = SvUnoImageMapObject::getImplementation( xObject ); 635*cdf0e10cSrcweir if( NULL == pObject ) 636*cdf0e10cSrcweir throw IllegalArgumentException(); 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir return pObject; 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir // XIndexContainer 642*cdf0e10cSrcweir void SAL_CALL SvUnoImageMap::insertByIndex( sal_Int32 Index, const Any& Element ) 643*cdf0e10cSrcweir throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir SvUnoImageMapObject* pObject = getObject( Element ); 646*cdf0e10cSrcweir const sal_Int32 nCount = maObjectList.size(); 647*cdf0e10cSrcweir if( NULL == pObject || Index > nCount ) 648*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir pObject->acquire(); 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir if( Index == nCount ) 653*cdf0e10cSrcweir maObjectList.push_back( pObject ); 654*cdf0e10cSrcweir else 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin(); 657*cdf0e10cSrcweir for( sal_Int32 n = 0; n < Index; n++ ) 658*cdf0e10cSrcweir aIter++; 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir maObjectList.insert( aIter, pObject ); 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir void SAL_CALL SvUnoImageMap::removeByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException) 665*cdf0e10cSrcweir { 666*cdf0e10cSrcweir const sal_Int32 nCount = maObjectList.size(); 667*cdf0e10cSrcweir if( Index >= nCount ) 668*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir if( nCount - 1 == Index ) 671*cdf0e10cSrcweir { 672*cdf0e10cSrcweir maObjectList.back()->release(); 673*cdf0e10cSrcweir maObjectList.pop_back(); 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir else 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin(); 678*cdf0e10cSrcweir for( sal_Int32 n = 0; n < Index; n++ ) 679*cdf0e10cSrcweir aIter++; 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir (*aIter)->release(); 682*cdf0e10cSrcweir maObjectList.erase( aIter ); 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir // XIndexReplace 687*cdf0e10cSrcweir void SAL_CALL SvUnoImageMap::replaceByIndex( sal_Int32 Index, const Any& Element ) throw(IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException) 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir SvUnoImageMapObject* pObject = getObject( Element ); 690*cdf0e10cSrcweir const sal_Int32 nCount = maObjectList.size(); 691*cdf0e10cSrcweir if( NULL == pObject || Index >= nCount ) 692*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin(); 695*cdf0e10cSrcweir for( sal_Int32 n = 0; n < Index; n++ ) 696*cdf0e10cSrcweir aIter++; 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir (*aIter)->release(); 699*cdf0e10cSrcweir *aIter = pObject; 700*cdf0e10cSrcweir pObject->acquire(); 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir // XIndexAccess 704*cdf0e10cSrcweir sal_Int32 SAL_CALL SvUnoImageMap::getCount( ) throw(RuntimeException) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir return maObjectList.size(); 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir Any SAL_CALL SvUnoImageMap::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException) 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir const sal_Int32 nCount = maObjectList.size(); 712*cdf0e10cSrcweir if( Index >= nCount ) 713*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir std::list< SvUnoImageMapObject* >::iterator aIter = maObjectList.begin(); 716*cdf0e10cSrcweir for( sal_Int32 n = 0; n < Index; n++ ) 717*cdf0e10cSrcweir aIter++; 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir Reference< XPropertySet > xObj( *aIter ); 720*cdf0e10cSrcweir return makeAny( xObj ); 721*cdf0e10cSrcweir } 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir // XElementAccess 724*cdf0e10cSrcweir Type SAL_CALL SvUnoImageMap::getElementType( ) throw(RuntimeException) 725*cdf0e10cSrcweir { 726*cdf0e10cSrcweir return ::getCppuType((const Reference< XPropertySet >*)0); 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir sal_Bool SAL_CALL SvUnoImageMap::hasElements( ) throw(RuntimeException) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir return maObjectList.size() != 0; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir // XSerivceInfo 735*cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvUnoImageMap::getImplementationName( ) 736*cdf0e10cSrcweir throw(RuntimeException) 737*cdf0e10cSrcweir { 738*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.svt.SvUnoImageMap" ) ); 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir sal_Bool SAL_CALL SvUnoImageMap::supportsService( const ::rtl::OUString& ServiceName ) 742*cdf0e10cSrcweir throw(RuntimeException) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir const Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); 745*cdf0e10cSrcweir const ::rtl::OUString * pArray = aSNL.getConstArray(); 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir const sal_Int32 nCount = aSNL.getLength(); 748*cdf0e10cSrcweir for( sal_Int32 i = 0; i < nCount; i++ ) 749*cdf0e10cSrcweir if( pArray[i] == ServiceName ) 750*cdf0e10cSrcweir return sal_True; 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir return sal_False; 753*cdf0e10cSrcweir } 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL SvUnoImageMap::getSupportedServiceNames( ) 756*cdf0e10cSrcweir throw(RuntimeException) 757*cdf0e10cSrcweir { 758*cdf0e10cSrcweir const ::rtl::OUString aSN( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.image.ImageMap" ) ); 759*cdf0e10cSrcweir return Sequence< ::rtl::OUString >( &aSN, 1 ); 760*cdf0e10cSrcweir } 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir sal_Bool SvUnoImageMap::fillImageMap( ImageMap& rMap ) const 763*cdf0e10cSrcweir { 764*cdf0e10cSrcweir rMap.ClearImageMap(); 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir rMap.SetName( maName ); 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir std::list< SvUnoImageMapObject* >::const_iterator aIter = maObjectList.begin(); 769*cdf0e10cSrcweir const std::list< SvUnoImageMapObject* >::const_iterator aEnd = maObjectList.end(); 770*cdf0e10cSrcweir while( aIter != aEnd ) 771*cdf0e10cSrcweir { 772*cdf0e10cSrcweir IMapObject* pNewMapObject = (*aIter)->createIMapObject(); 773*cdf0e10cSrcweir rMap.InsertIMapObject( *pNewMapObject ); 774*cdf0e10cSrcweir delete pNewMapObject; 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir aIter++; 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir return sal_True; 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir // ------------------------------------------------------------------- 783*cdf0e10cSrcweir // factory helper methods 784*cdf0e10cSrcweir // ------------------------------------------------------------------- 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir Reference< XInterface > SvUnoImageMapRectangleObject_createInstance( const SvEventDescription* pSupportedMacroItems ) 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir return (XWeak*)new SvUnoImageMapObject( IMAP_OBJ_RECTANGLE, pSupportedMacroItems ); 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir Reference< XInterface > SvUnoImageMapCircleObject_createInstance( const SvEventDescription* pSupportedMacroItems ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir return (XWeak*)new SvUnoImageMapObject( IMAP_OBJ_CIRCLE, pSupportedMacroItems ); 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir Reference< XInterface > SvUnoImageMapPolygonObject_createInstance( const SvEventDescription* pSupportedMacroItems ) 797*cdf0e10cSrcweir { 798*cdf0e10cSrcweir return (XWeak*)new SvUnoImageMapObject( IMAP_OBJ_POLYGON, pSupportedMacroItems ); 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir Reference< XInterface > SvUnoImageMap_createInstance( const SvEventDescription* pSupportedMacroItems ) 802*cdf0e10cSrcweir { 803*cdf0e10cSrcweir return (XWeak*)new SvUnoImageMap( pSupportedMacroItems ); 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir Reference< XInterface > SvUnoImageMap_createInstance( const ImageMap& rMap, const SvEventDescription* pSupportedMacroItems ) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir return (XWeak*)new SvUnoImageMap( rMap, pSupportedMacroItems ); 809*cdf0e10cSrcweir } 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir sal_Bool SvUnoImageMap_fillImageMap( Reference< XInterface > xImageMap, ImageMap& rMap ) 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir SvUnoImageMap* pUnoImageMap = SvUnoImageMap::getImplementation( xImageMap ); 814*cdf0e10cSrcweir if( NULL == pUnoImageMap ) 815*cdf0e10cSrcweir return sal_False; 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir return pUnoImageMap->fillImageMap( rMap ); 818*cdf0e10cSrcweir } 819