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 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_xmloff.hxx" 26 #include <tools/debug.hxx> 27 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28 #include <com/sun/star/text/TextContentAnchorType.hpp> 29 #include <com/sun/star/beans/XPropertySet.hpp> 30 #include <com/sun/star/text/XTextFrame.hpp> 31 #include <com/sun/star/container/XNamed.hpp> 32 #include <com/sun/star/text/SizeType.hpp> 33 #include <com/sun/star/drawing/XShape.hpp> 34 #include <com/sun/star/document/XEventsSupplier.hpp> 35 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp> 36 #include <com/sun/star/io/XOutputStream.hpp> 37 #include <com/sun/star/text/HoriOrientation.hpp> 38 #include <com/sun/star/text/VertOrientation.hpp> 39 #include <xmloff/xmlimp.hxx> 40 #include <xmloff/xmltoken.hxx> 41 #include "xmloff/xmlnmspe.hxx" 42 #include <xmloff/nmspmap.hxx> 43 #include <xmloff/xmluconv.hxx> 44 #include "XMLAnchorTypePropHdl.hxx" 45 #include "XMLEmbeddedObjectImportContext.hxx" 46 #include <xmloff/XMLBase64ImportContext.hxx> 47 #include "XMLReplacementImageContext.hxx" 48 #include <xmloff/prstylei.hxx> 49 #include "xmloff/i18nmap.hxx" 50 #include "xexptran.hxx" 51 #include <xmloff/shapeimport.hxx> 52 #include <xmloff/XMLEventsImportContext.hxx> 53 #include "XMLImageMapContext.hxx" 54 #include "XMLTextFrameContext.hxx" 55 56 #include "XMLTextListBlockContext.hxx" 57 #include "XMLTextListItemContext.hxx" 58 #include <xmloff/attrlist.hxx> 59 #include <comphelper/stl_types.hxx> 60 61 #include <map> 62 63 64 using ::rtl::OUString; 65 using ::rtl::OUStringBuffer; 66 67 using namespace ::com::sun::star; 68 using namespace ::com::sun::star::uno; 69 using namespace ::com::sun::star::text; 70 using namespace ::com::sun::star::xml::sax; 71 using namespace ::com::sun::star::beans; 72 using namespace ::com::sun::star::lang; 73 using namespace ::com::sun::star::container; 74 using namespace ::com::sun::star::drawing; 75 using namespace ::com::sun::star::document; 76 using namespace ::xmloff::token; 77 using ::com::sun::star::document::XEventsSupplier; 78 79 #define XML_TEXT_FRAME_TEXTBOX 1 80 #define XML_TEXT_FRAME_GRAPHIC 2 81 #define XML_TEXT_FRAME_OBJECT 3 82 #define XML_TEXT_FRAME_OBJECT_OLE 4 83 #define XML_TEXT_FRAME_APPLET 5 84 #define XML_TEXT_FRAME_PLUGIN 6 85 #define XML_TEXT_FRAME_FLOATING_FRAME 7 86 87 typedef ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess> ParamMap; 88 89 class XMLTextFrameContextHyperlink_Impl 90 { 91 OUString sHRef; 92 OUString sName; 93 OUString sTargetFrameName; 94 sal_Bool bMap; 95 96 public: 97 98 inline XMLTextFrameContextHyperlink_Impl( const OUString& rHRef, 99 const OUString& rName, 100 const OUString& rTargetFrameName, 101 sal_Bool bMap ); 102 103 const OUString& GetHRef() const { return sHRef; } 104 const OUString& GetName() const { return sName; } 105 const OUString& GetTargetFrameName() const { return sTargetFrameName; } 106 sal_Bool GetMap() const { return bMap; } 107 }; 108 109 inline XMLTextFrameContextHyperlink_Impl::XMLTextFrameContextHyperlink_Impl( 110 const OUString& rHRef, const OUString& rName, 111 const OUString& rTargetFrameName, sal_Bool bM ) : 112 sHRef( rHRef ), 113 sName( rName ), 114 sTargetFrameName( rTargetFrameName ), 115 bMap( bM ) 116 { 117 } 118 119 // --> OD 2009-07-22 #i73249# 120 class XMLTextFrameTitleOrDescContext_Impl : public SvXMLImportContext 121 { 122 OUString& mrTitleOrDesc; 123 124 public: 125 126 TYPEINFO(); 127 128 XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport, 129 sal_uInt16 nPrfx, 130 const ::rtl::OUString& rLName, 131 OUString& rTitleOrDesc ); 132 virtual ~XMLTextFrameTitleOrDescContext_Impl(); 133 134 virtual void Characters( const OUString& rText ); 135 }; 136 137 TYPEINIT1( XMLTextFrameTitleOrDescContext_Impl, SvXMLImportContext ); 138 139 XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl( 140 SvXMLImport& rImport, 141 sal_uInt16 nPrfx, 142 const OUString& rLName, 143 OUString& rTitleOrDesc ) 144 : SvXMLImportContext( rImport, nPrfx, rLName ) 145 , mrTitleOrDesc( rTitleOrDesc ) 146 { 147 } 148 149 XMLTextFrameTitleOrDescContext_Impl::~XMLTextFrameTitleOrDescContext_Impl() 150 { 151 } 152 153 void XMLTextFrameTitleOrDescContext_Impl::Characters( const OUString& rText ) 154 { 155 mrTitleOrDesc += rText; 156 } 157 // <-- 158 159 // ------------------------------------------------------------------------ 160 161 class XMLTextFrameParam_Impl : public SvXMLImportContext 162 { 163 public: 164 165 TYPEINFO(); 166 167 XMLTextFrameParam_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx, 168 const ::rtl::OUString& rLName, 169 const ::com::sun::star::uno::Reference< 170 ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 171 sal_uInt16 nType, 172 ParamMap &rParamMap); 173 virtual ~XMLTextFrameParam_Impl(); 174 }; 175 176 TYPEINIT1( XMLTextFrameParam_Impl, SvXMLImportContext ); 177 178 XMLTextFrameParam_Impl::~XMLTextFrameParam_Impl() 179 { 180 } 181 182 XMLTextFrameParam_Impl::XMLTextFrameParam_Impl( 183 SvXMLImport& rImport, sal_uInt16 nPrfx, 184 const ::rtl::OUString& rLName, 185 const ::com::sun::star::uno::Reference< 186 ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 187 sal_uInt16 /*nType*/, 188 ParamMap &rParamMap): 189 SvXMLImportContext( rImport, nPrfx, rLName ) 190 { 191 OUString sName, sValue; 192 sal_Bool bFoundValue = sal_False; // to allow empty values 193 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 194 for( sal_Int16 i=0; i < nAttrCount; i++ ) 195 { 196 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 197 const OUString& rValue = xAttrList->getValueByIndex( i ); 198 199 OUString aLocalName; 200 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); 201 if ( XML_NAMESPACE_DRAW == nPrefix ) 202 { 203 if( IsXMLToken(aLocalName, XML_VALUE) ) 204 { 205 sValue = rValue; 206 bFoundValue=sal_True; 207 } 208 else if( IsXMLToken(aLocalName, XML_NAME) ) 209 { 210 sName = rValue; 211 } 212 } 213 } 214 if (sName.getLength() && bFoundValue ) 215 rParamMap[sName] = sValue; 216 } 217 class XMLTextFrameContourContext_Impl : public SvXMLImportContext 218 { 219 Reference < XPropertySet > xPropSet; 220 221 public: 222 223 TYPEINFO(); 224 225 XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx, 226 const ::rtl::OUString& rLName, 227 const ::com::sun::star::uno::Reference< 228 ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 229 const Reference < XPropertySet >& rPropSet, 230 sal_Bool bPath ); 231 virtual ~XMLTextFrameContourContext_Impl(); 232 }; 233 234 TYPEINIT1( XMLTextFrameContourContext_Impl, SvXMLImportContext ); 235 236 XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl( 237 SvXMLImport& rImport, 238 sal_uInt16 nPrfx, const OUString& rLName, 239 const Reference< XAttributeList > & xAttrList, 240 const Reference < XPropertySet >& rPropSet, 241 sal_Bool bPath ) : 242 SvXMLImportContext( rImport, nPrfx, rLName ), 243 xPropSet( rPropSet ) 244 { 245 OUString sD, sPoints, sViewBox; 246 sal_Bool bPixelWidth = sal_False, bPixelHeight = sal_False; 247 sal_Bool bAuto = sal_False; 248 sal_Int32 nWidth = 0; 249 sal_Int32 nHeight = 0; 250 251 const SvXMLTokenMap& rTokenMap = 252 GetImport().GetTextImport()->GetTextContourAttrTokenMap(); 253 254 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 255 for( sal_Int16 i=0; i < nAttrCount; i++ ) 256 { 257 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 258 const OUString& rValue = xAttrList->getValueByIndex( i ); 259 260 OUString aLocalName; 261 sal_uInt16 nPrefix = 262 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 263 &aLocalName ); 264 switch( rTokenMap.Get( nPrefix, aLocalName ) ) 265 { 266 case XML_TOK_TEXT_CONTOUR_VIEWBOX: 267 sViewBox = rValue; 268 break; 269 case XML_TOK_TEXT_CONTOUR_D: 270 if( bPath ) 271 sD = rValue; 272 break; 273 case XML_TOK_TEXT_CONTOUR_POINTS: 274 if( !bPath ) 275 sPoints = rValue; 276 break; 277 case XML_TOK_TEXT_CONTOUR_WIDTH: 278 if( GetImport().GetMM100UnitConverter().convertMeasurePx( nWidth, 279 rValue) ) 280 bPixelWidth = sal_True; 281 else 282 GetImport().GetMM100UnitConverter().convertMeasure( nWidth, 283 rValue); 284 break; 285 case XML_TOK_TEXT_CONTOUR_HEIGHT: 286 if( GetImport().GetMM100UnitConverter().convertMeasurePx( nHeight, 287 rValue) ) 288 bPixelHeight = sal_True; 289 else 290 GetImport().GetMM100UnitConverter().convertMeasure( nHeight, 291 rValue); 292 break; 293 case XML_TOK_TEXT_CONTOUR_AUTO: 294 bAuto = IsXMLToken(rValue, XML_TRUE); 295 break; 296 } 297 } 298 299 OUString sContourPolyPolygon( 300 RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon") ); 301 Reference < XPropertySetInfo > xPropSetInfo = 302 rPropSet->getPropertySetInfo(); 303 if( xPropSetInfo->hasPropertyByName( 304 sContourPolyPolygon ) && 305 nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && 306 (bPath ? sD : sPoints).getLength() ) 307 { 308 awt::Point aPoint( 0, 0 ); 309 awt::Size aSize( nWidth, nHeight ); 310 SdXMLImExViewBox aViewBox( sViewBox, 311 GetImport().GetMM100UnitConverter()); 312 Any aAny; 313 if( bPath ) 314 { 315 SdXMLImExSvgDElement aPoints( sD, aViewBox, aPoint, aSize, 316 GetImport().GetMM100UnitConverter() ); 317 aAny <<= aPoints.GetPointSequenceSequence(); 318 } 319 else 320 { 321 SdXMLImExPointsElement aPoints( sPoints, aViewBox, aPoint, aSize, 322 GetImport().GetMM100UnitConverter() ); 323 aAny <<= aPoints.GetPointSequenceSequence(); 324 } 325 326 OUString sIsPixelContour( 327 RTL_CONSTASCII_USTRINGPARAM("IsPixelContour") ); 328 xPropSet->setPropertyValue( sContourPolyPolygon, aAny ); 329 330 if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) ) 331 { 332 aAny.setValue( &bPixelWidth, ::getBooleanCppuType() ); 333 xPropSet->setPropertyValue( sIsPixelContour, aAny ); 334 } 335 336 OUString sIsAutomaticContour( 337 RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour") ); 338 if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) 339 { 340 aAny.setValue( &bAuto, ::getBooleanCppuType() ); 341 xPropSet->setPropertyValue( sIsAutomaticContour, aAny ); 342 } 343 } 344 } 345 346 XMLTextFrameContourContext_Impl::~XMLTextFrameContourContext_Impl() 347 { 348 } 349 350 // ------------------------------------------------------------------------ 351 352 class XMLTextFrameContext_Impl : public SvXMLImportContext 353 { 354 ::com::sun::star::uno::Reference < 355 ::com::sun::star::text::XTextCursor > xOldTextCursor; 356 ::com::sun::star::uno::Reference < 357 ::com::sun::star::beans::XPropertySet > xPropSet; 358 ::com::sun::star::uno::Reference < 359 ::com::sun::star::io::XOutputStream > xBase64Stream; 360 361 /// old list item and block (#89891#) 362 bool mbListContextPushed; 363 364 const ::rtl::OUString sWidth; 365 const ::rtl::OUString sWidthType; 366 const ::rtl::OUString sRelativeWidth; 367 const ::rtl::OUString sHeight; 368 const ::rtl::OUString sRelativeHeight; 369 const ::rtl::OUString sSizeType; 370 const ::rtl::OUString sIsSyncWidthToHeight; 371 const ::rtl::OUString sIsSyncHeightToWidth; 372 const ::rtl::OUString sHoriOrient; 373 const ::rtl::OUString sHoriOrientPosition; 374 const ::rtl::OUString sVertOrient; 375 const ::rtl::OUString sVertOrientPosition; 376 const ::rtl::OUString sChainNextName; 377 const ::rtl::OUString sAnchorType; 378 const ::rtl::OUString sAnchorPageNo; 379 const ::rtl::OUString sGraphicURL; 380 const ::rtl::OUString sGraphicFilter; 381 // --> OD 2009-07-22 #i73249# 382 // const ::rtl::OUString sAlternativeText; 383 const ::rtl::OUString sTitle; 384 const ::rtl::OUString sDescription; 385 // <-- 386 const ::rtl::OUString sFrameStyleName; 387 const ::rtl::OUString sGraphicRotation; 388 const ::rtl::OUString sTextBoxServiceName; 389 const ::rtl::OUString sGraphicServiceName; 390 391 ::rtl::OUString sName; 392 ::rtl::OUString sStyleName; 393 ::rtl::OUString sNextName; 394 ::rtl::OUString sHRef; 395 ::rtl::OUString sFilterName; 396 ::rtl::OUString sCode; 397 ::rtl::OUString sObject; 398 ::rtl::OUString sArchive; 399 ::rtl::OUString sMimeType; 400 ::rtl::OUString sFrameName; 401 ::rtl::OUString sAppletName; 402 ::rtl::OUString sFilterService; 403 ::rtl::OUString sBase64CharsLeft; 404 ::rtl::OUString sTblName; 405 406 ParamMap aParamMap; 407 408 sal_Int32 nX; 409 sal_Int32 nY; 410 sal_Int32 nWidth; 411 sal_Int32 nHeight; 412 sal_Int32 nZIndex; 413 sal_Int16 nPage; 414 sal_Int16 nRotation; 415 sal_Int16 nRelWidth; 416 sal_Int16 nRelHeight; 417 418 sal_uInt16 nType; 419 ::com::sun::star::text::TextContentAnchorType eAnchorType; 420 421 sal_Bool bMayScript : 1; 422 sal_Bool bMinWidth : 1; 423 sal_Bool bMinHeight : 1; 424 sal_Bool bSyncWidth : 1; 425 sal_Bool bSyncHeight : 1; 426 sal_Bool bCreateFailed : 1; 427 sal_Bool bOwnBase64Stream : 1; 428 bool mbSetNameForFrame : 1; // #123261# remember if to set the NameForFrame 429 430 void Create( sal_Bool bHRefOrBase64 ); 431 432 public: 433 434 TYPEINFO(); 435 436 sal_Bool CreateIfNotThere(); 437 const OUString& GetHRef() const { return sHRef; } 438 439 XMLTextFrameContext_Impl( SvXMLImport& rImport, 440 sal_uInt16 nPrfx, 441 const ::rtl::OUString& rLName, 442 const ::com::sun::star::uno::Reference< 443 ::com::sun::star::xml::sax::XAttributeList > & rAttrList, 444 ::com::sun::star::text::TextContentAnchorType eAnchorType, 445 sal_uInt16 nType, 446 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList, 447 bool bSetNameForFrame); // #123261# control if to set the NameForFrame 448 virtual ~XMLTextFrameContext_Impl(); 449 450 virtual void EndElement(); 451 452 virtual void Characters( const ::rtl::OUString& rChars ); 453 454 SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 455 const ::rtl::OUString& rLocalName, 456 const ::com::sun::star::uno::Reference< 457 ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 458 459 void SetHyperlink( const ::rtl::OUString& rHRef, 460 const ::rtl::OUString& rName, 461 const ::rtl::OUString& rTargetFrameName, 462 sal_Bool bMap ); 463 // --> OD 2009-07-22 #i73249# 464 void SetTitle( const ::rtl::OUString& rTitle ); 465 // <-- 466 void SetDesc( const ::rtl::OUString& rDesc ); 467 468 ::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; } 469 470 const ::com::sun::star::uno::Reference < 471 ::com::sun::star::beans::XPropertySet >& GetPropSet() const { return xPropSet; } 472 473 // #123261# helper to set the NameForFrame 474 void SetNameForFrameFromPropSet(); 475 }; 476 477 TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext ); 478 479 void XMLTextFrameContext_Impl::SetNameForFrameFromPropSet() 480 { 481 // set name 482 UniReference < XMLTextImportHelper > xTextImportHelper = GetImport().GetTextImport(); 483 Reference < XNamed > xNamed( xPropSet, UNO_QUERY ); 484 485 if( xNamed.is() && xTextImportHelper.is() ) 486 { 487 OUString sOrigName( xNamed->getName() ); 488 if( !sOrigName.getLength() || 489 (sName.getLength() && sOrigName != sName) ) 490 { 491 OUString sOldName( sName ); 492 sal_Int32 i = 0; 493 while( xTextImportHelper->HasFrameByName( sName ) ) 494 { 495 sName = sOldName; 496 sName += OUString::valueOf( ++i ); 497 } 498 xNamed->setName( sName ); 499 if( sName != sOldName ) 500 xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME, 501 sOldName, sName ); 502 } 503 } 504 } 505 506 void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ ) 507 { 508 UniReference < XMLTextImportHelper > xTextImportHelper = 509 GetImport().GetTextImport(); 510 511 switch ( nType) 512 { 513 case XML_TEXT_FRAME_OBJECT: 514 case XML_TEXT_FRAME_OBJECT_OLE: 515 if( xBase64Stream.is() ) 516 { 517 OUString sURL( GetImport().ResolveEmbeddedObjectURLFromBase64() ); 518 if( sURL.getLength() ) 519 xPropSet = GetImport().GetTextImport() 520 ->createAndInsertOLEObject( GetImport(), sURL, 521 sStyleName, 522 sTblName, 523 nWidth, nHeight ); 524 } 525 else if( sHRef.getLength() ) 526 { 527 OUString sURL( GetImport().ResolveEmbeddedObjectURL( sHRef, 528 OUString() ) ); 529 530 if( GetImport().IsPackageURL( sHRef ) ) 531 { 532 xPropSet = GetImport().GetTextImport() 533 ->createAndInsertOLEObject( GetImport(), sURL, 534 sStyleName, 535 sTblName, 536 nWidth, nHeight ); 537 } 538 else 539 { 540 // it should be an own OOo link that has no storage persistance 541 xPropSet = GetImport().GetTextImport() 542 ->createAndInsertOOoLink( GetImport(), 543 sURL, 544 sStyleName, 545 sTblName, 546 nWidth, nHeight ); 547 } 548 } 549 else 550 { 551 OUString sURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.ServiceName:") ); 552 sURL += sFilterService; 553 xPropSet = GetImport().GetTextImport() 554 ->createAndInsertOLEObject( GetImport(), sURL, 555 sStyleName, 556 sTblName, 557 nWidth, nHeight ); 558 559 } 560 break; 561 case XML_TEXT_FRAME_APPLET: 562 { 563 xPropSet = GetImport().GetTextImport() 564 ->createAndInsertApplet( sAppletName, sCode, 565 bMayScript, sHRef, 566 nWidth, nHeight); 567 break; 568 } 569 case XML_TEXT_FRAME_PLUGIN: 570 { 571 if(sHRef.getLength()) 572 GetImport().GetAbsoluteReference(sHRef); 573 xPropSet = GetImport().GetTextImport() 574 ->createAndInsertPlugin( sMimeType, sHRef, 575 nWidth, nHeight); 576 577 break; 578 } 579 case XML_TEXT_FRAME_FLOATING_FRAME: 580 { 581 xPropSet = GetImport().GetTextImport() 582 ->createAndInsertFloatingFrame( sFrameName, sHRef, 583 sStyleName, 584 nWidth, nHeight); 585 break; 586 } 587 default: 588 { 589 Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(), 590 UNO_QUERY ); 591 if( xFactory.is() ) 592 { 593 OUString sServiceName; 594 switch( nType ) 595 { 596 case XML_TEXT_FRAME_TEXTBOX: sServiceName = sTextBoxServiceName; break; 597 case XML_TEXT_FRAME_GRAPHIC: sServiceName = sGraphicServiceName; break; 598 } 599 Reference<XInterface> xIfc = xFactory->createInstance( sServiceName ); 600 DBG_ASSERT( xIfc.is(), "couldn't create frame" ); 601 if( xIfc.is() ) 602 xPropSet = Reference < XPropertySet >( xIfc, UNO_QUERY ); 603 } 604 } 605 } 606 607 if( !xPropSet.is() ) 608 { 609 bCreateFailed = sal_True; 610 return; 611 } 612 613 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); 614 615 // #123261# set name, but only if wanted, e.g. for MultiImageSupport, it will be set after 616 // it is decided which image will be used. This is done e.g. to avoid double stuff and effects 617 // for the target to avoid double names 618 if(mbSetNameForFrame) 619 { 620 SetNameForFrameFromPropSet(); 621 } 622 623 // frame style 624 XMLPropStyleContext *pStyle = 0; 625 if( sStyleName.getLength() ) 626 { 627 pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName ); 628 if( pStyle ) 629 sStyleName = pStyle->GetParentName(); 630 } 631 632 Any aAny; 633 if( sStyleName.getLength() ) 634 { 635 OUString sDisplayStyleName( GetImport().GetStyleDisplayName( 636 XML_STYLE_FAMILY_SD_GRAPHICS_ID, sStyleName ) ); 637 const Reference < XNameContainer > & rStyles = 638 xTextImportHelper->GetFrameStyles(); 639 if( rStyles.is() && 640 rStyles->hasByName( sDisplayStyleName ) ) 641 { 642 aAny <<= sDisplayStyleName; 643 xPropSet->setPropertyValue( sFrameStyleName, aAny ); 644 } 645 } 646 647 // anchor type (must be set before any other properties, because 648 // otherwise some orientations cannot be set or will be changed 649 // afterwards) 650 aAny <<= eAnchorType; 651 xPropSet->setPropertyValue( sAnchorType, aAny ); 652 653 // hard properties 654 if( pStyle ) 655 pStyle->FillPropertySet( xPropSet ); 656 657 658 // x and y 659 sal_Int16 nHoriOrient = HoriOrientation::NONE; 660 aAny = xPropSet->getPropertyValue( sHoriOrient ); 661 aAny >>= nHoriOrient; 662 if( HoriOrientation::NONE == nHoriOrient ) 663 { 664 aAny <<= nX; 665 xPropSet->setPropertyValue( sHoriOrientPosition, aAny ); 666 } 667 668 sal_Int16 nVertOrient = VertOrientation::NONE; 669 aAny = xPropSet->getPropertyValue( sVertOrient ); 670 aAny >>= nVertOrient; 671 if( VertOrientation::NONE == nVertOrient ) 672 { 673 aAny <<= nY; 674 xPropSet->setPropertyValue( sVertOrientPosition, aAny ); 675 } 676 677 // width 678 if( nWidth > 0 ) 679 { 680 aAny <<= nWidth; 681 xPropSet->setPropertyValue( sWidth, aAny ); 682 } 683 if( nRelWidth > 0 || nWidth > 0 ) 684 { 685 aAny <<= nRelWidth; 686 xPropSet->setPropertyValue( sRelativeWidth, aAny ); 687 } 688 if( bSyncWidth || nWidth > 0 ) 689 { 690 sal_Bool bTmp = bSyncWidth; 691 aAny.setValue( &bTmp, ::getBooleanCppuType() ); 692 xPropSet->setPropertyValue( sIsSyncWidthToHeight, aAny ); 693 } 694 if( xPropSetInfo->hasPropertyByName( sWidthType ) && 695 (bMinWidth || nWidth > 0 || nRelWidth > 0 ) ) 696 { 697 sal_Int16 nSizeType = 698 (bMinWidth && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN 699 : SizeType::FIX; 700 aAny <<= nSizeType; 701 xPropSet->setPropertyValue( sWidthType, aAny ); 702 } 703 704 if( nHeight > 0 ) 705 { 706 aAny <<= nHeight; 707 xPropSet->setPropertyValue( sHeight, aAny ); 708 } 709 if( nRelHeight > 0 || nHeight > 0 ) 710 { 711 aAny <<= nRelHeight; 712 xPropSet->setPropertyValue( sRelativeHeight, aAny ); 713 } 714 if( bSyncHeight || nHeight > 0 ) 715 { 716 sal_Bool bTmp = bSyncHeight; 717 aAny.setValue( &bTmp, ::getBooleanCppuType() ); 718 xPropSet->setPropertyValue( sIsSyncHeightToWidth, aAny ); 719 } 720 if( xPropSetInfo->hasPropertyByName( sSizeType ) && 721 (bMinHeight || nHeight > 0 || nRelHeight > 0 ) ) 722 { 723 sal_Int16 nSizeType = 724 (bMinHeight && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN 725 : SizeType::FIX; 726 aAny <<= nSizeType; 727 xPropSet->setPropertyValue( sSizeType, aAny ); 728 } 729 730 if( XML_TEXT_FRAME_GRAPHIC == nType ) 731 { 732 // URL 733 OSL_ENSURE( sHRef.getLength() > 0 || xBase64Stream.is(), 734 "neither URL nor base64 image data given" ); 735 UniReference < XMLTextImportHelper > xTxtImport = 736 GetImport().GetTextImport(); 737 if( sHRef.getLength() ) 738 { 739 sal_Bool bForceLoad = xTxtImport->IsInsertMode() || 740 xTxtImport->IsBlockMode() || 741 xTxtImport->IsStylesOnlyMode() || 742 xTxtImport->IsOrganizerMode(); 743 sHRef = GetImport().ResolveGraphicObjectURL( sHRef, !bForceLoad ); 744 } 745 else if( xBase64Stream.is() ) 746 { 747 sHRef = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ); 748 xBase64Stream = 0; 749 } 750 aAny <<= sHRef; 751 xPropSet->setPropertyValue( sGraphicURL, aAny ); 752 753 // filter name 754 aAny <<=sFilterName; 755 xPropSet->setPropertyValue( sGraphicFilter, aAny ); 756 757 // rotation 758 aAny <<= nRotation; 759 xPropSet->setPropertyValue( sGraphicRotation, aAny ); 760 } 761 762 // page number (must be set after the frame is inserted, because it 763 // will be overwritten then inserting the frame. 764 if( TextContentAnchorType_AT_PAGE == eAnchorType && nPage > 0 ) 765 { 766 aAny <<= nPage; 767 xPropSet->setPropertyValue( sAnchorPageNo, aAny ); 768 } 769 770 if( XML_TEXT_FRAME_OBJECT != nType && 771 XML_TEXT_FRAME_OBJECT_OLE != nType && 772 XML_TEXT_FRAME_APPLET != nType && 773 XML_TEXT_FRAME_PLUGIN!= nType && 774 XML_TEXT_FRAME_FLOATING_FRAME != nType) 775 { 776 Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY ); 777 xTextImportHelper->InsertTextContent( xTxtCntnt ); 778 } 779 780 // #107848# 781 // Make adding the shepe to Z-Ordering dependent from if we are 782 // inside a inside_deleted_section (redlining). That is necessary 783 // since the shape will be removed again later. It would lead to 784 // errors if it would stay inside the Z-Ordering. Thus, the 785 // easiest way to solve that conflict is to not add it here. 786 if(!GetImport().HasTextImport() 787 || !GetImport().GetTextImport()->IsInsideDeleteContext()) 788 { 789 Reference < XShape > xShape( xPropSet, UNO_QUERY ); 790 791 GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex ); 792 } 793 794 if( XML_TEXT_FRAME_TEXTBOX == nType ) 795 { 796 xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet ); 797 Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY ); 798 Reference < XText > xTxt = xTxtFrame->getText(); 799 xOldTextCursor = xTextImportHelper->GetCursor(); 800 xTextImportHelper->SetCursor( xTxt->createTextCursor() ); 801 802 // remember old list item and block (#89892#) and reset them 803 // for the text frame 804 xTextImportHelper->PushListContext(); 805 mbListContextPushed = true; 806 } 807 } 808 809 sal_Bool XMLTextFrameContext_Impl::CreateIfNotThere() 810 { 811 if( !xPropSet.is() && 812 ( XML_TEXT_FRAME_OBJECT_OLE == nType || 813 XML_TEXT_FRAME_GRAPHIC == nType ) && 814 xBase64Stream.is() && !bCreateFailed ) 815 { 816 if( bOwnBase64Stream ) 817 xBase64Stream->closeOutput(); 818 Create( sal_True ); 819 } 820 821 return xPropSet.is(); 822 } 823 824 XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( 825 SvXMLImport& rImport, 826 sal_uInt16 nPrfx, const OUString& rLName, 827 const Reference< XAttributeList > & rAttrList, 828 TextContentAnchorType eATyp, 829 sal_uInt16 nNewType, 830 const Reference< XAttributeList > & rFrameAttrList, 831 bool bSetNameForFrame) 832 : SvXMLImportContext( rImport, nPrfx, rLName ) 833 , mbListContextPushed( false ) 834 , sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")) 835 , sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType")) 836 , sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")) 837 , sHeight(RTL_CONSTASCII_USTRINGPARAM("Height")) 838 , sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight")) 839 , sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType")) 840 , sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight")) 841 , sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth")) 842 , sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")) 843 , sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")) 844 , sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")) 845 , sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")) 846 , sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName")) 847 , sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")) 848 , sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo")) 849 , sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL")) 850 , sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter")) 851 // --> OD 2009-07-22 #i73249# 852 //, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")) 853 , sTitle(RTL_CONSTASCII_USTRINGPARAM("Title")) 854 , sDescription(RTL_CONSTASCII_USTRINGPARAM("Description")) 855 // <-- 856 , sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")) 857 , sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")) 858 , sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")) 859 , sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject")) 860 , nType( nNewType ) 861 , eAnchorType( eATyp ) 862 , mbSetNameForFrame(bSetNameForFrame) 863 { 864 nX = 0; 865 nY = 0; 866 nWidth = 0; 867 nHeight = 0; 868 nZIndex = -1; 869 nPage = 0; 870 nRotation = 0; 871 nRelWidth = 0; 872 nRelHeight = 0; 873 bMayScript = sal_False; 874 875 bMinHeight = sal_False; 876 bMinWidth = sal_False; 877 bSyncWidth = sal_False; 878 bSyncHeight = sal_False; 879 bCreateFailed = sal_False; 880 bOwnBase64Stream = sal_False; 881 882 UniReference < XMLTextImportHelper > xTxtImport = 883 GetImport().GetTextImport(); 884 const SvXMLTokenMap& rTokenMap = 885 xTxtImport->GetTextFrameAttrTokenMap(); 886 887 sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0; 888 sal_Int16 nTotalAttrCount = nAttrCount + (rFrameAttrList.is() ? rFrameAttrList->getLength() : 0); 889 for( sal_Int16 i=0; i < nTotalAttrCount; i++ ) 890 { 891 const OUString& rAttrName = 892 i < nAttrCount ? rAttrList->getNameByIndex( i ) : rFrameAttrList->getNameByIndex( i-nAttrCount ); 893 const OUString& rValue = 894 i < nAttrCount ? rAttrList->getValueByIndex( i ): rFrameAttrList->getValueByIndex( i-nAttrCount ); 895 896 OUString aLocalName; 897 sal_uInt16 nPrefix = 898 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 899 &aLocalName ); 900 switch( rTokenMap.Get( nPrefix, aLocalName ) ) 901 { 902 case XML_TOK_TEXT_FRAME_STYLE_NAME: 903 sStyleName = rValue; 904 break; 905 case XML_TOK_TEXT_FRAME_NAME: 906 sName = rValue; 907 break; 908 case XML_TOK_TEXT_FRAME_FRAME_NAME: 909 sFrameName = rValue; 910 break; 911 case XML_TOK_TEXT_FRAME_APPLET_NAME: 912 sAppletName = rValue; 913 break; 914 case XML_TOK_TEXT_FRAME_ANCHOR_TYPE: 915 if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType || 916 TextContentAnchorType_AT_CHARACTER == eAnchorType || 917 TextContentAnchorType_AS_CHARACTER == eAnchorType ) 918 { 919 920 TextContentAnchorType eNew; 921 if( XMLAnchorTypePropHdl::convert( rValue, eNew ) && 922 ( TextContentAnchorType_AT_PARAGRAPH == eNew || 923 TextContentAnchorType_AT_CHARACTER == eNew || 924 TextContentAnchorType_AS_CHARACTER == eNew || 925 TextContentAnchorType_AT_PAGE == eNew) ) 926 eAnchorType = eNew; 927 } 928 break; 929 case XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER: 930 { 931 sal_Int32 nTmp; 932 if( GetImport().GetMM100UnitConverter(). 933 convertNumber( nTmp, rValue, 1, SHRT_MAX ) ) 934 nPage = (sal_Int16)nTmp; 935 } 936 break; 937 case XML_TOK_TEXT_FRAME_X: 938 GetImport().GetMM100UnitConverter().convertMeasure( nX, rValue ); 939 break; 940 case XML_TOK_TEXT_FRAME_Y: 941 GetImport().GetMM100UnitConverter().convertMeasure( nY, rValue ); 942 break; 943 case XML_TOK_TEXT_FRAME_WIDTH: 944 // relative widths are obsolete since SRC617. Remove them some day! 945 if( rValue.indexOf( '%' ) != -1 ) 946 { 947 sal_Int32 nTmp; 948 GetImport().GetMM100UnitConverter().convertPercent( nTmp, 949 rValue ); 950 nRelWidth = (sal_Int16)nTmp; 951 } 952 else 953 { 954 GetImport().GetMM100UnitConverter().convertMeasure( nWidth, 955 rValue, 0 ); 956 } 957 break; 958 case XML_TOK_TEXT_FRAME_REL_WIDTH: 959 if( IsXMLToken(rValue, XML_SCALE) ) 960 { 961 bSyncWidth = sal_True; 962 } 963 else 964 { 965 sal_Int32 nTmp; 966 if( GetImport().GetMM100UnitConverter(). 967 convertPercent( nTmp, rValue ) ) 968 nRelWidth = (sal_Int16)nTmp; 969 } 970 break; 971 case XML_TOK_TEXT_FRAME_MIN_WIDTH: 972 if( rValue.indexOf( '%' ) != -1 ) 973 { 974 sal_Int32 nTmp; 975 GetImport().GetMM100UnitConverter().convertPercent( nTmp, 976 rValue ); 977 nRelWidth = (sal_Int16)nTmp; 978 } 979 else 980 { 981 GetImport().GetMM100UnitConverter().convertMeasure( nWidth, 982 rValue, 0 ); 983 } 984 bMinWidth = sal_True; 985 break; 986 case XML_TOK_TEXT_FRAME_HEIGHT: 987 // relative heights are obsolete since SRC617. Remove them some day! 988 if( rValue.indexOf( '%' ) != -1 ) 989 { 990 sal_Int32 nTmp; 991 GetImport().GetMM100UnitConverter().convertPercent( nTmp, 992 rValue ); 993 nRelHeight = (sal_Int16)nTmp; 994 } 995 else 996 { 997 GetImport().GetMM100UnitConverter().convertMeasure( nHeight, 998 rValue, 0 ); 999 } 1000 break; 1001 case XML_TOK_TEXT_FRAME_REL_HEIGHT: 1002 if( IsXMLToken( rValue, XML_SCALE ) ) 1003 { 1004 bSyncHeight = sal_True; 1005 } 1006 else if( IsXMLToken( rValue, XML_SCALE_MIN ) ) 1007 { 1008 bSyncHeight = sal_True; 1009 bMinHeight = sal_True; 1010 } 1011 else 1012 { 1013 sal_Int32 nTmp; 1014 if( GetImport().GetMM100UnitConverter(). 1015 convertPercent( nTmp, rValue ) ) 1016 nRelHeight = (sal_Int16)nTmp; 1017 } 1018 break; 1019 case XML_TOK_TEXT_FRAME_MIN_HEIGHT: 1020 if( rValue.indexOf( '%' ) != -1 ) 1021 { 1022 sal_Int32 nTmp; 1023 GetImport().GetMM100UnitConverter().convertPercent( nTmp, 1024 rValue ); 1025 nRelHeight = (sal_Int16)nTmp; 1026 } 1027 else 1028 { 1029 GetImport().GetMM100UnitConverter().convertMeasure( nHeight, 1030 rValue, 0 ); 1031 } 1032 bMinHeight = sal_True; 1033 break; 1034 case XML_TOK_TEXT_FRAME_Z_INDEX: 1035 GetImport().GetMM100UnitConverter().convertNumber( nZIndex, rValue, -1 ); 1036 break; 1037 case XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME: 1038 sNextName = rValue; 1039 break; 1040 case XML_TOK_TEXT_FRAME_HREF: 1041 sHRef = rValue; 1042 break; 1043 case XML_TOK_TEXT_FRAME_FILTER_NAME: 1044 sFilterName = rValue; 1045 break; 1046 case XML_TOK_TEXT_FRAME_TRANSFORM: 1047 { 1048 OUString sValue( rValue ); 1049 sValue.trim(); 1050 const OUString aRotate(GetXMLToken(XML_ROTATE)); 1051 const sal_Int32 nRotateLen(aRotate.getLength()); 1052 sal_Int32 nLen = sValue.getLength(); 1053 if( nLen >= nRotateLen+3 && 1054 0 == sValue.compareTo( aRotate, nRotateLen ) && 1055 '(' == sValue[nRotateLen] && 1056 ')' == sValue[nLen-1] ) 1057 { 1058 sValue = sValue.copy( nRotateLen+1, nLen-(nRotateLen+2) ); 1059 sValue.trim(); 1060 sal_Int32 nVal; 1061 if( GetImport().GetMM100UnitConverter().convertNumber( nVal, sValue ) ) 1062 nRotation = (sal_Int16)(nVal % 360 ); 1063 } 1064 } 1065 break; 1066 case XML_TOK_TEXT_FRAME_CODE: 1067 sCode = rValue; 1068 break; 1069 case XML_TOK_TEXT_FRAME_OBJECT: 1070 sObject = rValue; 1071 break; 1072 case XML_TOK_TEXT_FRAME_ARCHIVE: 1073 sArchive = rValue; 1074 break; 1075 case XML_TOK_TEXT_FRAME_MAY_SCRIPT: 1076 bMayScript = IsXMLToken( rValue, XML_TRUE ); 1077 break; 1078 case XML_TOK_TEXT_FRAME_MIME_TYPE: 1079 sMimeType = rValue; 1080 break; 1081 case XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE: 1082 sTblName = rValue; 1083 break; 1084 } 1085 } 1086 1087 if( ( (XML_TEXT_FRAME_GRAPHIC == nType || 1088 XML_TEXT_FRAME_OBJECT == nType || 1089 XML_TEXT_FRAME_OBJECT_OLE == nType) && 1090 !sHRef.getLength() ) || 1091 ( XML_TEXT_FRAME_APPLET == nType && !sCode.getLength() ) || 1092 ( XML_TEXT_FRAME_PLUGIN == nType && 1093 sHRef.getLength() == 0 && sMimeType.getLength() == 0 ) ) 1094 return; // no URL: no image or OLE object 1095 1096 Create( sal_True ); 1097 } 1098 1099 XMLTextFrameContext_Impl::~XMLTextFrameContext_Impl() 1100 { 1101 } 1102 1103 void XMLTextFrameContext_Impl::EndElement() 1104 { 1105 CreateIfNotThere(); 1106 1107 if( xOldTextCursor.is() ) 1108 { 1109 GetImport().GetTextImport()->DeleteParagraph(); 1110 GetImport().GetTextImport()->SetCursor( xOldTextCursor ); 1111 } 1112 1113 // reinstall old list item (if necessary) #89892# 1114 if (mbListContextPushed) { 1115 GetImport().GetTextImport()->PopListContext(); 1116 } 1117 1118 if (( nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN ) && xPropSet.is()) 1119 GetImport().GetTextImport()->endAppletOrPlugin( xPropSet, aParamMap); 1120 } 1121 1122 SvXMLImportContext *XMLTextFrameContext_Impl::CreateChildContext( 1123 sal_uInt16 nPrefix, 1124 const OUString& rLocalName, 1125 const Reference< XAttributeList > & xAttrList ) 1126 { 1127 SvXMLImportContext *pContext = 0; 1128 1129 if( XML_NAMESPACE_DRAW == nPrefix ) 1130 { 1131 if ( (nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN) && 1132 IsXMLToken( rLocalName, XML_PARAM ) ) 1133 { 1134 pContext = new XMLTextFrameParam_Impl( GetImport(), 1135 nPrefix, rLocalName, 1136 xAttrList, nType, aParamMap ); 1137 } 1138 } 1139 else if( (XML_NAMESPACE_OFFICE == nPrefix) ) 1140 { 1141 if( IsXMLToken( rLocalName, XML_BINARY_DATA ) ) 1142 { 1143 if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed ) 1144 { 1145 switch( nType ) 1146 { 1147 case XML_TEXT_FRAME_GRAPHIC: 1148 xBase64Stream = 1149 GetImport().GetStreamForGraphicObjectURLFromBase64(); 1150 break; 1151 case XML_TEXT_FRAME_OBJECT_OLE: 1152 xBase64Stream = 1153 GetImport().GetStreamForEmbeddedObjectURLFromBase64(); 1154 break; 1155 } 1156 if( xBase64Stream.is() ) 1157 pContext = new XMLBase64ImportContext( GetImport(), nPrefix, 1158 rLocalName, xAttrList, 1159 xBase64Stream ); 1160 } 1161 } 1162 } 1163 // --> OD 2009-08-17 #i100480# 1164 // correction of condition which also avoids warnings. 1165 if( !pContext && 1166 ( XML_TEXT_FRAME_OBJECT == nType && 1167 ( ( XML_NAMESPACE_OFFICE == nPrefix && 1168 IsXMLToken( rLocalName, XML_DOCUMENT ) ) || 1169 ( XML_NAMESPACE_MATH == nPrefix && 1170 IsXMLToken( rLocalName, XML_MATH ) ) ) ) ) 1171 // <-- 1172 { 1173 if( !xPropSet.is() && !bCreateFailed ) 1174 { 1175 XMLEmbeddedObjectImportContext *pEContext = 1176 new XMLEmbeddedObjectImportContext( GetImport(), nPrefix, 1177 rLocalName, xAttrList ); 1178 sFilterService = pEContext->GetFilterServiceName(); 1179 if( sFilterService.getLength() != 0 ) 1180 { 1181 Create( sal_False ); 1182 if( xPropSet.is() ) 1183 { 1184 Reference < XEmbeddedObjectSupplier > xEOS( xPropSet, 1185 UNO_QUERY ); 1186 OSL_ENSURE( xEOS.is(), 1187 "no embedded object supplier for own object" ); 1188 Reference<com::sun::star::lang::XComponent> aXComponent(xEOS->getEmbeddedObject()); 1189 pEContext->SetComponent( aXComponent ); 1190 } 1191 } 1192 pContext = pEContext; 1193 } 1194 } 1195 if( !pContext && xOldTextCursor.is() ) // text-box 1196 pContext = GetImport().GetTextImport()->CreateTextChildContext( 1197 GetImport(), nPrefix, rLocalName, xAttrList, 1198 XML_TEXT_TYPE_TEXTBOX ); 1199 1200 if( !pContext ) 1201 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); 1202 1203 return pContext; 1204 } 1205 1206 void XMLTextFrameContext_Impl::Characters( const OUString& rChars ) 1207 { 1208 if( ( XML_TEXT_FRAME_OBJECT_OLE == nType || 1209 XML_TEXT_FRAME_GRAPHIC == nType) && 1210 !xPropSet.is() && !bCreateFailed ) 1211 { 1212 OUString sTrimmedChars( rChars. trim() ); 1213 if( sTrimmedChars.getLength() ) 1214 { 1215 if( !xBase64Stream.is() ) 1216 { 1217 if( XML_TEXT_FRAME_GRAPHIC == nType ) 1218 { 1219 xBase64Stream = 1220 GetImport().GetStreamForGraphicObjectURLFromBase64(); 1221 } 1222 else 1223 { 1224 xBase64Stream = 1225 GetImport().GetStreamForEmbeddedObjectURLFromBase64(); 1226 } 1227 if( xBase64Stream.is() ) 1228 bOwnBase64Stream = sal_True; 1229 } 1230 if( bOwnBase64Stream && xBase64Stream.is() ) 1231 { 1232 OUString sChars; 1233 if( sBase64CharsLeft ) 1234 { 1235 sChars = sBase64CharsLeft; 1236 sChars += sTrimmedChars; 1237 sBase64CharsLeft = OUString(); 1238 } 1239 else 1240 { 1241 sChars = sTrimmedChars; 1242 } 1243 Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 ); 1244 sal_Int32 nCharsDecoded = 1245 GetImport().GetMM100UnitConverter(). 1246 decodeBase64SomeChars( aBuffer, sChars ); 1247 xBase64Stream->writeBytes( aBuffer ); 1248 if( nCharsDecoded != sChars.getLength() ) 1249 sBase64CharsLeft = sChars.copy( nCharsDecoded ); 1250 } 1251 } 1252 } 1253 } 1254 1255 void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef, 1256 const OUString& rName, 1257 const OUString& rTargetFrameName, 1258 sal_Bool bMap ) 1259 { 1260 static ::rtl::OUString s_HyperLinkURL( 1261 RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")); 1262 static ::rtl::OUString s_HyperLinkName( 1263 RTL_CONSTASCII_USTRINGPARAM("HyperLinkName")); 1264 static ::rtl::OUString s_HyperLinkTarget( 1265 RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget")); 1266 static ::rtl::OUString s_ServerMap( 1267 RTL_CONSTASCII_USTRINGPARAM("ServerMap")); 1268 if( !xPropSet.is() ) 1269 return; 1270 1271 UniReference< XMLTextImportHelper > xTxtImp = GetImport().GetTextImport(); 1272 Reference < XPropertySetInfo > xPropSetInfo = 1273 xPropSet->getPropertySetInfo(); 1274 if( !xPropSetInfo.is() || 1275 !xPropSetInfo->hasPropertyByName(s_HyperLinkURL)) 1276 return; 1277 1278 Any aAny; 1279 aAny <<= rHRef; 1280 xPropSet->setPropertyValue( s_HyperLinkURL, aAny ); 1281 1282 if (xPropSetInfo->hasPropertyByName(s_HyperLinkName)) 1283 { 1284 aAny <<= rName; 1285 xPropSet->setPropertyValue(s_HyperLinkName, aAny); 1286 } 1287 1288 if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget)) 1289 { 1290 aAny <<= rTargetFrameName; 1291 xPropSet->setPropertyValue( s_HyperLinkTarget, aAny ); 1292 } 1293 1294 if (xPropSetInfo->hasPropertyByName(s_ServerMap)) 1295 { 1296 aAny.setValue( &bMap, ::getBooleanCppuType() ); 1297 xPropSet->setPropertyValue(s_ServerMap, aAny); 1298 } 1299 } 1300 1301 // --> OD 2009-07-22 #i73249# 1302 void XMLTextFrameContext_Impl::SetTitle( const OUString& rTitle ) 1303 { 1304 if ( xPropSet.is() ) 1305 { 1306 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); 1307 if( xPropSetInfo->hasPropertyByName( sTitle ) ) 1308 { 1309 xPropSet->setPropertyValue( sTitle, makeAny( rTitle ) ); 1310 } 1311 } 1312 } 1313 1314 void XMLTextFrameContext_Impl::SetDesc( const OUString& rDesc ) 1315 { 1316 if ( xPropSet.is() ) 1317 { 1318 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); 1319 if( xPropSetInfo->hasPropertyByName( sDescription ) ) 1320 { 1321 xPropSet->setPropertyValue( sDescription, makeAny( rDesc ) ); 1322 } 1323 } 1324 } 1325 // <-- 1326 1327 //----------------------------------------------------------------------------------------------------- 1328 1329 TYPEINIT1( XMLTextFrameContext, SvXMLImportContext ); 1330 1331 void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const 1332 { 1333 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext); 1334 1335 if(pXMLTextFrameContext_Impl) 1336 { 1337 try 1338 { 1339 // just dispose to delete 1340 uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY); 1341 1342 if(xComp.is()) 1343 { 1344 xComp->dispose(); 1345 } 1346 } 1347 catch( uno::Exception& ) 1348 { 1349 DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" ); 1350 } 1351 } 1352 } 1353 1354 rtl::OUString XMLTextFrameContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const 1355 { 1356 rtl::OUString aRetval; 1357 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext); 1358 1359 if(pXMLTextFrameContext_Impl) 1360 { 1361 return pXMLTextFrameContext_Impl->GetHRef(); 1362 } 1363 1364 return aRetval; 1365 } 1366 1367 sal_Bool XMLTextFrameContext::CreateIfNotThere() 1368 { 1369 sal_Bool bRet = sal_False; 1370 SvXMLImportContext *pContext = &m_xImplContext; 1371 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1372 if( pImpl ) 1373 bRet = pImpl->CreateIfNotThere(); 1374 1375 return bRet; 1376 } 1377 1378 sal_Bool XMLTextFrameContext::CreateIfNotThere( ::com::sun::star::uno::Reference < 1379 ::com::sun::star::beans::XPropertySet >& rPropSet ) 1380 { 1381 SvXMLImportContext *pContext = &m_xImplContext; 1382 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1383 if( pImpl ) 1384 { 1385 if( pImpl->CreateIfNotThere() ) 1386 rPropSet = pImpl->GetPropSet(); 1387 } 1388 1389 return rPropSet.is(); 1390 } 1391 1392 XMLTextFrameContext::XMLTextFrameContext( 1393 SvXMLImport& rImport, 1394 sal_uInt16 nPrfx, const OUString& rLName, 1395 const Reference< XAttributeList > & xAttrList, 1396 TextContentAnchorType eATyp ) 1397 : SvXMLImportContext( rImport, nPrfx, rLName ) 1398 , multiImageImportHelper() 1399 , m_xAttrList( new SvXMLAttributeList( xAttrList ) ) 1400 , m_pHyperlink( 0 ) 1401 // --> OD 2009-07-22 #i73249# 1402 , m_sTitle() 1403 , m_sDesc() 1404 // <-- 1405 , m_eDefaultAnchorType( eATyp ) 1406 // --> OD 2006-03-10 #i51726# 1407 , m_HasAutomaticStyleWithoutParentStyle( sal_False ) 1408 // <-- 1409 , m_bSupportsReplacement( sal_False ) 1410 { 1411 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 1412 for( sal_Int16 i=0; i < nAttrCount; i++ ) 1413 { 1414 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 1415 1416 OUString aLocalName; 1417 sal_uInt16 nPrefix = 1418 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); 1419 // --> OD 2006-03-10 #i51726# 1420 // New distinguish attribute between Writer objects and Draw objects is: 1421 // Draw objects have an automatic style without a parent style 1422 if ( XML_NAMESPACE_DRAW == nPrefix && 1423 IsXMLToken( aLocalName, XML_STYLE_NAME ) ) 1424 { 1425 OUString aStyleName = xAttrList->getValueByIndex( i ); 1426 if( aStyleName.getLength() ) 1427 { 1428 UniReference < XMLTextImportHelper > xTxtImport = 1429 GetImport().GetTextImport(); 1430 XMLPropStyleContext* pStyle( 0L ); 1431 pStyle = xTxtImport->FindAutoFrameStyle( aStyleName ); 1432 if ( pStyle && !pStyle->GetParentName().getLength() ) 1433 { 1434 m_HasAutomaticStyleWithoutParentStyle = sal_True; 1435 } 1436 } 1437 } 1438 // <-- 1439 else if ( XML_NAMESPACE_TEXT == nPrefix && 1440 IsXMLToken( aLocalName, XML_ANCHOR_TYPE ) ) 1441 { 1442 TextContentAnchorType eNew; 1443 if( XMLAnchorTypePropHdl::convert( xAttrList->getValueByIndex(i), 1444 eNew ) && 1445 ( TextContentAnchorType_AT_PARAGRAPH == eNew || 1446 TextContentAnchorType_AT_CHARACTER == eNew || 1447 TextContentAnchorType_AS_CHARACTER == eNew || 1448 TextContentAnchorType_AT_PAGE == eNew) ) 1449 m_eDefaultAnchorType = eNew; 1450 } 1451 } 1452 } 1453 1454 XMLTextFrameContext::~XMLTextFrameContext() 1455 { 1456 delete m_pHyperlink; 1457 } 1458 1459 void XMLTextFrameContext::EndElement() 1460 { 1461 /// solve if multiple image child contexts were imported 1462 /// the winner is returned, if something has yet to be done with it 1463 const SvXMLImportContext* pWinner = solveMultipleImages(); 1464 1465 // #123261# see if the winner is a XMLTextFrameContext_Impl 1466 const XMLTextFrameContext_Impl* pImplWinner = dynamic_cast< const XMLTextFrameContext_Impl* >(pWinner); 1467 1468 if(pImplWinner) 1469 { 1470 // #123261# if yes, set name now, after the winner is identified (setting at each 1471 // candidate may run into problems due to colliding with efforts in the target to 1472 // avoid double names, so only set one name at one image and not at each) 1473 const_cast< XMLTextFrameContext_Impl* >(pImplWinner)->SetNameForFrameFromPropSet(); 1474 } 1475 1476 SvXMLImportContext *pContext = &m_xImplContext; 1477 XMLTextFrameContext_Impl *pImpl = dynamic_cast< XMLTextFrameContext_Impl* >(pContext); 1478 1479 if( pImpl ) 1480 { 1481 pImpl->CreateIfNotThere(); 1482 1483 // --> OD 2009-07-22 #i73249# 1484 // // alternative text 1485 // if( m_sDesc.getLength() ) 1486 // pImpl->SetDesc( m_sDesc ); 1487 // svg:title 1488 if( m_sTitle.getLength() ) 1489 { 1490 pImpl->SetTitle( m_sTitle ); 1491 } 1492 if( m_sDesc.getLength() ) 1493 { 1494 pImpl->SetDesc( m_sDesc ); 1495 } 1496 // <-- 1497 1498 if( m_pHyperlink ) 1499 { 1500 pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(), 1501 m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() ); 1502 delete m_pHyperlink; 1503 m_pHyperlink = 0; 1504 } 1505 1506 } 1507 } 1508 1509 SvXMLImportContext *XMLTextFrameContext::CreateChildContext( 1510 sal_uInt16 p_nPrefix, 1511 const OUString& rLocalName, 1512 const Reference< XAttributeList > & xAttrList ) 1513 { 1514 SvXMLImportContext *pContext = 0; 1515 1516 if( !m_xImplContext.Is() ) 1517 { 1518 // no child exists 1519 if( XML_NAMESPACE_DRAW == p_nPrefix ) 1520 { 1521 sal_uInt16 nFrameType = USHRT_MAX; 1522 if( IsXMLToken( rLocalName, XML_TEXT_BOX ) ) 1523 nFrameType = XML_TEXT_FRAME_TEXTBOX; 1524 else if( IsXMLToken( rLocalName, XML_IMAGE ) ) 1525 nFrameType = XML_TEXT_FRAME_GRAPHIC; 1526 else if( IsXMLToken( rLocalName, XML_OBJECT ) ) 1527 nFrameType = XML_TEXT_FRAME_OBJECT; 1528 else if( IsXMLToken( rLocalName, XML_OBJECT_OLE ) ) 1529 nFrameType = XML_TEXT_FRAME_OBJECT_OLE; 1530 else if( IsXMLToken( rLocalName, XML_APPLET) ) 1531 nFrameType = XML_TEXT_FRAME_APPLET; 1532 else if( IsXMLToken( rLocalName, XML_PLUGIN ) ) 1533 nFrameType = XML_TEXT_FRAME_PLUGIN; 1534 else if( IsXMLToken( rLocalName, XML_FLOATING_FRAME ) ) 1535 nFrameType = XML_TEXT_FRAME_FLOATING_FRAME; 1536 1537 if( USHRT_MAX != nFrameType ) 1538 { 1539 // --> OD 2006-03-10 #i51726# 1540 if ( ( XML_TEXT_FRAME_TEXTBOX == nFrameType || 1541 XML_TEXT_FRAME_GRAPHIC == nFrameType ) && 1542 m_HasAutomaticStyleWithoutParentStyle ) 1543 // <-- 1544 { 1545 Reference < XShapes > xShapes; 1546 pContext = GetImport().GetShapeImport()->CreateFrameChildContext( 1547 GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList ); 1548 } 1549 else if( XML_TEXT_FRAME_PLUGIN == nFrameType ) 1550 { 1551 bool bMedia = false; 1552 1553 // check, if we have a media object 1554 for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n ) 1555 { 1556 OUString aLocalName; 1557 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName ); 1558 1559 if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) ) 1560 { 1561 if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) ) 1562 bMedia = true; 1563 1564 // leave this loop 1565 n = nAttrCount - 1; 1566 } 1567 } 1568 1569 if( bMedia ) 1570 { 1571 Reference < XShapes > xShapes; 1572 pContext = GetImport().GetShapeImport()->CreateFrameChildContext( 1573 GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList ); 1574 } 1575 } 1576 else if( XML_TEXT_FRAME_OBJECT == nFrameType || 1577 XML_TEXT_FRAME_OBJECT_OLE == nFrameType ) 1578 { 1579 m_bSupportsReplacement = sal_True; 1580 } 1581 else if(XML_TEXT_FRAME_GRAPHIC == nFrameType) 1582 { 1583 setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE)); 1584 } 1585 1586 if( !pContext ) 1587 { 1588 pContext = new XMLTextFrameContext_Impl( 1589 GetImport(), 1590 p_nPrefix, 1591 rLocalName, 1592 xAttrList, 1593 m_eDefaultAnchorType, 1594 nFrameType, 1595 m_xAttrList, 1596 !getSupportsMultipleContents()); 1597 } 1598 1599 m_xImplContext = pContext; 1600 1601 if(getSupportsMultipleContents() && XML_TEXT_FRAME_GRAPHIC == nFrameType) 1602 { 1603 addContent(*m_xImplContext); 1604 } 1605 } 1606 } 1607 } 1608 else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix && IsXMLToken(rLocalName, XML_IMAGE)) 1609 { 1610 // read another image 1611 pContext = new XMLTextFrameContext_Impl( 1612 GetImport(), 1613 p_nPrefix, 1614 rLocalName, 1615 xAttrList, 1616 m_eDefaultAnchorType, 1617 XML_TEXT_FRAME_GRAPHIC, 1618 m_xAttrList, 1619 false); 1620 1621 m_xImplContext = pContext; 1622 addContent(*m_xImplContext); 1623 } 1624 else if( m_bSupportsReplacement && !m_xReplImplContext && 1625 XML_NAMESPACE_DRAW == p_nPrefix && 1626 IsXMLToken( rLocalName, XML_IMAGE ) ) 1627 { 1628 // read replacement image 1629 Reference < XPropertySet > xPropSet; 1630 if( CreateIfNotThere( xPropSet ) ) 1631 { 1632 pContext = new XMLReplacementImageContext( GetImport(), 1633 p_nPrefix, rLocalName, xAttrList, xPropSet ); 1634 m_xReplImplContext = pContext; 1635 } 1636 } 1637 else if( m_xImplContext->ISA( XMLTextFrameContext_Impl ) ) 1638 { 1639 // the child is a writer frame 1640 if( XML_NAMESPACE_SVG == p_nPrefix ) 1641 { 1642 // --> OD 2009-07-22 #i73249# 1643 // bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); 1644 // if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) ) 1645 // pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName, 1646 // xAttrList, m_sDesc ); 1647 const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); 1648 if ( bOld ) 1649 { 1650 if ( IsXMLToken( rLocalName, XML_DESC ) ) 1651 { 1652 pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), 1653 p_nPrefix, 1654 rLocalName, 1655 m_sTitle ); 1656 } 1657 } 1658 else 1659 { 1660 if( IsXMLToken( rLocalName, XML_TITLE ) ) 1661 { 1662 pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), 1663 p_nPrefix, 1664 rLocalName, 1665 m_sTitle ); 1666 } 1667 else if ( IsXMLToken( rLocalName, XML_DESC ) ) 1668 { 1669 pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(), 1670 p_nPrefix, 1671 rLocalName, 1672 m_sDesc ); 1673 } 1674 } 1675 // <-- 1676 } 1677 else if( XML_NAMESPACE_DRAW == p_nPrefix ) 1678 { 1679 Reference < XPropertySet > xPropSet; 1680 if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) ) 1681 { 1682 if( CreateIfNotThere( xPropSet ) ) 1683 pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName, 1684 xAttrList, xPropSet, sal_False ); 1685 } 1686 else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) ) 1687 { 1688 if( CreateIfNotThere( xPropSet ) ) 1689 pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName, 1690 xAttrList, xPropSet, sal_True ); 1691 } 1692 else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) ) 1693 { 1694 if( CreateIfNotThere( xPropSet ) ) 1695 pContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet ); 1696 } 1697 } 1698 else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) 1699 { 1700 // do we still have the frame object? 1701 Reference < XPropertySet > xPropSet; 1702 if( CreateIfNotThere( xPropSet ) ) 1703 { 1704 // is it an event supplier? 1705 Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY); 1706 if (xEventsSupplier.is()) 1707 { 1708 // OK, we have the events, so create the context 1709 pContext = new XMLEventsImportContext(GetImport(), p_nPrefix, 1710 rLocalName, xEventsSupplier); 1711 } 1712 } 1713 } 1714 } 1715 else if( p_nPrefix == XML_NAMESPACE_SVG && // #i68101# 1716 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) 1717 { 1718 pContext = m_xImplContext->CreateChildContext( p_nPrefix, rLocalName, xAttrList ); 1719 } 1720 else 1721 { 1722 // the child is a drawing shape 1723 pContext = GetImport().GetShapeImport()->CreateFrameChildContext( 1724 &m_xImplContext, p_nPrefix, rLocalName, xAttrList ); 1725 } 1726 1727 if( !pContext ) 1728 pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); 1729 1730 return pContext; 1731 } 1732 1733 void XMLTextFrameContext::SetHyperlink( const OUString& rHRef, 1734 const OUString& rName, 1735 const OUString& rTargetFrameName, 1736 sal_Bool bMap ) 1737 { 1738 OSL_ENSURE( !m_pHyperlink, "recursive SetHyperlink call" ); 1739 delete m_pHyperlink; 1740 m_pHyperlink = new XMLTextFrameContextHyperlink_Impl( 1741 rHRef, rName, rTargetFrameName, bMap ); 1742 } 1743 1744 TextContentAnchorType XMLTextFrameContext::GetAnchorType() const 1745 { 1746 SvXMLImportContext *pContext = &m_xImplContext; 1747 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1748 if( pImpl ) 1749 return pImpl->GetAnchorType(); 1750 else 1751 return m_eDefaultAnchorType; 1752 } 1753 1754 Reference < XTextContent > XMLTextFrameContext::GetTextContent() const 1755 { 1756 Reference < XTextContent > xTxtCntnt; 1757 SvXMLImportContext *pContext = &m_xImplContext; 1758 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext ); 1759 if( pImpl ) 1760 xTxtCntnt.set( pImpl->GetPropSet(), UNO_QUERY ); 1761 1762 return xTxtCntnt; 1763 } 1764 1765 // --> OD 2004-08-24 #33242# 1766 Reference < XShape > XMLTextFrameContext::GetShape() const 1767 { 1768 Reference < XShape > xShape; 1769 SvXMLImportContext* pContext = &m_xImplContext; 1770 SvXMLShapeContext* pImpl = PTR_CAST( SvXMLShapeContext, pContext ); 1771 if ( pImpl ) 1772 { 1773 xShape = pImpl->getShape(); 1774 } 1775 1776 return xShape; 1777 } 1778 // <-- 1779