LCOV - code coverage report
Current view: top level - xmloff/source/draw - ximpshap.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1342 1899 70.7 %
Date: 2014-11-03 Functions: 127 249 51.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10