LCOV - code coverage report
Current view: top level - xmloff/source/draw - ximpshap.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1885 0.0 %
Date: 2014-04-14 Functions: 0 249 0.0 %
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           0 : static bool ImpIsEmptyURL( const OUString& rURL )
     121             : {
     122           0 :     if( rURL.isEmpty() )
     123           0 :         return true;
     124             : 
     125             :     // #i13140# Also compare against 'toplevel' URLs. which also
     126             :     // result in empty filename strings.
     127           0 :     if( rURL.equalsAscii( "#./" ) )
     128           0 :         return true;
     129             : 
     130           0 :     return false;
     131             : }
     132             : 
     133           0 : TYPEINIT1( SvXMLShapeContext, SvXMLImportContext );
     134           0 : TYPEINIT1( SdXMLShapeContext, SvXMLShapeContext );
     135             : 
     136           0 : 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           0 :     , mbHaveXmlId(false)
     161             : {
     162           0 : }
     163             : 
     164           0 : SdXMLShapeContext::~SdXMLShapeContext()
     165             : {
     166           0 : }
     167             : 
     168           0 : SvXMLImportContext *SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix,
     169             :     const OUString& rLocalName,
     170             :     const uno::Reference< xml::sax::XAttributeList>& xAttrList )
     171             : {
     172           0 :     SvXMLImportContext * pContext = NULL;
     173             : 
     174             :     // #i68101#
     175           0 :     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           0 :     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           0 :     else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) )
     185             :     {
     186           0 :         addGluePoint( xAttrList );
     187             :     }
     188           0 :     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           0 :         if( !mxCursor.is() )
     212             :         {
     213           0 :             uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
     214           0 :             if( xText.is() )
     215             :             {
     216             :                 UniReference < XMLTextImportHelper > xTxtImport =
     217           0 :                     GetImport().GetTextImport();
     218           0 :                 mxOldCursor = xTxtImport->GetCursor();
     219           0 :                 mxCursor = xText->createTextCursor();
     220           0 :                 if( mxCursor.is() )
     221             :                 {
     222           0 :                     xTxtImport->SetCursor( mxCursor );
     223             :                 }
     224             : 
     225             :                 // remember old list item and block (#91964#) and reset them
     226             :                 // for the text frame
     227           0 :                 xTxtImport->PushListContext();
     228           0 :                 mbListContextPushed = true;
     229           0 :             }
     230             :         }
     231             : 
     232             :         // if we have a text cursor, lets  try to import some text
     233           0 :         if( mxCursor.is() )
     234             :         {
     235           0 :             pContext = GetImport().GetTextImport()->CreateTextChildContext(
     236           0 :                 GetImport(), p_nPrefix, rLocalName, xAttrList );
     237             :         }
     238             :     }
     239             : 
     240             :     // call parent for content
     241           0 :     if(!pContext)
     242           0 :         pContext = SvXMLImportContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
     243             : 
     244           0 :     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           0 : void SdXMLShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
     335             : {
     336           0 :     GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
     337           0 : }
     338             : 
     339           0 : void SdXMLShapeContext::EndElement()
     340             : {
     341           0 :     if(mxCursor.is())
     342             :     {
     343             :         // delete addition newline
     344           0 :         const OUString aEmpty;
     345           0 :         mxCursor->gotoEnd( sal_False );
     346           0 :         mxCursor->goLeft( 1, sal_True );
     347           0 :         mxCursor->setString( aEmpty );
     348             : 
     349             :         // reset cursor
     350           0 :         GetImport().GetTextImport()->ResetCursor();
     351             :     }
     352             : 
     353           0 :     if(mxOldCursor.is())
     354           0 :         GetImport().GetTextImport()->SetCursor( mxOldCursor );
     355             : 
     356             :     // reinstall old list item (if necessary) #91964#
     357           0 :     if (mbListContextPushed) {
     358           0 :         GetImport().GetTextImport()->PopListContext();
     359             :     }
     360             : 
     361           0 :     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           0 :     if( mxLockable.is() )
     411           0 :         mxLockable->removeActionLock();
     412           0 : }
     413             : 
     414           0 : void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
     415             : {
     416           0 :     if(xShape.is())
     417             :     {
     418             :         // set shape local
     419           0 :         mxShape = xShape;
     420             : 
     421           0 :         if(!maShapeName.isEmpty())
     422             :         {
     423           0 :             uno::Reference< container::XNamed > xNamed( mxShape, uno::UNO_QUERY );
     424           0 :             if( xNamed.is() )
     425           0 :                 xNamed->setName( maShapeName );
     426             :         }
     427             : 
     428           0 :         UniReference< XMLShapeImportHelper > xImp( GetImport().GetShapeImport() );
     429           0 :         xImp->addShape( xShape, mxAttrList, mxShapes );
     430             : 
     431           0 :         if( mbClearDefaultAttributes )
     432             :         {
     433           0 :             uno::Reference<beans::XMultiPropertyStates> xMultiPropertyStates(xShape, uno::UNO_QUERY );
     434           0 :             if (xMultiPropertyStates.is())
     435           0 :                 xMultiPropertyStates->setAllPropertiesToDefault();
     436             :         }
     437             : 
     438           0 :         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           0 :         if(!mbTemporaryShape && (!GetImport().HasTextImport()
     454           0 :             || !GetImport().GetTextImport()->IsInsideDeleteContext()))
     455             :         {
     456           0 :             xImp->shapeWithZIndexAdded( xShape, mnZOrder );
     457             :         }
     458             : 
     459           0 :         if (mnRelWidth || mnRelHeight)
     460             :         {
     461           0 :             uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
     462           0 :             uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
     463           0 :             if (mnRelWidth && xPropertySetInfo->hasPropertyByName("RelativeWidth"))
     464           0 :                 xPropertySet->setPropertyValue("RelativeWidth", uno::makeAny(mnRelWidth));
     465           0 :             if (mnRelHeight && xPropertySetInfo->hasPropertyByName("RelativeHeight"))
     466           0 :                 xPropertySet->setPropertyValue("RelativeHeight", uno::makeAny(mnRelHeight));
     467             :         }
     468             : 
     469           0 :         if( !maShapeId.isEmpty() )
     470             :         {
     471           0 :             uno::Reference< uno::XInterface > xRef( static_cast<uno::XInterface *>(xShape.get()) );
     472           0 :             GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId, xRef );
     473             :         }
     474             : 
     475             :         // #91065# count only if counting for shape import is enabled
     476           0 :         if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled())
     477             :         {
     478             :             // #80365# increment progress bar at load once for each draw object
     479           0 :             GetImport().GetProgressBarHelper()->Increment();
     480           0 :         }
     481             :     }
     482             : 
     483           0 :     mxLockable = uno::Reference< document::XActionLockable >::query( xShape );
     484             : 
     485           0 :     if( mxLockable.is() )
     486           0 :         mxLockable->addActionLock();
     487             : 
     488           0 : }
     489             : 
     490           0 : void SdXMLShapeContext::AddShape(OUString const & serviceName)
     491             : {
     492           0 :     uno::Reference< lang::XMultiServiceFactory > xServiceFact(GetImport().GetModel(), uno::UNO_QUERY);
     493           0 :     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           0 :             uno::Reference< drawing::XShape > xShape;
     504           0 :             if ( serviceName == "com.sun.star.drawing.OLE2Shape" &&
     505           0 :                  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           0 :             else if (serviceName == "com.sun.star.drawing.GraphicObjectShape"
     510           0 :                      || serviceName == "com.sun.star.drawing.MediaShape"
     511           0 :                      || serviceName == "com.sun.star.presentation.MediaShape")
     512             :             {
     513           0 :                 css::uno::Sequence<css::uno::Any> args(1);
     514           0 :                 args[0] <<= GetImport().GetDocumentBase();
     515           0 :                 xShape = css::uno::Reference<css::drawing::XShape>(
     516           0 :                     xServiceFact->createInstanceWithArguments(
     517           0 :                         serviceName, args),
     518           0 :                     css::uno::UNO_QUERY);
     519             :             }
     520             :             else
     521             :             {
     522           0 :                 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance(serviceName), uno::UNO_QUERY);
     523             :             }
     524           0 :             if( xShape.is() )
     525           0 :                 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           0 :     }
     535           0 : }
     536             : 
     537           0 : void SdXMLShapeContext::SetTransformation()
     538             : {
     539           0 :     if(mxShape.is())
     540             :     {
     541           0 :         uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
     542           0 :         if(xPropSet.is())
     543             :         {
     544           0 :             maUsedTransformation.identity();
     545             : 
     546           0 :             if(maSize.Width != 1 || maSize.Height != 1)
     547             :             {
     548             :                 // take care there are no zeros used by error
     549           0 :                 if(0 == maSize.Width)
     550           0 :                     maSize.Width = 1;
     551           0 :                 if(0 == maSize.Height)
     552           0 :                     maSize.Height = 1;
     553             : 
     554             :                 // set global size. This should always be used.
     555           0 :                 maUsedTransformation.scale(maSize.Width, maSize.Height);
     556             :             }
     557             : 
     558           0 :             if(maPosition.X != 0 || maPosition.Y != 0)
     559             :             {
     560             :                 // if global position is used, add it to transformation
     561           0 :                 maUsedTransformation.translate(maPosition.X, maPosition.Y);
     562             :             }
     563             : 
     564           0 :             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           0 :                 ::basegfx::B2DHomMatrix aMat;
     572           0 :                 mnTransform.GetFullTransform(aMat);
     573             : 
     574             :                 // now add to transformation
     575           0 :                 maUsedTransformation *= aMat;
     576             :             }
     577             : 
     578             :             // now set transformation for this object
     579           0 :             uno::Any aAny;
     580           0 :             drawing::HomogenMatrix3 aMatrix;
     581             : 
     582           0 :             aMatrix.Line1.Column1 = maUsedTransformation.get(0, 0);
     583           0 :             aMatrix.Line1.Column2 = maUsedTransformation.get(0, 1);
     584           0 :             aMatrix.Line1.Column3 = maUsedTransformation.get(0, 2);
     585             : 
     586           0 :             aMatrix.Line2.Column1 = maUsedTransformation.get(1, 0);
     587           0 :             aMatrix.Line2.Column2 = maUsedTransformation.get(1, 1);
     588           0 :             aMatrix.Line2.Column3 = maUsedTransformation.get(1, 2);
     589             : 
     590           0 :             aMatrix.Line3.Column1 = maUsedTransformation.get(2, 0);
     591           0 :             aMatrix.Line3.Column2 = maUsedTransformation.get(2, 1);
     592           0 :             aMatrix.Line3.Column3 = maUsedTransformation.get(2, 2);
     593             : 
     594           0 :             aAny <<= aMatrix;
     595             : 
     596           0 :             xPropSet->setPropertyValue(
     597           0 :                 OUString("Transformation"), aAny);
     598           0 :         }
     599             :     }
     600           0 : }
     601             : 
     602           0 : void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
     603             : {
     604             :     try
     605             :     {
     606           0 :         uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
     607           0 :         if( !xPropSet.is() )
     608           0 :             return;
     609             : 
     610             :         do
     611             :         {
     612           0 :             XMLPropStyleContext* pDocStyle = NULL;
     613             : 
     614             :             // set style on shape
     615           0 :             if(maDrawStyleName.isEmpty())
     616           0 :                 break;
     617             : 
     618           0 :             const SvXMLStyleContext* pStyle = 0L;
     619           0 :             sal_Bool bAutoStyle(sal_False);
     620             : 
     621           0 :             if(GetImport().GetShapeImport()->GetAutoStylesContext())
     622           0 :                 pStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
     623             : 
     624           0 :             if(pStyle)
     625           0 :                 bAutoStyle = sal_True;
     626             : 
     627           0 :             if(!pStyle && GetImport().GetShapeImport()->GetStylesContext())
     628           0 :                 pStyle = GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
     629             : 
     630           0 :             OUString aStyleName = maDrawStyleName;
     631           0 :             uno::Reference< style::XStyle > xStyle;
     632             : 
     633           0 :             if( pStyle && pStyle->ISA(XMLShapeStyleContext) )
     634             :             {
     635           0 :                 pDocStyle = PTR_CAST( XMLShapeStyleContext, pStyle );
     636             : 
     637           0 :                 if( pDocStyle->GetStyle().is() )
     638             :                 {
     639           0 :                     xStyle = pDocStyle->GetStyle();
     640             :                 }
     641             :                 else
     642             :                 {
     643           0 :                     aStyleName = pDocStyle->GetParentName();
     644             :                 }
     645             :             }
     646             : 
     647           0 :             if( !xStyle.is() && !aStyleName.isEmpty() )
     648             :             {
     649             :                 try
     650             :                 {
     651             : 
     652           0 :                     uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY );
     653             : 
     654           0 :                     if( xFamiliesSupplier.is() )
     655             :                     {
     656           0 :                         uno::Reference< container::XNameAccess > xFamilies( xFamiliesSupplier->getStyleFamilies() );
     657           0 :                         if( xFamilies.is() )
     658             :                         {
     659             : 
     660           0 :                             uno::Reference< container::XNameAccess > xFamily;
     661             : 
     662           0 :                             if( XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily )
     663             :                             {
     664           0 :                                 aStyleName = GetImport().GetStyleDisplayName(
     665             :                                     XML_STYLE_FAMILY_SD_PRESENTATION_ID,
     666           0 :                                     aStyleName );
     667           0 :                                 sal_Int32 nPos = aStyleName.lastIndexOf( '-' );
     668           0 :                                 if( -1 != nPos )
     669             :                                 {
     670           0 :                                     OUString aFamily( aStyleName.copy( 0, nPos ) );
     671             : 
     672           0 :                                     xFamilies->getByName( aFamily ) >>= xFamily;
     673           0 :                                     aStyleName = aStyleName.copy( nPos + 1 );
     674             :                                 }
     675             :                             }
     676             :                             else
     677             :                             {
     678             :                                 // get graphics familie
     679           0 :                                 xFamilies->getByName("graphics") >>= xFamily;
     680           0 :                                 aStyleName = GetImport().GetStyleDisplayName(
     681             :                                     XML_STYLE_FAMILY_SD_GRAPHICS_ID,
     682           0 :                                     aStyleName );
     683             :                             }
     684             : 
     685           0 :                             if( xFamily.is() )
     686           0 :                                 xFamily->getByName( aStyleName ) >>= xStyle;
     687           0 :                         }
     688           0 :                     }
     689             :                 }
     690           0 :                 catch(const uno::Exception&)
     691             :                 {
     692             :                     OSL_FAIL( "could not find style for shape!" );
     693             :                 }
     694             :             }
     695             : 
     696           0 :             if( bSupportsStyle && xStyle.is() )
     697             :             {
     698             :                 try
     699             :                 {
     700             :                     // set style on object
     701           0 :                     uno::Any aAny;
     702           0 :                     aAny <<= xStyle;
     703           0 :                     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           0 :             if(bAutoStyle && pDocStyle)
     713             :             {
     714             :                 // set PropertySet on object
     715           0 :                 pDocStyle->FillPropertySet(xPropSet);
     716           0 :             }
     717             : 
     718             :         } while(false);
     719             : 
     720             :         // try to set text auto style
     721             :         do
     722             :         {
     723             :             // set style on shape
     724           0 :             if( maTextStyleName.isEmpty() )
     725           0 :                 break;
     726             : 
     727           0 :             if( NULL == GetImport().GetShapeImport()->GetAutoStylesContext())
     728           0 :                 break;
     729             : 
     730           0 :             const SvXMLStyleContext* pTempStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_PARAGRAPH, maTextStyleName);
     731           0 :             XMLPropStyleContext* pStyle = PTR_CAST( XMLPropStyleContext, pTempStyle ); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
     732           0 :             if( pStyle == NULL )
     733           0 :                 break;
     734             : 
     735             :             // set PropertySet on object
     736           0 :             pStyle->FillPropertySet(xPropSet);
     737             : 
     738           0 :         } while(false);
     739             :     }
     740           0 :     catch(const uno::Exception&)
     741             :     {
     742             :     }
     743             : }
     744             : 
     745           0 : void SdXMLShapeContext::SetLayer()
     746             : {
     747           0 :     if( !maLayerName.isEmpty() )
     748             :     {
     749             :         try
     750             :         {
     751           0 :             uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
     752           0 :             if(xPropSet.is() )
     753             :             {
     754           0 :                 uno::Any aAny;
     755           0 :                 aAny <<= maLayerName;
     756             : 
     757           0 :                 xPropSet->setPropertyValue("LayerName", aAny);
     758           0 :                 return;
     759           0 :             }
     760             :         }
     761           0 :         catch(const uno::Exception&)
     762             :         {
     763             :         }
     764             :     }
     765             : }
     766             : 
     767           0 : void SdXMLShapeContext::SetThumbnail()
     768             : {
     769           0 :     if( maThumbnailURL.isEmpty() )
     770           0 :         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           0 : void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
     797             : {
     798           0 :     if( (XML_NAMESPACE_DRAW == nPrefix) || (XML_NAMESPACE_DRAW_EXT == nPrefix) )
     799             :     {
     800           0 :         if( IsXMLToken( rLocalName, XML_ZINDEX ) )
     801             :         {
     802           0 :             mnZOrder = rValue.toInt32();
     803             :         }
     804           0 :         else if( IsXMLToken( rLocalName, XML_ID ) )
     805             :         {
     806           0 :             if (!mbHaveXmlId) { maShapeId = rValue; };
     807             :         }
     808           0 :         else if( IsXMLToken( rLocalName, XML_NAME ) )
     809             :         {
     810           0 :             maShapeName = rValue;
     811             :         }
     812           0 :         else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) )
     813             :         {
     814           0 :             maDrawStyleName = rValue;
     815             :         }
     816           0 :         else if( IsXMLToken( rLocalName, XML_TEXT_STYLE_NAME ) )
     817             :         {
     818           0 :             maTextStyleName = rValue;
     819             :         }
     820           0 :         else if( IsXMLToken( rLocalName, XML_LAYER ) )
     821             :         {
     822           0 :             maLayerName = rValue;
     823             :         }
     824           0 :         else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
     825             :         {
     826           0 :             mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
     827             :         }
     828           0 :         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           0 :     else if( XML_NAMESPACE_PRESENTATION == nPrefix )
     835             :     {
     836           0 :         if( IsXMLToken( rLocalName, XML_USER_TRANSFORMED ) )
     837             :         {
     838           0 :             mbIsUserTransformed = IsXMLToken( rValue, XML_TRUE );
     839             :         }
     840           0 :         else if( IsXMLToken( rLocalName, XML_PLACEHOLDER ) )
     841             :         {
     842           0 :             mbIsPlaceholder = IsXMLToken( rValue, XML_TRUE );
     843           0 :             if( mbIsPlaceholder )
     844           0 :                 mbClearDefaultAttributes = false;
     845             :         }
     846           0 :         else if( IsXMLToken( rLocalName, XML_CLASS ) )
     847             :         {
     848           0 :             maPresentationClass = rValue;
     849             :         }
     850           0 :         else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) )
     851             :         {
     852           0 :             maDrawStyleName = rValue;
     853           0 :             mnStyleFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
     854             :         }
     855             :     }
     856           0 :     else if( XML_NAMESPACE_SVG == nPrefix )
     857             :     {
     858           0 :         if( IsXMLToken( rLocalName, XML_X ) )
     859             :         {
     860           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
     861           0 :                     maPosition.X, rValue);
     862             :         }
     863           0 :         else if( IsXMLToken( rLocalName, XML_Y ) )
     864             :         {
     865           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
     866           0 :                     maPosition.Y, rValue);
     867             :         }
     868           0 :         else if( IsXMLToken( rLocalName, XML_WIDTH ) )
     869             :         {
     870           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
     871           0 :                     maSize.Width, rValue);
     872           0 :             if( maSize.Width > 0 )
     873           0 :                 maSize.Width += 1;
     874           0 :             else if( maSize.Width < 0 )
     875           0 :                 maSize.Width -= 1;
     876             :         }
     877           0 :         else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
     878             :         {
     879           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
     880           0 :                     maSize.Height, rValue);
     881           0 :             if( maSize.Height > 0 )
     882           0 :                 maSize.Height += 1;
     883           0 :             else if( maSize.Height < 0 )
     884           0 :                 maSize.Height -= 1;
     885             :         }
     886           0 :         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           0 :         else if( IsXMLToken( rLocalName, XML_TITLE ) )
     895             :         {
     896           0 :             maShapeTitle = rValue;
     897             :         }
     898           0 :         else if( IsXMLToken( rLocalName, XML_DESC ) )
     899             :         {
     900           0 :             maShapeDescription = rValue;
     901             :         }
     902             :     }
     903           0 :     else if (nPrefix == XML_NAMESPACE_STYLE)
     904             :     {
     905             :         sal_Int32 nTmp;
     906           0 :         if (IsXMLToken(rLocalName, XML_REL_WIDTH))
     907             :         {
     908           0 :             if (sax::Converter::convertPercent(nTmp, rValue))
     909           0 :                 mnRelWidth = static_cast<sal_Int16>(nTmp);
     910             :         }
     911           0 :         else if (IsXMLToken(rLocalName, XML_REL_HEIGHT))
     912             :         {
     913           0 :             if (sax::Converter::convertPercent(nTmp, rValue))
     914           0 :                 mnRelHeight = static_cast<sal_Int16>(nTmp);
     915             :         }
     916             :     }
     917           0 :     else if( (XML_NAMESPACE_NONE == nPrefix) || (XML_NAMESPACE_XML == nPrefix) )
     918             :     {
     919           0 :         if( IsXMLToken( rLocalName, XML_ID ) )
     920             :         {
     921           0 :             maShapeId = rValue;
     922           0 :             mbHaveXmlId = true;
     923             :         }
     924             :     }
     925           0 : }
     926             : 
     927           0 : sal_Bool SdXMLShapeContext::isPresentationShape() const
     928             : {
     929           0 :     if( !maPresentationClass.isEmpty() && (const_cast<SdXMLShapeContext*>(this))->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
     930             :     {
     931           0 :         if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily)
     932             :         {
     933           0 :             return sal_True;
     934             :         }
     935             : 
     936           0 :         if( IsXMLToken( maPresentationClass, XML_HEADER ) || IsXMLToken( maPresentationClass, XML_FOOTER ) ||
     937           0 :             IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) || IsXMLToken( maPresentationClass, XML_DATE_TIME ) )
     938             :         {
     939           0 :             return sal_True;
     940             :         }
     941             :     }
     942             : 
     943           0 :     return sal_False;
     944             : }
     945             : 
     946           0 : void SdXMLShapeContext::onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& rCandidate )
     947             : {
     948           0 :     const SdXMLShapeContext* pCandidate = dynamic_cast< const SdXMLShapeContext* >(&rCandidate);
     949             : 
     950           0 :     if(!mxGluePoints.is() && pCandidate)
     951             :     {
     952             :         // try to rescue GluePoints from rCandidate to local if we not yet have GluePoints by copying them
     953           0 :         uno::Reference< drawing::XGluePointsSupplier > xSourceSupplier( pCandidate->getShape(), uno::UNO_QUERY );
     954           0 :         if( !xSourceSupplier.is() )
     955           0 :             return;
     956             : 
     957           0 :         uno::Reference< container::XIdentifierAccess > xSourceGluePoints( xSourceSupplier->getGluePoints(), uno::UNO_QUERY );
     958           0 :         if( !xSourceGluePoints.is() )
     959           0 :             return;
     960             : 
     961           0 :         uno::Sequence< sal_Int32 > aSourceIdSequence( xSourceGluePoints->getIdentifiers() );
     962           0 :         const sal_Int32 nSourceCount(aSourceIdSequence.getLength());
     963           0 :         UniReference< XMLShapeImportHelper > xSourceShapeImportHelper(const_cast< SdXMLShapeContext* >(pCandidate)->GetImport().GetShapeImport());
     964             : 
     965           0 :         if(nSourceCount)
     966             :         {
     967             :             // rCandidate has GluePoints; prepare the GluePoint container for the local shape
     968           0 :             uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY );
     969           0 :             if( !xSupplier.is() )
     970           0 :                 return;
     971             : 
     972           0 :             mxGluePoints = uno::Reference< container::XIdentifierContainer >::query( xSupplier->getGluePoints() );
     973             : 
     974           0 :             if( !mxGluePoints.is() )
     975           0 :                 return;
     976             : 
     977           0 :             drawing::GluePoint2 aSourceGluePoint;
     978             : 
     979           0 :             for( sal_Int32 nSourceIndex(0); nSourceIndex < nSourceCount; nSourceIndex++ )
     980             :             {
     981           0 :                 const sal_Int32 nSourceIdentifier = aSourceIdSequence[nSourceIndex];
     982             : 
     983             :                 // loop over GluePoints which are UserDefined (avoid the auto mapped ones)
     984           0 :                 if((xSourceGluePoints->getByIdentifier( nSourceIdentifier ) >>= aSourceGluePoint)
     985           0 :                     && 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           0 :             }
    1009           0 :         }
    1010             :     }
    1011             : }
    1012             : 
    1013           0 : TYPEINIT1( SdXMLRectShapeContext, SdXMLShapeContext );
    1014             : 
    1015           0 : 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           0 :     mnRadius( 0L )
    1024             : {
    1025           0 : }
    1026             : 
    1027           0 : SdXMLRectShapeContext::~SdXMLRectShapeContext()
    1028             : {
    1029           0 : }
    1030             : 
    1031             : // this is called from the parent group for each unparsed attribute in the attribute list
    1032           0 : void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    1033             : {
    1034           0 :     if( XML_NAMESPACE_DRAW == nPrefix )
    1035             :     {
    1036           0 :         if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
    1037             :         {
    1038           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1039           0 :                     mnRadius, rValue);
    1040           0 :             return;
    1041             :         }
    1042             :     }
    1043             : 
    1044           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    1045             : }
    1046             : 
    1047           0 : void SdXMLRectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
    1048             : {
    1049             :     // create rectangle shape
    1050           0 :     AddShape("com.sun.star.drawing.RectangleShape");
    1051           0 :     if(mxShape.is())
    1052             :     {
    1053             :         // Add, set Style and properties from base shape
    1054           0 :         SetStyle();
    1055           0 :         SetLayer();
    1056             : 
    1057             :         // set pos, size, shear and rotate
    1058           0 :         SetTransformation();
    1059             : 
    1060           0 :         if(mnRadius)
    1061             :         {
    1062           0 :             uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
    1063           0 :             if(xPropSet.is())
    1064             :             {
    1065             :                 try
    1066             :                 {
    1067           0 :                     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           0 :             }
    1074             :         }
    1075           0 :         SdXMLShapeContext::StartElement(xAttrList);
    1076             :     }
    1077           0 : }
    1078             : 
    1079           0 : TYPEINIT1( SdXMLLineShapeContext, SdXMLShapeContext );
    1080             : 
    1081           0 : 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           0 :     mnY2( 1L )
    1093             : {
    1094           0 : }
    1095             : 
    1096           0 : SdXMLLineShapeContext::~SdXMLLineShapeContext()
    1097             : {
    1098           0 : }
    1099             : 
    1100             : // this is called from the parent group for each unparsed attribute in the attribute list
    1101           0 : void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    1102             : {
    1103           0 :     if( XML_NAMESPACE_SVG == nPrefix )
    1104             :     {
    1105           0 :         if( IsXMLToken( rLocalName, XML_X1 ) )
    1106             :         {
    1107           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1108           0 :                     mnX1, rValue);
    1109           0 :             return;
    1110             :         }
    1111           0 :         if( IsXMLToken( rLocalName, XML_Y1 ) )
    1112             :         {
    1113           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1114           0 :                     mnY1, rValue);
    1115           0 :             return;
    1116             :         }
    1117           0 :         if( IsXMLToken( rLocalName, XML_X2 ) )
    1118             :         {
    1119           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1120           0 :                     mnX2, rValue);
    1121           0 :             return;
    1122             :         }
    1123           0 :         if( IsXMLToken( rLocalName, XML_Y2 ) )
    1124             :         {
    1125           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1126           0 :                     mnY2, rValue);
    1127           0 :             return;
    1128             :         }
    1129             :     }
    1130             : 
    1131           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    1132             : }
    1133             : 
    1134           0 : 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           0 :     AddShape("com.sun.star.drawing.PolyLineShape");
    1141             : 
    1142           0 :     if(mxShape.is())
    1143             :     {
    1144             :         // Add, set Style and properties from base shape
    1145           0 :         SetStyle();
    1146           0 :         SetLayer();
    1147             : 
    1148             :         // get sizes and offsets
    1149           0 :         awt::Point aTopLeft(mnX1, mnY1);
    1150           0 :         awt::Point aBottomRight(mnX2, mnY2);
    1151             : 
    1152           0 :         if(mnX1 > mnX2)
    1153             :         {
    1154           0 :             aTopLeft.X = mnX2;
    1155           0 :             aBottomRight.X = mnX1;
    1156             :         }
    1157             : 
    1158           0 :         if(mnY1 > mnY2)
    1159             :         {
    1160           0 :             aTopLeft.Y = mnY2;
    1161           0 :             aBottomRight.Y = mnY1;
    1162             :         }
    1163             : 
    1164             :         // set local parameters on shape
    1165           0 :         uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
    1166           0 :         if(xPropSet.is())
    1167             :         {
    1168           0 :             drawing::PointSequenceSequence aPolyPoly(1L);
    1169           0 :             drawing::PointSequence* pOuterSequence = aPolyPoly.getArray();
    1170           0 :             pOuterSequence->realloc(2L);
    1171           0 :             awt::Point* pInnerSequence = pOuterSequence->getArray();
    1172           0 :             uno::Any aAny;
    1173             : 
    1174           0 :             *pInnerSequence = awt::Point( mnX1 - aTopLeft.X, mnY1 - aTopLeft.Y);
    1175           0 :             pInnerSequence++;
    1176           0 :             *pInnerSequence = awt::Point( mnX2 - aTopLeft.X, mnY2 - aTopLeft.Y);
    1177             : 
    1178           0 :             aAny <<= aPolyPoly;
    1179           0 :             xPropSet->setPropertyValue(
    1180           0 :                 OUString("Geometry"), aAny);
    1181             :         }
    1182             : 
    1183             :         // set sizes for transformation
    1184           0 :         maSize.Width = aBottomRight.X - aTopLeft.X;
    1185           0 :         maSize.Height = aBottomRight.Y - aTopLeft.Y;
    1186           0 :         maPosition.X = aTopLeft.X;
    1187           0 :         maPosition.Y = aTopLeft.Y;
    1188             : 
    1189             :         // set pos, size, shear and rotate and get copy of matrix
    1190           0 :         SetTransformation();
    1191             : 
    1192           0 :         SdXMLShapeContext::StartElement(xAttrList);
    1193             :     }
    1194           0 : }
    1195             : 
    1196           0 : TYPEINIT1( SdXMLEllipseShapeContext, SdXMLShapeContext );
    1197             : 
    1198           0 : 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           0 :     mnEndAngle( 0 )
    1213             : {
    1214           0 : }
    1215             : 
    1216           0 : SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext()
    1217             : {
    1218           0 : }
    1219             : 
    1220             : // this is called from the parent group for each unparsed attribute in the attribute list
    1221           0 : void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    1222             : {
    1223           0 :     if( XML_NAMESPACE_SVG == nPrefix )
    1224             :     {
    1225           0 :         if( IsXMLToken( rLocalName, XML_RX ) )
    1226             :         {
    1227           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1228           0 :                     mnRX, rValue);
    1229           0 :             return;
    1230             :         }
    1231           0 :         if( IsXMLToken( rLocalName, XML_RY ) )
    1232             :         {
    1233           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1234           0 :                     mnRY, rValue);
    1235           0 :             return;
    1236             :         }
    1237           0 :         if( IsXMLToken( rLocalName, XML_CX ) )
    1238             :         {
    1239           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1240           0 :                     mnCX, rValue);
    1241           0 :             return;
    1242             :         }
    1243           0 :         if( IsXMLToken( rLocalName, XML_CY ) )
    1244             :         {
    1245           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1246           0 :                     mnCY, rValue);
    1247           0 :             return;
    1248             :         }
    1249           0 :         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           0 :     else if( XML_NAMESPACE_DRAW == nPrefix )
    1259             :     {
    1260           0 :         if( IsXMLToken( rLocalName, XML_KIND ) )
    1261             :         {
    1262             :             sal_uInt16 eKind;
    1263           0 :             if( SvXMLUnitConverter::convertEnum( eKind, rValue, aXML_CircleKind_EnumMap ) )
    1264             :             {
    1265           0 :                 meKind = eKind;
    1266             :             }
    1267           0 :             return;
    1268             :         }
    1269           0 :         if( IsXMLToken( rLocalName, XML_START_ANGLE ) )
    1270             :         {
    1271             :             double dStartAngle;
    1272           0 :             if (::sax::Converter::convertDouble( dStartAngle, rValue ))
    1273           0 :                 mnStartAngle = (sal_Int32)(dStartAngle * 100.0);
    1274           0 :             return;
    1275             :         }
    1276           0 :         if( IsXMLToken( rLocalName, XML_END_ANGLE ) )
    1277             :         {
    1278             :             double dEndAngle;
    1279           0 :             if (::sax::Converter::convertDouble( dEndAngle, rValue ))
    1280           0 :                 mnEndAngle = (sal_Int32)(dEndAngle * 100.0);
    1281           0 :             return;
    1282             :         }
    1283             :     }
    1284             : 
    1285           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    1286             : }
    1287             : 
    1288           0 : void SdXMLEllipseShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
    1289             : {
    1290             :     // create rectangle shape
    1291           0 :     AddShape("com.sun.star.drawing.EllipseShape");
    1292           0 :     if(mxShape.is())
    1293             :     {
    1294             :         // Add, set Style and properties from base shape
    1295           0 :         SetStyle();
    1296           0 :         SetLayer();
    1297             : 
    1298           0 :         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           0 :         SetTransformation();
    1309             : 
    1310           0 :         if( meKind != drawing::CircleKind_FULL )
    1311             :         {
    1312           0 :             uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
    1313           0 :             if( xPropSet.is() )
    1314             :             {
    1315           0 :                 uno::Any aAny;
    1316           0 :                 aAny <<= (drawing::CircleKind)meKind;
    1317           0 :                 xPropSet->setPropertyValue("CircleKind", aAny );
    1318             : 
    1319           0 :                 aAny <<= mnStartAngle;
    1320           0 :                 xPropSet->setPropertyValue("CircleStartAngle", aAny );
    1321             : 
    1322           0 :                 aAny <<= mnEndAngle;
    1323           0 :                 xPropSet->setPropertyValue("CircleEndAngle", aAny );
    1324           0 :             }
    1325             :         }
    1326             : 
    1327           0 :         SdXMLShapeContext::StartElement(xAttrList);
    1328             :     }
    1329           0 : }
    1330             : 
    1331           0 : TYPEINIT1( SdXMLPolygonShapeContext, SdXMLShapeContext );
    1332             : 
    1333           0 : 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           0 :     mbClosed( bClosed )
    1341             : {
    1342           0 : }
    1343             : 
    1344             : // this is called from the parent group for each unparsed attribute in the attribute list
    1345           0 : void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    1346             : {
    1347           0 :     if( XML_NAMESPACE_SVG == nPrefix )
    1348             :     {
    1349           0 :         if( IsXMLToken( rLocalName, XML_VIEWBOX ) )
    1350             :         {
    1351           0 :             maViewBox = rValue;
    1352           0 :             return;
    1353             :         }
    1354             :     }
    1355           0 :     else if( XML_NAMESPACE_DRAW == nPrefix )
    1356             :     {
    1357           0 :         if( IsXMLToken( rLocalName, XML_POINTS ) )
    1358             :         {
    1359           0 :             maPoints = rValue;
    1360           0 :             return;
    1361             :         }
    1362             :     }
    1363             : 
    1364           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    1365             : }
    1366             : 
    1367           0 : SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext()
    1368             : {
    1369           0 : }
    1370             : 
    1371           0 : void SdXMLPolygonShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
    1372             : {
    1373             :     // Add, set Style and properties from base shape
    1374           0 :     if(mbClosed)
    1375           0 :         AddShape("com.sun.star.drawing.PolyPolygonShape");
    1376             :     else
    1377           0 :         AddShape("com.sun.star.drawing.PolyLineShape");
    1378             : 
    1379           0 :     if( mxShape.is() )
    1380             :     {
    1381           0 :         SetStyle();
    1382           0 :         SetLayer();
    1383             : 
    1384             :         // set local parameters on shape
    1385           0 :         uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
    1386           0 :         if(xPropSet.is())
    1387             :         {
    1388             :             // set polygon
    1389           0 :             if(!maPoints.isEmpty() && !maViewBox.isEmpty())
    1390             :             {
    1391           0 :                 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
    1392           0 :                 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           0 :                 if(maSize.Width != 0 && maSize.Height != 0)
    1397             :                 {
    1398           0 :                     aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
    1399             :                 }
    1400             : 
    1401           0 :                 basegfx::B2DPolygon aPolygon;
    1402             : 
    1403           0 :                 if(basegfx::tools::importFromSvgPoints(aPolygon, maPoints))
    1404             :                 {
    1405           0 :                     if(aPolygon.count())
    1406             :                     {
    1407             :                         const basegfx::B2DRange aSourceRange(
    1408             :                             aViewBox.GetX(), aViewBox.GetY(),
    1409           0 :                             aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
    1410             :                         const basegfx::B2DRange aTargetRange(
    1411             :                             aViewBox.GetX(), aViewBox.GetY(),
    1412           0 :                             aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
    1413             : 
    1414           0 :                         if(!aSourceRange.equal(aTargetRange))
    1415             :                         {
    1416             :                             aPolygon.transform(
    1417             :                                 basegfx::tools::createSourceRangeTargetRangeTransform(
    1418             :                                     aSourceRange,
    1419           0 :                                     aTargetRange));
    1420             :                         }
    1421             : 
    1422           0 :                         com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence;
    1423           0 :                         uno::Any aAny;
    1424             : 
    1425           0 :                         basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(basegfx::B2DPolyPolygon(aPolygon), aPointSequenceSequence);
    1426           0 :                         aAny <<= aPointSequenceSequence;
    1427           0 :                         xPropSet->setPropertyValue(OUString("Geometry"), aAny);
    1428             :                     }
    1429           0 :                 }
    1430             :             }
    1431             :         }
    1432             : 
    1433             :         // set pos, size, shear and rotate and get copy of matrix
    1434           0 :         SetTransformation();
    1435             : 
    1436           0 :         SdXMLShapeContext::StartElement(xAttrList);
    1437             :     }
    1438           0 : }
    1439             : 
    1440           0 : TYPEINIT1( SdXMLPathShapeContext, SdXMLShapeContext );
    1441             : 
    1442           0 : 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           0 : :   SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
    1450             : {
    1451           0 : }
    1452             : 
    1453           0 : SdXMLPathShapeContext::~SdXMLPathShapeContext()
    1454             : {
    1455           0 : }
    1456             : 
    1457             : // this is called from the parent group for each unparsed attribute in the attribute list
    1458           0 : void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    1459             : {
    1460           0 :     if( XML_NAMESPACE_SVG == nPrefix )
    1461             :     {
    1462           0 :         if( IsXMLToken( rLocalName, XML_VIEWBOX ) )
    1463             :         {
    1464           0 :             maViewBox = rValue;
    1465           0 :             return;
    1466             :         }
    1467           0 :         else if( IsXMLToken( rLocalName, XML_D ) )
    1468             :         {
    1469           0 :             maD = rValue;
    1470           0 :             return;
    1471             :         }
    1472             :     }
    1473             : 
    1474           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    1475             : }
    1476             : 
    1477           0 : void SdXMLPathShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
    1478             : {
    1479             :     // create polygon shape
    1480           0 :     if(!maD.isEmpty())
    1481             :     {
    1482           0 :         const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
    1483           0 :         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           0 :         if(maSize.Width != 0 && maSize.Height != 0)
    1488             :         {
    1489           0 :             aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
    1490             :         }
    1491             : 
    1492           0 :         basegfx::B2DPolyPolygon aPolyPolygon;
    1493             : 
    1494           0 :         if(basegfx::tools::importFromSvgD(aPolyPolygon, maD, GetImport().needFixPositionAfterZ(), 0))
    1495             :         {
    1496           0 :             if(aPolyPolygon.count())
    1497             :             {
    1498             :                 const basegfx::B2DRange aSourceRange(
    1499             :                     aViewBox.GetX(), aViewBox.GetY(),
    1500           0 :                     aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
    1501             :                 const basegfx::B2DRange aTargetRange(
    1502             :                     aViewBox.GetX(), aViewBox.GetY(),
    1503           0 :                     aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
    1504             : 
    1505           0 :                 if(!aSourceRange.equal(aTargetRange))
    1506             :                 {
    1507             :                     aPolyPolygon.transform(
    1508             :                         basegfx::tools::createSourceRangeTargetRangeTransform(
    1509             :                             aSourceRange,
    1510           0 :                             aTargetRange));
    1511             :                 }
    1512             : 
    1513             :                 // create shape
    1514           0 :                 OUString service;
    1515             : 
    1516           0 :                 if(aPolyPolygon.areControlPointsUsed())
    1517             :                 {
    1518           0 :                     if(aPolyPolygon.isClosed())
    1519             :                     {
    1520           0 :                         service = "com.sun.star.drawing.ClosedBezierShape";
    1521             :                     }
    1522             :                     else
    1523             :                     {
    1524           0 :                         service = "com.sun.star.drawing.OpenBezierShape";
    1525             :                     }
    1526             :                 }
    1527             :                 else
    1528             :                 {
    1529           0 :                     if(aPolyPolygon.isClosed())
    1530             :                     {
    1531           0 :                         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           0 :                 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           0 :                 if( mxShape.is() )
    1546             :                 {
    1547           0 :                     SetStyle();
    1548           0 :                     SetLayer();
    1549             : 
    1550             :                     // set local parameters on shape
    1551           0 :                     uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
    1552             : 
    1553           0 :                     if(xPropSet.is())
    1554             :                     {
    1555           0 :                         uno::Any aAny;
    1556             : 
    1557             :                         // set polygon data
    1558           0 :                         if(aPolyPolygon.areControlPointsUsed())
    1559             :                         {
    1560           0 :                             drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
    1561             : 
    1562             :                             basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords(
    1563             :                                 aPolyPolygon,
    1564           0 :                                 aSourcePolyPolygon);
    1565           0 :                             aAny <<= aSourcePolyPolygon;
    1566             :                         }
    1567             :                         else
    1568             :                         {
    1569           0 :                             drawing::PointSequenceSequence aSourcePolyPolygon;
    1570             : 
    1571             :                             basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(
    1572             :                                 aPolyPolygon,
    1573           0 :                                 aSourcePolyPolygon);
    1574           0 :                             aAny <<= aSourcePolyPolygon;
    1575             :                         }
    1576             : 
    1577           0 :                         xPropSet->setPropertyValue(OUString("Geometry"), aAny);
    1578             :                     }
    1579             : 
    1580             :                     // set pos, size, shear and rotate
    1581           0 :                     SetTransformation();
    1582             : 
    1583           0 :                     SdXMLShapeContext::StartElement(xAttrList);
    1584           0 :                 }
    1585             :             }
    1586           0 :         }
    1587             :     }
    1588           0 : }
    1589             : 
    1590           0 : TYPEINIT1( SdXMLTextBoxShapeContext, SdXMLShapeContext );
    1591             : 
    1592           0 : 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           0 :     mnRadius(0)
    1601             : {
    1602           0 : }
    1603             : 
    1604           0 : SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext()
    1605             : {
    1606           0 : }
    1607             : 
    1608             : // this is called from the parent group for each unparsed attribute in the attribute list
    1609           0 : void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    1610             : {
    1611           0 :     if( XML_NAMESPACE_DRAW == nPrefix )
    1612             :     {
    1613           0 :         if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
    1614             :         {
    1615           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1616           0 :                     mnRadius, rValue);
    1617           0 :             return;
    1618             :         }
    1619             :     }
    1620             : 
    1621           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    1622             : }
    1623             : 
    1624           0 : void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
    1625             : {
    1626             :     // create textbox shape
    1627           0 :     sal_Bool bIsPresShape = sal_False;
    1628           0 :     bool bClearText = false;
    1629             : 
    1630           0 :     OUString service;
    1631             : 
    1632           0 :     if( isPresentationShape() )
    1633             :     {
    1634             :         // check if the current document supports presentation shapes
    1635           0 :         if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
    1636             :         {
    1637           0 :             if( IsXMLToken( maPresentationClass, XML_PRESENTATION_SUBTITLE ))
    1638             :             {
    1639             :                 // XmlShapeTypePresSubtitleShape
    1640           0 :                 service = "com.sun.star.presentation.SubtitleShape";
    1641             :             }
    1642           0 :             else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OUTLINE ) )
    1643             :             {
    1644             :                 // XmlShapeTypePresOutlinerShape
    1645           0 :                 service = "com.sun.star.presentation.OutlinerShape";
    1646             :             }
    1647           0 :             else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_NOTES ) )
    1648             :             {
    1649             :                 // XmlShapeTypePresNotesShape
    1650           0 :                 service = "com.sun.star.presentation.NotesShape";
    1651             :             }
    1652           0 :             else if( IsXMLToken( maPresentationClass, XML_HEADER ) )
    1653             :             {
    1654             :                 // XmlShapeTypePresHeaderShape
    1655           0 :                 service = "com.sun.star.presentation.HeaderShape";
    1656           0 :                 bClearText = true;
    1657             :             }
    1658           0 :             else if( IsXMLToken( maPresentationClass, XML_FOOTER ) )
    1659             :             {
    1660             :                 // XmlShapeTypePresFooterShape
    1661           0 :                 service = "com.sun.star.presentation.FooterShape";
    1662           0 :                 bClearText = true;
    1663             :             }
    1664           0 :             else if( IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) )
    1665             :             {
    1666             :                 // XmlShapeTypePresSlideNumberShape
    1667           0 :                 service = "com.sun.star.presentation.SlideNumberShape";
    1668           0 :                 bClearText = true;
    1669             :             }
    1670           0 :             else if( IsXMLToken( maPresentationClass, XML_DATE_TIME ) )
    1671             :             {
    1672             :                 // XmlShapeTypePresDateTimeShape
    1673           0 :                 service = "com.sun.star.presentation.DateTimeShape";
    1674           0 :                 bClearText = true;
    1675             :             }
    1676             :             else //  IsXMLToken( maPresentationClass, XML_PRESENTATION_TITLE ) )
    1677             :             {
    1678             :                 // XmlShapeTypePresTitleTextShape
    1679           0 :                 service = "com.sun.star.presentation.TitleTextShape";
    1680             :             }
    1681           0 :             bIsPresShape = sal_True;
    1682             :         }
    1683             :     }
    1684             : 
    1685           0 :     if( service.isEmpty() )
    1686             :     {
    1687             :         // normal text shape
    1688           0 :         service = "com.sun.star.drawing.TextShape";
    1689             :     }
    1690             : 
    1691             :     // Add, set Style and properties from base shape
    1692           0 :     AddShape(service);
    1693             : 
    1694           0 :     if( mxShape.is() )
    1695             :     {
    1696           0 :         SetStyle();
    1697           0 :         SetLayer();
    1698             : 
    1699           0 :         if(bIsPresShape)
    1700             :         {
    1701           0 :             uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
    1702           0 :             if(xProps.is())
    1703             :             {
    1704           0 :                 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
    1705           0 :                 if( xPropsInfo.is() )
    1706             :                 {
    1707           0 :                     if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
    1708           0 :                         xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
    1709             : 
    1710           0 :                     if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
    1711           0 :                         xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
    1712           0 :                 }
    1713           0 :             }
    1714             :         }
    1715             : 
    1716           0 :         if( bClearText )
    1717             :         {
    1718           0 :             uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
    1719           0 :             OUString aEmpty;
    1720           0 :             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           0 :         SetTransformation();
    1735             : 
    1736           0 :         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           0 :         SdXMLShapeContext::StartElement(mxAttrList);
    1753           0 :     }
    1754           0 : }
    1755             : 
    1756           0 : TYPEINIT1( SdXMLControlShapeContext, SdXMLShapeContext );
    1757             : 
    1758           0 : 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           0 : :   SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
    1766             : {
    1767           0 : }
    1768             : 
    1769           0 : SdXMLControlShapeContext::~SdXMLControlShapeContext()
    1770             : {
    1771           0 : }
    1772             : 
    1773             : // this is called from the parent group for each unparsed attribute in the attribute list
    1774           0 : void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    1775             : {
    1776           0 :     if( XML_NAMESPACE_DRAW == nPrefix )
    1777             :     {
    1778           0 :         if( IsXMLToken( rLocalName, XML_CONTROL ) )
    1779             :         {
    1780           0 :             maFormId = rValue;
    1781           0 :             return;
    1782             :         }
    1783             :     }
    1784             : 
    1785           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    1786             : }
    1787             : 
    1788           0 : 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           0 :     AddShape("com.sun.star.drawing.ControlShape");
    1793           0 :     if( mxShape.is() )
    1794             :     {
    1795             :         DBG_ASSERT( !maFormId.isEmpty(), "draw:control without a form:id attribute!" );
    1796           0 :         if( !maFormId.isEmpty() )
    1797             :         {
    1798           0 :             if( GetImport().IsFormsSupported() )
    1799             :             {
    1800           0 :                 uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY );
    1801           0 :                 if( xControlModel.is() )
    1802             :                 {
    1803           0 :                     uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY );
    1804           0 :                     if( xControl.is() )
    1805           0 :                         xControl->setControl(  xControlModel );
    1806             : 
    1807           0 :                 }
    1808             :             }
    1809             :         }
    1810             : 
    1811           0 :         SetStyle();
    1812           0 :         SetLayer();
    1813             : 
    1814             :         // set pos, size, shear and rotate
    1815           0 :         SetTransformation();
    1816             : 
    1817           0 :         SdXMLShapeContext::StartElement(xAttrList);
    1818             :     }
    1819           0 : }
    1820             : 
    1821           0 : TYPEINIT1( SdXMLConnectorShapeContext, SdXMLShapeContext );
    1822             : 
    1823           0 : 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           0 :     mnDelta3(0)
    1839             : {
    1840           0 : }
    1841             : 
    1842           0 : SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext()
    1843             : {
    1844           0 : }
    1845             : 
    1846           0 : bool SvXMLImport::needFixPositionAfterZ() const
    1847             : {
    1848           0 :     bool bWrongPositionAfterZ( false );
    1849           0 :     sal_Int32 nUPD( 0 );
    1850           0 :     sal_Int32 nBuildId( 0 );
    1851           0 :     if ( getBuildIds( nUPD, nBuildId ) &&
    1852           0 :        ( ( nUPD == 641 ) || ( nUPD == 645 ) || ( nUPD == 680 ) || ( nUPD == 300 ) ||
    1853           0 :          ( nUPD == 310 ) || ( nUPD == 320 ) || ( nUPD == 330 ) || ( nUPD == 340 ) ||
    1854           0 :          ( nUPD == 350 && nBuildId < 202 ) ) )
    1855             :     {
    1856           0 :         bWrongPositionAfterZ = true;
    1857             :     }
    1858           0 :     return bWrongPositionAfterZ;
    1859             : }
    1860             : 
    1861             : 
    1862             : // this is called from the parent group for each unparsed attribute in the attribute list
    1863           0 : void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    1864             : {
    1865           0 :     switch( nPrefix )
    1866             :     {
    1867             :     case XML_NAMESPACE_DRAW:
    1868             :     {
    1869           0 :         if( IsXMLToken( rLocalName, XML_START_SHAPE ) )
    1870             :         {
    1871           0 :             maStartShapeId = rValue;
    1872           0 :             return;
    1873             :         }
    1874           0 :         if( IsXMLToken( rLocalName, XML_START_GLUE_POINT ) )
    1875             :         {
    1876           0 :             mnStartGlueId = rValue.toInt32();
    1877           0 :             return;
    1878             :         }
    1879           0 :         if( IsXMLToken( rLocalName, XML_END_SHAPE ) )
    1880             :         {
    1881           0 :             maEndShapeId = rValue;
    1882           0 :             return;
    1883             :         }
    1884           0 :         if( IsXMLToken( rLocalName, XML_END_GLUE_POINT ) )
    1885             :         {
    1886           0 :             mnEndGlueId = rValue.toInt32();
    1887           0 :             return;
    1888             :         }
    1889           0 :         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           0 :         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           0 :         else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
    1917             :         {
    1918           0 :             mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
    1919             :         }
    1920             :     }
    1921           0 :     break;
    1922             : 
    1923             :     case XML_NAMESPACE_SVG:
    1924             :     {
    1925           0 :         if( IsXMLToken( rLocalName, XML_X1 ) )
    1926             :         {
    1927           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1928           0 :                     maStart.X, rValue);
    1929           0 :             return;
    1930             :         }
    1931           0 :         if( IsXMLToken( rLocalName, XML_Y1 ) )
    1932             :         {
    1933           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1934           0 :                     maStart.Y, rValue);
    1935           0 :             return;
    1936             :         }
    1937           0 :         if( IsXMLToken( rLocalName, XML_X2 ) )
    1938             :         {
    1939           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1940           0 :                     maEnd.X, rValue);
    1941           0 :             return;
    1942             :         }
    1943           0 :         if( IsXMLToken( rLocalName, XML_Y2 ) )
    1944             :         {
    1945           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    1946           0 :                     maEnd.Y, rValue);
    1947           0 :             return;
    1948             :         }
    1949           0 :         if( IsXMLToken( rLocalName, XML_D ) )
    1950             :         {
    1951           0 :             basegfx::B2DPolyPolygon aPolyPolygon;
    1952             : 
    1953           0 :             if(basegfx::tools::importFromSvgD(aPolyPolygon, rValue, GetImport().needFixPositionAfterZ(), 0))
    1954             :             {
    1955           0 :                 if(aPolyPolygon.count())
    1956             :                 {
    1957           0 :                     drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
    1958             : 
    1959             :                     basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords(
    1960             :                         aPolyPolygon,
    1961           0 :                         aSourcePolyPolygon);
    1962           0 :                     maPath <<= aSourcePolyPolygon;
    1963             :                 }
    1964           0 :             }
    1965             :         }
    1966             :     }
    1967             :     }
    1968             : 
    1969           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    1970             : }
    1971             : 
    1972           0 : 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           0 :     sal_Bool bDoAdd(sal_True);
    1979             : 
    1980           0 :     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           0 :         && 0 == mnDelta3
    1987             :         )
    1988             :     {
    1989           0 :         bDoAdd = sal_False;
    1990             :     }
    1991             : 
    1992           0 :     if(bDoAdd)
    1993             :     {
    1994             :         // create Connector shape
    1995             :         // add, set style and properties from base shape
    1996           0 :         AddShape("com.sun.star.drawing.ConnectorShape");
    1997           0 :         if(mxShape.is())
    1998             :         {
    1999             :             // #121965# if draw:transform is used, apply directly to the start
    2000             :             // and end positions before using these
    2001           0 :             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           0 :             if( !maStartShapeId.isEmpty() )
    2024           0 :                 GetImport().GetShapeImport()->addShapeConnection( mxShape, true, maStartShapeId, mnStartGlueId );
    2025           0 :             if( !maEndShapeId.isEmpty() )
    2026           0 :                 GetImport().GetShapeImport()->addShapeConnection( mxShape, false, maEndShapeId, mnEndGlueId );
    2027             : 
    2028           0 :             uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
    2029           0 :             if( xProps.is() )
    2030             :             {
    2031           0 :                 uno::Any aAny;
    2032           0 :                 aAny <<= maStart;
    2033           0 :                 xProps->setPropertyValue("StartPosition", aAny);
    2034             : 
    2035           0 :                 aAny <<= maEnd;
    2036           0 :                 xProps->setPropertyValue("EndPosition", aAny );
    2037             : 
    2038           0 :                 aAny <<= (drawing::ConnectorType)mnType;
    2039           0 :                 xProps->setPropertyValue("EdgeKind", aAny );
    2040             : 
    2041           0 :                 aAny <<= mnDelta1;
    2042           0 :                 xProps->setPropertyValue("EdgeLine1Delta", aAny );
    2043             : 
    2044           0 :                 aAny <<= mnDelta2;
    2045           0 :                 xProps->setPropertyValue("EdgeLine2Delta", aAny );
    2046             : 
    2047           0 :                 aAny <<= mnDelta3;
    2048           0 :                 xProps->setPropertyValue("EdgeLine3Delta", aAny );
    2049             :             }
    2050           0 :             SetStyle();
    2051           0 :             SetLayer();
    2052             : 
    2053           0 :             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           0 :                 bool bApplySVGD( true );
    2060           0 :                 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           0 :                 if ( bApplySVGD )
    2078             :                 {
    2079             :                     assert(maPath.getValueType() == ::getCppuType((const drawing::PolyPolygonBezierCoords*)0));
    2080           0 :                     xProps->setPropertyValue("PolyPolygonBezier", maPath);
    2081             :                 }
    2082             :             }
    2083             : 
    2084           0 :             SdXMLShapeContext::StartElement(xAttrList);
    2085             :         }
    2086             :     }
    2087           0 : }
    2088             : 
    2089           0 : TYPEINIT1( SdXMLMeasureShapeContext, SdXMLShapeContext );
    2090             : 
    2091           0 : 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           0 :     maEnd(1,1)
    2101             : {
    2102           0 : }
    2103             : 
    2104           0 : SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext()
    2105             : {
    2106           0 : }
    2107             : 
    2108             : // this is called from the parent group for each unparsed attribute in the attribute list
    2109           0 : void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    2110             : {
    2111           0 :     switch( nPrefix )
    2112             :     {
    2113             :     case XML_NAMESPACE_SVG:
    2114             :     {
    2115           0 :         if( IsXMLToken( rLocalName, XML_X1 ) )
    2116             :         {
    2117           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    2118           0 :                     maStart.X, rValue);
    2119           0 :             return;
    2120             :         }
    2121           0 :         if( IsXMLToken( rLocalName, XML_Y1 ) )
    2122             :         {
    2123           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    2124           0 :                     maStart.Y, rValue);
    2125           0 :             return;
    2126             :         }
    2127           0 :         if( IsXMLToken( rLocalName, XML_X2 ) )
    2128             :         {
    2129           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    2130           0 :                     maEnd.X, rValue);
    2131           0 :             return;
    2132             :         }
    2133           0 :         if( IsXMLToken( rLocalName, XML_Y2 ) )
    2134             :         {
    2135           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    2136           0 :                     maEnd.Y, rValue);
    2137           0 :             return;
    2138             :         }
    2139             :     }
    2140             :     }
    2141             : 
    2142           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    2143             : }
    2144             : 
    2145           0 : 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           0 :     AddShape("com.sun.star.drawing.MeasureShape");
    2150           0 :     if(mxShape.is())
    2151             :     {
    2152           0 :         SetStyle();
    2153           0 :         SetLayer();
    2154             : 
    2155           0 :         uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
    2156           0 :         if( xProps.is() )
    2157             :         {
    2158           0 :             uno::Any aAny;
    2159           0 :             aAny <<= maStart;
    2160           0 :             xProps->setPropertyValue("StartPosition", aAny);
    2161             : 
    2162           0 :             aAny <<= maEnd;
    2163           0 :             xProps->setPropertyValue("EndPosition", aAny );
    2164             :         }
    2165             : 
    2166             :         // delete pre created fields
    2167           0 :         uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
    2168           0 :         if( xText.is() )
    2169             :         {
    2170           0 :             const OUString aEmpty(  " "  );
    2171           0 :             xText->setString( aEmpty );
    2172             :         }
    2173             : 
    2174           0 :         SdXMLShapeContext::StartElement(xAttrList);
    2175             :     }
    2176           0 : }
    2177             : 
    2178           0 : void SdXMLMeasureShapeContext::EndElement()
    2179             : {
    2180             :     do
    2181             :     {
    2182             :         // delete pre created fields
    2183           0 :         uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
    2184           0 :         if( !xText.is() )
    2185           0 :             break;
    2186             : 
    2187           0 :         uno::Reference< text::XTextCursor > xCursor( xText->createTextCursor() );
    2188           0 :         if( !xCursor.is() )
    2189           0 :             break;
    2190             : 
    2191           0 :         const OUString aEmpty;
    2192           0 :         xCursor->collapseToStart();
    2193           0 :         xCursor->goRight( 1, sal_True );
    2194           0 :         xCursor->setString( aEmpty );
    2195             :     }
    2196             :     while(false);
    2197             : 
    2198           0 :     SdXMLShapeContext::EndElement();
    2199           0 : }
    2200             : 
    2201           0 : TYPEINIT1( SdXMLPageShapeContext, SdXMLShapeContext );
    2202             : 
    2203           0 : 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           0 : :   SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), mnPageNumber(0)
    2211             : {
    2212           0 :     mbClearDefaultAttributes = false;
    2213           0 : }
    2214             : 
    2215           0 : SdXMLPageShapeContext::~SdXMLPageShapeContext()
    2216             : {
    2217           0 : }
    2218             : 
    2219             : // this is called from the parent group for each unparsed attribute in the attribute list
    2220           0 : void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    2221             : {
    2222           0 :     if( XML_NAMESPACE_DRAW == nPrefix )
    2223             :     {
    2224           0 :         if( IsXMLToken( rLocalName, XML_PAGE_NUMBER ) )
    2225             :         {
    2226           0 :             mnPageNumber = rValue.toInt32();
    2227           0 :             return;
    2228             :         }
    2229             :     }
    2230             : 
    2231           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    2232             : }
    2233             : 
    2234           0 : 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           0 :     sal_Bool bIsPresentation = !maPresentationClass.isEmpty() &&
    2242           0 :            GetImport().GetShapeImport()->IsPresentationShapesSupported();
    2243             : 
    2244           0 :     uno::Reference< lang::XServiceInfo > xInfo( mxShapes, uno::UNO_QUERY );
    2245           0 :     const sal_Bool bIsOnHandoutPage = xInfo.is() && xInfo->supportsService("com.sun.star.presentation.HandoutMasterPage");
    2246             : 
    2247           0 :     if( bIsOnHandoutPage )
    2248             :     {
    2249           0 :         AddShape("com.sun.star.presentation.HandoutShape");
    2250             :     }
    2251             :     else
    2252             :     {
    2253           0 :         if(bIsPresentation && !IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) )
    2254             :         {
    2255           0 :             bIsPresentation = sal_False;
    2256             :         }
    2257             : 
    2258           0 :         if(bIsPresentation)
    2259             :         {
    2260           0 :             AddShape("com.sun.star.presentation.PageShape");
    2261             :         }
    2262             :         else
    2263             :         {
    2264           0 :             AddShape("com.sun.star.drawing.PageShape");
    2265             :         }
    2266             :     }
    2267             : 
    2268           0 :     if(mxShape.is())
    2269             :     {
    2270           0 :         SetStyle();
    2271           0 :         SetLayer();
    2272             : 
    2273             :         // set pos, size, shear and rotate
    2274           0 :         SetTransformation();
    2275             : 
    2276           0 :         uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
    2277           0 :         if(xPropSet.is())
    2278             :         {
    2279           0 :             uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
    2280           0 :             const OUString aPageNumberStr("PageNumber");
    2281           0 :             if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
    2282           0 :                 xPropSet->setPropertyValue(aPageNumberStr, uno::makeAny( mnPageNumber ));
    2283             :         }
    2284             : 
    2285           0 :         SdXMLShapeContext::StartElement(xAttrList);
    2286           0 :     }
    2287           0 : }
    2288             : 
    2289           0 : TYPEINIT1( SdXMLCaptionShapeContext, SdXMLShapeContext );
    2290             : 
    2291           0 : 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           0 :     mnRadius( 0L )
    2301             : {
    2302           0 : }
    2303             : 
    2304           0 : SdXMLCaptionShapeContext::~SdXMLCaptionShapeContext()
    2305             : {
    2306           0 : }
    2307             : 
    2308           0 : 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           0 :     AddShape("com.sun.star.drawing.CaptionShape");
    2313           0 :     if( mxShape.is() )
    2314             :     {
    2315           0 :         SetStyle();
    2316           0 :         SetLayer();
    2317             : 
    2318           0 :         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           0 :         sal_Bool bIsAutoGrowWidth = sal_False;
    2326           0 :         if ( xProps.is() )
    2327             :         {
    2328           0 :             uno::Any aAny( xProps->getPropertyValue("TextAutoGrowWidth") );
    2329           0 :             aAny >>= bIsAutoGrowWidth;
    2330             : 
    2331           0 :             if ( bIsAutoGrowWidth )
    2332           0 :                 xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( sal_False ) );
    2333             :         }
    2334             : 
    2335             :         // set pos, size, shear and rotate
    2336           0 :         SetTransformation();
    2337           0 :         if( xProps.is() )
    2338           0 :             xProps->setPropertyValue("CaptionPoint", uno::makeAny( maCaptionPoint ) );
    2339             : 
    2340           0 :         if ( bIsAutoGrowWidth )
    2341           0 :             xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( sal_True ) );
    2342             : 
    2343           0 :         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           0 :         SdXMLShapeContext::StartElement(xAttrList);
    2360             :     }
    2361           0 : }
    2362             : 
    2363             : // this is called from the parent group for each unparsed attribute in the attribute list
    2364           0 : void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    2365             : {
    2366           0 :     if( XML_NAMESPACE_DRAW == nPrefix )
    2367             :     {
    2368           0 :         if( IsXMLToken( rLocalName, XML_CAPTION_POINT_X ) )
    2369             :         {
    2370           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    2371           0 :                     maCaptionPoint.X, rValue);
    2372           0 :             return;
    2373             :         }
    2374           0 :         if( IsXMLToken( rLocalName, XML_CAPTION_POINT_Y ) )
    2375             :         {
    2376           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    2377           0 :                     maCaptionPoint.Y, rValue);
    2378           0 :             return;
    2379             :         }
    2380           0 :         if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
    2381             :         {
    2382           0 :             GetImport().GetMM100UnitConverter().convertMeasureToCore(
    2383           0 :                     mnRadius, rValue);
    2384           0 :             return;
    2385             :         }
    2386             :     }
    2387           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    2388             : }
    2389             : 
    2390           0 : TYPEINIT1( SdXMLGraphicObjectShapeContext, SdXMLShapeContext );
    2391             : 
    2392           0 : 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           0 :     maURL()
    2401             : {
    2402           0 : }
    2403             : 
    2404             : // this is called from the parent group for each unparsed attribute in the attribute list
    2405           0 : void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    2406             : {
    2407           0 :     if( XML_NAMESPACE_XLINK == nPrefix )
    2408             :     {
    2409           0 :         if( IsXMLToken( rLocalName, XML_HREF ) )
    2410             :         {
    2411           0 :             maURL = rValue;
    2412           0 :             return;
    2413             :         }
    2414             :     }
    2415             : 
    2416           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    2417             : }
    2418             : 
    2419           0 : void SdXMLGraphicObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
    2420             : {
    2421             :     // create graphic object shape
    2422           0 :     OUString service;
    2423             : 
    2424           0 :     if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
    2425             :     {
    2426           0 :         service = "com.sun.star.presentation.GraphicObjectShape";
    2427             :     }
    2428             :     else
    2429             :     {
    2430           0 :         service = "com.sun.star.drawing.GraphicObjectShape";
    2431             :     }
    2432             : 
    2433           0 :     AddShape(service);
    2434             : 
    2435           0 :     if(mxShape.is())
    2436             :     {
    2437           0 :         SetStyle();
    2438           0 :         SetLayer();
    2439             : 
    2440           0 :         uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY);
    2441           0 :         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           0 :             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           0 :             uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() );
    2456           0 :             if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
    2457           0 :                 xPropset->setPropertyValue("IsEmptyPresentationObject", css::uno::makeAny( mbIsPlaceholder ) );
    2458             : 
    2459           0 :             if( !mbIsPlaceholder )
    2460             :             {
    2461           0 :                 if( !maURL.isEmpty() )
    2462             :                 {
    2463           0 :                     uno::Any aAny;
    2464           0 :                     aAny <<= GetImport().ResolveGraphicObjectURL( maURL, GetImport().isGraphicLoadOnDemandSupported() );
    2465             :                     try
    2466             :                     {
    2467           0 :                         xPropset->setPropertyValue("GraphicURL", aAny );
    2468           0 :                         xPropset->setPropertyValue("GraphicStreamURL", aAny );
    2469             :                     }
    2470           0 :                     catch (const lang::IllegalArgumentException&)
    2471             :                     {
    2472           0 :                     }
    2473             :                 }
    2474           0 :             }
    2475             :         }
    2476             : 
    2477           0 :         if(mbIsUserTransformed)
    2478             :         {
    2479           0 :             uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
    2480           0 :             if(xProps.is())
    2481             :             {
    2482           0 :                 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
    2483           0 :                 if( xPropsInfo.is() )
    2484             :                 {
    2485           0 :                     if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
    2486           0 :                         xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
    2487           0 :                 }
    2488           0 :             }
    2489             :         }
    2490             : 
    2491             :         // set pos, size, shear and rotate
    2492           0 :         SetTransformation();
    2493             : 
    2494           0 :         SdXMLShapeContext::StartElement(mxAttrList);
    2495           0 :     }
    2496           0 : }
    2497             : 
    2498           0 : void SdXMLGraphicObjectShapeContext::EndElement()
    2499             : {
    2500           0 :     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           0 :     SdXMLShapeContext::EndElement();
    2522           0 : }
    2523             : 
    2524           0 : SvXMLImportContext* SdXMLGraphicObjectShapeContext::CreateChildContext(
    2525             :     sal_uInt16 nPrefix, const OUString& rLocalName,
    2526             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList )
    2527             : {
    2528           0 :     SvXMLImportContext* pContext = NULL;
    2529             : 
    2530           0 :     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           0 :     if ( NULL == pContext )
    2545             :         pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName,
    2546           0 :                                                          xAttrList);
    2547             : 
    2548           0 :     return pContext;
    2549             : }
    2550             : 
    2551           0 : SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext()
    2552             : {
    2553             : 
    2554           0 : }
    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           0 : TYPEINIT1( SdXMLObjectShapeContext, SdXMLShapeContext );
    2663             : 
    2664           0 : 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           0 : : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
    2670             : {
    2671           0 : }
    2672             : 
    2673           0 : SdXMLObjectShapeContext::~SdXMLObjectShapeContext()
    2674             : {
    2675           0 : }
    2676             : 
    2677           0 : 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           0 :     if( !(GetImport().getImportFlags() & IMPORT_EMBEDDED) && !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
    2691           0 :         return;
    2692             : 
    2693           0 :     OUString service("com.sun.star.drawing.OLE2Shape");
    2694             : 
    2695           0 :     sal_Bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
    2696             : 
    2697           0 :     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           0 :     AddShape(service);
    2714             : 
    2715           0 :     if( mxShape.is() )
    2716             :     {
    2717           0 :         SetLayer();
    2718             : 
    2719           0 :         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           0 :         if( !mbIsPlaceholder && !maHref.isEmpty() )
    2737             :         {
    2738           0 :             uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
    2739             : 
    2740           0 :             if( xProps.is() )
    2741             :             {
    2742           0 :                 OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID );
    2743             : 
    2744           0 :                 if ( GetImport().IsPackageURL( maHref ) )
    2745             :                 {
    2746           0 :                     const OUString  sURL( "vnd.sun.star.EmbeddedObject:" );
    2747             : 
    2748           0 :                     if ( aPersistName.startsWith( sURL ) )
    2749           0 :                         aPersistName = aPersistName.copy( sURL.getLength() );
    2750             : 
    2751           0 :                     xProps->setPropertyValue("PersistName",
    2752           0 :                                               uno::makeAny( aPersistName ) );
    2753             :                 }
    2754             :                 else
    2755             :                 {
    2756             :                     // this is OOo link object
    2757           0 :                     xProps->setPropertyValue("LinkURL",
    2758           0 :                                               uno::makeAny( aPersistName ) );
    2759           0 :                 }
    2760           0 :             }
    2761             :         }
    2762             : 
    2763             :         // set pos, size, shear and rotate
    2764           0 :         SetTransformation();
    2765             : 
    2766           0 :         SetStyle();
    2767             : 
    2768           0 :         GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
    2769           0 :     }
    2770             : }
    2771             : 
    2772           0 : void SdXMLObjectShapeContext::EndElement()
    2773             : {
    2774           0 :     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           0 :         uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
    2784             : 
    2785           0 :         if( xProps.is() )
    2786             :         {
    2787           0 :             xProps->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_NONE));
    2788           0 :             xProps->setPropertyValue("LineStyle", uno::makeAny(drawing::LineStyle_NONE));
    2789           0 :         }
    2790             :     }
    2791             : 
    2792             :     // #100592#
    2793           0 :     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           0 :     SdXMLShapeContext::EndElement();
    2806           0 : }
    2807             : 
    2808             : // this is called from the parent group for each unparsed attribute in the attribute list
    2809           0 : void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    2810             : {
    2811           0 :     switch( nPrefix )
    2812             :     {
    2813             :     case XML_NAMESPACE_DRAW:
    2814           0 :         if( IsXMLToken( rLocalName, XML_CLASS_ID ) )
    2815             :         {
    2816           0 :             maCLSID = rValue;
    2817           0 :             return;
    2818             :         }
    2819           0 :         break;
    2820             :     case XML_NAMESPACE_XLINK:
    2821           0 :         if( IsXMLToken( rLocalName, XML_HREF ) )
    2822             :         {
    2823           0 :             maHref = rValue;
    2824           0 :             return;
    2825             :         }
    2826           0 :         break;
    2827             :     }
    2828             : 
    2829           0 :     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           0 : 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           0 : mbMedia( false )
    3048             : {
    3049           0 : }
    3050             : 
    3051           0 : SdXMLPluginShapeContext::~SdXMLPluginShapeContext()
    3052             : {
    3053           0 : }
    3054             : 
    3055           0 : 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           0 :     for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n )
    3059             :     {
    3060           0 :         OUString    aLocalName;
    3061           0 :         sal_uInt16  nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName );
    3062             : 
    3063           0 :         if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
    3064             :         {
    3065           0 :             if( xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.sun.star.media" ) ||
    3066           0 :                 xAttrList->getValueByIndex( n ).equalsAscii( "application/vnd.gltf+json" ))
    3067           0 :                 mbMedia = true;
    3068             : 
    3069             :             // leave this loop
    3070           0 :             n = nAttrCount - 1;
    3071             :         }
    3072           0 :     }
    3073             : 
    3074           0 :     OUString service;
    3075             : 
    3076           0 :     sal_Bool bIsPresShape = sal_False;
    3077             : 
    3078           0 :     if( mbMedia )
    3079             :     {
    3080           0 :         service = "com.sun.star.drawing.MediaShape";
    3081             : 
    3082           0 :         bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
    3083           0 :         if( bIsPresShape )
    3084             :         {
    3085           0 :             if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
    3086             :             {
    3087           0 :                 service = "com.sun.star.presentation.MediaShape";
    3088             :             }
    3089             :         }
    3090             :     }
    3091             :     else
    3092           0 :         service = "com.sun.star.drawing.PluginShape";
    3093             : 
    3094           0 :     AddShape(service);
    3095             : 
    3096           0 :     if( mxShape.is() )
    3097             :     {
    3098           0 :         SetLayer();
    3099             : 
    3100           0 :         if(bIsPresShape)
    3101             :         {
    3102           0 :             uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
    3103           0 :             if(xProps.is())
    3104             :             {
    3105           0 :                 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
    3106           0 :                 if( xPropsInfo.is() )
    3107             :                 {
    3108           0 :                     if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
    3109           0 :                         xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
    3110             : 
    3111           0 :                     if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
    3112           0 :                         xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
    3113           0 :                 }
    3114           0 :             }
    3115             :         }
    3116             : 
    3117             :         // set pos, size, shear and rotate
    3118           0 :         SetTransformation();
    3119           0 :         GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
    3120           0 :     }
    3121           0 : }
    3122             : 
    3123             : static OUString
    3124           0 : lcl_GetMediaReference(SvXMLImport const& rImport, OUString const& rURL)
    3125             : {
    3126           0 :     if (rImport.IsPackageURL(rURL))
    3127             :     {
    3128           0 :         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           0 : void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    3138             : {
    3139           0 :     switch( nPrefix )
    3140             :     {
    3141             :     case XML_NAMESPACE_DRAW:
    3142           0 :         if( IsXMLToken( rLocalName, XML_MIME_TYPE ) )
    3143             :         {
    3144           0 :             maMimeType = rValue;
    3145           0 :             return;
    3146             :         }
    3147           0 :         break;
    3148             :     case XML_NAMESPACE_XLINK:
    3149           0 :         if( IsXMLToken( rLocalName, XML_HREF ) )
    3150             :         {
    3151           0 :             maHref = lcl_GetMediaReference(GetImport(), rValue);
    3152           0 :             return;
    3153             :         }
    3154           0 :         break;
    3155             :     }
    3156             : 
    3157           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    3158             : }
    3159             : 
    3160           0 : void SdXMLPluginShapeContext::EndElement()
    3161             : {
    3162           0 :     uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
    3163             : 
    3164           0 :     if( xProps.is() )
    3165             :     {
    3166           0 :         uno::Any aAny;
    3167             : 
    3168           0 :         if ( maSize.Width && maSize.Height )
    3169             :         {
    3170           0 :             const OUString sVisibleArea(  "VisibleArea"  );
    3171           0 :             uno::Reference< beans::XPropertySetInfo > aXPropSetInfo( xProps->getPropertySetInfo() );
    3172           0 :             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           0 :             }
    3179             :         }
    3180             : 
    3181           0 :         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           0 :             xProps->setPropertyValue(
    3206             :                     OUString("MediaURL"),
    3207           0 :                     uno::makeAny(maHref));
    3208             : 
    3209           0 :             xProps->setPropertyValue("MediaMimeType", uno::makeAny(maMimeType) );
    3210             : 
    3211           0 :             for( sal_Int32 nParam = 0; nParam < maParams.getLength(); ++nParam )
    3212             :             {
    3213           0 :                 const OUString& rName = maParams[ nParam ].Name;
    3214             : 
    3215           0 :                 if( rName.equalsAscii( "Loop" ) )
    3216             :                 {
    3217           0 :                     OUString aValueStr;
    3218           0 :                     maParams[ nParam ].Value >>= aValueStr;
    3219           0 :                     xProps->setPropertyValue("Loop",
    3220           0 :                         uno::makeAny( static_cast< sal_Bool >( aValueStr.equalsAscii( "true" ) ) ) );
    3221             :                 }
    3222           0 :                 else if( rName.equalsAscii( "Mute" ) )
    3223             :                 {
    3224           0 :                     OUString aValueStr;
    3225           0 :                     maParams[ nParam ].Value >>= aValueStr;
    3226           0 :                     xProps->setPropertyValue("Mute",
    3227           0 :                         uno::makeAny( static_cast< sal_Bool >( aValueStr.equalsAscii( "true" ) ) ) );
    3228             :                 }
    3229           0 :                 else if( rName.equalsAscii( "VolumeDB" ) )
    3230             :                 {
    3231           0 :                     OUString aValueStr;
    3232           0 :                     maParams[ nParam ].Value >>= aValueStr;
    3233           0 :                     xProps->setPropertyValue("VolumeDB",
    3234           0 :                                                 uno::makeAny( static_cast< sal_Int16 >( aValueStr.toInt32() ) ) );
    3235             :                 }
    3236           0 :                 else if( rName.equalsAscii( "Zoom" ) )
    3237             :                 {
    3238           0 :                     OUString            aZoomStr;
    3239             :                     media::ZoomLevel    eZoomLevel;
    3240             : 
    3241           0 :                     maParams[ nParam ].Value >>= aZoomStr;
    3242             : 
    3243           0 :                     if( aZoomStr.equalsAscii( "25%" ) )
    3244           0 :                         eZoomLevel = media::ZoomLevel_ZOOM_1_TO_4;
    3245           0 :                     else if( aZoomStr.equalsAscii( "50%" ) )
    3246           0 :                         eZoomLevel = media::ZoomLevel_ZOOM_1_TO_2;
    3247           0 :                     else if( aZoomStr.equalsAscii( "100%" ) )
    3248           0 :                         eZoomLevel = media::ZoomLevel_ORIGINAL;
    3249           0 :                     else if( aZoomStr.equalsAscii( "200%" ) )
    3250           0 :                         eZoomLevel = media::ZoomLevel_ZOOM_2_TO_1;
    3251           0 :                     else if( aZoomStr.equalsAscii( "400%" ) )
    3252           0 :                         eZoomLevel = media::ZoomLevel_ZOOM_4_TO_1;
    3253           0 :                     else if( aZoomStr.equalsAscii( "fit" ) )
    3254           0 :                         eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
    3255           0 :                     else if( aZoomStr.equalsAscii( "fixedfit" ) )
    3256           0 :                         eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT;
    3257           0 :                     else if( aZoomStr.equalsAscii( "fullscreen" ) )
    3258           0 :                         eZoomLevel = media::ZoomLevel_FULLSCREEN;
    3259             :                     else
    3260           0 :                         eZoomLevel = media::ZoomLevel_NOT_AVAILABLE;
    3261             : 
    3262           0 :                     xProps->setPropertyValue("Zoom", uno::makeAny( eZoomLevel ) );
    3263             :                 }
    3264             :             }
    3265             :         }
    3266             : 
    3267           0 :         SetThumbnail();
    3268             :     }
    3269             : 
    3270           0 :     SdXMLShapeContext::EndElement();
    3271           0 : }
    3272             : 
    3273           0 : 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           0 :     if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) )
    3276             :     {
    3277           0 :         OUString aParamName, aParamValue;
    3278           0 :         const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
    3279             :         // now parse the attribute list and look for draw:name and draw:value
    3280           0 :         for(sal_Int16 a(0); a < nAttrCount; a++)
    3281             :         {
    3282           0 :             const OUString& rAttrName = xAttrList->getNameByIndex(a);
    3283           0 :             OUString aLocalName;
    3284           0 :             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
    3285           0 :             const OUString aValue( xAttrList->getValueByIndex(a) );
    3286             : 
    3287           0 :             if( nPrefix == XML_NAMESPACE_DRAW )
    3288             :             {
    3289           0 :                 if( IsXMLToken( aLocalName, XML_NAME ) )
    3290             :                 {
    3291           0 :                     aParamName = aValue;
    3292             :                 }
    3293           0 :                 else if( IsXMLToken( aLocalName, XML_VALUE ) )
    3294             :                 {
    3295           0 :                     aParamValue = aValue;
    3296             :                 }
    3297             :             }
    3298             : 
    3299           0 :             if( !aParamName.isEmpty() )
    3300             :             {
    3301           0 :                 sal_Int32 nIndex = maParams.getLength();
    3302           0 :                 maParams.realloc( nIndex + 1 );
    3303           0 :                 maParams[nIndex].Name = aParamName;
    3304           0 :                 maParams[nIndex].Handle = -1;
    3305           0 :                 maParams[nIndex].Value <<= aParamValue;
    3306           0 :                 maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
    3307             :             }
    3308           0 :         }
    3309             : 
    3310           0 :         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           0 : 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           0 :     mxReplImplContext()
    3422             : {
    3423           0 :     uno::Reference < util::XCloneable > xClone( xAttrList, uno::UNO_QUERY );
    3424           0 :     if( xClone.is() )
    3425           0 :         mxAttrList.set( xClone->createClone(), uno::UNO_QUERY );
    3426             :     else
    3427           0 :         mxAttrList = new SvXMLAttributeList( xAttrList );
    3428             : 
    3429           0 : }
    3430             : 
    3431           0 : SdXMLFrameShapeContext::~SdXMLFrameShapeContext()
    3432             : {
    3433           0 : }
    3434             : 
    3435           0 : void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
    3436             : {
    3437           0 :     const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
    3438             : 
    3439           0 :     if(pSdXMLGraphicObjectShapeContext)
    3440             :     {
    3441             :         try
    3442             :         {
    3443           0 :             uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
    3444             : 
    3445           0 :             if(xChild.is())
    3446             :             {
    3447           0 :                 uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW);
    3448             : 
    3449           0 :                 if(xParent.is())
    3450             :                 {
    3451             :                     // remove from parent
    3452           0 :                     xParent->remove(pSdXMLGraphicObjectShapeContext->getShape());
    3453             : 
    3454             :                     // dispose
    3455           0 :                     uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY);
    3456             : 
    3457           0 :                     if(xComp.is())
    3458             :                     {
    3459           0 :                         xComp->dispose();
    3460           0 :                     }
    3461           0 :                 }
    3462           0 :             }
    3463             :         }
    3464           0 :         catch( uno::Exception& )
    3465             :         {
    3466             :             OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
    3467             :         }
    3468             :     }
    3469           0 : }
    3470             : 
    3471           0 : OUString SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
    3472             : {
    3473           0 :     OUString aRetval;
    3474           0 :     const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
    3475             : 
    3476           0 :     if(pSdXMLGraphicObjectShapeContext)
    3477             :     {
    3478             :         try
    3479             :         {
    3480           0 :             const uno::Reference< beans::XPropertySet > xPropSet(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
    3481             : 
    3482           0 :             if(xPropSet.is())
    3483             :             {
    3484           0 :                 xPropSet->getPropertyValue("GraphicStreamURL") >>= aRetval;
    3485             : 
    3486           0 :                 if(!aRetval.getLength())
    3487             :                 {
    3488             :                     // it maybe a link, try GraphicURL
    3489           0 :                     xPropSet->getPropertyValue("GraphicURL") >>= aRetval;
    3490             :                 }
    3491           0 :             }
    3492             :         }
    3493           0 :         catch( uno::Exception& )
    3494             :         {
    3495             :             OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
    3496             :         }
    3497             :     }
    3498             : 
    3499           0 :     return aRetval;
    3500             : }
    3501             : 
    3502           0 : SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix,
    3503             :     const OUString& rLocalName,
    3504             :     const uno::Reference< xml::sax::XAttributeList>& xAttrList )
    3505             : {
    3506           0 :     SvXMLImportContext * pContext = 0;
    3507             : 
    3508           0 :     if( !mxImplContext.Is() )
    3509             :     {
    3510             : 
    3511           0 :         SvXMLShapeContext* pShapeContext= GetImport().GetShapeImport()->CreateFrameChildContext(
    3512           0 :                         GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList );
    3513             : 
    3514           0 :         pContext = pShapeContext;
    3515             : 
    3516             :         // propagate the hyperlink to child context
    3517           0 :         if ( !msHyperlink.isEmpty() )
    3518           0 :             pShapeContext->setHyperlink( msHyperlink );
    3519             : 
    3520           0 :         mxImplContext = pContext;
    3521           0 :         mbSupportsReplacement = IsXMLToken(rLocalName, XML_OBJECT ) || IsXMLToken(rLocalName, XML_OBJECT_OLE);
    3522           0 :         setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
    3523             : 
    3524           0 :         if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext))
    3525             :         {
    3526           0 :             addContent(*mxImplContext);
    3527             :         }
    3528             :     }
    3529           0 :     else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
    3530             :     {
    3531             :         // read another image
    3532           0 :         pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
    3533           0 :             GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
    3534           0 :         mxImplContext = pContext;
    3535             : 
    3536           0 :         if(dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext))
    3537             :         {
    3538           0 :             addContent(*mxImplContext);
    3539             :         }
    3540             :     }
    3541           0 :     else if( mbSupportsReplacement && !mxReplImplContext &&
    3542           0 :              XML_NAMESPACE_DRAW == nPrefix &&
    3543           0 :              IsXMLToken( rLocalName, XML_IMAGE ) )
    3544             :     {
    3545             :         // read replacement image
    3546           0 :         SvXMLImportContext *pImplContext = &mxImplContext;
    3547             :         SdXMLShapeContext *pSContext =
    3548           0 :             PTR_CAST( SdXMLShapeContext, pImplContext );
    3549           0 :         if( pSContext )
    3550             :         {
    3551             :             uno::Reference < beans::XPropertySet > xPropSet(
    3552           0 :                     pSContext->getShape(), uno::UNO_QUERY );
    3553           0 :             if( xPropSet.is() )
    3554             :             {
    3555           0 :                 pContext = new XMLReplacementImageContext( GetImport(),
    3556           0 :                                     nPrefix, rLocalName, xAttrList, xPropSet );
    3557           0 :                 mxReplImplContext = pContext;
    3558           0 :             }
    3559             :         }
    3560             :     }
    3561           0 :     else if(
    3562           0 :             ( nPrefix == XML_NAMESPACE_SVG &&   // #i68101#
    3563           0 :                 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) ||
    3564           0 :              (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) ||
    3565           0 :              (nPrefix == XML_NAMESPACE_DRAW && (IsXMLToken( rLocalName, XML_GLUE_POINT ) ||
    3566           0 :                                                 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           0 :     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           0 :     if(!pContext)
    3587           0 :         pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
    3588             : 
    3589           0 :     return pContext;
    3590             : }
    3591             : 
    3592           0 : void SdXMLFrameShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
    3593             : {
    3594             :     // ignore
    3595           0 : }
    3596             : 
    3597           0 : void SdXMLFrameShapeContext::EndElement()
    3598             : {
    3599             :     // solve if multiple image child contexts were imported
    3600           0 :     SvXMLImportContextRef const pSelectedContext(solveMultipleImages());
    3601             :     const SdXMLGraphicObjectShapeContext* pShapeContext(
    3602           0 :         dynamic_cast<const SdXMLGraphicObjectShapeContext*>(&pSelectedContext));
    3603           0 :     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           0 :         const uno::Reference< uno::XInterface > xShape( pShapeContext->getShape() );
    3609           0 :         GetImport().getInterfaceToIdentifierMapper().registerReferenceAlways( maShapeId, xShape );
    3610             :     }
    3611             : 
    3612           0 :     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           0 :     mxImplContext = 0;
    3668           0 :     SdXMLShapeContext::EndElement();
    3669           0 : }
    3670             : 
    3671           0 : void SdXMLFrameShapeContext::processAttribute( sal_uInt16 nPrefix,
    3672             :         const OUString& rLocalName, const OUString& rValue )
    3673             : {
    3674           0 :     bool bId( false );
    3675             : 
    3676           0 :     switch ( nPrefix )
    3677             :     {
    3678             :         case XML_NAMESPACE_DRAW :
    3679             :         case XML_NAMESPACE_DRAW_EXT :
    3680           0 :             bId = IsXMLToken( rLocalName, XML_ID );
    3681           0 :             break;
    3682             :         case XML_NAMESPACE_NONE :
    3683             :         case XML_NAMESPACE_XML :
    3684           0 :             bId = IsXMLToken( rLocalName, XML_ID );
    3685           0 :             break;
    3686             :     }
    3687             : 
    3688           0 :     if ( bId )
    3689           0 :         SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    3690           0 : }
    3691             : 
    3692           0 : TYPEINIT1( SdXMLCustomShapeContext, SdXMLShapeContext );
    3693             : 
    3694           0 : 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           0 : :   SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
    3702             : {
    3703           0 : }
    3704             : 
    3705           0 : SdXMLCustomShapeContext::~SdXMLCustomShapeContext()
    3706             : {
    3707           0 : }
    3708             : 
    3709             : // this is called from the parent group for each unparsed attribute in the attribute list
    3710           0 : void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    3711             : {
    3712           0 :     if( XML_NAMESPACE_DRAW == nPrefix )
    3713             :     {
    3714           0 :         if( IsXMLToken( rLocalName, XML_ENGINE ) )
    3715             :         {
    3716           0 :             maCustomShapeEngine = rValue;
    3717           0 :             return;
    3718             :         }
    3719           0 :         if ( IsXMLToken( rLocalName, XML_DATA ) )
    3720             :         {
    3721           0 :             maCustomShapeData = rValue;
    3722           0 :             return;
    3723             :         }
    3724             :     }
    3725           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    3726             : }
    3727             : 
    3728           0 : void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
    3729             : {
    3730             :     // create rectangle shape
    3731           0 :     AddShape("com.sun.star.drawing.CustomShape");
    3732           0 :     if ( mxShape.is() )
    3733             :     {
    3734             :         // Add, set Style and properties from base shape
    3735           0 :         SetStyle();
    3736           0 :         SetLayer();
    3737             : 
    3738             :         // set pos, size, shear and rotate
    3739           0 :         SetTransformation();
    3740             : 
    3741             :         try
    3742             :         {
    3743           0 :             uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
    3744           0 :             if( xPropSet.is() )
    3745             :             {
    3746           0 :                 if ( !maCustomShapeEngine.isEmpty() )
    3747             :                 {
    3748           0 :                     uno::Any aAny;
    3749           0 :                     aAny <<= maCustomShapeEngine;
    3750           0 :                     xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), aAny );
    3751             :                 }
    3752           0 :                 if ( !maCustomShapeData.isEmpty() )
    3753             :                 {
    3754           0 :                     uno::Any aAny;
    3755           0 :                     aAny <<= maCustomShapeData;
    3756           0 :                     xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), aAny );
    3757             :                 }
    3758           0 :             }
    3759             :         }
    3760           0 :         catch(const uno::Exception&)
    3761             :         {
    3762             :             OSL_FAIL( "could not set enhanced customshape geometry" );
    3763             :         }
    3764           0 :         SdXMLShapeContext::StartElement(xAttrList);
    3765             :     }
    3766           0 : }
    3767             : 
    3768           0 : 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           0 :     if(!maUsedTransformation.isIdentity())
    3776             :     {
    3777           0 :         basegfx::B2DVector aScale, aTranslate;
    3778             :         double fRotate, fShearX;
    3779             : 
    3780           0 :         maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
    3781             : 
    3782           0 :         bool bFlippedX(aScale.getX() < 0.0);
    3783           0 :         bool bFlippedY(aScale.getY() < 0.0);
    3784             : 
    3785           0 :         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           0 :         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           0 :         }
    3810             :     }
    3811             : 
    3812           0 :     if ( !maCustomShapeGeometry.empty() )
    3813             :     {
    3814           0 :         const OUString sCustomShapeGeometry    (  "CustomShapeGeometry"  );
    3815             : 
    3816             :         // converting the vector to a sequence
    3817           0 :         uno::Sequence< beans::PropertyValue > aSeq( maCustomShapeGeometry.size() );
    3818           0 :         beans::PropertyValue* pValues = aSeq.getArray();
    3819           0 :         std::vector< beans::PropertyValue >::const_iterator aIter( maCustomShapeGeometry.begin() );
    3820           0 :         std::vector< beans::PropertyValue >::const_iterator aEnd( maCustomShapeGeometry.end() );
    3821           0 :         while ( aIter != aEnd )
    3822           0 :             *pValues++ = *aIter++;
    3823             : 
    3824             :         try
    3825             :         {
    3826           0 :             uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
    3827           0 :             if( xPropSet.is() )
    3828             :             {
    3829           0 :                 uno::Any aAny;
    3830           0 :                 aAny <<= aSeq;
    3831           0 :                 xPropSet->setPropertyValue( sCustomShapeGeometry, aAny );
    3832           0 :             }
    3833             :         }
    3834           0 :         catch(const uno::Exception&)
    3835             :         {
    3836             :             OSL_FAIL( "could not set enhanced customshape geometry" );
    3837             :         }
    3838             : 
    3839           0 :         sal_Int32 nUPD( 0 );
    3840           0 :         sal_Int32 nBuild( 0 );
    3841           0 :         GetImport().getBuildIds( nUPD, nBuild );
    3842           0 :         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           0 :         }
    3851             :     }
    3852             : 
    3853           0 :     SdXMLShapeContext::EndElement();
    3854           0 : }
    3855             : 
    3856           0 : SvXMLImportContext* SdXMLCustomShapeContext::CreateChildContext(
    3857             :     sal_uInt16 nPrefix, const OUString& rLocalName,
    3858             :     const uno::Reference<xml::sax::XAttributeList>& xAttrList )
    3859             : {
    3860           0 :     SvXMLImportContext* pContext = NULL;
    3861           0 :     if ( XML_NAMESPACE_DRAW == nPrefix )
    3862             :     {
    3863           0 :         if ( IsXMLToken( rLocalName, XML_ENHANCED_GEOMETRY ) )
    3864             :         {
    3865           0 :             uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY );
    3866           0 :             if ( xPropSet.is() )
    3867           0 :                 pContext = new XMLEnhancedCustomShapeContext( GetImport(), mxShape, nPrefix, rLocalName, maCustomShapeGeometry );
    3868             :         }
    3869             :     }
    3870             :     // delegate to parent class if no context could be created
    3871           0 :     if ( NULL == pContext )
    3872             :         pContext = SdXMLShapeContext::CreateChildContext( nPrefix, rLocalName,
    3873           0 :                                                          xAttrList);
    3874           0 :     return pContext;
    3875             : }
    3876             : 
    3877           0 : TYPEINIT1( SdXMLTableShapeContext, SdXMLShapeContext );
    3878             : 
    3879           0 : 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           0 : : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, sal_False )
    3881             : {
    3882           0 :     memset( &maTemplateStylesUsed, 0, sizeof( maTemplateStylesUsed ) );
    3883           0 : }
    3884             : 
    3885           0 : SdXMLTableShapeContext::~SdXMLTableShapeContext()
    3886             : {
    3887           0 : }
    3888             : 
    3889           0 : void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
    3890             : {
    3891           0 :     OUString service("com.sun.star.drawing.TableShape");
    3892             : 
    3893           0 :     sal_Bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
    3894           0 :     if( bIsPresShape )
    3895             :     {
    3896           0 :         if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) )
    3897             :         {
    3898           0 :             service = "com.sun.star.presentation.TableShape";
    3899             :         }
    3900             :     }
    3901             : 
    3902           0 :     AddShape(service);
    3903             : 
    3904           0 :     if( mxShape.is() )
    3905             :     {
    3906           0 :         SetLayer();
    3907             : 
    3908           0 :         uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
    3909             : 
    3910           0 :         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           0 :         SetStyle();
    3927             : 
    3928           0 :         if( xProps.is() )
    3929             :         {
    3930           0 :             if( !msTemplateStyleName.isEmpty() ) try
    3931             :             {
    3932           0 :                 Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW );
    3933           0 :                 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
    3934           0 :                 const OUString sFamilyName( "table"  );
    3935           0 :                 Reference< XNameAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
    3936           0 :                 Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW );
    3937           0 :                 xProps->setPropertyValue("TableTemplate", Any( xTableStyle ) );
    3938             :             }
    3939           0 :             catch(const Exception&)
    3940             :             {
    3941             :                 OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
    3942             :             }
    3943             : 
    3944           0 :             const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
    3945           0 :             for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ )
    3946             :             {
    3947             :                 try
    3948             :                 {
    3949           0 :                     const OUString sAPIPropertyName( pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US );
    3950           0 :                     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           0 :         GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
    3960             : 
    3961           0 :         const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
    3962           0 :         if( xTableImport.is() && xProps.is() )
    3963             :         {
    3964             :             uno::Reference< table::XColumnRowRange > xColumnRowRange(
    3965           0 :                 xProps->getPropertyValue("Model"), uno::UNO_QUERY );
    3966             : 
    3967           0 :             if( xColumnRowRange.is() )
    3968           0 :                 mxTableImportContext = xTableImport->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange );
    3969             : 
    3970           0 :             if( mxTableImportContext.Is() )
    3971           0 :                 mxTableImportContext->StartElement( xAttrList );
    3972           0 :         }
    3973           0 :     }
    3974           0 : }
    3975             : 
    3976           0 : void SdXMLTableShapeContext::EndElement()
    3977             : {
    3978           0 :     if( mxTableImportContext.Is() )
    3979           0 :         mxTableImportContext->EndElement();
    3980             : 
    3981           0 :     SdXMLShapeContext::EndElement();
    3982             : 
    3983           0 :     if( mxShape.is() )
    3984             :     {
    3985             :         // set pos, size, shear and rotate
    3986           0 :         SetTransformation();
    3987             :     }
    3988           0 : }
    3989             : 
    3990             : // this is called from the parent group for each unparsed attribute in the attribute list
    3991           0 : void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
    3992             : {
    3993           0 :     if( nPrefix == XML_NAMESPACE_TABLE )
    3994             :     {
    3995           0 :         if( IsXMLToken( rLocalName, XML_TEMPLATE_NAME ) )
    3996             :         {
    3997           0 :             msTemplateStyleName = rValue;
    3998             :         }
    3999             :         else
    4000             :         {
    4001           0 :             int i = 0;
    4002           0 :             const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
    4003           0 :             while( pEntry->msApiName && (i < 6) )
    4004             :             {
    4005           0 :                 if( IsXMLToken( rLocalName, pEntry->meXMLName ) )
    4006             :                 {
    4007           0 :                     if( IsXMLToken( rValue, XML_TRUE ) )
    4008           0 :                         maTemplateStylesUsed[i] = sal_True;
    4009           0 :                     break;
    4010             :                 }
    4011           0 :                 pEntry++;
    4012           0 :                 i++;
    4013             :             }
    4014             :         }
    4015             :     }
    4016           0 :     SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
    4017           0 : }
    4018             : 
    4019           0 : SvXMLImportContext* SdXMLTableShapeContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList )
    4020             : {
    4021           0 :     if( mxTableImportContext.Is() && (nPrefix == XML_NAMESPACE_TABLE) )
    4022           0 :         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