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 25 #include <tools/debug.hxx> 26 #include <com/sun/star/document/XEventsSupplier.hpp> 27 #include <com/sun/star/container/XNameReplace.hpp> 28 #include <com/sun/star/presentation/ClickAction.hpp> 29 #include <com/sun/star/drawing/FillStyle.hpp> 30 #include <com/sun/star/drawing/LineStyle.hpp> 31 #include "unointerfacetouniqueidentifiermapper.hxx" 32 #include <com/sun/star/drawing/XGluePointsSupplier.hpp> 33 #include <com/sun/star/container/XIdentifierAccess.hpp> 34 #include <com/sun/star/drawing/GluePoint2.hpp> 35 #include <com/sun/star/drawing/Alignment.hpp> 36 #include <com/sun/star/drawing/EscapeDirection.hpp> 37 #include <com/sun/star/media/ZoomLevel.hpp> 38 #include <com/sun/star/awt/Rectangle.hpp> 39 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 40 #include <com/sun/star/container/XNameAccess.hpp> 41 #include <comphelper/extract.hxx> 42 #include "ximpshap.hxx" 43 #include <xmloff/XMLBase64ImportContext.hxx> 44 #include <xmloff/XMLShapeStyleContext.hxx> 45 #include <xmloff/xmluconv.hxx> 46 #include <com/sun/star/container/XNamed.hpp> 47 #include <com/sun/star/drawing/CircleKind.hpp> 48 #include <com/sun/star/beans/XPropertySet.hpp> 49 #include <com/sun/star/awt/XControlModel.hpp> 50 #include <com/sun/star/drawing/XControlShape.hpp> 51 #include <com/sun/star/drawing/PointSequenceSequence.hpp> 52 #include <com/sun/star/drawing/PointSequence.hpp> 53 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 54 #include <com/sun/star/lang/XServiceInfo.hpp> 55 #include <com/sun/star/util/XCloneable.hpp> 56 #include <com/sun/star/beans/XMultiPropertyStates.hpp> 57 #include "xexptran.hxx" 58 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> 59 #include <com/sun/star/beans/XPropertySetInfo.hpp> 60 #include <com/sun/star/drawing/ConnectorType.hpp> 61 #include <com/sun/star/drawing/HomogenMatrix3.hpp> 62 #include "PropertySetMerger.hxx" 63 #include <xmloff/families.hxx> 64 #include "ximpstyl.hxx" 65 #include"xmloff/xmlnmspe.hxx" 66 #include <xmloff/xmltoken.hxx> 67 #include "EnhancedCustomShapeToken.hxx" 68 #include "XMLReplacementImageContext.hxx" 69 #include "XMLImageMapContext.hxx" 70 #include "sdpropls.hxx" 71 #include "eventimp.hxx" 72 #include "descriptionimp.hxx" 73 #include "ximpcustomshape.hxx" 74 #include "XMLEmbeddedObjectImportContext.hxx" 75 #include "xmloff/xmlerror.hxx" 76 #include <basegfx/matrix/b2dhommatrix.hxx> 77 #include <tools/string.hxx> 78 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp> 79 #include <com/sun/star/container/XChild.hpp> 80 #include <com/sun/star/text/XTextDocument.hpp> 81 #include <basegfx/vector/b2dvector.hxx> 82 #include <basegfx/point/b2dpoint.hxx> 83 #include <basegfx/polygon/b2dpolygon.hxx> 84 #include <basegfx/polygon/b2dpolygontools.hxx> 85 #include <basegfx/polygon/b2dpolypolygontools.hxx> 86 #include <basegfx/matrix/b2dhommatrixtools.hxx> 87 88 using ::rtl::OUString; 89 using ::rtl::OUStringBuffer; 90 91 using namespace ::com::sun::star; 92 using namespace ::com::sun::star::uno; 93 using namespace ::com::sun::star::drawing; 94 using namespace ::com::sun::star::style; 95 using namespace ::com::sun::star::container; 96 using namespace ::com::sun::star::document; 97 using namespace ::xmloff::token; 98 using namespace ::xmloff::EnhancedCustomShapeToken; 99 100 SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[] = 101 { 102 { XML_TOP_LEFT, drawing::Alignment_TOP_LEFT }, 103 { XML_TOP, drawing::Alignment_TOP }, 104 { XML_TOP_RIGHT, drawing::Alignment_TOP_RIGHT }, 105 { XML_LEFT, drawing::Alignment_LEFT }, 106 { XML_CENTER, drawing::Alignment_CENTER }, 107 { XML_RIGHT, drawing::Alignment_RIGHT }, 108 { XML_BOTTOM_LEFT, drawing::Alignment_BOTTOM_LEFT }, 109 { XML_BOTTOM, drawing::Alignment_BOTTOM }, 110 { XML_BOTTOM_RIGHT, drawing::Alignment_BOTTOM_RIGHT }, 111 { XML_TOKEN_INVALID, 0 } 112 }; 113 114 SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[] = 115 { 116 { XML_AUTO, drawing::EscapeDirection_SMART }, 117 { XML_LEFT, drawing::EscapeDirection_LEFT }, 118 { XML_RIGHT, drawing::EscapeDirection_RIGHT }, 119 { XML_UP, drawing::EscapeDirection_UP }, 120 { XML_DOWN, drawing::EscapeDirection_DOWN }, 121 { XML_HORIZONTAL, drawing::EscapeDirection_HORIZONTAL }, 122 { XML_VERTICAL, drawing::EscapeDirection_VERTICAL }, 123 { XML_TOKEN_INVALID, 0 } 124 }; 125 126 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 127 128 static bool ImpIsEmptyURL( const ::rtl::OUString& rURL ) 129 { 130 if( rURL.getLength() == 0 ) 131 return true; 132 133 // #i13140# Also compare against 'toplevel' URLs. which also 134 // result in empty filename strings. 135 if( 0 == rURL.compareToAscii( "#./" ) ) 136 return true; 137 138 return false; 139 } 140 141 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 142 143 TYPEINIT1( SvXMLShapeContext, SvXMLImportContext ); 144 TYPEINIT1( SdXMLShapeContext, SvXMLShapeContext ); 145 146 SdXMLShapeContext::SdXMLShapeContext( 147 SvXMLImport& rImport, 148 sal_uInt16 nPrfx, 149 const OUString& rLocalName, 150 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 151 uno::Reference< drawing::XShapes >& rShapes, 152 sal_Bool bTemporaryShape) 153 : SvXMLShapeContext( rImport, nPrfx, rLocalName, bTemporaryShape ) 154 , mxShapes( rShapes ) 155 , mxAttrList(xAttrList) 156 , mbListContextPushed( false ) 157 , mnStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID) 158 , mbIsPlaceholder(sal_False) 159 , mbClearDefaultAttributes( true ) 160 , mbIsUserTransformed(sal_False) 161 , mnZOrder(-1) 162 , maSize(1, 1) 163 , maPosition(0, 0) 164 , maUsedTransformation() 165 , mbVisible(true) 166 , mbPrintable(true) 167 { 168 } 169 170 ////////////////////////////////////////////////////////////////////////////// 171 172 SdXMLShapeContext::~SdXMLShapeContext() 173 { 174 } 175 176 ////////////////////////////////////////////////////////////////////////////// 177 178 SvXMLImportContext *SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, 179 const OUString& rLocalName, 180 const uno::Reference< xml::sax::XAttributeList>& xAttrList ) 181 { 182 SvXMLImportContext * pContext = NULL; 183 184 // #i68101# 185 if( p_nPrefix == XML_NAMESPACE_SVG && 186 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) 187 { 188 pContext = new SdXMLDescriptionContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape ); 189 } 190 else if( p_nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) 191 { 192 pContext = new SdXMLEventsContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape ); 193 } 194 else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) ) 195 { 196 addGluePoint( xAttrList ); 197 } 198 else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_THUMBNAIL ) ) 199 { 200 // search attributes for xlink:href 201 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 202 for(sal_Int16 i=0; i < nAttrCount; i++) 203 { 204 OUString sAttrName = xAttrList->getNameByIndex( i ); 205 OUString aLocalName; 206 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); 207 208 if( nPrefix == XML_NAMESPACE_XLINK ) 209 { 210 if( IsXMLToken( aLocalName, XML_HREF ) ) 211 { 212 maThumbnailURL = xAttrList->getValueByIndex( i ); 213 break; 214 } 215 } 216 } 217 } 218 else 219 { 220 // create text cursor on demand 221 if( !mxCursor.is() ) 222 { 223 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); 224 if( xText.is() ) 225 { 226 UniReference < XMLTextImportHelper > xTxtImport = 227 GetImport().GetTextImport(); 228 mxOldCursor = xTxtImport->GetCursor(); 229 mxCursor = xText->createTextCursor(); 230 if( mxCursor.is() ) 231 { 232 xTxtImport->SetCursor( mxCursor ); 233 } 234 235 // remember old list item and block (#91964#) and reset them 236 // for the text frame 237 xTxtImport->PushListContext(); 238 mbListContextPushed = true; 239 } 240 } 241 242 // if we have a text cursor, lets try to import some text 243 if( mxCursor.is() ) 244 { 245 pContext = GetImport().GetTextImport()->CreateTextChildContext( 246 GetImport(), p_nPrefix, rLocalName, xAttrList ); 247 } 248 } 249 250 // call parent for content 251 if(!pContext) 252 pContext = SvXMLImportContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList ); 253 254 return pContext; 255 } 256 257 void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XAttributeList>& xAttrList ) 258 { 259 // get the glue points container for this shape if its not already there 260 if( !mxGluePoints.is() ) 261 { 262 uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY ); 263 if( !xSupplier.is() ) 264 return; 265 266 mxGluePoints = uno::Reference< container::XIdentifierContainer >::query( xSupplier->getGluePoints() ); 267 268 if( !mxGluePoints.is() ) 269 return; 270 } 271 272 drawing::GluePoint2 aGluePoint; 273 aGluePoint.IsUserDefined = sal_True; 274 aGluePoint.Position.X = 0; 275 aGluePoint.Position.Y = 0; 276 aGluePoint.Escape = drawing::EscapeDirection_SMART; 277 aGluePoint.PositionAlignment = drawing::Alignment_CENTER; 278 aGluePoint.IsRelative = sal_True; 279 280 sal_Int32 nId = -1; 281 282 // read attributes for the 3DScene 283 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 284 for(sal_Int16 i=0; i < nAttrCount; i++) 285 { 286 OUString sAttrName = xAttrList->getNameByIndex( i ); 287 OUString aLocalName; 288 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName ); 289 const OUString sValue( xAttrList->getValueByIndex( i ) ); 290 291 if( nPrefix == XML_NAMESPACE_SVG ) 292 { 293 if( IsXMLToken( aLocalName, XML_X ) ) 294 { 295 GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint.Position.X, sValue); 296 } 297 else if( IsXMLToken( aLocalName, XML_Y ) ) 298 { 299 GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint.Position.Y, sValue); 300 } 301 } 302 else if( nPrefix == XML_NAMESPACE_DRAW ) 303 { 304 if( IsXMLToken( aLocalName, XML_ID ) ) 305 { 306 nId = sValue.toInt32(); 307 } 308 else if( IsXMLToken( aLocalName, XML_ALIGN ) ) 309 { 310 sal_uInt16 eKind; 311 if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueAlignment_EnumMap ) ) 312 { 313 aGluePoint.PositionAlignment = (drawing::Alignment)eKind; 314 aGluePoint.IsRelative = sal_False; 315 } 316 } 317 else if( IsXMLToken( aLocalName, XML_ESCAPE_DIRECTION ) ) 318 { 319 sal_uInt16 eKind; 320 if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueEscapeDirection_EnumMap ) ) 321 { 322 aGluePoint.Escape = (drawing::EscapeDirection)eKind; 323 } 324 } 325 } 326 } 327 328 if( nId != -1 ) 329 { 330 try 331 { 332 sal_Int32 nInternalId = mxGluePoints->insert( uno::makeAny( aGluePoint ) ); 333 GetImport().GetShapeImport()->addGluePointMapping( mxShape, nId, nInternalId ); 334 } 335 catch( uno::Exception& ) 336 { 337 DBG_ERROR( "exception during setting of glue points!"); 338 } 339 } 340 } 341 ////////////////////////////////////////////////////////////////////////////// 342 343 void SdXMLShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&) 344 { 345 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); 346 } 347 348 void SdXMLShapeContext::EndElement() 349 { 350 if(mxCursor.is()) 351 { 352 // delete addition newline 353 const OUString aEmpty; 354 mxCursor->gotoEnd( sal_False ); 355 mxCursor->goLeft( 1, sal_True ); 356 mxCursor->setString( aEmpty ); 357 358 // reset cursor 359 GetImport().GetTextImport()->ResetCursor(); 360 } 361 362 if(mxOldCursor.is()) 363 GetImport().GetTextImport()->SetCursor( mxOldCursor ); 364 365 // reinstall old list item (if necessary) #91964# 366 if (mbListContextPushed) { 367 GetImport().GetTextImport()->PopListContext(); 368 } 369 370 if( msHyperlink.getLength() != 0 ) try 371 { 372 const OUString sBookmark( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) ); 373 374 Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY ); 375 if( xEventsSupplier.is() ) 376 { 377 const OUString sEventType( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) ); 378 const OUString sClickAction( RTL_CONSTASCII_USTRINGPARAM( "ClickAction" ) ); 379 380 Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW ); 381 382 uno::Sequence< beans::PropertyValue > aProperties( 3 ); 383 aProperties[0].Name = sEventType; 384 aProperties[0].Handle = -1; 385 aProperties[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") ); 386 aProperties[0].State = beans::PropertyState_DIRECT_VALUE; 387 388 aProperties[1].Name = sClickAction; 389 aProperties[1].Handle = -1; 390 aProperties[1].Value <<= ::com::sun::star::presentation::ClickAction_DOCUMENT; 391 aProperties[1].State = beans::PropertyState_DIRECT_VALUE; 392 393 aProperties[2].Name = sBookmark; 394 aProperties[2].Handle = -1; 395 aProperties[2].Value <<= msHyperlink; 396 aProperties[2].State = beans::PropertyState_DIRECT_VALUE; 397 398 const OUString sAPIEventName( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ); 399 xEvents->replaceByName( sAPIEventName, Any( aProperties ) ); 400 } 401 else 402 { 403 // in draw use the Bookmark property 404 Reference< beans::XPropertySet > xSet( mxShape, UNO_QUERY_THROW ); 405 xSet->setPropertyValue( sBookmark, Any( msHyperlink ) ); 406 xSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ), Any( ::com::sun::star::presentation::ClickAction_DOCUMENT ) ); 407 } 408 } 409 catch( Exception& ) 410 { 411 DBG_ERROR("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!"); 412 } 413 414 if( mxLockable.is() ) 415 mxLockable->removeActionLock(); 416 } 417 418 ////////////////////////////////////////////////////////////////////////////// 419 420 void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape) 421 { 422 if(xShape.is()) 423 { 424 // set shape local 425 mxShape = xShape; 426 427 if(maShapeName.getLength()) 428 { 429 uno::Reference< container::XNamed > xNamed( mxShape, uno::UNO_QUERY ); 430 if( xNamed.is() ) 431 xNamed->setName( maShapeName ); 432 } 433 434 UniReference< XMLShapeImportHelper > xImp( GetImport().GetShapeImport() ); 435 xImp->addShape( xShape, mxAttrList, mxShapes ); 436 437 if( mbClearDefaultAttributes ) 438 { 439 uno::Reference<beans::XMultiPropertyStates> xMultiPropertyStates(xShape, uno::UNO_QUERY ); 440 if (xMultiPropertyStates.is()) 441 xMultiPropertyStates->setAllPropertiesToDefault(); 442 } 443 444 if( !mbVisible || !mbPrintable ) try 445 { 446 uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY_THROW ); 447 if( !mbVisible ) 448 xSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ), uno::Any( sal_False ) ); 449 450 if( !mbPrintable ) 451 xSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Printable" ) ), uno::Any( sal_False ) ); 452 } 453 catch( Exception& ) 454 { 455 DBG_ERROR( "SdXMLShapeContext::AddShape(), exception caught!" ); 456 } 457 458 // #107848# 459 if(!mbTemporaryShape && (!GetImport().HasTextImport() 460 || !GetImport().GetTextImport()->IsInsideDeleteContext())) 461 { 462 xImp->shapeWithZIndexAdded( xShape, mnZOrder ); 463 } 464 465 if( maShapeId.getLength() ) 466 { 467 const SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(this); 468 469 /* avoid registering when LateRegister is needed. E.g. MultiImage support where in-between multiple 470 xShapes with the same ID would be registered. Registration is done after deciding which image 471 to keep, see calls to solveMultipleImages */ 472 if(!pGSC || !pGSC->getLateAddToIdentifierMapper()) 473 { 474 uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY ); 475 GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId, xRef ); 476 } 477 } 478 479 // #91065# count only if counting for shape import is enabled 480 if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled()) 481 { 482 // #80365# increment progress bar at load once for each draw object 483 GetImport().GetProgressBarHelper()->Increment(); 484 } 485 } 486 487 mxLockable = uno::Reference< document::XActionLockable >::query( xShape ); 488 489 if( mxLockable.is() ) 490 mxLockable->addActionLock(); 491 492 } 493 494 ////////////////////////////////////////////////////////////////////////////// 495 496 void SdXMLShapeContext::AddShape(const char* pServiceName ) 497 { 498 uno::Reference< lang::XMultiServiceFactory > xServiceFact(GetImport().GetModel(), uno::UNO_QUERY); 499 if(xServiceFact.is()) 500 { 501 try 502 { 503 // --> OD 2006-02-22 #b6382898# 504 // Since fix for issue i33294 the Writer model doesn't support 505 // com.sun.star.drawing.OLE2Shape anymore. 506 // To handle Draw OLE objects it's decided to import these 507 // objects as com.sun.star.drawing.OLE2Shape and convert these 508 // objects after the import into com.sun.star.drawing.GraphicObjectShape. 509 uno::Reference< drawing::XShape > xShape; 510 if ( OUString::createFromAscii(pServiceName).compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 && 511 uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() ) 512 { 513 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance(OUString::createFromAscii("com.sun.star.drawing.temporaryForXMLImportOLE2Shape")), uno::UNO_QUERY); 514 } 515 else 516 { 517 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance(OUString::createFromAscii(pServiceName)), uno::UNO_QUERY); 518 } 519 // <-- 520 if( xShape.is() ) 521 AddShape( xShape ); 522 } 523 catch( const uno::Exception& e ) 524 { 525 uno::Sequence<rtl::OUString> aSeq( 1 ); 526 aSeq[0] = OUString::createFromAscii(pServiceName); 527 GetImport().SetError( XMLERROR_FLAG_ERROR | XMLERROR_API, 528 aSeq, e.Message, NULL ); 529 } 530 } 531 } 532 533 ////////////////////////////////////////////////////////////////////////////// 534 535 void SdXMLShapeContext::SetTransformation() 536 { 537 if(mxShape.is()) 538 { 539 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 540 if(xPropSet.is()) 541 { 542 maUsedTransformation.identity(); 543 544 if(maSize.Width != 1 || maSize.Height != 1) 545 { 546 // take care there are no zeros used by error 547 if(0 == maSize.Width) 548 maSize.Width = 1; 549 if(0 == maSize.Height) 550 maSize.Height = 1; 551 552 // set global size. This should always be used. 553 maUsedTransformation.scale(maSize.Width, maSize.Height); 554 } 555 556 if(maPosition.X != 0 || maPosition.Y != 0) 557 { 558 // if global position is used, add it to transformation 559 maUsedTransformation.translate(maPosition.X, maPosition.Y); 560 } 561 562 if(mnTransform.NeedsAction()) 563 { 564 // transformation is used, apply to object. 565 // NOTICE: The transformation is applied AFTER evtl. used 566 // global positioning and scaling is used, so any shear or 567 // rotate used herein is applied around the (0,0) position 568 // of the PAGE object !!! 569 ::basegfx::B2DHomMatrix aMat; 570 mnTransform.GetFullTransform(aMat); 571 572 // now add to transformation 573 maUsedTransformation *= aMat; 574 } 575 576 // now set transformation for this object 577 uno::Any aAny; 578 drawing::HomogenMatrix3 aMatrix; 579 580 aMatrix.Line1.Column1 = maUsedTransformation.get(0, 0); 581 aMatrix.Line1.Column2 = maUsedTransformation.get(0, 1); 582 aMatrix.Line1.Column3 = maUsedTransformation.get(0, 2); 583 584 aMatrix.Line2.Column1 = maUsedTransformation.get(1, 0); 585 aMatrix.Line2.Column2 = maUsedTransformation.get(1, 1); 586 aMatrix.Line2.Column3 = maUsedTransformation.get(1, 2); 587 588 aMatrix.Line3.Column1 = maUsedTransformation.get(2, 0); 589 aMatrix.Line3.Column2 = maUsedTransformation.get(2, 1); 590 aMatrix.Line3.Column3 = maUsedTransformation.get(2, 2); 591 592 aAny <<= aMatrix; 593 594 xPropSet->setPropertyValue( 595 OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")), aAny); 596 } 597 } 598 } 599 600 ////////////////////////////////////////////////////////////////////////////// 601 602 void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */) 603 { 604 try 605 { 606 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 607 if( !xPropSet.is() ) 608 return; 609 610 do 611 { 612 XMLPropStyleContext* pDocStyle = NULL; 613 614 // set style on shape 615 if(maDrawStyleName.getLength() == 0) 616 break; 617 618 const SvXMLStyleContext* pStyle = 0L; 619 sal_Bool bAutoStyle(sal_False); 620 621 if(GetImport().GetShapeImport()->GetAutoStylesContext()) 622 pStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName); 623 624 if(pStyle) 625 bAutoStyle = sal_True; 626 627 if(!pStyle && GetImport().GetShapeImport()->GetStylesContext()) 628 pStyle = GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName); 629 630 OUString aStyleName = maDrawStyleName; 631 uno::Reference< style::XStyle > xStyle; 632 633 if( pStyle && pStyle->ISA(XMLShapeStyleContext) ) 634 { 635 pDocStyle = PTR_CAST( XMLShapeStyleContext, pStyle ); 636 637 if( pDocStyle->GetStyle().is() ) 638 { 639 xStyle = pDocStyle->GetStyle(); 640 } 641 else 642 { 643 aStyleName = pDocStyle->GetParentName(); 644 } 645 } 646 647 if( !xStyle.is() && aStyleName.getLength() ) 648 { 649 try 650 { 651 652 uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY ); 653 654 if( xFamiliesSupplier.is() ) 655 { 656 uno::Reference< container::XNameAccess > xFamilies( xFamiliesSupplier->getStyleFamilies() ); 657 if( xFamilies.is() ) 658 { 659 660 uno::Reference< container::XNameAccess > xFamily; 661 662 if( XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily ) 663 { 664 aStyleName = GetImport().GetStyleDisplayName( 665 XML_STYLE_FAMILY_SD_PRESENTATION_ID, 666 aStyleName ); 667 sal_Int32 nPos = aStyleName.lastIndexOf( sal_Unicode('-') ); 668 if( -1 != nPos ) 669 { 670 OUString aFamily( aStyleName.copy( 0, nPos ) ); 671 672 xFamilies->getByName( aFamily ) >>= xFamily; 673 aStyleName = aStyleName.copy( nPos + 1 ); 674 } 675 } 676 else 677 { 678 // get graphics familie 679 xFamilies->getByName( OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) ) ) >>= xFamily; 680 aStyleName = GetImport().GetStyleDisplayName( 681 XML_STYLE_FAMILY_SD_GRAPHICS_ID, 682 aStyleName ); 683 } 684 685 if( xFamily.is() ) 686 xFamily->getByName( aStyleName ) >>= xStyle; 687 } 688 } 689 } 690 catch( uno::Exception& ) 691 { 692 DBG_ERROR( "could not find style for shape!" ); 693 } 694 } 695 696 if( bSupportsStyle && xStyle.is() ) 697 { 698 try 699 { 700 // set style on object 701 uno::Any aAny; 702 aAny <<= xStyle; 703 xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style")), aAny); 704 } 705 catch( uno::Exception& ) 706 { 707 DBG_ERROR( "could not find style for shape!" ); 708 } 709 } 710 711 // if this is an auto style, set its properties 712 if(bAutoStyle && pDocStyle) 713 { 714 // set PropertySet on object 715 pDocStyle->FillPropertySet(xPropSet); 716 } 717 718 } while(0); 719 720 // try to set text auto style 721 do 722 { 723 // set style on shape 724 if( 0 == maTextStyleName.getLength() ) 725 break; 726 727 if( NULL == GetImport().GetShapeImport()->GetAutoStylesContext()) 728 break; 729 730 const SvXMLStyleContext* pTempStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_PARAGRAPH, maTextStyleName); 731 XMLPropStyleContext* pStyle = PTR_CAST( XMLPropStyleContext, pTempStyle ); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice 732 if( pStyle == NULL ) 733 break; 734 735 // set PropertySet on object 736 pStyle->FillPropertySet(xPropSet); 737 738 } while(0); 739 } 740 catch( uno::Exception& ) 741 { 742 } 743 } 744 745 void SdXMLShapeContext::SetLayer() 746 { 747 if( maLayerName.getLength() ) 748 { 749 try 750 { 751 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 752 if(xPropSet.is() ) 753 { 754 uno::Any aAny; 755 aAny <<= maLayerName; 756 757 xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LayerName")), aAny); 758 return; 759 } 760 } 761 catch( uno::Exception e ) 762 { 763 } 764 } 765 } 766 767 void SdXMLShapeContext::SetThumbnail() 768 { 769 if( 0 == maThumbnailURL.getLength() ) 770 return; 771 772 try 773 { 774 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 775 if( !xPropSet.is() ) 776 return; 777 778 const OUString sProperty(RTL_CONSTASCII_USTRINGPARAM("ThumbnailGraphicURL")); 779 780 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); 781 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( sProperty ) ) 782 { 783 // load the thumbnail graphic and export it to a wmf stream so we can set 784 // it at the api 785 786 const OUString aInternalURL( GetImport().ResolveGraphicObjectURL( maThumbnailURL, sal_False ) ); 787 xPropSet->setPropertyValue( sProperty, uno::makeAny( aInternalURL ) ); 788 } 789 } 790 catch( uno::Exception e ) 791 { 792 } 793 } 794 795 // this is called from the parent group for each unparsed attribute in the attribute list 796 void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 797 { 798 bool bHaveXmlId( false ); 799 if( (XML_NAMESPACE_DRAW == nPrefix) || (XML_NAMESPACE_DRAW_EXT == nPrefix) ) 800 { 801 if( IsXMLToken( rLocalName, XML_ZINDEX ) ) 802 { 803 mnZOrder = rValue.toInt32(); 804 } 805 else if( IsXMLToken( rLocalName, XML_ID ) ) 806 { 807 if (!bHaveXmlId) { maShapeId = rValue; }; 808 } 809 else if( IsXMLToken( rLocalName, XML_NAME ) ) 810 { 811 maShapeName = rValue; 812 } 813 else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) ) 814 { 815 maDrawStyleName = rValue; 816 } 817 else if( IsXMLToken( rLocalName, XML_TEXT_STYLE_NAME ) ) 818 { 819 maTextStyleName = rValue; 820 } 821 else if( IsXMLToken( rLocalName, XML_LAYER ) ) 822 { 823 maLayerName = rValue; 824 } 825 else if( IsXMLToken( rLocalName, XML_TRANSFORM ) ) 826 { 827 mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter()); 828 } 829 else if( IsXMLToken( rLocalName, XML_DISPLAY ) ) 830 { 831 mbVisible = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_SCREEN ); 832 mbPrintable = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_PRINTER ); 833 } 834 } 835 else if( XML_NAMESPACE_PRESENTATION == nPrefix ) 836 { 837 if( IsXMLToken( rLocalName, XML_USER_TRANSFORMED ) ) 838 { 839 mbIsUserTransformed = IsXMLToken( rValue, XML_TRUE ); 840 } 841 else if( IsXMLToken( rLocalName, XML_PLACEHOLDER ) ) 842 { 843 mbIsPlaceholder = IsXMLToken( rValue, XML_TRUE ); 844 if( mbIsPlaceholder ) 845 mbClearDefaultAttributes = false; 846 } 847 else if( IsXMLToken( rLocalName, XML_CLASS ) ) 848 { 849 maPresentationClass = rValue; 850 } 851 else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) ) 852 { 853 maDrawStyleName = rValue; 854 mnStyleFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID; 855 } 856 } 857 else if( XML_NAMESPACE_SVG == nPrefix ) 858 { 859 if( IsXMLToken( rLocalName, XML_X ) ) 860 { 861 GetImport().GetMM100UnitConverter().convertMeasure(maPosition.X, rValue); 862 } 863 else if( IsXMLToken( rLocalName, XML_Y ) ) 864 { 865 GetImport().GetMM100UnitConverter().convertMeasure(maPosition.Y, rValue); 866 } 867 else if( IsXMLToken( rLocalName, XML_WIDTH ) ) 868 { 869 GetImport().GetMM100UnitConverter().convertMeasure(maSize.Width, rValue); 870 if( maSize.Width > 0 ) 871 maSize.Width += 1; 872 else if( maSize.Width < 0 ) 873 maSize.Width -= 1; 874 } 875 else if( IsXMLToken( rLocalName, XML_HEIGHT ) ) 876 { 877 GetImport().GetMM100UnitConverter().convertMeasure(maSize.Height, rValue); 878 if( maSize.Height > 0 ) 879 maSize.Height += 1; 880 else if( maSize.Height < 0 ) 881 maSize.Height -= 1; 882 } 883 else if( IsXMLToken( rLocalName, XML_TRANSFORM ) ) 884 { 885 // because of #85127# take svg:transform into account and hanle like 886 // draw:transform for compatibility 887 mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter()); 888 } 889 890 // #i68101# 891 else if( IsXMLToken( rLocalName, XML_TITLE ) ) 892 { 893 maShapeTitle = rValue; 894 } 895 else if( IsXMLToken( rLocalName, XML_DESC ) ) 896 { 897 maShapeDescription = rValue; 898 } 899 } 900 else if( (XML_NAMESPACE_NONE == nPrefix) || (XML_NAMESPACE_XML == nPrefix) ) 901 { 902 if( IsXMLToken( rLocalName, XML_ID ) ) 903 { 904 maShapeId = rValue; 905 bHaveXmlId = true; 906 } 907 } 908 } 909 910 sal_Bool SdXMLShapeContext::isPresentationShape() const 911 { 912 if( maPresentationClass.getLength() && (const_cast<SdXMLShapeContext*>(this))->GetImport().GetShapeImport()->IsPresentationShapesSupported() ) 913 { 914 if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily) 915 { 916 return sal_True; 917 } 918 919 if( IsXMLToken( maPresentationClass, XML_HEADER ) || IsXMLToken( maPresentationClass, XML_FOOTER ) || 920 IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) || IsXMLToken( maPresentationClass, XML_DATE_TIME ) ) 921 { 922 return sal_True; 923 } 924 } 925 926 return sal_False; 927 } 928 929 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 930 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 931 932 TYPEINIT1( SdXMLRectShapeContext, SdXMLShapeContext ); 933 934 SdXMLRectShapeContext::SdXMLRectShapeContext( 935 SvXMLImport& rImport, 936 sal_uInt16 nPrfx, 937 const OUString& rLocalName, 938 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 939 uno::Reference< drawing::XShapes >& rShapes, 940 sal_Bool bTemporaryShape) 941 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 942 mnRadius( 0L ) 943 { 944 } 945 946 ////////////////////////////////////////////////////////////////////////////// 947 948 SdXMLRectShapeContext::~SdXMLRectShapeContext() 949 { 950 } 951 952 ////////////////////////////////////////////////////////////////////////////// 953 954 // this is called from the parent group for each unparsed attribute in the attribute list 955 void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 956 { 957 if( XML_NAMESPACE_DRAW == nPrefix ) 958 { 959 if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) ) 960 { 961 GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue); 962 return; 963 } 964 } 965 966 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 967 } 968 969 ////////////////////////////////////////////////////////////////////////////// 970 971 void SdXMLRectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 972 { 973 // create rectangle shape 974 AddShape("com.sun.star.drawing.RectangleShape"); 975 if(mxShape.is()) 976 { 977 // Add, set Style and properties from base shape 978 SetStyle(); 979 SetLayer(); 980 981 // set pos, size, shear and rotate 982 SetTransformation(); 983 984 if(mnRadius) 985 { 986 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 987 if(xPropSet.is()) 988 { 989 try 990 { 991 xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) ); 992 } 993 catch( uno::Exception& ) 994 { 995 DBG_ERROR( "exception during setting of corner radius!"); 996 } 997 } 998 } 999 SdXMLShapeContext::StartElement(xAttrList); 1000 } 1001 } 1002 1003 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1004 ////////////////////////////////////////3//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1005 1006 TYPEINIT1( SdXMLLineShapeContext, SdXMLShapeContext ); 1007 1008 SdXMLLineShapeContext::SdXMLLineShapeContext( 1009 SvXMLImport& rImport, 1010 sal_uInt16 nPrfx, 1011 const OUString& rLocalName, 1012 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 1013 uno::Reference< drawing::XShapes >& rShapes, 1014 sal_Bool bTemporaryShape) 1015 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 1016 mnX1( 0L ), 1017 mnY1( 0L ), 1018 mnX2( 1L ), 1019 mnY2( 1L ) 1020 { 1021 } 1022 1023 ////////////////////////////////////////////////////////////////////////////// 1024 1025 SdXMLLineShapeContext::~SdXMLLineShapeContext() 1026 { 1027 } 1028 1029 ////////////////////////////////////////////////////////////////////////////// 1030 1031 // this is called from the parent group for each unparsed attribute in the attribute list 1032 void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 1033 { 1034 if( XML_NAMESPACE_SVG == nPrefix ) 1035 { 1036 if( IsXMLToken( rLocalName, XML_X1 ) ) 1037 { 1038 GetImport().GetMM100UnitConverter().convertMeasure(mnX1, rValue); 1039 return; 1040 } 1041 if( IsXMLToken( rLocalName, XML_Y1 ) ) 1042 { 1043 GetImport().GetMM100UnitConverter().convertMeasure(mnY1, rValue); 1044 return; 1045 } 1046 if( IsXMLToken( rLocalName, XML_X2 ) ) 1047 { 1048 GetImport().GetMM100UnitConverter().convertMeasure(mnX2, rValue); 1049 return; 1050 } 1051 if( IsXMLToken( rLocalName, XML_Y2 ) ) 1052 { 1053 GetImport().GetMM100UnitConverter().convertMeasure(mnY2, rValue); 1054 return; 1055 } 1056 } 1057 1058 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 1059 } 1060 1061 ////////////////////////////////////////////////////////////////////////////// 1062 1063 void SdXMLLineShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 1064 { 1065 // #85920# use SetTransformation() to handle import of simple lines. 1066 // This is necessary to kake into account all anchor positions and 1067 // other things. All shape imports use the same import schemata now. 1068 // create necessary shape (Line Shape) 1069 AddShape("com.sun.star.drawing.PolyLineShape"); 1070 1071 if(mxShape.is()) 1072 { 1073 // Add, set Style and properties from base shape 1074 SetStyle(); 1075 SetLayer(); 1076 1077 // get sizes and offsets 1078 awt::Point aTopLeft(mnX1, mnY1); 1079 awt::Point aBottomRight(mnX2, mnY2); 1080 1081 if(mnX1 > mnX2) 1082 { 1083 aTopLeft.X = mnX2; 1084 aBottomRight.X = mnX1; 1085 } 1086 1087 if(mnY1 > mnY2) 1088 { 1089 aTopLeft.Y = mnY2; 1090 aBottomRight.Y = mnY1; 1091 } 1092 1093 // set local parameters on shape 1094 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 1095 if(xPropSet.is()) 1096 { 1097 drawing::PointSequenceSequence aPolyPoly(1L); 1098 drawing::PointSequence* pOuterSequence = aPolyPoly.getArray(); 1099 pOuterSequence->realloc(2L); 1100 awt::Point* pInnerSequence = pOuterSequence->getArray(); 1101 uno::Any aAny; 1102 1103 *pInnerSequence = awt::Point( mnX1 - aTopLeft.X, mnY1 - aTopLeft.Y); 1104 pInnerSequence++; 1105 *pInnerSequence = awt::Point( mnX2 - aTopLeft.X, mnY2 - aTopLeft.Y); 1106 1107 aAny <<= aPolyPoly; 1108 xPropSet->setPropertyValue( 1109 OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny); 1110 } 1111 1112 // set sizes for transformation 1113 maSize.Width = aBottomRight.X - aTopLeft.X; 1114 maSize.Height = aBottomRight.Y - aTopLeft.Y; 1115 maPosition.X = aTopLeft.X; 1116 maPosition.Y = aTopLeft.Y; 1117 1118 // set pos, size, shear and rotate and get copy of matrix 1119 SetTransformation(); 1120 1121 SdXMLShapeContext::StartElement(xAttrList); 1122 } 1123 } 1124 1125 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1126 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1127 1128 TYPEINIT1( SdXMLEllipseShapeContext, SdXMLShapeContext ); 1129 1130 SdXMLEllipseShapeContext::SdXMLEllipseShapeContext( 1131 SvXMLImport& rImport, 1132 sal_uInt16 nPrfx, 1133 const OUString& rLocalName, 1134 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 1135 uno::Reference< drawing::XShapes >& rShapes, 1136 sal_Bool bTemporaryShape) 1137 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 1138 mnCX( 0L ), 1139 mnCY( 0L ), 1140 mnRX( 1L ), 1141 mnRY( 1L ), 1142 meKind( drawing::CircleKind_FULL ), 1143 mnStartAngle( 0 ), 1144 mnEndAngle( 0 ) 1145 { 1146 } 1147 1148 ////////////////////////////////////////////////////////////////////////////// 1149 1150 SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext() 1151 { 1152 } 1153 1154 ////////////////////////////////////////////////////////////////////////////// 1155 1156 // this is called from the parent group for each unparsed attribute in the attribute list 1157 void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 1158 { 1159 if( XML_NAMESPACE_SVG == nPrefix ) 1160 { 1161 if( IsXMLToken( rLocalName, XML_RX ) ) 1162 { 1163 GetImport().GetMM100UnitConverter().convertMeasure(mnRX, rValue); 1164 return; 1165 } 1166 if( IsXMLToken( rLocalName, XML_RY ) ) 1167 { 1168 GetImport().GetMM100UnitConverter().convertMeasure(mnRY, rValue); 1169 return; 1170 } 1171 if( IsXMLToken( rLocalName, XML_CX ) ) 1172 { 1173 GetImport().GetMM100UnitConverter().convertMeasure(mnCX, rValue); 1174 return; 1175 } 1176 if( IsXMLToken( rLocalName, XML_CY ) ) 1177 { 1178 GetImport().GetMM100UnitConverter().convertMeasure(mnCY, rValue); 1179 return; 1180 } 1181 if( IsXMLToken( rLocalName, XML_R ) ) 1182 { 1183 // single radius, it's a circle and both radii are the same 1184 GetImport().GetMM100UnitConverter().convertMeasure(mnRX, rValue); 1185 mnRY = mnRX; 1186 return; 1187 } 1188 } 1189 else if( XML_NAMESPACE_DRAW == nPrefix ) 1190 { 1191 if( IsXMLToken( rLocalName, XML_KIND ) ) 1192 { 1193 sal_uInt16 eKind; 1194 if( SvXMLUnitConverter::convertEnum( eKind, rValue, aXML_CircleKind_EnumMap ) ) 1195 { 1196 meKind = eKind; 1197 } 1198 return; 1199 } 1200 if( IsXMLToken( rLocalName, XML_START_ANGLE ) ) 1201 { 1202 double dStartAngle; 1203 if( SvXMLUnitConverter::convertDouble( dStartAngle, rValue ) ) 1204 mnStartAngle = (sal_Int32)(dStartAngle * 100.0); 1205 return; 1206 } 1207 if( IsXMLToken( rLocalName, XML_END_ANGLE ) ) 1208 { 1209 double dEndAngle; 1210 if( SvXMLUnitConverter::convertDouble( dEndAngle, rValue ) ) 1211 mnEndAngle = (sal_Int32)(dEndAngle * 100.0); 1212 return; 1213 } 1214 } 1215 1216 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 1217 } 1218 1219 ////////////////////////////////////////////////////////////////////////////// 1220 1221 void SdXMLEllipseShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 1222 { 1223 // create rectangle shape 1224 AddShape("com.sun.star.drawing.EllipseShape"); 1225 if(mxShape.is()) 1226 { 1227 // Add, set Style and properties from base shape 1228 SetStyle(); 1229 SetLayer(); 1230 1231 if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1) 1232 { 1233 // #121972# center/radius is used, put to pos and size 1234 maSize.Width = 2 * mnRX; 1235 maSize.Height = 2 * mnRY; 1236 maPosition.X = mnCX - mnRX; 1237 maPosition.Y = mnCY - mnRY; 1238 } 1239 1240 // set pos, size, shear and rotate 1241 SetTransformation(); 1242 1243 if( meKind != drawing::CircleKind_FULL ) 1244 { 1245 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY ); 1246 if( xPropSet.is() ) 1247 { 1248 uno::Any aAny; 1249 aAny <<= (drawing::CircleKind)meKind; 1250 xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleKind")), aAny ); 1251 1252 aAny <<= mnStartAngle; 1253 xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleStartAngle")), aAny ); 1254 1255 aAny <<= mnEndAngle; 1256 xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleEndAngle")), aAny ); 1257 } 1258 } 1259 1260 SdXMLShapeContext::StartElement(xAttrList); 1261 } 1262 } 1263 1264 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1265 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1266 1267 TYPEINIT1( SdXMLPolygonShapeContext, SdXMLShapeContext ); 1268 1269 SdXMLPolygonShapeContext::SdXMLPolygonShapeContext( 1270 SvXMLImport& rImport, 1271 sal_uInt16 nPrfx, 1272 const OUString& rLocalName, 1273 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 1274 uno::Reference< drawing::XShapes >& rShapes, sal_Bool bClosed, sal_Bool bTemporaryShape) 1275 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 1276 mbClosed( bClosed ) 1277 { 1278 } 1279 1280 ////////////////////////////////////////////////////////////////////////////// 1281 1282 // this is called from the parent group for each unparsed attribute in the attribute list 1283 void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 1284 { 1285 if( XML_NAMESPACE_SVG == nPrefix ) 1286 { 1287 if( IsXMLToken( rLocalName, XML_VIEWBOX ) ) 1288 { 1289 maViewBox = rValue; 1290 return; 1291 } 1292 } 1293 else if( XML_NAMESPACE_DRAW == nPrefix ) 1294 { 1295 if( IsXMLToken( rLocalName, XML_POINTS ) ) 1296 { 1297 maPoints = rValue; 1298 return; 1299 } 1300 } 1301 1302 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 1303 } 1304 1305 ////////////////////////////////////////////////////////////////////////////// 1306 1307 SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext() 1308 { 1309 } 1310 1311 ////////////////////////////////////////////////////////////////////////////// 1312 1313 void SdXMLPolygonShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 1314 { 1315 // Add, set Style and properties from base shape 1316 if(mbClosed) 1317 AddShape("com.sun.star.drawing.PolyPolygonShape"); 1318 else 1319 AddShape("com.sun.star.drawing.PolyLineShape"); 1320 1321 if( mxShape.is() ) 1322 { 1323 SetStyle(); 1324 SetLayer(); 1325 1326 // set local parameters on shape 1327 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 1328 if(xPropSet.is()) 1329 { 1330 // set polygon 1331 if(maPoints.getLength() && maViewBox.getLength()) 1332 { 1333 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); 1334 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); 1335 1336 // Is this correct? It overrides ViewBox stuff; OTOH it makes no 1337 // sense to have the geometry content size different from object size 1338 if(maSize.Width != 0 && maSize.Height != 0) 1339 { 1340 aSize = basegfx::B2DVector(maSize.Width, maSize.Height); 1341 } 1342 1343 basegfx::B2DPolygon aPolygon; 1344 1345 if(basegfx::tools::importFromSvgPoints(aPolygon, maPoints)) 1346 { 1347 if(aPolygon.count()) 1348 { 1349 const basegfx::B2DRange aSourceRange( 1350 aViewBox.GetX(), aViewBox.GetY(), 1351 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); 1352 const basegfx::B2DRange aTargetRange( 1353 aViewBox.GetX(), aViewBox.GetY(), 1354 aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY()); 1355 1356 if(!aSourceRange.equal(aTargetRange)) 1357 { 1358 aPolygon.transform( 1359 basegfx::tools::createSourceRangeTargetRangeTransform( 1360 aSourceRange, 1361 aTargetRange)); 1362 } 1363 1364 com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence; 1365 uno::Any aAny; 1366 1367 basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(basegfx::B2DPolyPolygon(aPolygon), aPointSequenceSequence); 1368 aAny <<= aPointSequenceSequence; 1369 xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny); 1370 } 1371 } 1372 } 1373 } 1374 1375 // set pos, size, shear and rotate and get copy of matrix 1376 SetTransformation(); 1377 1378 SdXMLShapeContext::StartElement(xAttrList); 1379 } 1380 } 1381 1382 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1383 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1384 1385 TYPEINIT1( SdXMLPathShapeContext, SdXMLShapeContext ); 1386 1387 SdXMLPathShapeContext::SdXMLPathShapeContext( 1388 SvXMLImport& rImport, 1389 sal_uInt16 nPrfx, 1390 const OUString& rLocalName, 1391 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 1392 uno::Reference< drawing::XShapes >& rShapes, 1393 sal_Bool bTemporaryShape) 1394 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 1395 mbClosed( sal_True ) 1396 { 1397 } 1398 1399 ////////////////////////////////////////////////////////////////////////////// 1400 1401 SdXMLPathShapeContext::~SdXMLPathShapeContext() 1402 { 1403 } 1404 1405 ////////////////////////////////////////////////////////////////////////////// 1406 1407 // this is called from the parent group for each unparsed attribute in the attribute list 1408 void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 1409 { 1410 if( XML_NAMESPACE_SVG == nPrefix ) 1411 { 1412 if( IsXMLToken( rLocalName, XML_VIEWBOX ) ) 1413 { 1414 maViewBox = rValue; 1415 return; 1416 } 1417 else if( IsXMLToken( rLocalName, XML_D ) ) 1418 { 1419 maD = rValue; 1420 return; 1421 } 1422 } 1423 1424 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 1425 } 1426 1427 ////////////////////////////////////////////////////////////////////////////// 1428 1429 void SdXMLPathShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 1430 { 1431 // create polygon shape 1432 if(maD.getLength()) 1433 { 1434 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); 1435 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); 1436 1437 // Is this correct? It overrides ViewBox stuff; OTOH it makes no 1438 // sense to have the geometry content size different from object size 1439 if(maSize.Width != 0 && maSize.Height != 0) 1440 { 1441 aSize = basegfx::B2DVector(maSize.Width, maSize.Height); 1442 } 1443 1444 basegfx::B2DPolyPolygon aPolyPolygon; 1445 1446 if(basegfx::tools::importFromSvgD(aPolyPolygon, maD, true, 0)) 1447 { 1448 if(aPolyPolygon.count()) 1449 { 1450 const basegfx::B2DRange aSourceRange( 1451 aViewBox.GetX(), aViewBox.GetY(), 1452 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); 1453 const basegfx::B2DRange aTargetRange( 1454 aViewBox.GetX(), aViewBox.GetY(), 1455 aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY()); 1456 1457 if(!aSourceRange.equal(aTargetRange)) 1458 { 1459 aPolyPolygon.transform( 1460 basegfx::tools::createSourceRangeTargetRangeTransform( 1461 aSourceRange, 1462 aTargetRange)); 1463 } 1464 1465 // create shape 1466 const char* pService; 1467 1468 if(aPolyPolygon.areControlPointsUsed()) 1469 { 1470 if(aPolyPolygon.isClosed()) 1471 { 1472 pService = "com.sun.star.drawing.ClosedBezierShape"; 1473 } 1474 else 1475 { 1476 pService = "com.sun.star.drawing.OpenBezierShape"; 1477 } 1478 } 1479 else 1480 { 1481 if(aPolyPolygon.isClosed()) 1482 { 1483 pService = "com.sun.star.drawing.PolyPolygonShape"; 1484 } 1485 else 1486 { 1487 pService = "com.sun.star.drawing.PolyLineShape"; 1488 } 1489 } 1490 1491 // Add, set Style and properties from base shape 1492 AddShape(pService); 1493 1494 // #89344# test for mxShape.is() and not for mxShapes.is() to support 1495 // shape import helper classes WITHOUT XShapes (member mxShapes). This 1496 // is used by the writer. 1497 if( mxShape.is() ) 1498 { 1499 SetStyle(); 1500 SetLayer(); 1501 1502 // set local parameters on shape 1503 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 1504 1505 if(xPropSet.is()) 1506 { 1507 uno::Any aAny; 1508 1509 // set polygon data 1510 if(aPolyPolygon.areControlPointsUsed()) 1511 { 1512 drawing::PolyPolygonBezierCoords aSourcePolyPolygon; 1513 1514 basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords( 1515 aPolyPolygon, 1516 aSourcePolyPolygon); 1517 aAny <<= aSourcePolyPolygon; 1518 } 1519 else 1520 { 1521 drawing::PointSequenceSequence aSourcePolyPolygon; 1522 1523 basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence( 1524 aPolyPolygon, 1525 aSourcePolyPolygon); 1526 aAny <<= aSourcePolyPolygon; 1527 } 1528 1529 xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny); 1530 } 1531 1532 // set pos, size, shear and rotate 1533 SetTransformation(); 1534 1535 SdXMLShapeContext::StartElement(xAttrList); 1536 } 1537 } 1538 } 1539 } 1540 } 1541 1542 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1543 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1544 1545 TYPEINIT1( SdXMLTextBoxShapeContext, SdXMLShapeContext ); 1546 1547 SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext( 1548 SvXMLImport& rImport, 1549 sal_uInt16 nPrfx, 1550 const OUString& rLocalName, 1551 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 1552 uno::Reference< drawing::XShapes >& rShapes, 1553 sal_Bool bTemporaryShape) 1554 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 1555 mnRadius(0) 1556 { 1557 } 1558 1559 ////////////////////////////////////////////////////////////////////////////// 1560 1561 SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext() 1562 { 1563 } 1564 1565 ////////////////////////////////////////////////////////////////////////////// 1566 1567 // this is called from the parent group for each unparsed attribute in the attribute list 1568 void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 1569 { 1570 if( XML_NAMESPACE_DRAW == nPrefix ) 1571 { 1572 if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) ) 1573 { 1574 GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue); 1575 return; 1576 } 1577 } 1578 1579 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 1580 } 1581 1582 ////////////////////////////////////////////////////////////////////////////// 1583 1584 void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&) 1585 { 1586 // create textbox shape 1587 sal_Bool bIsPresShape = sal_False; 1588 bool bClearText = false; 1589 1590 const char *pService = NULL; 1591 1592 if( isPresentationShape() ) 1593 { 1594 // check if the current document supports presentation shapes 1595 if( GetImport().GetShapeImport()->IsPresentationShapesSupported() ) 1596 { 1597 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_SUBTITLE )) 1598 { 1599 // XmlShapeTypePresSubtitleShape 1600 pService = "com.sun.star.presentation.SubtitleShape"; 1601 } 1602 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OUTLINE ) ) 1603 { 1604 // XmlShapeTypePresOutlinerShape 1605 pService = "com.sun.star.presentation.OutlinerShape"; 1606 } 1607 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_NOTES ) ) 1608 { 1609 // XmlShapeTypePresNotesShape 1610 pService = "com.sun.star.presentation.NotesShape"; 1611 } 1612 else if( IsXMLToken( maPresentationClass, XML_HEADER ) ) 1613 { 1614 // XmlShapeTypePresHeaderShape 1615 pService = "com.sun.star.presentation.HeaderShape"; 1616 bClearText = true; 1617 } 1618 else if( IsXMLToken( maPresentationClass, XML_FOOTER ) ) 1619 { 1620 // XmlShapeTypePresFooterShape 1621 pService = "com.sun.star.presentation.FooterShape"; 1622 bClearText = true; 1623 } 1624 else if( IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) ) 1625 { 1626 // XmlShapeTypePresSlideNumberShape 1627 pService = "com.sun.star.presentation.SlideNumberShape"; 1628 bClearText = true; 1629 } 1630 else if( IsXMLToken( maPresentationClass, XML_DATE_TIME ) ) 1631 { 1632 // XmlShapeTypePresDateTimeShape 1633 pService = "com.sun.star.presentation.DateTimeShape"; 1634 bClearText = true; 1635 } 1636 else // IsXMLToken( maPresentationClass, XML_PRESENTATION_TITLE ) ) 1637 { 1638 // XmlShapeTypePresTitleTextShape 1639 pService = "com.sun.star.presentation.TitleTextShape"; 1640 } 1641 bIsPresShape = sal_True; 1642 } 1643 } 1644 1645 if( NULL == pService ) 1646 { 1647 // normal text shape 1648 pService = "com.sun.star.drawing.TextShape"; 1649 } 1650 1651 // Add, set Style and properties from base shape 1652 AddShape(pService); 1653 1654 if( mxShape.is() ) 1655 { 1656 SetStyle(); 1657 SetLayer(); 1658 1659 if(bIsPresShape) 1660 { 1661 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 1662 if(xProps.is()) 1663 { 1664 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); 1665 if( xPropsInfo.is() ) 1666 { 1667 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ))) 1668 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) ); 1669 1670 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ))) 1671 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) ); 1672 } 1673 } 1674 } 1675 1676 if( bClearText ) 1677 { 1678 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); 1679 OUString aEmpty; 1680 xText->setString( aEmpty ); 1681 } 1682 1683 // set parameters on shape 1684 //A AW->CL: Eventually You need to strip scale and translate from the transformation 1685 //A to reach the same goal again. 1686 //A if(!bIsPresShape || mbIsUserTransformed) 1687 //A { 1688 //A // set pos and size on shape, this should remove binding 1689 //A // to pres object on masterpage 1690 //A SetSizeAndPosition(); 1691 //A } 1692 1693 // set pos, size, shear and rotate 1694 SetTransformation(); 1695 1696 if(mnRadius) 1697 { 1698 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 1699 if(xPropSet.is()) 1700 { 1701 try 1702 { 1703 xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) ); 1704 } 1705 catch( uno::Exception& ) 1706 { 1707 DBG_ERROR( "exception during setting of corner radius!"); 1708 } 1709 } 1710 } 1711 1712 SdXMLShapeContext::StartElement(mxAttrList); 1713 } 1714 } 1715 1716 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1717 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1718 1719 TYPEINIT1( SdXMLControlShapeContext, SdXMLShapeContext ); 1720 1721 SdXMLControlShapeContext::SdXMLControlShapeContext( 1722 SvXMLImport& rImport, 1723 sal_uInt16 nPrfx, 1724 const OUString& rLocalName, 1725 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 1726 uno::Reference< drawing::XShapes >& rShapes, 1727 sal_Bool bTemporaryShape) 1728 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ) 1729 { 1730 } 1731 1732 ////////////////////////////////////////////////////////////////////////////// 1733 1734 SdXMLControlShapeContext::~SdXMLControlShapeContext() 1735 { 1736 } 1737 1738 ////////////////////////////////////////////////////////////////////////////// 1739 1740 // this is called from the parent group for each unparsed attribute in the attribute list 1741 void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 1742 { 1743 if( XML_NAMESPACE_DRAW == nPrefix ) 1744 { 1745 if( IsXMLToken( rLocalName, XML_CONTROL ) ) 1746 { 1747 maFormId = rValue; 1748 return; 1749 } 1750 } 1751 1752 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 1753 } 1754 1755 void SdXMLControlShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 1756 { 1757 // create Control shape 1758 // add, set style and properties from base shape 1759 AddShape("com.sun.star.drawing.ControlShape"); 1760 if( mxShape.is() ) 1761 { 1762 DBG_ASSERT( maFormId.getLength(), "draw:control without a form:id attribute!" ); 1763 if( maFormId.getLength() ) 1764 { 1765 #ifndef SVX_LIGHT 1766 if( GetImport().IsFormsSupported() ) 1767 { 1768 uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY ); 1769 if( xControlModel.is() ) 1770 { 1771 uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY ); 1772 if( xControl.is() ) 1773 xControl->setControl( xControlModel ); 1774 1775 } 1776 } 1777 #endif // #ifndef SVX_LIGHT 1778 } 1779 1780 SetStyle(); 1781 SetLayer(); 1782 1783 // set pos, size, shear and rotate 1784 SetTransformation(); 1785 1786 SdXMLShapeContext::StartElement(xAttrList); 1787 } 1788 } 1789 1790 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1791 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1792 1793 TYPEINIT1( SdXMLConnectorShapeContext, SdXMLShapeContext ); 1794 1795 SdXMLConnectorShapeContext::SdXMLConnectorShapeContext( 1796 SvXMLImport& rImport, 1797 sal_uInt16 nPrfx, 1798 const OUString& rLocalName, 1799 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 1800 uno::Reference< drawing::XShapes >& rShapes, 1801 sal_Bool bTemporaryShape) 1802 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 1803 maStart(0,0), 1804 maEnd(1,1), 1805 mnType( (sal_uInt16)drawing::ConnectorType_STANDARD ), 1806 mnStartGlueId(-1), 1807 mnEndGlueId(-1), 1808 mnDelta1(0), 1809 mnDelta2(0), 1810 mnDelta3(0) 1811 { 1812 } 1813 1814 ////////////////////////////////////////////////////////////////////////////// 1815 1816 SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext() 1817 { 1818 } 1819 1820 ////////////////////////////////////////////////////////////////////////////// 1821 1822 // this is called from the parent group for each unparsed attribute in the attribute list 1823 void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 1824 { 1825 switch( nPrefix ) 1826 { 1827 case XML_NAMESPACE_DRAW: 1828 { 1829 if( IsXMLToken( rLocalName, XML_START_SHAPE ) ) 1830 { 1831 maStartShapeId = rValue; 1832 return; 1833 } 1834 if( IsXMLToken( rLocalName, XML_START_GLUE_POINT ) ) 1835 { 1836 mnStartGlueId = rValue.toInt32(); 1837 return; 1838 } 1839 if( IsXMLToken( rLocalName, XML_END_SHAPE ) ) 1840 { 1841 maEndShapeId = rValue; 1842 return; 1843 } 1844 if( IsXMLToken( rLocalName, XML_END_GLUE_POINT ) ) 1845 { 1846 mnEndGlueId = rValue.toInt32(); 1847 return; 1848 } 1849 if( IsXMLToken( rLocalName, XML_LINE_SKEW ) ) 1850 { 1851 SvXMLTokenEnumerator aTokenEnum( rValue ); 1852 OUString aToken; 1853 if( aTokenEnum.getNextToken( aToken ) ) 1854 { 1855 GetImport().GetMM100UnitConverter().convertMeasure(mnDelta1, aToken); 1856 if( aTokenEnum.getNextToken( aToken ) ) 1857 { 1858 GetImport().GetMM100UnitConverter().convertMeasure(mnDelta2, aToken); 1859 if( aTokenEnum.getNextToken( aToken ) ) 1860 { 1861 GetImport().GetMM100UnitConverter().convertMeasure(mnDelta3, aToken); 1862 } 1863 } 1864 } 1865 return; 1866 } 1867 if( IsXMLToken( rLocalName, XML_TYPE ) ) 1868 { 1869 SvXMLUnitConverter::convertEnum( mnType, rValue, aXML_ConnectionKind_EnumMap ); 1870 return; 1871 } 1872 // #121965# draw:transform may be used in ODF1.2, e.g. exports from MS seem to use these 1873 else if( IsXMLToken( rLocalName, XML_TRANSFORM ) ) 1874 { 1875 mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter()); 1876 } 1877 } 1878 case XML_NAMESPACE_SVG: 1879 { 1880 if( IsXMLToken( rLocalName, XML_X1 ) ) 1881 { 1882 GetImport().GetMM100UnitConverter().convertMeasure(maStart.X, rValue); 1883 return; 1884 } 1885 if( IsXMLToken( rLocalName, XML_Y1 ) ) 1886 { 1887 GetImport().GetMM100UnitConverter().convertMeasure(maStart.Y, rValue); 1888 return; 1889 } 1890 if( IsXMLToken( rLocalName, XML_X2 ) ) 1891 { 1892 GetImport().GetMM100UnitConverter().convertMeasure(maEnd.X, rValue); 1893 return; 1894 } 1895 if( IsXMLToken( rLocalName, XML_Y2 ) ) 1896 { 1897 GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue); 1898 return; 1899 } 1900 if( IsXMLToken( rLocalName, XML_D ) ) 1901 { 1902 basegfx::B2DPolyPolygon aPolyPolygon; 1903 1904 if(basegfx::tools::importFromSvgD(aPolyPolygon, rValue, true, 0)) 1905 { 1906 if(aPolyPolygon.count()) 1907 { 1908 // set polygon data 1909 if(aPolyPolygon.areControlPointsUsed()) 1910 { 1911 drawing::PolyPolygonBezierCoords aSourcePolyPolygon; 1912 1913 basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords( 1914 aPolyPolygon, 1915 aSourcePolyPolygon); 1916 maPath <<= aSourcePolyPolygon; 1917 } 1918 else 1919 { 1920 drawing::PointSequenceSequence aSourcePolyPolygon; 1921 1922 basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence( 1923 aPolyPolygon, 1924 aSourcePolyPolygon); 1925 maPath <<= aSourcePolyPolygon; 1926 } 1927 } 1928 } 1929 } 1930 } 1931 } 1932 1933 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 1934 } 1935 1936 ////////////////////////////////////////////////////////////////////////////// 1937 1938 void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 1939 { 1940 // #107928# 1941 // For security reasons, do not add empty connectors. There may have been an error in EA2 1942 // that created empty, far set off connectors (e.g. 63 meters below top of document). This 1943 // is not guaranteed, but it's definitely safe to not add empty connectors. 1944 sal_Bool bDoAdd(sal_True); 1945 1946 if( 0 == maStartShapeId.getLength() 1947 && 0 == maEndShapeId.getLength() 1948 && maStart.X == maEnd.X 1949 && maStart.Y == maEnd.Y 1950 && 0 == mnDelta1 1951 && 0 == mnDelta2 1952 && 0 == mnDelta3 1953 ) 1954 { 1955 bDoAdd = sal_False; 1956 } 1957 1958 if(bDoAdd) 1959 { 1960 // create Connector shape 1961 // add, set style and properties from base shape 1962 AddShape("com.sun.star.drawing.ConnectorShape"); 1963 if(mxShape.is()) 1964 { 1965 // #121965# if draw:transform is used, apply directly to the start 1966 // and end positions before using these 1967 if(mnTransform.NeedsAction()) 1968 { 1969 // transformation is used, apply to object. 1970 ::basegfx::B2DHomMatrix aMat; 1971 mnTransform.GetFullTransform(aMat); 1972 1973 if(!aMat.isIdentity()) 1974 { 1975 basegfx::B2DPoint aStart(maStart.X, maStart.Y); 1976 basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y); 1977 1978 aStart = aMat * aStart; 1979 aEnd = aMat * aEnd; 1980 1981 maStart.X = basegfx::fround(aStart.getX()); 1982 maStart.Y = basegfx::fround(aStart.getY()); 1983 maEnd.X = basegfx::fround(aEnd.getX()); 1984 maEnd.Y = basegfx::fround(aEnd.getY()); 1985 } 1986 } 1987 1988 // add connection ids 1989 if( maStartShapeId.getLength() ) 1990 GetImport().GetShapeImport()->addShapeConnection( mxShape, sal_True, maStartShapeId, mnStartGlueId ); 1991 if( maEndShapeId.getLength() ) 1992 GetImport().GetShapeImport()->addShapeConnection( mxShape, sal_False, maEndShapeId, mnEndGlueId ); 1993 1994 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 1995 if( xProps.is() ) 1996 { 1997 uno::Any aAny; 1998 aAny <<= maStart; 1999 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny); 2000 2001 aAny <<= maEnd; 2002 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny ); 2003 2004 aAny <<= (drawing::ConnectorType)mnType; 2005 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind")), aAny ); 2006 2007 aAny <<= mnDelta1; 2008 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta")), aAny ); 2009 2010 aAny <<= mnDelta2; 2011 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta")), aAny ); 2012 2013 aAny <<= mnDelta3; 2014 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta")), aAny ); 2015 } 2016 SetStyle(); 2017 SetLayer(); 2018 2019 if ( maPath.hasValue() ) 2020 { 2021 // --> OD #i115492# 2022 // Ignore svg:d attribute for text documents created by OpenOffice.org 2023 // versions before OOo 3.3, because these OOo versions are storing 2024 // svg:d values not using the correct unit. 2025 bool bApplySVGD( true ); 2026 if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() ) 2027 { 2028 sal_Int32 nUPD( 0 ); 2029 sal_Int32 nBuild( 0 ); 2030 const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); 2031 if ( GetImport().IsTextDocInOOoFileFormat() || 2032 ( bBuildIdFound && 2033 ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0 2034 ( nUPD == 680 ) || // OOo 2.x 2035 ( nUPD == 300 ) || // OOo 3.0 - OOo 3.0.1 2036 ( nUPD == 310 ) || // OOo 3.1 - OOo 3.1.1 2037 ( nUPD == 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1 2038 { 2039 bApplySVGD = false; 2040 } 2041 } 2042 2043 if ( bApplySVGD ) 2044 { 2045 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ), maPath ); 2046 } 2047 // <-- 2048 } 2049 2050 SdXMLShapeContext::StartElement(xAttrList); 2051 } 2052 } 2053 } 2054 2055 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2056 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2057 2058 TYPEINIT1( SdXMLMeasureShapeContext, SdXMLShapeContext ); 2059 2060 SdXMLMeasureShapeContext::SdXMLMeasureShapeContext( 2061 SvXMLImport& rImport, 2062 sal_uInt16 nPrfx, 2063 const OUString& rLocalName, 2064 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 2065 uno::Reference< drawing::XShapes >& rShapes, 2066 sal_Bool bTemporaryShape) 2067 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 2068 maStart(0,0), 2069 maEnd(1,1) 2070 { 2071 } 2072 2073 ////////////////////////////////////////////////////////////////////////////// 2074 2075 SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext() 2076 { 2077 } 2078 2079 // this is called from the parent group for each unparsed attribute in the attribute list 2080 void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 2081 { 2082 switch( nPrefix ) 2083 { 2084 case XML_NAMESPACE_SVG: 2085 { 2086 if( IsXMLToken( rLocalName, XML_X1 ) ) 2087 { 2088 GetImport().GetMM100UnitConverter().convertMeasure(maStart.X, rValue); 2089 return; 2090 } 2091 if( IsXMLToken( rLocalName, XML_Y1 ) ) 2092 { 2093 GetImport().GetMM100UnitConverter().convertMeasure(maStart.Y, rValue); 2094 return; 2095 } 2096 if( IsXMLToken( rLocalName, XML_X2 ) ) 2097 { 2098 GetImport().GetMM100UnitConverter().convertMeasure(maEnd.X, rValue); 2099 return; 2100 } 2101 if( IsXMLToken( rLocalName, XML_Y2 ) ) 2102 { 2103 GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue); 2104 return; 2105 } 2106 } 2107 } 2108 2109 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 2110 } 2111 2112 ////////////////////////////////////////////////////////////////////////////// 2113 2114 void SdXMLMeasureShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 2115 { 2116 // create Measure shape 2117 // add, set style and properties from base shape 2118 AddShape("com.sun.star.drawing.MeasureShape"); 2119 if(mxShape.is()) 2120 { 2121 SetStyle(); 2122 SetLayer(); 2123 2124 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 2125 if( xProps.is() ) 2126 { 2127 uno::Any aAny; 2128 aAny <<= maStart; 2129 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny); 2130 2131 aAny <<= maEnd; 2132 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny ); 2133 } 2134 2135 // delete pre created fields 2136 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); 2137 if( xText.is() ) 2138 { 2139 const OUString aEmpty( RTL_CONSTASCII_USTRINGPARAM( " " ) ); 2140 xText->setString( aEmpty ); 2141 } 2142 2143 SdXMLShapeContext::StartElement(xAttrList); 2144 } 2145 } 2146 2147 void SdXMLMeasureShapeContext::EndElement() 2148 { 2149 do 2150 { 2151 // delete pre created fields 2152 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); 2153 if( !xText.is() ) 2154 break; 2155 2156 uno::Reference< text::XTextCursor > xCursor( xText->createTextCursor() ); 2157 if( !xCursor.is() ) 2158 break; 2159 2160 const OUString aEmpty; 2161 xCursor->collapseToStart(); 2162 xCursor->goRight( 1, sal_True ); 2163 xCursor->setString( aEmpty ); 2164 } 2165 while(0); 2166 2167 SdXMLShapeContext::EndElement(); 2168 } 2169 2170 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2171 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2172 2173 TYPEINIT1( SdXMLPageShapeContext, SdXMLShapeContext ); 2174 2175 SdXMLPageShapeContext::SdXMLPageShapeContext( 2176 SvXMLImport& rImport, 2177 sal_uInt16 nPrfx, 2178 const OUString& rLocalName, 2179 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 2180 uno::Reference< drawing::XShapes >& rShapes, 2181 sal_Bool bTemporaryShape) 2182 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), mnPageNumber(0) 2183 { 2184 mbClearDefaultAttributes = false; 2185 } 2186 2187 ////////////////////////////////////////////////////////////////////////////// 2188 2189 SdXMLPageShapeContext::~SdXMLPageShapeContext() 2190 { 2191 } 2192 2193 ////////////////////////////////////////////////////////////////////////////// 2194 2195 // this is called from the parent group for each unparsed attribute in the attribute list 2196 void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 2197 { 2198 if( XML_NAMESPACE_DRAW == nPrefix ) 2199 { 2200 if( IsXMLToken( rLocalName, XML_PAGE_NUMBER ) ) 2201 { 2202 mnPageNumber = rValue.toInt32(); 2203 return; 2204 } 2205 } 2206 2207 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 2208 } 2209 2210 ////////////////////////////////////////////////////////////////////////////// 2211 2212 void SdXMLPageShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 2213 { 2214 // create Page shape 2215 // add, set style and properties from base shape 2216 2217 // #86163# take into account which type of PageShape needs to 2218 // be constructed. It's an pres shape if presentation:XML_CLASS == XML_PRESENTATION_PAGE. 2219 sal_Bool bIsPresentation = maPresentationClass.getLength() && 2220 GetImport().GetShapeImport()->IsPresentationShapesSupported(); 2221 2222 uno::Reference< lang::XServiceInfo > xInfo( mxShapes, uno::UNO_QUERY ); 2223 const sal_Bool bIsOnHandoutPage = xInfo.is() && xInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutMasterPage")) ); 2224 2225 if( bIsOnHandoutPage ) 2226 { 2227 AddShape("com.sun.star.presentation.HandoutShape"); 2228 } 2229 else 2230 { 2231 if(bIsPresentation && !IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) ) 2232 { 2233 bIsPresentation = sal_False; 2234 } 2235 2236 if(bIsPresentation) 2237 { 2238 AddShape("com.sun.star.presentation.PageShape"); 2239 } 2240 else 2241 { 2242 AddShape("com.sun.star.drawing.PageShape"); 2243 } 2244 } 2245 2246 if(mxShape.is()) 2247 { 2248 SetStyle(); 2249 SetLayer(); 2250 2251 // set pos, size, shear and rotate 2252 SetTransformation(); 2253 2254 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 2255 if(xPropSet.is()) 2256 { 2257 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); 2258 const OUString aPageNumberStr(RTL_CONSTASCII_USTRINGPARAM("PageNumber")); 2259 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr)) 2260 xPropSet->setPropertyValue(aPageNumberStr, uno::makeAny( mnPageNumber )); 2261 } 2262 2263 SdXMLShapeContext::StartElement(xAttrList); 2264 } 2265 } 2266 2267 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2268 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2269 2270 TYPEINIT1( SdXMLCaptionShapeContext, SdXMLShapeContext ); 2271 2272 SdXMLCaptionShapeContext::SdXMLCaptionShapeContext( 2273 SvXMLImport& rImport, 2274 sal_uInt16 nPrfx, 2275 const OUString& rLocalName, 2276 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 2277 uno::Reference< drawing::XShapes >& rShapes, 2278 sal_Bool bTemporaryShape) 2279 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 2280 // #86616# for correct edge rounding import mnRadius needs to be initialized 2281 mnRadius( 0L ) 2282 { 2283 } 2284 2285 ////////////////////////////////////////////////////////////////////////////// 2286 2287 SdXMLCaptionShapeContext::~SdXMLCaptionShapeContext() 2288 { 2289 } 2290 2291 ////////////////////////////////////////////////////////////////////////////// 2292 2293 void SdXMLCaptionShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 2294 { 2295 // create Caption shape 2296 // add, set style and properties from base shape 2297 AddShape("com.sun.star.drawing.CaptionShape"); 2298 if( mxShape.is() ) 2299 { 2300 SetStyle(); 2301 SetLayer(); 2302 2303 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 2304 2305 // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect 2306 // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment 2307 // is the default setting, so the top left reference point that is used by the caption point is 2308 // no longer correct) There are two ways to solve this problem, temporarily disabling the 2309 // autogrowwith as we are doing here or to apply the CaptionPoint after setting text 2310 sal_Bool bIsAutoGrowWidth = sal_False; 2311 if ( xProps.is() ) 2312 { 2313 uno::Any aAny( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth") ) ) ); 2314 aAny >>= bIsAutoGrowWidth; 2315 2316 if ( bIsAutoGrowWidth ) 2317 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth")), uno::makeAny( sal_False ) ); 2318 } 2319 2320 // set pos, size, shear and rotate 2321 SetTransformation(); 2322 if( xProps.is() ) 2323 xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CaptionPoint")), uno::makeAny( maCaptionPoint ) ); 2324 2325 if ( bIsAutoGrowWidth ) 2326 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth")), uno::makeAny( sal_True ) ); 2327 2328 if(mnRadius) 2329 { 2330 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 2331 if(xPropSet.is()) 2332 { 2333 try 2334 { 2335 xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) ); 2336 } 2337 catch( uno::Exception& ) 2338 { 2339 DBG_ERROR( "exception during setting of corner radius!"); 2340 } 2341 } 2342 } 2343 2344 SdXMLShapeContext::StartElement(xAttrList); 2345 } 2346 } 2347 2348 // this is called from the parent group for each unparsed attribute in the attribute list 2349 void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 2350 { 2351 if( XML_NAMESPACE_DRAW == nPrefix ) 2352 { 2353 if( IsXMLToken( rLocalName, XML_CAPTION_POINT_X ) ) 2354 { 2355 GetImport().GetMM100UnitConverter().convertMeasure(maCaptionPoint.X, rValue); 2356 return; 2357 } 2358 if( IsXMLToken( rLocalName, XML_CAPTION_POINT_Y ) ) 2359 { 2360 GetImport().GetMM100UnitConverter().convertMeasure(maCaptionPoint.Y, rValue); 2361 return; 2362 } 2363 if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) ) 2364 { 2365 GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue); 2366 return; 2367 } 2368 } 2369 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 2370 } 2371 2372 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2373 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2374 2375 TYPEINIT1( SdXMLGraphicObjectShapeContext, SdXMLShapeContext ); 2376 2377 SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext( 2378 SvXMLImport& rImport, 2379 sal_uInt16 nPrfx, 2380 const OUString& rLocalName, 2381 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 2382 uno::Reference< drawing::XShapes >& rShapes, 2383 sal_Bool bTemporaryShape) 2384 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 2385 maURL(), 2386 mbLateAddToIdentifierMapper(false) 2387 { 2388 } 2389 2390 ////////////////////////////////////////////////////////////////////////////// 2391 2392 // this is called from the parent group for each unparsed attribute in the attribute list 2393 void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 2394 { 2395 if( XML_NAMESPACE_XLINK == nPrefix ) 2396 { 2397 if( IsXMLToken( rLocalName, XML_HREF ) ) 2398 { 2399 maURL = rValue; 2400 return; 2401 } 2402 } 2403 2404 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 2405 } 2406 2407 ////////////////////////////////////////////////////////////////////////////// 2408 2409 void SdXMLGraphicObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& ) 2410 { 2411 // create graphic object shape 2412 const char *pService; 2413 2414 if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) && GetImport().GetShapeImport()->IsPresentationShapesSupported() ) 2415 { 2416 pService = "com.sun.star.presentation.GraphicObjectShape"; 2417 } 2418 else 2419 { 2420 pService = "com.sun.star.drawing.GraphicObjectShape"; 2421 } 2422 2423 AddShape( pService ); 2424 2425 if(mxShape.is()) 2426 { 2427 SetStyle(); 2428 SetLayer(); 2429 2430 uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY); 2431 if(xPropset.is()) 2432 { 2433 // since OOo 1.x had no line or fill style for graphics, but may create 2434 // documents with them, we have to override them here 2435 sal_Int32 nUPD, nBuildId; 2436 if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try 2437 { 2438 xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")), Any( FillStyle_NONE ) ); 2439 xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("LineStyle")), Any( LineStyle_NONE ) ); 2440 } 2441 catch( Exception& ) 2442 { 2443 } 2444 2445 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() ); 2446 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ))) 2447 xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( mbIsPlaceholder ) ); 2448 2449 if( !mbIsPlaceholder ) 2450 { 2451 if( maURL.getLength() ) 2452 { 2453 uno::Any aAny; 2454 aAny <<= GetImport().ResolveGraphicObjectURL( maURL, GetImport().isGraphicLoadOnDemandSupported() ); 2455 try 2456 { 2457 xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL") ), aAny ); 2458 xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL") ), aAny ); 2459 } 2460 catch (lang::IllegalArgumentException const &) 2461 { 2462 } 2463 } 2464 } 2465 } 2466 2467 if(mbIsUserTransformed) 2468 { 2469 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 2470 if(xProps.is()) 2471 { 2472 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); 2473 if( xPropsInfo.is() ) 2474 { 2475 if( xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ))) 2476 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) ); 2477 } 2478 } 2479 } 2480 2481 // set pos, size, shear and rotate 2482 SetTransformation(); 2483 2484 SdXMLShapeContext::StartElement(mxAttrList); 2485 } 2486 } 2487 2488 void SdXMLGraphicObjectShapeContext::EndElement() 2489 { 2490 if( mxBase64Stream.is() ) 2491 { 2492 OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream ) ); 2493 if( sURL.getLength() ) 2494 { 2495 try 2496 { 2497 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 2498 if(xProps.is()) 2499 { 2500 const uno::Any aAny( uno::makeAny( sURL ) ); 2501 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL") ), aAny ); 2502 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL") ), aAny ); 2503 } 2504 } 2505 catch (lang::IllegalArgumentException const &) 2506 { 2507 } 2508 } 2509 } 2510 2511 SdXMLShapeContext::EndElement(); 2512 } 2513 2514 2515 ////////////////////////////////////////////////////////////////////////////// 2516 2517 SvXMLImportContext* SdXMLGraphicObjectShapeContext::CreateChildContext( 2518 sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, 2519 const uno::Reference<xml::sax::XAttributeList>& xAttrList ) 2520 { 2521 SvXMLImportContext* pContext = NULL; 2522 2523 if( (XML_NAMESPACE_OFFICE == nPrefix) && 2524 xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_BINARY_DATA ) ) 2525 { 2526 if( !maURL.getLength() && !mxBase64Stream.is() ) 2527 { 2528 mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); 2529 if( mxBase64Stream.is() ) 2530 pContext = new XMLBase64ImportContext( GetImport(), nPrefix, 2531 rLocalName, xAttrList, 2532 mxBase64Stream ); 2533 } 2534 } 2535 2536 // delegate to parent class if no context could be created 2537 if ( NULL == pContext ) 2538 pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, 2539 xAttrList); 2540 2541 return pContext; 2542 } 2543 2544 ////////////////////////////////////////////////////////////////////////////// 2545 2546 SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext() 2547 { 2548 2549 } 2550 2551 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2552 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2553 2554 TYPEINIT1( SdXMLChartShapeContext, SdXMLShapeContext ); 2555 2556 SdXMLChartShapeContext::SdXMLChartShapeContext( 2557 SvXMLImport& rImport, 2558 sal_uInt16 nPrfx, 2559 const OUString& rLocalName, 2560 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 2561 uno::Reference< drawing::XShapes >& rShapes, 2562 sal_Bool bTemporaryShape) 2563 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 2564 mpChartContext( NULL ) 2565 { 2566 } 2567 2568 ////////////////////////////////////////////////////////////////////////////// 2569 2570 SdXMLChartShapeContext::~SdXMLChartShapeContext() 2571 { 2572 if( mpChartContext ) 2573 delete mpChartContext; 2574 } 2575 2576 ////////////////////////////////////////////////////////////////////////////// 2577 2578 void SdXMLChartShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) 2579 { 2580 const sal_Bool bIsPresentation = isPresentationShape(); 2581 2582 AddShape( bIsPresentation ? "com.sun.star.presentation.ChartShape" : "com.sun.star.drawing.OLE2Shape" ); 2583 2584 if(mxShape.is()) 2585 { 2586 SetStyle(); 2587 SetLayer(); 2588 2589 if( !mbIsPlaceholder ) 2590 { 2591 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 2592 if(xProps.is()) 2593 { 2594 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); 2595 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ))) 2596 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) ); 2597 2598 uno::Any aAny; 2599 2600 const OUString aCLSID( RTL_CONSTASCII_USTRINGPARAM("12DCAE26-281F-416F-a234-c3086127382e")); 2601 2602 aAny <<= aCLSID; 2603 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), aAny ); 2604 2605 #ifndef SVX_LIGHT 2606 aAny = xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ); 2607 uno::Reference< frame::XModel > xChartModel; 2608 if( aAny >>= xChartModel ) 2609 { 2610 mpChartContext = GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList ); 2611 } 2612 #endif 2613 } 2614 } 2615 2616 if(mbIsUserTransformed) 2617 { 2618 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 2619 if(xProps.is()) 2620 { 2621 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); 2622 if( xPropsInfo.is() ) 2623 { 2624 if( xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ))) 2625 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) ); 2626 } 2627 } 2628 } 2629 2630 2631 // set pos, size, shear and rotate 2632 SetTransformation(); 2633 2634 SdXMLShapeContext::StartElement(xAttrList); 2635 2636 if( mpChartContext ) 2637 mpChartContext->StartElement( xAttrList ); 2638 } 2639 } 2640 2641 void SdXMLChartShapeContext::EndElement() 2642 { 2643 if( mpChartContext ) 2644 mpChartContext->EndElement(); 2645 2646 SdXMLShapeContext::EndElement(); 2647 } 2648 2649 void SdXMLChartShapeContext::Characters( const ::rtl::OUString& rChars ) 2650 { 2651 if( mpChartContext ) 2652 mpChartContext->Characters( rChars ); 2653 } 2654 2655 SvXMLImportContext * SdXMLChartShapeContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, 2656 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ) 2657 { 2658 if( mpChartContext ) 2659 return mpChartContext->CreateChildContext( nPrefix, rLocalName, xAttrList ); 2660 2661 return NULL; 2662 } 2663 2664 ////////////////////////////////////////////////////////////////////////////// 2665 2666 TYPEINIT1( SdXMLObjectShapeContext, SdXMLShapeContext ); 2667 2668 SdXMLObjectShapeContext::SdXMLObjectShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 2669 const rtl::OUString& rLocalName, 2670 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 2671 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes, 2672 sal_Bool bTemporaryShape) 2673 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ) 2674 { 2675 } 2676 2677 SdXMLObjectShapeContext::~SdXMLObjectShapeContext() 2678 { 2679 } 2680 2681 void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& ) 2682 { 2683 // #96717# in theorie, if we don't have a url we shouldn't even 2684 // export this ole shape. But practical its to risky right now 2685 // to change this so we better dispose this on load 2686 //if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) ) 2687 // return; 2688 2689 // #100592# this BugFix prevents that a shape is created. CL 2690 // is thinking about an alternative. 2691 // #i13140# Check for more than empty string in maHref, there are 2692 // other possibilities that maHref results in empty container 2693 // storage names 2694 if( !(GetImport().getImportFlags() & IMPORT_EMBEDDED) && !mbIsPlaceholder && ImpIsEmptyURL(maHref) ) 2695 return; 2696 2697 const char* pService = "com.sun.star.drawing.OLE2Shape"; 2698 2699 sal_Bool bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported(); 2700 2701 if( bIsPresShape ) 2702 { 2703 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_CHART ) ) 2704 { 2705 pService = "com.sun.star.presentation.ChartShape"; 2706 } 2707 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) ) 2708 { 2709 pService = "com.sun.star.presentation.CalcShape"; 2710 } 2711 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) ) 2712 { 2713 pService = "com.sun.star.presentation.OLE2Shape"; 2714 } 2715 } 2716 2717 AddShape( pService ); 2718 2719 if( mxShape.is() ) 2720 { 2721 SetLayer(); 2722 2723 if(bIsPresShape) 2724 { 2725 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 2726 if(xProps.is()) 2727 { 2728 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); 2729 if( xPropsInfo.is() ) 2730 { 2731 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ))) 2732 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) ); 2733 2734 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ))) 2735 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) ); 2736 } 2737 } 2738 } 2739 2740 if( !mbIsPlaceholder && maHref.getLength() ) 2741 { 2742 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 2743 2744 if( xProps.is() ) 2745 { 2746 OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID ); 2747 2748 if ( GetImport().IsPackageURL( maHref ) ) 2749 { 2750 const OUString sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" )); 2751 2752 if ( aPersistName.compareTo( sURL, sURL.getLength() ) == 0 ) 2753 aPersistName = aPersistName.copy( sURL.getLength() ); 2754 2755 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ), 2756 uno::makeAny( aPersistName ) ); 2757 } 2758 else 2759 { 2760 // this is OOo link object 2761 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LinkURL" ) ), 2762 uno::makeAny( aPersistName ) ); 2763 } 2764 } 2765 } 2766 2767 // set pos, size, shear and rotate 2768 SetTransformation(); 2769 2770 SetStyle(); 2771 2772 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); 2773 } 2774 } 2775 2776 void SdXMLObjectShapeContext::EndElement() 2777 { 2778 // #i67705# 2779 const sal_uInt16 nGeneratorVersion(GetImport().getGeneratorVersion()); 2780 2781 if(nGeneratorVersion < SvXMLImport::OOo_34x) 2782 { 2783 // #i118485# 2784 // If it's an old file from us written before OOo3.4, we need to correct 2785 // FillStyle and LineStyle for OLE2 objects. The error was that the old paint 2786 // implementations just ignored added fill/linestyles completely, thus 2787 // those objects need to be corrected to not show blue and hairline which 2788 // always was the default, but would be shown now 2789 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 2790 2791 if( xProps.is() ) 2792 { 2793 xProps->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")), uno::makeAny(drawing::FillStyle_NONE)); 2794 xProps->setPropertyValue(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineStyle")), uno::makeAny(drawing::LineStyle_NONE)); 2795 } 2796 } 2797 2798 // #100592# 2799 if( mxBase64Stream.is() ) 2800 { 2801 OUString aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() ); 2802 const OUString sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" )); 2803 2804 aPersistName = aPersistName.copy( sURL.getLength() ); 2805 2806 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 2807 if( xProps.is() ) 2808 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ), uno::makeAny( aPersistName ) ); 2809 } 2810 2811 SdXMLShapeContext::EndElement(); 2812 } 2813 2814 // this is called from the parent group for each unparsed attribute in the attribute list 2815 void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 2816 { 2817 switch( nPrefix ) 2818 { 2819 case XML_NAMESPACE_DRAW: 2820 if( IsXMLToken( rLocalName, XML_CLASS_ID ) ) 2821 { 2822 maCLSID = rValue; 2823 return; 2824 } 2825 break; 2826 case XML_NAMESPACE_XLINK: 2827 if( IsXMLToken( rLocalName, XML_HREF ) ) 2828 { 2829 maHref = rValue; 2830 return; 2831 } 2832 break; 2833 } 2834 2835 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 2836 } 2837 2838 SvXMLImportContext* SdXMLObjectShapeContext::CreateChildContext( 2839 sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, 2840 const uno::Reference<xml::sax::XAttributeList>& xAttrList ) 2841 { 2842 // #100592# 2843 SvXMLImportContext* pContext = NULL; 2844 2845 if((XML_NAMESPACE_OFFICE == nPrefix) && IsXMLToken(rLocalName, XML_BINARY_DATA)) 2846 { 2847 mxBase64Stream = GetImport().GetStreamForEmbeddedObjectURLFromBase64(); 2848 if( mxBase64Stream.is() ) 2849 pContext = new XMLBase64ImportContext( GetImport(), nPrefix, 2850 rLocalName, xAttrList, 2851 mxBase64Stream ); 2852 } 2853 else if( ((XML_NAMESPACE_OFFICE == nPrefix) && IsXMLToken(rLocalName, XML_DOCUMENT)) || 2854 ((XML_NAMESPACE_MATH == nPrefix) && IsXMLToken(rLocalName, XML_MATH)) ) 2855 { 2856 XMLEmbeddedObjectImportContext *pEContext = 2857 new XMLEmbeddedObjectImportContext( GetImport(), nPrefix, 2858 rLocalName, xAttrList ); 2859 maCLSID = pEContext->GetFilterCLSID(); 2860 if( maCLSID.getLength() != 0 ) 2861 { 2862 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); 2863 if( xPropSet.is() ) 2864 { 2865 xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), uno::makeAny( maCLSID ) ); 2866 2867 uno::Reference< lang::XComponent > xComp; 2868 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xComp; 2869 DBG_ASSERT( xComp.is(), "no xModel for own OLE format" ); 2870 pEContext->SetComponent( xComp ); 2871 } 2872 } 2873 pContext = pEContext; 2874 } 2875 2876 // delegate to parent class if no context could be created 2877 if(!pContext) 2878 pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList); 2879 2880 return pContext; 2881 } 2882 2883 ////////////////////////////////////////////////////////////////////////////// 2884 2885 TYPEINIT1( SdXMLAppletShapeContext, SdXMLShapeContext ); 2886 2887 SdXMLAppletShapeContext::SdXMLAppletShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 2888 const rtl::OUString& rLocalName, 2889 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 2890 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes, 2891 sal_Bool bTemporaryShape) 2892 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 2893 mbIsScript( sal_False ) 2894 { 2895 } 2896 2897 SdXMLAppletShapeContext::~SdXMLAppletShapeContext() 2898 { 2899 } 2900 2901 void SdXMLAppletShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& ) 2902 { 2903 const char* pService = "com.sun.star.drawing.AppletShape"; 2904 AddShape( pService ); 2905 2906 if( mxShape.is() ) 2907 { 2908 SetLayer(); 2909 2910 // set pos, size, shear and rotate 2911 SetTransformation(); 2912 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); 2913 } 2914 } 2915 2916 // this is called from the parent group for each unparsed attribute in the attribute list 2917 void SdXMLAppletShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 2918 { 2919 switch( nPrefix ) 2920 { 2921 case XML_NAMESPACE_DRAW: 2922 if( IsXMLToken( rLocalName, XML_APPLET_NAME ) ) 2923 { 2924 maAppletName = rValue; 2925 return; 2926 } 2927 if( IsXMLToken( rLocalName, XML_CODE ) ) 2928 { 2929 maAppletCode = rValue; 2930 return; 2931 } 2932 if( IsXMLToken( rLocalName, XML_MAY_SCRIPT ) ) 2933 { 2934 mbIsScript = IsXMLToken( rValue, XML_TRUE ); 2935 return; 2936 } 2937 break; 2938 case XML_NAMESPACE_XLINK: 2939 if( IsXMLToken( rLocalName, XML_HREF ) ) 2940 { 2941 maHref = GetImport().GetAbsoluteReference(rValue); 2942 return; 2943 } 2944 break; 2945 } 2946 2947 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 2948 } 2949 2950 void SdXMLAppletShapeContext::EndElement() 2951 { 2952 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 2953 if( xProps.is() ) 2954 { 2955 uno::Any aAny; 2956 2957 if ( maSize.Width && maSize.Height ) 2958 { 2959 // the visual area for applet must be set on loading 2960 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height ); 2961 aAny <<= aRect; 2962 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny ); 2963 } 2964 2965 if( maParams.getLength() ) 2966 { 2967 aAny <<= maParams; 2968 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCommands" ) ), aAny ); 2969 } 2970 2971 if( maHref.getLength() ) 2972 { 2973 aAny <<= maHref; 2974 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCodeBase" ) ), aAny ); 2975 } 2976 2977 if( maAppletName.getLength() ) 2978 { 2979 aAny <<= maAppletName; 2980 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletName" ) ), aAny ); 2981 } 2982 2983 if( mbIsScript ) 2984 { 2985 aAny <<= mbIsScript; 2986 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletIsScript" ) ), aAny ); 2987 2988 } 2989 2990 if( maAppletCode.getLength() ) 2991 { 2992 aAny <<= maAppletCode; 2993 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCode" ) ), aAny ); 2994 } 2995 2996 aAny <<= ::rtl::OUString( GetImport().GetDocumentBase() ); 2997 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletDocBase" ) ), aAny ); 2998 2999 SetThumbnail(); 3000 } 3001 3002 SdXMLShapeContext::EndElement(); 3003 } 3004 3005 SvXMLImportContext * SdXMLAppletShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ) 3006 { 3007 if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) ) 3008 { 3009 OUString aParamName, aParamValue; 3010 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 3011 // now parse the attribute list and look for draw:name and draw:value 3012 for(sal_Int16 a(0); a < nAttrCount; a++) 3013 { 3014 const OUString& rAttrName = xAttrList->getNameByIndex(a); 3015 OUString aLocalName; 3016 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName); 3017 const OUString aValue( xAttrList->getValueByIndex(a) ); 3018 3019 if( nPrefix == XML_NAMESPACE_DRAW ) 3020 { 3021 if( IsXMLToken( aLocalName, XML_NAME ) ) 3022 { 3023 aParamName = aValue; 3024 } 3025 else if( IsXMLToken( aLocalName, XML_VALUE ) ) 3026 { 3027 aParamValue = aValue; 3028 } 3029 } 3030 } 3031 3032 if( aParamName.getLength() ) 3033 { 3034 sal_Int32 nIndex = maParams.getLength(); 3035 maParams.realloc( nIndex + 1 ); 3036 maParams[nIndex].Name = aParamName; 3037 maParams[nIndex].Handle = -1; 3038 maParams[nIndex].Value <<= aParamValue; 3039 maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE; 3040 } 3041 3042 return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); 3043 } 3044 3045 return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList ); 3046 } 3047 3048 ////////////////////////////////////////////////////////////////////////////// 3049 3050 TYPEINIT1( SdXMLPluginShapeContext, SdXMLShapeContext ); 3051 3052 SdXMLPluginShapeContext::SdXMLPluginShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 3053 const rtl::OUString& rLocalName, 3054 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 3055 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes, 3056 sal_Bool bTemporaryShape) : 3057 SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 3058 mbMedia( false ) 3059 { 3060 } 3061 3062 SdXMLPluginShapeContext::~SdXMLPluginShapeContext() 3063 { 3064 } 3065 3066 void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList) 3067 { 3068 // watch for MimeType attribute to see if we have a media object 3069 for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n ) 3070 { 3071 OUString aLocalName; 3072 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName ); 3073 3074 if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) ) 3075 { 3076 if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) ) 3077 mbMedia = true; 3078 3079 // leave this loop 3080 n = nAttrCount - 1; 3081 } 3082 } 3083 3084 const char* pService; 3085 3086 sal_Bool bIsPresShape = sal_False; 3087 3088 if( mbMedia ) 3089 { 3090 pService = "com.sun.star.drawing.MediaShape"; 3091 3092 bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported(); 3093 if( bIsPresShape ) 3094 { 3095 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) ) 3096 { 3097 pService = "com.sun.star.presentation.MediaShape"; 3098 } 3099 } 3100 } 3101 else 3102 pService = "com.sun.star.drawing.PluginShape"; 3103 3104 AddShape( pService ); 3105 3106 if( mxShape.is() ) 3107 { 3108 SetLayer(); 3109 3110 if(bIsPresShape) 3111 { 3112 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 3113 if(xProps.is()) 3114 { 3115 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); 3116 if( xPropsInfo.is() ) 3117 { 3118 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ))) 3119 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) ); 3120 3121 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ))) 3122 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) ); 3123 } 3124 } 3125 } 3126 3127 // set pos, size, shear and rotate 3128 SetTransformation(); 3129 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); 3130 } 3131 } 3132 3133 // this is called from the parent group for each unparsed attribute in the attribute list 3134 void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 3135 { 3136 switch( nPrefix ) 3137 { 3138 case XML_NAMESPACE_DRAW: 3139 if( IsXMLToken( rLocalName, XML_MIME_TYPE ) ) 3140 { 3141 maMimeType = rValue; 3142 return; 3143 } 3144 break; 3145 case XML_NAMESPACE_XLINK: 3146 if( IsXMLToken( rLocalName, XML_HREF ) ) 3147 { 3148 maHref = GetImport().GetAbsoluteReference(rValue); 3149 return; 3150 } 3151 break; 3152 } 3153 3154 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 3155 } 3156 3157 void SdXMLPluginShapeContext::EndElement() 3158 { 3159 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 3160 3161 if( xProps.is() ) 3162 { 3163 uno::Any aAny; 3164 3165 if ( maSize.Width && maSize.Height ) 3166 { 3167 const rtl::OUString sVisibleArea( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ); 3168 uno::Reference< beans::XPropertySetInfo > aXPropSetInfo( xProps->getPropertySetInfo() ); 3169 if ( !aXPropSetInfo.is() || aXPropSetInfo->hasPropertyByName( sVisibleArea ) ) 3170 { 3171 // the visual area for a plugin must be set on loading 3172 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height ); 3173 aAny <<= aRect; 3174 xProps->setPropertyValue( sVisibleArea, aAny ); 3175 } 3176 } 3177 3178 if( !mbMedia ) 3179 { 3180 // in case we have a plugin object 3181 if( maParams.getLength() ) 3182 { 3183 aAny <<= maParams; 3184 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginCommands" ) ), aAny ); 3185 } 3186 3187 if( maMimeType.getLength() ) 3188 { 3189 aAny <<= maMimeType; 3190 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginMimeType" ) ), aAny ); 3191 } 3192 3193 if( maHref.getLength() ) 3194 { 3195 aAny <<= maHref; 3196 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginURL" ) ), aAny ); 3197 } 3198 } 3199 else 3200 { 3201 // in case we have a media object 3202 3203 OUString sTempRef; 3204 3205 // check for package URL 3206 if( GetImport().IsPackageURL( maHref ) ) 3207 { 3208 sTempRef = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) ); 3209 } 3210 3211 sTempRef += maHref; 3212 3213 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ), uno::makeAny( sTempRef ) ); 3214 3215 for( sal_Int32 nParam = 0; nParam < maParams.getLength(); ++nParam ) 3216 { 3217 const OUString& rName = maParams[ nParam ].Name; 3218 3219 if( 0 == rName.compareToAscii( "Loop" ) ) 3220 { 3221 OUString aValueStr; 3222 maParams[ nParam ].Value >>= aValueStr; 3223 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Loop" ) ), 3224 uno::makeAny( static_cast< sal_Bool >( 0 == aValueStr.compareToAscii( "true" ) ) ) ); 3225 } 3226 else if( 0 == rName.compareToAscii( "Mute" ) ) 3227 { 3228 OUString aValueStr; 3229 maParams[ nParam ].Value >>= aValueStr; 3230 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Mute" ) ), 3231 uno::makeAny( static_cast< sal_Bool >( 0 == aValueStr.compareToAscii( "true" ) ) ) ); 3232 } 3233 else if( 0 == rName.compareToAscii( "VolumeDB" ) ) 3234 { 3235 OUString aValueStr; 3236 maParams[ nParam ].Value >>= aValueStr; 3237 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ) ), 3238 uno::makeAny( static_cast< sal_Int16 >( aValueStr.toInt32() ) ) ); 3239 } 3240 else if( 0 == rName.compareToAscii( "Zoom" ) ) 3241 { 3242 OUString aZoomStr; 3243 media::ZoomLevel eZoomLevel; 3244 3245 maParams[ nParam ].Value >>= aZoomStr; 3246 3247 if( 0 == aZoomStr.compareToAscii( "25%" ) ) 3248 eZoomLevel = media::ZoomLevel_ZOOM_1_TO_4; 3249 else if( 0 == aZoomStr.compareToAscii( "50%" ) ) 3250 eZoomLevel = media::ZoomLevel_ZOOM_1_TO_2; 3251 else if( 0 == aZoomStr.compareToAscii( "100%" ) ) 3252 eZoomLevel = media::ZoomLevel_ORIGINAL; 3253 else if( 0 == aZoomStr.compareToAscii( "200%" ) ) 3254 eZoomLevel = media::ZoomLevel_ZOOM_2_TO_1; 3255 else if( 0 == aZoomStr.compareToAscii( "400%" ) ) 3256 eZoomLevel = media::ZoomLevel_ZOOM_4_TO_1; 3257 else if( 0 == aZoomStr.compareToAscii( "fit" ) ) 3258 eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW; 3259 else if( 0 == aZoomStr.compareToAscii( "fixedfit" ) ) 3260 eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT; 3261 else if( 0 == aZoomStr.compareToAscii( "fullscreen" ) ) 3262 eZoomLevel = media::ZoomLevel_FULLSCREEN; 3263 else 3264 eZoomLevel = media::ZoomLevel_NOT_AVAILABLE; 3265 3266 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ), uno::makeAny( eZoomLevel ) ); 3267 } 3268 } 3269 } 3270 3271 SetThumbnail(); 3272 } 3273 3274 SdXMLShapeContext::EndElement(); 3275 } 3276 3277 SvXMLImportContext * SdXMLPluginShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList ) 3278 { 3279 if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) ) 3280 { 3281 OUString aParamName, aParamValue; 3282 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 3283 // now parse the attribute list and look for draw:name and draw:value 3284 for(sal_Int16 a(0); a < nAttrCount; a++) 3285 { 3286 const OUString& rAttrName = xAttrList->getNameByIndex(a); 3287 OUString aLocalName; 3288 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName); 3289 const OUString aValue( xAttrList->getValueByIndex(a) ); 3290 3291 if( nPrefix == XML_NAMESPACE_DRAW ) 3292 { 3293 if( IsXMLToken( aLocalName, XML_NAME ) ) 3294 { 3295 aParamName = aValue; 3296 } 3297 else if( IsXMLToken( aLocalName, XML_VALUE ) ) 3298 { 3299 aParamValue = aValue; 3300 } 3301 } 3302 3303 if( aParamName.getLength() ) 3304 { 3305 sal_Int32 nIndex = maParams.getLength(); 3306 maParams.realloc( nIndex + 1 ); 3307 maParams[nIndex].Name = aParamName; 3308 maParams[nIndex].Handle = -1; 3309 maParams[nIndex].Value <<= aParamValue; 3310 maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE; 3311 } 3312 } 3313 3314 return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName ); 3315 } 3316 3317 return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList ); 3318 } 3319 3320 ////////////////////////////////////////////////////////////////////////////// 3321 3322 TYPEINIT1( SdXMLFloatingFrameShapeContext, SdXMLShapeContext ); 3323 3324 SdXMLFloatingFrameShapeContext::SdXMLFloatingFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 3325 const rtl::OUString& rLocalName, 3326 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 3327 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes, 3328 sal_Bool bTemporaryShape) 3329 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ) 3330 { 3331 } 3332 3333 SdXMLFloatingFrameShapeContext::~SdXMLFloatingFrameShapeContext() 3334 { 3335 } 3336 3337 void SdXMLFloatingFrameShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& ) 3338 { 3339 const char* pService = "com.sun.star.drawing.FrameShape"; 3340 AddShape( pService ); 3341 3342 if( mxShape.is() ) 3343 { 3344 SetLayer(); 3345 3346 // set pos, size, shear and rotate 3347 SetTransformation(); 3348 3349 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 3350 if( xProps.is() ) 3351 { 3352 uno::Any aAny; 3353 3354 if( maFrameName.getLength() ) 3355 { 3356 aAny <<= maFrameName; 3357 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameName" ) ), aAny ); 3358 } 3359 3360 if( maHref.getLength() ) 3361 { 3362 aAny <<= maHref; 3363 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameURL" ) ), aAny ); 3364 } 3365 } 3366 3367 SetStyle(); 3368 3369 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); 3370 } 3371 } 3372 3373 // this is called from the parent group for each unparsed attribute in the attribute list 3374 void SdXMLFloatingFrameShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 3375 { 3376 switch( nPrefix ) 3377 { 3378 case XML_NAMESPACE_DRAW: 3379 if( IsXMLToken( rLocalName, XML_FRAME_NAME ) ) 3380 { 3381 maFrameName = rValue; 3382 return; 3383 } 3384 break; 3385 case XML_NAMESPACE_XLINK: 3386 if( IsXMLToken( rLocalName, XML_HREF ) ) 3387 { 3388 maHref = GetImport().GetAbsoluteReference(rValue); 3389 return; 3390 } 3391 break; 3392 } 3393 3394 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 3395 } 3396 3397 void SdXMLFloatingFrameShapeContext::EndElement() 3398 { 3399 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); 3400 3401 if( xProps.is() ) 3402 { 3403 if ( maSize.Width && maSize.Height ) 3404 { 3405 // the visual area for a floating frame must be set on loading 3406 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height ); 3407 uno::Any aAny; 3408 aAny <<= aRect; 3409 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny ); 3410 } 3411 } 3412 3413 SetThumbnail(); 3414 SdXMLShapeContext::EndElement(); 3415 } 3416 3417 ////////////////////////////////////////////////////////////////////////////// 3418 3419 TYPEINIT1( SdXMLFrameShapeContext, SdXMLShapeContext ); 3420 3421 SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 3422 const rtl::OUString& rLocalName, 3423 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 3424 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes, 3425 sal_Bool bTemporaryShape) 3426 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), 3427 multiImageImportHelper(), 3428 mbSupportsReplacement( sal_False ), 3429 mxImplContext(), 3430 mxReplImplContext() 3431 { 3432 uno::Reference < util::XCloneable > xClone( xAttrList, uno::UNO_QUERY ); 3433 if( xClone.is() ) 3434 mxAttrList.set( xClone->createClone(), uno::UNO_QUERY ); 3435 else 3436 mxAttrList = new SvXMLAttributeList( xAttrList ); 3437 3438 } 3439 3440 SdXMLFrameShapeContext::~SdXMLFrameShapeContext() 3441 { 3442 } 3443 3444 void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const 3445 { 3446 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext); 3447 3448 if(pSdXMLGraphicObjectShapeContext) 3449 { 3450 try 3451 { 3452 uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW); 3453 3454 if(xChild.is()) 3455 { 3456 uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW); 3457 3458 if(xParent.is()) 3459 { 3460 // remove from parent 3461 xParent->remove(pSdXMLGraphicObjectShapeContext->getShape()); 3462 3463 // dispose 3464 uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY); 3465 3466 if(xComp.is()) 3467 { 3468 xComp->dispose(); 3469 } 3470 } 3471 } 3472 } 3473 catch( uno::Exception& ) 3474 { 3475 DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" ); 3476 } 3477 } 3478 } 3479 3480 rtl::OUString SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const 3481 { 3482 rtl::OUString aRetval; 3483 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext); 3484 3485 if(pSdXMLGraphicObjectShapeContext) 3486 { 3487 try 3488 { 3489 const uno::Reference< beans::XPropertySet > xPropSet(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW); 3490 3491 if(xPropSet.is()) 3492 { 3493 xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL"))) >>= aRetval; 3494 3495 if(!aRetval.getLength()) 3496 { 3497 // it maybe a link, try GraphicURL 3498 xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))) >>= aRetval; 3499 } 3500 } 3501 } 3502 catch( uno::Exception& ) 3503 { 3504 DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" ); 3505 } 3506 } 3507 3508 return aRetval; 3509 } 3510 3511 SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix, 3512 const OUString& rLocalName, 3513 const uno::Reference< xml::sax::XAttributeList>& xAttrList ) 3514 { 3515 SvXMLImportContext * pContext = 0; 3516 3517 if( !mxImplContext.Is() ) 3518 { 3519 pContext = GetImport().GetShapeImport()->CreateFrameChildContext( 3520 GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList); 3521 3522 mxImplContext = pContext; 3523 mbSupportsReplacement = IsXMLToken(rLocalName, XML_OBJECT ) || IsXMLToken(rLocalName, XML_OBJECT_OLE); 3524 setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE)); 3525 3526 if(getSupportsMultipleContents()) 3527 { 3528 SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext); 3529 3530 if(pGSC) 3531 { 3532 // mark context as LateAdd to avoid conflicts with multiple objects registering with the same ID 3533 pGSC->setLateAddToIdentifierMapper(true); 3534 addContent(*mxImplContext); 3535 } 3536 } 3537 } 3538 else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == nPrefix && IsXMLToken(rLocalName, XML_IMAGE)) 3539 { 3540 // read another image 3541 pContext = GetImport().GetShapeImport()->CreateFrameChildContext( 3542 GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList); 3543 mxImplContext = pContext; 3544 3545 SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext); 3546 3547 if(pGSC) 3548 { 3549 // mark context as LateAdd to avoid conflicts with multiple objects registering with the same ID 3550 pGSC->setLateAddToIdentifierMapper(true); 3551 addContent(*mxImplContext); 3552 } 3553 } 3554 else if( mbSupportsReplacement && !mxReplImplContext && 3555 XML_NAMESPACE_DRAW == nPrefix && 3556 IsXMLToken( rLocalName, XML_IMAGE ) ) 3557 { 3558 // read replacement image 3559 SvXMLImportContext *pImplContext = &mxImplContext; 3560 SdXMLShapeContext *pSContext = 3561 PTR_CAST( SdXMLShapeContext, pImplContext ); 3562 if( pSContext ) 3563 { 3564 uno::Reference < beans::XPropertySet > xPropSet( 3565 pSContext->getShape(), uno::UNO_QUERY ); 3566 if( xPropSet.is() ) 3567 { 3568 pContext = new XMLReplacementImageContext( GetImport(), 3569 nPrefix, rLocalName, xAttrList, xPropSet ); 3570 mxReplImplContext = pContext; 3571 } 3572 } 3573 } 3574 else if( 3575 ( nPrefix == XML_NAMESPACE_SVG && // #i68101# 3576 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) || 3577 (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) || 3578 (nPrefix == XML_NAMESPACE_DRAW && (IsXMLToken( rLocalName, XML_GLUE_POINT ) || 3579 IsXMLToken( rLocalName, XML_THUMBNAIL ) ) ) ) 3580 { 3581 SvXMLImportContext *pImplContext = &mxImplContext; 3582 pContext = PTR_CAST( SdXMLShapeContext, pImplContext )->CreateChildContext( nPrefix, 3583 rLocalName, xAttrList ); 3584 } 3585 else if ( (XML_NAMESPACE_DRAW == nPrefix) && IsXMLToken( rLocalName, XML_IMAGE_MAP ) ) 3586 { 3587 SdXMLShapeContext *pSContext = dynamic_cast< SdXMLShapeContext* >( &mxImplContext ); 3588 if( pSContext ) 3589 { 3590 uno::Reference < beans::XPropertySet > xPropSet( pSContext->getShape(), uno::UNO_QUERY ); 3591 if (xPropSet.is()) 3592 { 3593 pContext = new XMLImageMapContext(GetImport(), nPrefix, rLocalName, xPropSet); 3594 } 3595 } 3596 } 3597 3598 // call parent for content 3599 if(!pContext) 3600 pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList ); 3601 3602 return pContext; 3603 } 3604 3605 void SdXMLFrameShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&) 3606 { 3607 // ignore 3608 } 3609 3610 void SdXMLFrameShapeContext::EndElement() 3611 { 3612 /// solve if multiple image child contexts were imported 3613 const SvXMLImportContext* pWinner = solveMultipleImages(); 3614 const SdXMLGraphicObjectShapeContext* pGSCWinner = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(pWinner); 3615 3616 /// if we have a winner and it's on LateAdd, add it now 3617 if(pGSCWinner && pGSCWinner->getLateAddToIdentifierMapper() && pGSCWinner->getShapeId().getLength()) 3618 { 3619 uno::Reference< uno::XInterface > xRef( pGSCWinner->getShape(), uno::UNO_QUERY ); 3620 GetImport().getInterfaceToIdentifierMapper().registerReference( pGSCWinner->getShapeId(), xRef ); 3621 } 3622 3623 if( !mxImplContext.Is() ) 3624 { 3625 // now check if this is an empty presentation object 3626 sal_Int16 nAttrCount = mxAttrList.is() ? mxAttrList->getLength() : 0; 3627 for(sal_Int16 a(0); a < nAttrCount; a++) 3628 { 3629 OUString aLocalName; 3630 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList->getNameByIndex(a), &aLocalName); 3631 3632 if( nPrefix == XML_NAMESPACE_PRESENTATION ) 3633 { 3634 if( IsXMLToken( aLocalName, XML_PLACEHOLDER ) ) 3635 { 3636 mbIsPlaceholder = IsXMLToken( mxAttrList->getValueByIndex(a), XML_TRUE ); 3637 } 3638 else if( IsXMLToken( aLocalName, XML_CLASS ) ) 3639 { 3640 maPresentationClass = mxAttrList->getValueByIndex(a); 3641 } 3642 } 3643 } 3644 3645 if( (maPresentationClass.getLength() != 0) && mbIsPlaceholder ) 3646 { 3647 uno::Reference< xml::sax::XAttributeList> xEmpty; 3648 3649 enum XMLTokenEnum eToken = XML_TEXT_BOX; 3650 3651 if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) ) 3652 { 3653 eToken = XML_IMAGE; 3654 3655 } 3656 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) ) 3657 { 3658 eToken = XML_PAGE_THUMBNAIL; 3659 } 3660 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_CHART ) || 3661 IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) || 3662 IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) ) 3663 { 3664 eToken = XML_OBJECT; 3665 } 3666 3667 mxImplContext = GetImport().GetShapeImport()->CreateFrameChildContext( 3668 GetImport(), XML_NAMESPACE_DRAW, GetXMLToken( eToken ), mxAttrList, mxShapes, xEmpty ); 3669 3670 if( mxImplContext.Is() ) 3671 { 3672 mxImplContext->StartElement( mxAttrList ); 3673 mxImplContext->EndElement(); 3674 } 3675 } 3676 } 3677 3678 mxImplContext = 0; 3679 SdXMLShapeContext::EndElement(); 3680 } 3681 3682 void SdXMLFrameShapeContext::processAttribute( sal_uInt16, 3683 const ::rtl::OUString&, const ::rtl::OUString& ) 3684 { 3685 // ignore 3686 } 3687 3688 TYPEINIT1( SdXMLCustomShapeContext, SdXMLShapeContext ); 3689 3690 SdXMLCustomShapeContext::SdXMLCustomShapeContext( 3691 SvXMLImport& rImport, 3692 sal_uInt16 nPrfx, 3693 const OUString& rLocalName, 3694 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, 3695 uno::Reference< drawing::XShapes >& rShapes, 3696 sal_Bool bTemporaryShape) 3697 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ) 3698 { 3699 } 3700 3701 ////////////////////////////////////////////////////////////////////////////// 3702 3703 SdXMLCustomShapeContext::~SdXMLCustomShapeContext() 3704 { 3705 } 3706 3707 ////////////////////////////////////////////////////////////////////////////// 3708 3709 // this is called from the parent group for each unparsed attribute in the attribute list 3710 void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 3711 { 3712 if( XML_NAMESPACE_DRAW == nPrefix ) 3713 { 3714 if( IsXMLToken( rLocalName, XML_ENGINE ) ) 3715 { 3716 maCustomShapeEngine = rValue; 3717 return; 3718 } 3719 if ( IsXMLToken( rLocalName, XML_DATA ) ) 3720 { 3721 maCustomShapeData = rValue; 3722 return; 3723 } 3724 } 3725 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 3726 } 3727 3728 ////////////////////////////////////////////////////////////////////////////// 3729 3730 void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) 3731 { 3732 // create rectangle shape 3733 AddShape("com.sun.star.drawing.CustomShape"); 3734 if ( mxShape.is() ) 3735 { 3736 // Add, set Style and properties from base shape 3737 SetStyle(); 3738 SetLayer(); 3739 3740 // set pos, size, shear and rotate 3741 SetTransformation(); 3742 3743 try 3744 { 3745 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY ); 3746 if( xPropSet.is() ) 3747 { 3748 if ( maCustomShapeEngine.getLength() ) 3749 { 3750 uno::Any aAny; 3751 aAny <<= maCustomShapeEngine; 3752 xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), aAny ); 3753 } 3754 if ( maCustomShapeData.getLength() ) 3755 { 3756 uno::Any aAny; 3757 aAny <<= maCustomShapeData; 3758 xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), aAny ); 3759 } 3760 } 3761 } 3762 catch( uno::Exception& ) 3763 { 3764 DBG_ERROR( "could not set enhanced customshape geometry" ); 3765 } 3766 SdXMLShapeContext::StartElement(xAttrList); 3767 } 3768 } 3769 3770 void SdXMLCustomShapeContext::EndElement() 3771 { 3772 // for backward compatibility, the above SetTransformation() may alraedy have 3773 // applied a call to SetMirroredX/SetMirroredY. This is not yet added to the 3774 // beans::PropertyValues in maCustomShapeGeometry. When applying these now, this 3775 // would be lost again. 3776 // TTTT: Remove again after aw080 3777 if(!maUsedTransformation.isIdentity()) 3778 { 3779 basegfx::B2DVector aScale, aTranslate; 3780 double fRotate, fShearX; 3781 3782 maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX); 3783 3784 bool bFlippedX(aScale.getX() < 0.0); 3785 bool bFlippedY(aScale.getY() < 0.0); 3786 3787 if(bFlippedX && bFlippedY) 3788 { 3789 // when both are used it is the same as 180 degree rotation; reset 3790 bFlippedX = bFlippedY = false; 3791 } 3792 3793 if(bFlippedX || bFlippedY) 3794 { 3795 beans::PropertyValue aNewPoroperty; 3796 3797 if(bFlippedX) 3798 { 3799 aNewPoroperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MirroredX")); 3800 } 3801 else 3802 { 3803 aNewPoroperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MirroredY")); 3804 } 3805 3806 aNewPoroperty.Handle = -1; 3807 aNewPoroperty.Value <<= sal_True; 3808 aNewPoroperty.State = beans::PropertyState_DIRECT_VALUE; 3809 3810 maCustomShapeGeometry.push_back(aNewPoroperty); 3811 } 3812 } 3813 3814 if ( !maCustomShapeGeometry.empty() ) 3815 { 3816 const rtl::OUString sCustomShapeGeometry ( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) ); 3817 3818 // converting the vector to a sequence 3819 uno::Sequence< beans::PropertyValue > aSeq( maCustomShapeGeometry.size() ); 3820 beans::PropertyValue* pValues = aSeq.getArray(); 3821 std::vector< beans::PropertyValue >::const_iterator aIter( maCustomShapeGeometry.begin() ); 3822 std::vector< beans::PropertyValue >::const_iterator aEnd( maCustomShapeGeometry.end() ); 3823 while ( aIter != aEnd ) 3824 *pValues++ = *aIter++; 3825 3826 try 3827 { 3828 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY ); 3829 if( xPropSet.is() ) 3830 { 3831 uno::Any aAny; 3832 aAny <<= aSeq; 3833 xPropSet->setPropertyValue( sCustomShapeGeometry, aAny ); 3834 } 3835 } 3836 catch( uno::Exception& ) 3837 { 3838 DBG_ERROR( "could not set enhanced customshape geometry" ); 3839 } 3840 3841 sal_Int32 nUPD( 0 ); 3842 sal_Int32 nBuild( 0 ); 3843 GetImport().getBuildIds( nUPD, nBuild ); 3844 if( ((nUPD >= 640 && nUPD <= 645) || (nUPD == 680)) && (nBuild <= 9221) ) 3845 { 3846 Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( mxShape, UNO_QUERY ); 3847 if( xDefaulter.is() ) 3848 { 3849 rtl::OUString aEmptyType; 3850 xDefaulter->createCustomShapeDefaults( aEmptyType ); 3851 } 3852 } 3853 } 3854 3855 SdXMLShapeContext::EndElement(); 3856 } 3857 3858 ////////////////////////////////////////////////////////////////////////////// 3859 3860 SvXMLImportContext* SdXMLCustomShapeContext::CreateChildContext( 3861 sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, 3862 const uno::Reference<xml::sax::XAttributeList>& xAttrList ) 3863 { 3864 SvXMLImportContext* pContext = NULL; 3865 if ( XML_NAMESPACE_DRAW == nPrefix ) 3866 { 3867 if ( IsXMLToken( rLocalName, XML_ENHANCED_GEOMETRY ) ) 3868 { 3869 uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY ); 3870 if ( xPropSet.is() ) 3871 pContext = new XMLEnhancedCustomShapeContext( GetImport(), mxShape, nPrefix, rLocalName, maCustomShapeGeometry ); 3872 } 3873 } 3874 // delegate to parent class if no context could be created 3875 if ( NULL == pContext ) 3876 pContext = SdXMLShapeContext::CreateChildContext( nPrefix, rLocalName, 3877 xAttrList); 3878 return pContext; 3879 } 3880 3881 /////////////////////////////////////////////////////////////////////// 3882 3883 ////////////////////////////////////////////////////////////////////////////// 3884 3885 TYPEINIT1( SdXMLTableShapeContext, SdXMLShapeContext ); 3886 3887 SdXMLTableShapeContext::SdXMLTableShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes ) 3888 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, sal_False ) 3889 { 3890 memset( &maTemplateStylesUsed, 0, sizeof( maTemplateStylesUsed ) ); 3891 } 3892 3893 SdXMLTableShapeContext::~SdXMLTableShapeContext() 3894 { 3895 } 3896 3897 void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) 3898 { 3899 const char* pService = "com.sun.star.drawing.TableShape"; 3900 3901 sal_Bool bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported(); 3902 if( bIsPresShape ) 3903 { 3904 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) ) 3905 { 3906 pService = "com.sun.star.presentation.TableShape"; 3907 } 3908 } 3909 3910 AddShape( pService ); 3911 3912 if( mxShape.is() ) 3913 { 3914 SetLayer(); 3915 3916 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); 3917 3918 if(bIsPresShape) 3919 { 3920 if(xProps.is()) 3921 { 3922 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); 3923 if( xPropsInfo.is() ) 3924 { 3925 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ))) 3926 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) ); 3927 3928 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ))) 3929 xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) ); 3930 } 3931 } 3932 } 3933 3934 SetStyle(); 3935 3936 if( xProps.is() ) 3937 { 3938 if( msTemplateStyleName.getLength() ) try 3939 { 3940 Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW ); 3941 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() ); 3942 const OUString sFamilyName( RTL_CONSTASCII_USTRINGPARAM("table" ) ); 3943 Reference< XNameAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW ); 3944 Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW ); 3945 xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TableTemplate" ) ), Any( xTableStyle ) ); 3946 } 3947 catch( Exception& ) 3948 { 3949 DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!"); 3950 } 3951 3952 const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0]; 3953 for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ ) 3954 { 3955 try 3956 { 3957 const OUString sAPIPropertyName( OUString(pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ) ); 3958 xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i] ) ); 3959 } 3960 catch( Exception& ) 3961 { 3962 DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!"); 3963 } 3964 } 3965 } 3966 3967 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); 3968 3969 const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() ); 3970 if( xTableImport.is() && xProps.is() ) 3971 { 3972 uno::Reference< table::XColumnRowRange > xColumnRowRange( 3973 xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ), uno::UNO_QUERY ); 3974 3975 if( xColumnRowRange.is() ) 3976 mxTableImportContext = xTableImport->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange ); 3977 3978 if( mxTableImportContext.Is() ) 3979 mxTableImportContext->StartElement( xAttrList ); 3980 } 3981 } 3982 } 3983 3984 void SdXMLTableShapeContext::EndElement() 3985 { 3986 if( mxTableImportContext.Is() ) 3987 mxTableImportContext->EndElement(); 3988 3989 SdXMLShapeContext::EndElement(); 3990 3991 if( mxShape.is() ) 3992 { 3993 // set pos, size, shear and rotate 3994 SetTransformation(); 3995 } 3996 } 3997 3998 // this is called from the parent group for each unparsed attribute in the attribute list 3999 void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue ) 4000 { 4001 if( nPrefix == XML_NAMESPACE_TABLE ) 4002 { 4003 if( IsXMLToken( rLocalName, XML_TEMPLATE_NAME ) ) 4004 { 4005 msTemplateStyleName = rValue; 4006 } 4007 else 4008 { 4009 int i = 0; 4010 const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0]; 4011 while( pEntry->msApiName && (i < 6) ) 4012 { 4013 if( IsXMLToken( rLocalName, pEntry->meXMLName ) ) 4014 { 4015 if( IsXMLToken( rValue, XML_TRUE ) ) 4016 maTemplateStylesUsed[i] = sal_True; 4017 break; 4018 } 4019 pEntry++; 4020 i++; 4021 } 4022 } 4023 } 4024 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue ); 4025 } 4026 4027 SvXMLImportContext* SdXMLTableShapeContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList ) 4028 { 4029 if( mxTableImportContext.Is() && (nPrefix == XML_NAMESPACE_TABLE) ) 4030 return mxTableImportContext->CreateChildContext(nPrefix, rLocalName, xAttrList); 4031 else 4032 return SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList); 4033 } 4034 4035