1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmloff.hxx"
30 #include "XMLImageMapContext.hxx"
31 #include <rtl/ustrbuf.hxx>
32 #include <com/sun/star/uno/Reference.h>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP
35 #include <com/sun/star/beans/XPropertySetInfo.hpp>
36 #endif
37 #include <com/sun/star/xml/sax/XAttributeList.hpp>
38 #include <com/sun/star/container/XIndexContainer.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
41 
42 #ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP
43 #include <com/sun/star/document/XEventsSupplier.hpp>
44 #endif
45 #include <com/sun/star/awt/Rectangle.hpp>
46 #include <xmloff/xmltoken.hxx>
47 #include <xmloff/xmlimp.hxx>
48 #include <xmloff/xmltkmap.hxx>
49 #include "xmloff/xmlnmspe.hxx"
50 #include <xmloff/nmspmap.hxx>
51 #include <xmloff/xmluconv.hxx>
52 #include "xexptran.hxx"
53 #include "xmloff/xmlerror.hxx"
54 #include <xmloff/XMLEventsImportContext.hxx>
55 #include "XMLStringBufferImportContext.hxx"
56 #include <tools/debug.hxx>
57 
58 
59 using namespace ::com::sun::star;
60 using namespace ::xmloff::token;
61 
62 using ::rtl::OUString;
63 using ::rtl::OUStringBuffer;
64 using ::com::sun::star::beans::XPropertySet;
65 using ::com::sun::star::beans::XPropertySetInfo;
66 using ::com::sun::star::container::XIndexContainer;
67 using ::com::sun::star::lang::XMultiServiceFactory;
68 using ::com::sun::star::uno::Reference;
69 using ::com::sun::star::uno::UNO_QUERY;
70 using ::com::sun::star::xml::sax::XAttributeList;
71 using ::com::sun::star::uno::XInterface;
72 using ::com::sun::star::uno::Any;
73 using ::com::sun::star::drawing::PointSequenceSequence;
74 using ::com::sun::star::document::XEventsSupplier;
75 
76 
77 enum XMLImageMapToken
78 {
79 	XML_TOK_IMAP_URL,
80 	XML_TOK_IMAP_X,
81 	XML_TOK_IMAP_Y,
82 	XML_TOK_IMAP_CENTER_X,
83 	XML_TOK_IMAP_CENTER_Y,
84 	XML_TOK_IMAP_WIDTH,
85 	XML_TOK_IMAP_HEIGTH,
86 	XML_TOK_IMAP_POINTS,
87 	XML_TOK_IMAP_VIEWBOX,
88 	XML_TOK_IMAP_NOHREF,
89 	XML_TOK_IMAP_NAME,
90 	XML_TOK_IMAP_RADIUS,
91 	XML_TOK_IMAP_TARGET
92 };
93 
94 static __FAR_DATA SvXMLTokenMapEntry aImageMapObjectTokenMap[] =
95 {
96 	{ XML_NAMESPACE_XLINK,	XML_HREF,			XML_TOK_IMAP_URL 			},
97 	{ XML_NAMESPACE_OFFICE,	XML_NAME,			XML_TOK_IMAP_NAME			},
98 	{ XML_NAMESPACE_DRAW,	XML_NOHREF, 		XML_TOK_IMAP_NOHREF			},
99 	{ XML_NAMESPACE_SVG,	XML_X,				XML_TOK_IMAP_X				},
100 	{ XML_NAMESPACE_SVG,	XML_Y,				XML_TOK_IMAP_Y				},
101 	{ XML_NAMESPACE_SVG,	XML_CX,			    XML_TOK_IMAP_CENTER_X		},
102 	{ XML_NAMESPACE_SVG,	XML_CY,			    XML_TOK_IMAP_CENTER_Y		},
103 	{ XML_NAMESPACE_SVG,	XML_WIDTH,			XML_TOK_IMAP_WIDTH			},
104 	{ XML_NAMESPACE_SVG,	XML_HEIGHT,		    XML_TOK_IMAP_HEIGTH			},
105 	{ XML_NAMESPACE_SVG,	XML_R,				XML_TOK_IMAP_RADIUS			},
106 	{ XML_NAMESPACE_SVG,	XML_VIEWBOX,		XML_TOK_IMAP_VIEWBOX		},
107 	{ XML_NAMESPACE_DRAW,	XML_POINTS,		    XML_TOK_IMAP_POINTS			},
108 	{ XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, XML_TOK_IMAP_TARGET		},
109 	XML_TOKEN_MAP_END
110 };
111 
112 
113 
114 class XMLImageMapObjectContext : public SvXMLImportContext
115 {
116 
117 protected:
118 
119 	const ::rtl::OUString sBoundary;
120 	const ::rtl::OUString sCenter;
121 	const ::rtl::OUString sTitle;
122 	const ::rtl::OUString sDescription;
123 	const ::rtl::OUString sImageMap;
124 	const ::rtl::OUString sIsActive;
125 	const ::rtl::OUString sName;
126 	const ::rtl::OUString sPolygon;
127 	const ::rtl::OUString sRadius;
128 	const ::rtl::OUString sTarget;
129 	const ::rtl::OUString sURL;
130 
131 	::rtl::OUString sServiceName;
132 
133 	Reference<XIndexContainer> xImageMap;	/// the image map
134 	Reference<XPropertySet> xMapEntry;		/// one map-entry (one area)
135 
136 	::rtl::OUString sUrl;
137 	::rtl::OUString sTargt;
138 	::rtl::OUStringBuffer sDescriptionBuffer;
139 	::rtl::OUStringBuffer sTitleBuffer;
140 	::rtl::OUString sNam;
141 	sal_Bool bIsActive;
142 
143 	sal_Bool bValid;
144 
145 public:
146 	TYPEINFO();
147 
148 	XMLImageMapObjectContext(
149 		SvXMLImport& rImport,
150 		sal_uInt16 nPrefix,
151 		const ::rtl::OUString& rLocalName,
152 		::com::sun::star::uno::Reference<
153 			::com::sun::star::container::XIndexContainer> xMap,
154 		const sal_Char* pServiceName);
155 
156 	void StartElement(
157 		const ::com::sun::star::uno::Reference<
158 		::com::sun::star::xml::sax::XAttributeList >& xAttrList );
159 
160 	void EndElement();
161 
162 	SvXMLImportContext *CreateChildContext(
163 		sal_uInt16 nPrefix,
164 		const ::rtl::OUString& rLocalName,
165 		const ::com::sun::star::uno::Reference<
166 			::com::sun::star::xml::sax::XAttributeList> & xAttrList );
167 
168 protected:
169 
170 	virtual void ProcessAttribute(
171 		enum XMLImageMapToken eToken,
172 		const ::rtl::OUString& rValue);
173 
174 	virtual void Prepare(
175 		::com::sun::star::uno::Reference<
176 			::com::sun::star::beans::XPropertySet> & rPropertySet);
177 };
178 
179 
180 TYPEINIT1( XMLImageMapObjectContext, SvXMLImportContext );
181 
182 XMLImageMapObjectContext::XMLImageMapObjectContext(
183 	SvXMLImport& rImport,
184 	sal_uInt16 nPrefix,
185 	const OUString& rLocalName,
186 	Reference<XIndexContainer> xMap,
187 	const sal_Char* pServiceName) :
188 		SvXMLImportContext(rImport, nPrefix, rLocalName),
189 		sBoundary(RTL_CONSTASCII_USTRINGPARAM("Boundary")),
190 		sCenter(RTL_CONSTASCII_USTRINGPARAM("Center")),
191 		sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")),
192 		sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")),
193 		sImageMap(RTL_CONSTASCII_USTRINGPARAM("ImageMap")),
194 		sIsActive(RTL_CONSTASCII_USTRINGPARAM("IsActive")),
195 		sName(RTL_CONSTASCII_USTRINGPARAM("Name")),
196 		sPolygon(RTL_CONSTASCII_USTRINGPARAM("Polygon")),
197 		sRadius(RTL_CONSTASCII_USTRINGPARAM("Radius")),
198 		sTarget(RTL_CONSTASCII_USTRINGPARAM("Target")),
199 		sURL(RTL_CONSTASCII_USTRINGPARAM("URL")),
200 		xImageMap(xMap),
201 		bIsActive(sal_True),
202 		bValid(sal_False)
203 {
204 	DBG_ASSERT(NULL != pServiceName,
205 			   "Please supply the image map object service name");
206 
207 	Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY);
208 	if( xFactory.is() )
209 	{
210 		Reference<XInterface> xIfc = xFactory->createInstance(
211 			OUString::createFromAscii(pServiceName));
212 		DBG_ASSERT(xIfc.is(), "can't create image map object!");
213 		if( xIfc.is() )
214 		{
215 			Reference<XPropertySet> xPropertySet( xIfc, UNO_QUERY );
216 
217 			xMapEntry = xPropertySet;
218 		}
219 		// else: can't create service -> ignore
220 	}
221 	// else: can't even get factory -> ignore
222 }
223 
224 void XMLImageMapObjectContext::StartElement(
225 	const Reference<XAttributeList >& xAttrList )
226 {
227 	SvXMLTokenMap aMap(aImageMapObjectTokenMap);
228 
229 	sal_Int16 nLength = xAttrList->getLength();
230 	for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
231 	{
232 		OUString sLocalName;
233 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
234 			GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
235 							  &sLocalName );
236 		OUString sValue = xAttrList->getValueByIndex(nAttr);
237 
238 		ProcessAttribute(
239 			(enum XMLImageMapToken)aMap.Get(nPrefix, sLocalName), sValue);
240 	}
241 }
242 
243 void XMLImageMapObjectContext::EndElement()
244 {
245 	// only create and insert image map object if validity flag is set
246 	// (and we actually have an image map)
247 	if ( bValid && xImageMap.is() && xMapEntry.is() )
248 	{
249 		// set values
250 		Prepare( xMapEntry );
251 
252 		// insert into image map
253 		Any aAny;
254 		aAny <<= xMapEntry;
255 		xImageMap->insertByIndex( xImageMap->getCount(), aAny );
256 	}
257 	// else: not valid -> don't create and insert
258 }
259 
260 SvXMLImportContext* XMLImageMapObjectContext::CreateChildContext(
261 	sal_uInt16 nPrefix,
262 	const OUString& rLocalName,
263 	const Reference<XAttributeList> & xAttrList )
264 {
265 	if ( (XML_NAMESPACE_OFFICE == nPrefix) &&
266 		 IsXMLToken(rLocalName, XML_EVENT_LISTENERS) )
267 	{
268 		Reference<XEventsSupplier> xEvents( xMapEntry, UNO_QUERY );
269 		return new XMLEventsImportContext(
270 			GetImport(), nPrefix, rLocalName, xEvents);
271 	}
272 	else if ( (XML_NAMESPACE_SVG == nPrefix) &&
273 			  IsXMLToken(rLocalName, XML_TITLE) )
274 	{
275 		return new XMLStringBufferImportContext(
276 			GetImport(), nPrefix, rLocalName, sTitleBuffer);
277 	}
278 	else if ( (XML_NAMESPACE_SVG == nPrefix) &&
279 			  IsXMLToken(rLocalName, XML_DESC) )
280 	{
281 		return new XMLStringBufferImportContext(
282 			GetImport(), nPrefix, rLocalName, sDescriptionBuffer);
283 	}
284 	else
285 		return SvXMLImportContext::CreateChildContext(nPrefix, rLocalName,
286 													  xAttrList);
287 
288 }
289 
290 void XMLImageMapObjectContext::ProcessAttribute(
291 	enum XMLImageMapToken eToken,
292 	const OUString& rValue)
293 {
294 	switch (eToken)
295 	{
296 		case XML_TOK_IMAP_URL:
297 			sUrl = GetImport().GetAbsoluteReference(rValue);
298 			break;
299 
300 		case XML_TOK_IMAP_TARGET:
301 			sTargt = rValue;
302 			break;
303 
304 		case XML_TOK_IMAP_NOHREF:
305 			bIsActive = ! IsXMLToken(rValue, XML_NOHREF);
306 			break;
307 
308 		case XML_TOK_IMAP_NAME:
309 			sNam = rValue;
310 			break;
311 		default:
312 			// do nothing
313 			break;
314 	}
315 }
316 
317 void XMLImageMapObjectContext::Prepare(
318 	Reference<XPropertySet> & rPropertySet)
319 {
320 	rPropertySet->setPropertyValue( sURL, Any( sUrl ) );
321 	rPropertySet->setPropertyValue( sTitle, Any( sTitleBuffer.makeStringAndClear() ) );
322 	rPropertySet->setPropertyValue( sDescription, Any( sDescriptionBuffer.makeStringAndClear() ) );
323 	rPropertySet->setPropertyValue( sTarget, Any( sTargt ) );
324 	rPropertySet->setPropertyValue( sIsActive, Any( bIsActive ) );
325 	rPropertySet->setPropertyValue( sName, Any( sNam ) );
326 }
327 
328 
329 
330 class XMLImageMapRectangleContext : public XMLImageMapObjectContext
331 {
332 	awt::Rectangle aRectangle;
333 
334 	sal_Bool bXOK;
335 	sal_Bool bYOK;
336 	sal_Bool bWidthOK;
337 	sal_Bool bHeightOK;
338 
339 public:
340 	TYPEINFO();
341 
342 	XMLImageMapRectangleContext(
343 		SvXMLImport& rImport,
344 		sal_uInt16 nPrefix,
345 		const ::rtl::OUString& rLocalName,
346 		::com::sun::star::uno::Reference<
347 			::com::sun::star::container::XIndexContainer> xMap);
348 
349 	virtual ~XMLImageMapRectangleContext();
350 
351 protected:
352 	virtual void ProcessAttribute(
353 		enum XMLImageMapToken eToken,
354 		const ::rtl::OUString& rValue);
355 
356 	virtual void Prepare(
357 		::com::sun::star::uno::Reference<
358 			::com::sun::star::beans::XPropertySet> & rPropertySet);
359 };
360 
361 
362 
363 TYPEINIT1(XMLImageMapRectangleContext, XMLImageMapObjectContext);
364 
365 XMLImageMapRectangleContext::XMLImageMapRectangleContext(
366 	SvXMLImport& rImport,
367 	sal_uInt16 nPrefix,
368 	const OUString& rLocalName,
369 	Reference<XIndexContainer> xMap) :
370 		XMLImageMapObjectContext(rImport, nPrefix, rLocalName, xMap,
371 								 "com.sun.star.image.ImageMapRectangleObject"),
372 		bXOK(sal_False),
373 		bYOK(sal_False),
374 		bWidthOK(sal_False),
375 		bHeightOK(sal_False)
376 {
377 }
378 
379 XMLImageMapRectangleContext::~XMLImageMapRectangleContext()
380 {
381 }
382 
383 void XMLImageMapRectangleContext::ProcessAttribute(
384 	enum XMLImageMapToken eToken,
385 	const OUString& rValue)
386 {
387 	sal_Int32 nTmp;
388 	switch (eToken)
389 	{
390 		case XML_TOK_IMAP_X:
391 			if (GetImport().GetMM100UnitConverter().convertMeasure(nTmp,
392 																   rValue))
393 			{
394 				aRectangle.X = nTmp;
395 				bXOK = sal_True;
396 			}
397 			break;
398 		case XML_TOK_IMAP_Y:
399 			if (GetImport().GetMM100UnitConverter().convertMeasure(nTmp,
400 																   rValue))
401 			{
402 				aRectangle.Y = nTmp;
403 				bYOK = sal_True;
404 			}
405 			break;
406 		case XML_TOK_IMAP_WIDTH:
407 			if (GetImport().GetMM100UnitConverter().convertMeasure(nTmp,
408 																   rValue))
409 			{
410 				aRectangle.Width = nTmp;
411 				bWidthOK = sal_True;
412 			}
413 			break;
414 		case XML_TOK_IMAP_HEIGTH:
415 			if (GetImport().GetMM100UnitConverter().convertMeasure(nTmp,
416 																   rValue))
417 			{
418 				aRectangle.Height = nTmp;
419 				bHeightOK = sal_True;
420 			}
421 			break;
422 		default:
423 			XMLImageMapObjectContext::ProcessAttribute(eToken, rValue);
424 	}
425 
426 	bValid = bHeightOK && bXOK && bYOK && bWidthOK;
427 }
428 
429 void XMLImageMapRectangleContext::Prepare(
430 	Reference<XPropertySet> & rPropertySet)
431 {
432 	Any aAny;
433 	aAny <<= aRectangle;
434 	rPropertySet->setPropertyValue( sBoundary, aAny );
435 
436 	// common properties handled by super class
437 	XMLImageMapObjectContext::Prepare(rPropertySet);
438 }
439 
440 
441 class XMLImageMapPolygonContext : public XMLImageMapObjectContext
442 {
443 	::rtl::OUString sViewBoxString;
444 	::rtl::OUString sPointsString;
445 
446 	sal_Bool bViewBoxOK;
447 	sal_Bool bPointsOK;
448 
449 public:
450 	TYPEINFO();
451 
452 	XMLImageMapPolygonContext(
453 		SvXMLImport& rImport,
454 		sal_uInt16 nPrefix,
455 		const ::rtl::OUString& rLocalName,
456 		::com::sun::star::uno::Reference<
457 			::com::sun::star::container::XIndexContainer> xMap);
458 
459 	virtual ~XMLImageMapPolygonContext();
460 
461 protected:
462 	virtual void ProcessAttribute(
463 		enum XMLImageMapToken eToken,
464 		const ::rtl::OUString& rValue);
465 
466 	virtual void Prepare(
467 		::com::sun::star::uno::Reference<
468 			::com::sun::star::beans::XPropertySet> & rPropertySet);
469 };
470 
471 
472 
473 TYPEINIT1(XMLImageMapPolygonContext, XMLImageMapObjectContext);
474 
475 XMLImageMapPolygonContext::XMLImageMapPolygonContext(
476 	SvXMLImport& rImport,
477 	sal_uInt16 nPrefix,
478 	const OUString& rLocalName,
479 	Reference<XIndexContainer> xMap) :
480 		XMLImageMapObjectContext(rImport, nPrefix, rLocalName, xMap,
481 								 "com.sun.star.image.ImageMapPolygonObject"),
482 		bViewBoxOK(sal_False),
483 		bPointsOK(sal_False)
484 {
485 }
486 
487 XMLImageMapPolygonContext::~XMLImageMapPolygonContext()
488 {
489 }
490 
491 void XMLImageMapPolygonContext::ProcessAttribute(
492 	enum XMLImageMapToken eToken,
493 	const OUString& rValue)
494 {
495 	switch (eToken)
496 	{
497 		case XML_TOK_IMAP_POINTS:
498 			sPointsString = rValue;
499 			bPointsOK = sal_True;
500 			break;
501 		case XML_TOK_IMAP_VIEWBOX:
502 			sViewBoxString = rValue;
503 			bViewBoxOK = sal_True;
504 			break;
505 		default:
506 			XMLImageMapObjectContext::ProcessAttribute(eToken, rValue);
507 			break;
508 	}
509 
510 	bValid = bViewBoxOK && bPointsOK;
511 }
512 
513 void XMLImageMapPolygonContext::Prepare(
514 	Reference<XPropertySet> & rPropertySet)
515 {
516 	// process view box
517 	SdXMLImExViewBox aViewBox(sViewBoxString,
518 							  GetImport().GetMM100UnitConverter());
519 
520 	// get polygon sequence
521 	awt::Point aPoint(aViewBox.GetX(), aViewBox.GetY());
522 	awt::Size aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
523 	SdXMLImExPointsElement aPoints( sPointsString, aViewBox, aPoint, aSize,
524 									GetImport().GetMM100UnitConverter() );
525 	PointSequenceSequence aPointSeqSeq = aPoints.GetPointSequenceSequence();
526 
527 	// only use first element of sequence-sequence
528 	if (aPointSeqSeq.getLength() > 0)
529 	{
530 		Any aAny;
531 		aAny <<= aPointSeqSeq[0];
532 		rPropertySet->setPropertyValue(sPolygon, aAny);
533 	}
534 
535 	// parent properties
536 	XMLImageMapObjectContext::Prepare(rPropertySet);
537 }
538 
539 
540 
541 class XMLImageMapCircleContext : public XMLImageMapObjectContext
542 {
543 	awt::Point aCenter;
544 	sal_Int32 nRadius;
545 
546 	sal_Bool bXOK;
547 	sal_Bool bYOK;
548 	sal_Bool bRadiusOK;
549 
550 public:
551 	TYPEINFO();
552 
553 	XMLImageMapCircleContext(
554 		SvXMLImport& rImport,
555 		sal_uInt16 nPrefix,
556 		const ::rtl::OUString& rLocalName,
557 		::com::sun::star::uno::Reference<
558 			::com::sun::star::container::XIndexContainer> xMap);
559 
560 	virtual ~XMLImageMapCircleContext();
561 
562 protected:
563 	virtual void ProcessAttribute(
564 		enum XMLImageMapToken eToken,
565 		const ::rtl::OUString& rValue);
566 
567 	virtual void Prepare(
568 		::com::sun::star::uno::Reference<
569 			::com::sun::star::beans::XPropertySet> & rPropertySet);
570 };
571 
572 TYPEINIT1(XMLImageMapCircleContext, XMLImageMapObjectContext);
573 
574 XMLImageMapCircleContext::XMLImageMapCircleContext(
575 	SvXMLImport& rImport,
576 	sal_uInt16 nPrefix,
577 	const OUString& rLocalName,
578 	Reference<XIndexContainer> xMap) :
579 		XMLImageMapObjectContext(rImport, nPrefix, rLocalName, xMap,
580 								 "com.sun.star.image.ImageMapCircleObject"),
581 		bXOK(sal_False),
582 		bYOK(sal_False),
583 		bRadiusOK(sal_False)
584 {
585 }
586 
587 XMLImageMapCircleContext::~XMLImageMapCircleContext()
588 {
589 }
590 
591 void XMLImageMapCircleContext::ProcessAttribute(
592 	enum XMLImageMapToken eToken,
593 	const OUString& rValue)
594 {
595 	sal_Int32 nTmp;
596 	switch (eToken)
597 	{
598 		case XML_TOK_IMAP_CENTER_X:
599 			if (GetImport().GetMM100UnitConverter().convertMeasure(nTmp,
600 																   rValue))
601 			{
602 				aCenter.X = nTmp;
603 				bXOK = sal_True;
604 			}
605 			break;
606 		case XML_TOK_IMAP_CENTER_Y:
607 			if (GetImport().GetMM100UnitConverter().convertMeasure(nTmp,
608 																   rValue))
609 			{
610 				aCenter.Y = nTmp;
611 				bYOK = sal_True;
612 			}
613 			break;
614 		case XML_TOK_IMAP_RADIUS:
615 			if (GetImport().GetMM100UnitConverter().convertMeasure(nTmp,
616 																   rValue))
617 			{
618 				nRadius = nTmp;
619 				bRadiusOK = sal_True;
620 			}
621 			break;
622 		default:
623 			XMLImageMapObjectContext::ProcessAttribute(eToken, rValue);
624 	}
625 
626 	bValid = bRadiusOK && bXOK && bYOK;
627 }
628 
629 void XMLImageMapCircleContext::Prepare(
630 	Reference<XPropertySet> & rPropertySet)
631 {
632 	// center (x,y)
633 	Any aAny;
634 	aAny <<= aCenter;
635 	rPropertySet->setPropertyValue( sCenter, aAny );
636 
637 	// radius
638 	aAny <<= nRadius;
639 	rPropertySet->setPropertyValue( sRadius, aAny );
640 
641 	// common properties handled by super class
642 	XMLImageMapObjectContext::Prepare(rPropertySet);
643 }
644 
645 
646 
647 
648 
649 
650 
651 
652 
653 
654 TYPEINIT1(XMLImageMapContext, SvXMLImportContext);
655 
656 XMLImageMapContext::XMLImageMapContext(
657 	SvXMLImport& rImport,
658 	sal_uInt16 nPrefix,
659 	const OUString& rLocalName,
660 	Reference<XPropertySet> & rPropertySet) :
661 		SvXMLImportContext(rImport, nPrefix, rLocalName),
662 		sImageMap(RTL_CONSTASCII_USTRINGPARAM("ImageMap")),
663 		xPropertySet(rPropertySet)
664 
665 {
666 	try
667 	{
668 		Reference < XPropertySetInfo > xInfo =
669 			xPropertySet->getPropertySetInfo();
670 		if( xInfo.is() && xInfo->hasPropertyByName( sImageMap ) )
671 			xPropertySet->getPropertyValue(sImageMap) >>= xImageMap;
672 	}
673 	catch( com::sun::star::uno::Exception e )
674 	{
675 		uno::Sequence<OUString> aSeq(0);
676         rImport.SetError( XMLERROR_FLAG_WARNING | XMLERROR_API, aSeq, e.Message, NULL );
677 	}
678 }
679 
680 XMLImageMapContext::~XMLImageMapContext()
681 {
682 }
683 
684 SvXMLImportContext *XMLImageMapContext::CreateChildContext(
685 	sal_uInt16 nPrefix,
686 	const OUString& rLocalName,
687 	const Reference<XAttributeList> & xAttrList )
688 {
689 	SvXMLImportContext* pContext = NULL;
690 
691 	if ( XML_NAMESPACE_DRAW == nPrefix )
692 	{
693 		if ( IsXMLToken(rLocalName, XML_AREA_RECTANGLE) )
694 		{
695 			pContext = new XMLImageMapRectangleContext(
696 				GetImport(), nPrefix, rLocalName, xImageMap);
697 		}
698 		else if ( IsXMLToken(rLocalName, XML_AREA_POLYGON) )
699 		{
700 			pContext = new XMLImageMapPolygonContext(
701 				GetImport(), nPrefix, rLocalName, xImageMap);
702 		}
703 		else if ( IsXMLToken(rLocalName, XML_AREA_CIRCLE) )
704 		{
705 			pContext = new XMLImageMapCircleContext(
706 				GetImport(), nPrefix, rLocalName, xImageMap);
707 		}
708 	}
709 	else
710 		pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName,
711 														  xAttrList);
712 
713 	return pContext;
714 }
715 
716 void XMLImageMapContext::EndElement()
717 {
718 	Reference < XPropertySetInfo > xInfo =
719 		xPropertySet->getPropertySetInfo();
720 	if( xInfo.is() && xInfo->hasPropertyByName( sImageMap ) )
721 		xPropertySet->setPropertyValue(sImageMap, uno::makeAny( xImageMap ) );
722 }
723 
724