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