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