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

Generated by: LCOV version 1.10