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