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