LCOV - code coverage report
Current view: top level - xmloff/source/draw - ximpshap.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1284 1885 68.1 %
Date: 2014-04-11 Functions: 126 249 50.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10