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

Generated by: LCOV version 1.11