LCOV - code coverage report
Current view: top level - xmloff/source/draw - shapeimport.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 407 0.0 %
Date: 2014-04-14 Functions: 0 49 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/debug.hxx>
      21             : 
      22             : #include <com/sun/star/text/PositionLayoutDir.hpp>
      23             : #include <com/sun/star/chart/XChartDocument.hpp>
      24             : 
      25             : #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
      26             : 
      27             : #include <list>
      28             : 
      29             : #include <xmloff/shapeimport.hxx>
      30             : #include <xmloff/xmltkmap.hxx>
      31             : #include <xmloff/xmlnmspe.hxx>
      32             : #include <xmloff/xmltoken.hxx>
      33             : #include "ximpstyl.hxx"
      34             : #include "ximpshap.hxx"
      35             : #include "sdpropls.hxx"
      36             : #include <xmloff/xmlprmap.hxx>
      37             : #include "ximp3dscene.hxx"
      38             : #include "ximp3dobject.hxx"
      39             : #include "ximpgrp.hxx"
      40             : #include "ximplink.hxx"
      41             : 
      42             : #include <map>
      43             : #include <vector>
      44             : 
      45             : using namespace ::std;
      46             : using namespace ::com::sun::star;
      47             : using namespace ::xmloff::token;
      48             : 
      49             : struct ltint32
      50             : {
      51           0 :   bool operator()(const sal_Int32 p, sal_Int32 q) const
      52             :   {
      53           0 :     return p < q;
      54             :   }
      55             : };
      56             : 
      57             : typedef std::map<sal_Int32,com::sun::star::uno::Reference< com::sun::star::drawing::XShape >,ltint32> IdShapeMap;
      58             : 
      59           0 : struct ConnectionHint
      60             : {
      61             :     com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxConnector;
      62             :     bool      bStart;
      63             :     OUString  aDestShapeId;
      64             :     sal_Int32 nDestGlueId;
      65             : };
      66             : 
      67             : struct XShapeCompareHelper
      68             : {
      69           0 :   bool operator()(com::sun::star::uno::Reference < com::sun::star::drawing::XShape > x1,
      70             :                   com::sun::star::uno::Reference < com::sun::star::drawing::XShape > x2 ) const
      71             :   {
      72           0 :     return x1.get() < x2.get();
      73             :   }
      74             : };
      75             : 
      76             : /** this map store all glue point id mappings for shapes that had user defined glue points. This
      77             :     is needed because on insertion the glue points will get a new and unique id */
      78             : typedef std::map<sal_Int32,sal_Int32,ltint32> GluePointIdMap;
      79             : typedef std::map< com::sun::star::uno::Reference < com::sun::star::drawing::XShape >, GluePointIdMap, XShapeCompareHelper > ShapeGluePointsMap;
      80             : 
      81             : /** this struct is created for each startPage() call and stores information that is needed during
      82             :     import of shapes for one page. Since pages could be nested ( notes pages inside impress ) there
      83             :     is a pointer so one can build up a stack of this structs */
      84           0 : struct XMLShapeImportPageContextImpl
      85             : {
      86             :     ShapeGluePointsMap      maShapeGluePointsMap;
      87             : 
      88             :     uno::Reference < drawing::XShapes > mxShapes;
      89             : 
      90             :     struct XMLShapeImportPageContextImpl* mpNext;
      91             : };
      92             : 
      93             : /** this class is to enable adding members to the XMLShapeImportHelper without getting incompatible */
      94           0 : struct XMLShapeImportHelperImpl
      95             : {
      96             :     // context for sorting shapes
      97             :     ShapeSortContext*           mpSortContext;
      98             : 
      99             :     IdShapeMap                  maShapeIds;
     100             : 
     101             :     std::vector<ConnectionHint> maConnections;
     102             : 
     103             :     // #88546# possibility to swich progress bar handling on/off
     104             :     bool                        mbHandleProgressBar;
     105             : 
     106             :     // stores the capability of the current model to create presentation shapes
     107             :     bool                        mbIsPresentationShapesSupported;
     108             : };
     109             : 
     110           0 : XMLShapeImportHelper::XMLShapeImportHelper(
     111             :         SvXMLImport& rImporter,
     112             :         const uno::Reference< frame::XModel>& rModel,
     113             :         SvXMLImportPropertyMapper *pExtMapper )
     114             : :   mpPageContext(NULL),
     115             :     mxModel(rModel),
     116             : 
     117             :     mpPropertySetMapper(0L),
     118             :     mpPresPagePropsMapper(0L),
     119             :     mpStylesContext(0L),
     120             :     mpAutoStylesContext(0L),
     121             :     mpGroupShapeElemTokenMap(0L),
     122             :     mpFrameShapeElemTokenMap(0L),
     123             :     mp3DSceneShapeElemTokenMap(0L),
     124             :     mp3DObjectAttrTokenMap(0L),
     125             :     mp3DPolygonBasedAttrTokenMap(0L),
     126             :     mp3DCubeObjectAttrTokenMap(0L),
     127             :     mp3DSphereObjectAttrTokenMap(0L),
     128             :     mp3DSceneShapeAttrTokenMap(0L),
     129             :     mp3DLightAttrTokenMap(0L),
     130             :     mpPathShapeAttrTokenMap(0L),
     131             :     mpPolygonShapeAttrTokenMap(0L),
     132             :     msStartShape("StartShape"),
     133             :     msEndShape("EndShape"),
     134             :     msStartGluePointIndex("StartGluePointIndex"),
     135             :     msEndGluePointIndex("EndGluePointIndex"),
     136             : 
     137           0 :     mrImporter( rImporter )
     138             : {
     139           0 :     mpImpl = new XMLShapeImportHelperImpl();
     140           0 :     mpImpl->mpSortContext = 0;
     141             : 
     142             :     // #88546# init to sal_False
     143           0 :     mpImpl->mbHandleProgressBar = false;
     144             : 
     145           0 :     mpSdPropHdlFactory = new XMLSdPropHdlFactory( rModel, rImporter );
     146             : 
     147             :     // set lock to avoid deletion
     148           0 :     mpSdPropHdlFactory->acquire();
     149             : 
     150             :     // construct PropertySetMapper
     151           0 :     UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper(mpSdPropHdlFactory, false);
     152           0 :     mpPropertySetMapper = new SvXMLImportPropertyMapper( xMapper, rImporter );
     153             :     // set lock to avoid deletion
     154           0 :     mpPropertySetMapper->acquire();
     155             : 
     156           0 :     if( pExtMapper )
     157             :     {
     158           0 :         UniReference < SvXMLImportPropertyMapper > xExtMapper( pExtMapper );
     159           0 :         mpPropertySetMapper->ChainImportMapper( xExtMapper );
     160             :     }
     161             : 
     162             :     // chain text attributes
     163           0 :     mpPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(rImporter));
     164           0 :     mpPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaDefaultExtPropMapper(rImporter));
     165             : 
     166             :     // construct PresPagePropsMapper
     167           0 :     xMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLSDPresPageProps, mpSdPropHdlFactory, false);
     168           0 :     mpPresPagePropsMapper = new SvXMLImportPropertyMapper( xMapper, rImporter );
     169           0 :     if(mpPresPagePropsMapper)
     170             :     {
     171             :         // set lock to avoid deletion
     172           0 :         mpPresPagePropsMapper->acquire();
     173             :     }
     174             : 
     175           0 :     uno::Reference< lang::XServiceInfo > xInfo( rImporter.GetModel(), uno::UNO_QUERY );
     176           0 :     const OUString aSName( "com.sun.star.presentation.PresentationDocument" );
     177           0 :     mpImpl->mbIsPresentationShapesSupported = xInfo.is() && xInfo->supportsService( aSName );
     178           0 : }
     179             : 
     180           0 : XMLShapeImportHelper::~XMLShapeImportHelper()
     181             : {
     182             :     DBG_ASSERT( mpImpl->maConnections.empty(), "XMLShapeImportHelper::restoreConnections() was not called!" );
     183             : 
     184             :     // cleanup factory, decrease refcount. Should lead to destruction.
     185           0 :     if(mpSdPropHdlFactory)
     186             :     {
     187           0 :         mpSdPropHdlFactory->release();
     188           0 :         mpSdPropHdlFactory = 0L;
     189             :     }
     190             : 
     191             :     // cleanup mapper, decrease refcount. Should lead to destruction.
     192           0 :     if(mpPropertySetMapper)
     193             :     {
     194           0 :         mpPropertySetMapper->release();
     195           0 :         mpPropertySetMapper = 0L;
     196             :     }
     197             : 
     198             :     // cleanup presPage mapper, decrease refcount. Should lead to destruction.
     199           0 :     if(mpPresPagePropsMapper)
     200             :     {
     201           0 :         mpPresPagePropsMapper->release();
     202           0 :         mpPresPagePropsMapper = 0L;
     203             :     }
     204             : 
     205           0 :     if(mpGroupShapeElemTokenMap) delete mpGroupShapeElemTokenMap;
     206           0 :     if(mpFrameShapeElemTokenMap) delete mpFrameShapeElemTokenMap;
     207             : 
     208           0 :     if(mpPolygonShapeAttrTokenMap) delete mpPolygonShapeAttrTokenMap;
     209           0 :     if(mpPathShapeAttrTokenMap) delete mpPathShapeAttrTokenMap;
     210           0 :     if(mp3DSceneShapeElemTokenMap) delete mp3DSceneShapeElemTokenMap;
     211           0 :     if(mp3DObjectAttrTokenMap) delete mp3DObjectAttrTokenMap;
     212           0 :     if(mp3DPolygonBasedAttrTokenMap) delete mp3DPolygonBasedAttrTokenMap;
     213           0 :     if(mp3DCubeObjectAttrTokenMap) delete mp3DCubeObjectAttrTokenMap;
     214           0 :     if(mp3DSphereObjectAttrTokenMap) delete mp3DSphereObjectAttrTokenMap;
     215           0 :     if(mp3DSceneShapeAttrTokenMap) delete mp3DSceneShapeAttrTokenMap;
     216           0 :     if(mp3DLightAttrTokenMap) delete mp3DLightAttrTokenMap;
     217             : 
     218             :     // Styles or AutoStyles context?
     219           0 :     if(mpStylesContext)
     220             :     {
     221           0 :         mpStylesContext->Clear();
     222           0 :         mpStylesContext->ReleaseRef();
     223             :     }
     224             : 
     225           0 :     if(mpAutoStylesContext)
     226             :     {
     227           0 :         mpAutoStylesContext->Clear();
     228           0 :         mpAutoStylesContext->ReleaseRef();
     229             :     }
     230             : 
     231           0 :     delete mpImpl;
     232           0 : }
     233             : 
     234           0 : const SvXMLTokenMap& XMLShapeImportHelper::GetGroupShapeElemTokenMap()
     235             : {
     236           0 :     if(!mpGroupShapeElemTokenMap)
     237             :     {
     238             :         static const SvXMLTokenMapEntry aGroupShapeElemTokenMap[] =
     239             : {
     240             :     { XML_NAMESPACE_DRAW,           XML_G,              XML_TOK_GROUP_GROUP         },
     241             :     { XML_NAMESPACE_DRAW,           XML_RECT,           XML_TOK_GROUP_RECT          },
     242             :     { XML_NAMESPACE_DRAW,           XML_LINE,           XML_TOK_GROUP_LINE          },
     243             :     { XML_NAMESPACE_DRAW,           XML_CIRCLE,         XML_TOK_GROUP_CIRCLE        },
     244             :     { XML_NAMESPACE_DRAW,           XML_ELLIPSE,        XML_TOK_GROUP_ELLIPSE       },
     245             :     { XML_NAMESPACE_DRAW,           XML_POLYGON,        XML_TOK_GROUP_POLYGON       },
     246             :     { XML_NAMESPACE_DRAW,           XML_POLYLINE,       XML_TOK_GROUP_POLYLINE      },
     247             :     { XML_NAMESPACE_DRAW,           XML_PATH,           XML_TOK_GROUP_PATH          },
     248             : 
     249             :     { XML_NAMESPACE_DRAW,           XML_CONTROL,        XML_TOK_GROUP_CONTROL       },
     250             :     { XML_NAMESPACE_DRAW,           XML_CONNECTOR,      XML_TOK_GROUP_CONNECTOR     },
     251             :     { XML_NAMESPACE_DRAW,           XML_MEASURE,        XML_TOK_GROUP_MEASURE       },
     252             :     { XML_NAMESPACE_DRAW,           XML_PAGE_THUMBNAIL, XML_TOK_GROUP_PAGE          },
     253             :     { XML_NAMESPACE_DRAW,           XML_CAPTION,        XML_TOK_GROUP_CAPTION       },
     254             : 
     255             :     { XML_NAMESPACE_CHART,          XML_CHART,          XML_TOK_GROUP_CHART         },
     256             :     { XML_NAMESPACE_DR3D,           XML_SCENE,          XML_TOK_GROUP_3DSCENE       },
     257             : 
     258             :     { XML_NAMESPACE_DRAW,           XML_FRAME,          XML_TOK_GROUP_FRAME         },
     259             :     { XML_NAMESPACE_DRAW,           XML_CUSTOM_SHAPE,   XML_TOK_GROUP_CUSTOM_SHAPE  },
     260             : 
     261             :     { XML_NAMESPACE_DRAW,           XML_CUSTOM_SHAPE,   XML_TOK_GROUP_CUSTOM_SHAPE  },
     262             :     { XML_NAMESPACE_OFFICE,         XML_ANNOTATION,     XML_TOK_GROUP_ANNOTATION    },
     263             :     { XML_NAMESPACE_DRAW,           XML_A,              XML_TOK_GROUP_A             },
     264             : 
     265             :     XML_TOKEN_MAP_END
     266             : };
     267             : 
     268           0 :         mpGroupShapeElemTokenMap = new SvXMLTokenMap(aGroupShapeElemTokenMap);
     269             :     } // if(!mpGroupShapeElemTokenMap)
     270             : 
     271           0 :     return *mpGroupShapeElemTokenMap;
     272             : }
     273             : 
     274           0 : const SvXMLTokenMap& XMLShapeImportHelper::GetFrameShapeElemTokenMap()
     275             : {
     276           0 :     if(!mpFrameShapeElemTokenMap)
     277             :     {
     278             :         static const SvXMLTokenMapEntry aFrameShapeElemTokenMap[] =
     279             : {
     280             :     { XML_NAMESPACE_DRAW,           XML_TEXT_BOX,       XML_TOK_FRAME_TEXT_BOX      },
     281             :     { XML_NAMESPACE_DRAW,           XML_IMAGE,          XML_TOK_FRAME_IMAGE         },
     282             :     { XML_NAMESPACE_DRAW,           XML_OBJECT,         XML_TOK_FRAME_OBJECT        },
     283             :     { XML_NAMESPACE_DRAW,           XML_OBJECT_OLE,     XML_TOK_FRAME_OBJECT_OLE    },
     284             :     { XML_NAMESPACE_DRAW,           XML_PLUGIN,         XML_TOK_FRAME_PLUGIN        },
     285             :     { XML_NAMESPACE_DRAW,           XML_FLOATING_FRAME, XML_TOK_FRAME_FLOATING_FRAME},
     286             :     { XML_NAMESPACE_DRAW,           XML_APPLET,         XML_TOK_FRAME_APPLET        },
     287             :     { XML_NAMESPACE_TABLE,          XML_TABLE,          XML_TOK_FRAME_TABLE         },
     288             :     XML_TOKEN_MAP_END
     289             : };
     290             : 
     291           0 :         mpFrameShapeElemTokenMap = new SvXMLTokenMap(aFrameShapeElemTokenMap);
     292             :     } // if(!mpFrameShapeElemTokenMap)
     293             : 
     294           0 :     return *mpFrameShapeElemTokenMap;
     295             : }
     296             : 
     297           0 : const SvXMLTokenMap& XMLShapeImportHelper::Get3DSceneShapeElemTokenMap()
     298             : {
     299           0 :     if(!mp3DSceneShapeElemTokenMap)
     300             :     {
     301             :         static const SvXMLTokenMapEntry a3DSceneShapeElemTokenMap[] =
     302             : {
     303             :     { XML_NAMESPACE_DR3D,           XML_SCENE,      XML_TOK_3DSCENE_3DSCENE     },
     304             :     { XML_NAMESPACE_DR3D,           XML_CUBE,       XML_TOK_3DSCENE_3DCUBE      },
     305             :     { XML_NAMESPACE_DR3D,           XML_SPHERE,     XML_TOK_3DSCENE_3DSPHERE    },
     306             :     { XML_NAMESPACE_DR3D,           XML_ROTATE,     XML_TOK_3DSCENE_3DLATHE     },
     307             :     { XML_NAMESPACE_DR3D,           XML_EXTRUDE,    XML_TOK_3DSCENE_3DEXTRUDE   },
     308             :     XML_TOKEN_MAP_END
     309             : };
     310             : 
     311           0 :         mp3DSceneShapeElemTokenMap = new SvXMLTokenMap(a3DSceneShapeElemTokenMap);
     312             :     } // if(!mp3DSceneShapeElemTokenMap)
     313             : 
     314           0 :     return *mp3DSceneShapeElemTokenMap;
     315             : }
     316             : 
     317           0 : const SvXMLTokenMap& XMLShapeImportHelper::Get3DObjectAttrTokenMap()
     318             : {
     319           0 :     if(!mp3DObjectAttrTokenMap)
     320             :     {
     321             :         static const SvXMLTokenMapEntry a3DObjectAttrTokenMap[] =
     322             : {
     323             :     { XML_NAMESPACE_DRAW,           XML_STYLE_NAME,         XML_TOK_3DOBJECT_DRAWSTYLE_NAME     },
     324             :     { XML_NAMESPACE_DR3D,           XML_TRANSFORM,          XML_TOK_3DOBJECT_TRANSFORM          },
     325             :     XML_TOKEN_MAP_END
     326             : };
     327             : 
     328           0 :         mp3DObjectAttrTokenMap = new SvXMLTokenMap(a3DObjectAttrTokenMap);
     329             :     } // if(!mp3DObjectAttrTokenMap)
     330             : 
     331           0 :     return *mp3DObjectAttrTokenMap;
     332             : }
     333             : 
     334           0 : const SvXMLTokenMap& XMLShapeImportHelper::Get3DPolygonBasedAttrTokenMap()
     335             : {
     336           0 :     if(!mp3DPolygonBasedAttrTokenMap)
     337             :     {
     338             :         static const SvXMLTokenMapEntry a3DPolygonBasedAttrTokenMap[] =
     339             : {
     340             :     { XML_NAMESPACE_SVG,            XML_VIEWBOX,            XML_TOK_3DPOLYGONBASED_VIEWBOX      },
     341             :     { XML_NAMESPACE_SVG,            XML_D,                  XML_TOK_3DPOLYGONBASED_D            },
     342             :     XML_TOKEN_MAP_END
     343             : };
     344             : 
     345           0 :         mp3DPolygonBasedAttrTokenMap = new SvXMLTokenMap(a3DPolygonBasedAttrTokenMap);
     346             :     } // if(!mp3DPolygonBasedAttrTokenMap)
     347             : 
     348           0 :     return *mp3DPolygonBasedAttrTokenMap;
     349             : }
     350             : 
     351           0 : const SvXMLTokenMap& XMLShapeImportHelper::Get3DCubeObjectAttrTokenMap()
     352             : {
     353           0 :     if(!mp3DCubeObjectAttrTokenMap)
     354             :     {
     355             :         static const SvXMLTokenMapEntry a3DCubeObjectAttrTokenMap[] =
     356             : {
     357             :     { XML_NAMESPACE_DR3D,           XML_MIN_EDGE,           XML_TOK_3DCUBEOBJ_MINEDGE   },
     358             :     { XML_NAMESPACE_DR3D,           XML_MAX_EDGE,           XML_TOK_3DCUBEOBJ_MAXEDGE   },
     359             :     XML_TOKEN_MAP_END
     360             : };
     361             : 
     362           0 :         mp3DCubeObjectAttrTokenMap = new SvXMLTokenMap(a3DCubeObjectAttrTokenMap);
     363             :     } // if(!mp3DCubeObjectAttrTokenMap)
     364             : 
     365           0 :     return *mp3DCubeObjectAttrTokenMap;
     366             : }
     367             : 
     368           0 : const SvXMLTokenMap& XMLShapeImportHelper::Get3DSphereObjectAttrTokenMap()
     369             : {
     370           0 :     if(!mp3DSphereObjectAttrTokenMap)
     371             :     {
     372             :         static const SvXMLTokenMapEntry a3DSphereObjectAttrTokenMap[] =
     373             : {
     374             :     { XML_NAMESPACE_DR3D,           XML_CENTER,             XML_TOK_3DSPHEREOBJ_CENTER  },
     375             :     { XML_NAMESPACE_DR3D,           XML_SIZE,               XML_TOK_3DSPHEREOBJ_SIZE    },
     376             :     XML_TOKEN_MAP_END
     377             : };
     378             : 
     379           0 :         mp3DSphereObjectAttrTokenMap = new SvXMLTokenMap(a3DSphereObjectAttrTokenMap);
     380             :     } // if(!mp3DSphereObjectAttrTokenMap)
     381             : 
     382           0 :     return *mp3DSphereObjectAttrTokenMap;
     383             : }
     384             : 
     385           0 : const SvXMLTokenMap& XMLShapeImportHelper::Get3DLightAttrTokenMap()
     386             : {
     387           0 :     if(!mp3DLightAttrTokenMap)
     388             :     {
     389             :         static const SvXMLTokenMapEntry a3DLightAttrTokenMap[] =
     390             : {
     391             :     { XML_NAMESPACE_DR3D,   XML_DIFFUSE_COLOR,      XML_TOK_3DLIGHT_DIFFUSE_COLOR       },
     392             :     { XML_NAMESPACE_DR3D,   XML_DIRECTION,          XML_TOK_3DLIGHT_DIRECTION           },
     393             :     { XML_NAMESPACE_DR3D,   XML_ENABLED,            XML_TOK_3DLIGHT_ENABLED             },
     394             :     { XML_NAMESPACE_DR3D,   XML_SPECULAR,           XML_TOK_3DLIGHT_SPECULAR            },
     395             :     XML_TOKEN_MAP_END
     396             : };
     397             : 
     398           0 :         mp3DLightAttrTokenMap = new SvXMLTokenMap(a3DLightAttrTokenMap);
     399             :     } // if(!mp3DLightAttrTokenMap)
     400             : 
     401           0 :     return *mp3DLightAttrTokenMap;
     402             : }
     403             : 
     404           0 : SvXMLShapeContext* XMLShapeImportHelper::Create3DSceneChildContext(
     405             :     SvXMLImport& rImport,
     406             :     sal_uInt16 p_nPrefix,
     407             :     const OUString& rLocalName,
     408             :     const uno::Reference< xml::sax::XAttributeList>& xAttrList,
     409             :     uno::Reference< drawing::XShapes >& rShapes)
     410             : {
     411           0 :     SdXMLShapeContext *pContext = 0L;
     412             : 
     413           0 :     if(rShapes.is())
     414             :     {
     415           0 :         const SvXMLTokenMap& rTokenMap = Get3DSceneShapeElemTokenMap();
     416           0 :         switch(rTokenMap.Get(p_nPrefix, rLocalName))
     417             :         {
     418             :             case XML_TOK_3DSCENE_3DSCENE:
     419             :             {
     420             :                 // dr3d:3dscene inside dr3d:3dscene context
     421           0 :                 pContext = new SdXML3DSceneShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
     422           0 :                 break;
     423             :             }
     424             :             case XML_TOK_3DSCENE_3DCUBE:
     425             :             {
     426             :                 // dr3d:3dcube inside dr3d:3dscene context
     427           0 :                 pContext = new SdXML3DCubeObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
     428           0 :                 break;
     429             :             }
     430             :             case XML_TOK_3DSCENE_3DSPHERE:
     431             :             {
     432             :                 // dr3d:3dsphere inside dr3d:3dscene context
     433           0 :                 pContext = new SdXML3DSphereObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
     434           0 :                 break;
     435             :             }
     436             :             case XML_TOK_3DSCENE_3DLATHE:
     437             :             {
     438             :                 // dr3d:3dlathe inside dr3d:3dscene context
     439           0 :                 pContext = new SdXML3DLatheObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
     440           0 :                 break;
     441             :             }
     442             :             case XML_TOK_3DSCENE_3DEXTRUDE:
     443             :             {
     444             :                 // dr3d:3dextrude inside dr3d:3dscene context
     445           0 :                 pContext = new SdXML3DExtrudeObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
     446           0 :                 break;
     447             :             }
     448             :         }
     449             :     }
     450             : 
     451             :     // now parse the attribute list and call the child context for each unknown attribute
     452           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     453           0 :     for(sal_Int16 a(0); a < nAttrCount; a++)
     454             :     {
     455           0 :         const OUString& rAttrName = xAttrList->getNameByIndex(a);
     456           0 :         OUString aLocalName;
     457           0 :         sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
     458           0 :         const OUString aValue( xAttrList->getValueByIndex(a) );
     459             : 
     460           0 :         pContext->processAttribute( nPrefix, aLocalName, aValue );
     461           0 :     }
     462             : 
     463           0 :     return pContext;
     464             : }
     465             : 
     466           0 : void XMLShapeImportHelper::SetStylesContext(SvXMLStylesContext* pNew)
     467             : {
     468           0 :     mpStylesContext = pNew;
     469           0 :     if (mpStylesContext)
     470           0 :         mpStylesContext->AddRef();
     471           0 : }
     472             : 
     473           0 : void XMLShapeImportHelper::SetAutoStylesContext(SvXMLStylesContext* pNew)
     474             : {
     475           0 :     mpAutoStylesContext = pNew;
     476           0 :     if (mpAutoStylesContext)
     477           0 :         mpAutoStylesContext->AddRef();
     478           0 : }
     479             : 
     480           0 : SvXMLShapeContext* XMLShapeImportHelper::CreateGroupChildContext(
     481             :     SvXMLImport& rImport,
     482             :     sal_uInt16 p_nPrefix,
     483             :     const OUString& rLocalName,
     484             :     const uno::Reference< xml::sax::XAttributeList>& xAttrList,
     485             :     uno::Reference< drawing::XShapes >& rShapes,
     486             :     bool bTemporaryShape)
     487             : {
     488           0 :     SdXMLShapeContext *pContext = 0L;
     489             : 
     490           0 :     const SvXMLTokenMap& rTokenMap = GetGroupShapeElemTokenMap();
     491           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     492             : 
     493           0 :     switch(rTokenMap.Get(p_nPrefix, rLocalName))
     494             :     {
     495             :         case XML_TOK_GROUP_GROUP:
     496             :         {
     497             :             // draw:g inside group context (RECURSIVE)
     498           0 :             pContext = new SdXMLGroupShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape);
     499           0 :             break;
     500             :         }
     501             :         case XML_TOK_GROUP_3DSCENE:
     502             :         {
     503             :             // dr3d:3dscene inside group context
     504           0 :             pContext = new SdXML3DSceneShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape);
     505           0 :             break;
     506             :         }
     507             :         case XML_TOK_GROUP_RECT:
     508             :         {
     509             :             // draw:rect inside group context
     510           0 :             pContext = new SdXMLRectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     511           0 :             break;
     512             :         }
     513             :         case XML_TOK_GROUP_LINE:
     514             :         {
     515             :             // draw:line inside group context
     516           0 :             pContext = new SdXMLLineShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     517           0 :             break;
     518             :         }
     519             :         case XML_TOK_GROUP_CIRCLE:
     520             :         case XML_TOK_GROUP_ELLIPSE:
     521             :         {
     522             :             // draw:circle or draw:ellipse inside group context
     523           0 :             pContext = new SdXMLEllipseShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     524           0 :             break;
     525             :         }
     526             :         case XML_TOK_GROUP_POLYGON:
     527             :         case XML_TOK_GROUP_POLYLINE:
     528             :         {
     529             :             // draw:polygon or draw:polyline inside group context
     530             :             pContext = new SdXMLPolygonShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes,
     531           0 :                 rTokenMap.Get(p_nPrefix, rLocalName) == XML_TOK_GROUP_POLYGON ? sal_True : sal_False, bTemporaryShape );
     532           0 :             break;
     533             :         }
     534             :         case XML_TOK_GROUP_PATH:
     535             :         {
     536             :             // draw:path inside group context
     537           0 :             pContext = new SdXMLPathShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape);
     538           0 :             break;
     539             :         }
     540             :         case XML_TOK_GROUP_FRAME:
     541             :         {
     542             :             // text:text-box inside group context
     543           0 :             pContext = new SdXMLFrameShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     544           0 :             break;
     545             :         }
     546             :         case XML_TOK_GROUP_CONTROL:
     547             :         {
     548             :             // draw:control inside group context
     549           0 :             pContext = new SdXMLControlShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     550           0 :             break;
     551             :         }
     552             :         case XML_TOK_GROUP_CONNECTOR:
     553             :         {
     554             :             // draw:connector inside group context
     555           0 :             pContext = new SdXMLConnectorShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     556           0 :             break;
     557             :         }
     558             :         case XML_TOK_GROUP_MEASURE:
     559             :         {
     560             :             // draw:measure inside group context
     561           0 :             pContext = new SdXMLMeasureShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     562           0 :             break;
     563             :         }
     564             :         case XML_TOK_GROUP_PAGE:
     565             :         {
     566             :             // draw:page inside group context
     567           0 :             pContext = new SdXMLPageShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     568           0 :             break;
     569             :         }
     570             :         case XML_TOK_GROUP_CAPTION:
     571             :         case XML_TOK_GROUP_ANNOTATION:
     572             :         {
     573             :             // draw:caption inside group context
     574           0 :             pContext = new SdXMLCaptionShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     575           0 :             break;
     576             :         }
     577             :         case XML_TOK_GROUP_CHART:
     578             :         {
     579             :             // chart:chart inside group context
     580           0 :             pContext = new SdXMLChartShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
     581           0 :             break;
     582             :         }
     583             :         case XML_TOK_GROUP_CUSTOM_SHAPE:
     584             :         {
     585             :             // draw:customshape
     586           0 :             pContext = new SdXMLCustomShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
     587           0 :             break;
     588             :         }
     589             :          case XML_TOK_GROUP_A:
     590             :          {
     591           0 :              return new SdXMLShapeLinkContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes );
     592             :          }
     593             :         // add other shapes here...
     594             :         default:
     595           0 :             return new SvXMLShapeContext( rImport, p_nPrefix, rLocalName, bTemporaryShape );
     596             :     }
     597             : 
     598             :     // now parse the attribute list and call the child context for each unknown attribute
     599           0 :     for(sal_Int16 a(0); a < nAttrCount; a++)
     600             :     {
     601           0 :         const OUString& rAttrName = xAttrList->getNameByIndex(a);
     602           0 :         OUString aLocalName;
     603           0 :         sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
     604           0 :         const OUString aValue( xAttrList->getValueByIndex(a) );
     605             : 
     606           0 :         pContext->processAttribute( nPrefix, aLocalName, aValue );
     607           0 :     }
     608             : 
     609           0 :     return pContext;
     610             : }
     611             : 
     612             : // This method is called from SdXMLFrameContext to create children of drawe:frame
     613           0 : SvXMLShapeContext* XMLShapeImportHelper::CreateFrameChildContext(
     614             :     SvXMLImport& rImport,
     615             :     sal_uInt16 p_nPrefix,
     616             :     const OUString& rLocalName,
     617             :     const uno::Reference< xml::sax::XAttributeList>& rAttrList,
     618             :     uno::Reference< drawing::XShapes >& rShapes,
     619             :     const uno::Reference< xml::sax::XAttributeList>& rFrameAttrList)
     620             : {
     621           0 :     SdXMLShapeContext *pContext = 0L;
     622             : 
     623           0 :     const SvXMLTokenMap& rTokenMap = GetFrameShapeElemTokenMap();
     624             : 
     625           0 :     SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList );
     626           0 :     if( rFrameAttrList.is() )
     627           0 :         pAttrList->AppendAttributeList( rFrameAttrList );
     628           0 :     uno::Reference < xml::sax::XAttributeList > xAttrList = pAttrList;
     629             : 
     630           0 :     switch(rTokenMap.Get(p_nPrefix, rLocalName))
     631             :     {
     632             :         case XML_TOK_FRAME_TEXT_BOX:
     633             :         {
     634             :             // text:text-box inside group context
     635           0 :             pContext = new SdXMLTextBoxShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
     636           0 :             break;
     637             :         }
     638             :         case XML_TOK_FRAME_IMAGE:
     639             :         {
     640             :             // office:image inside group context
     641           0 :             pContext = new SdXMLGraphicObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
     642           0 :             break;
     643             :         }
     644             :         case XML_TOK_FRAME_OBJECT:
     645             :         case XML_TOK_FRAME_OBJECT_OLE:
     646             :         {
     647             :             // draw:object or draw:object_ole
     648           0 :             pContext = new SdXMLObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
     649           0 :             break;
     650             :         }
     651             :         case XML_TOK_FRAME_TABLE:
     652             :         {
     653             :             // draw:object or draw:object_ole
     654           0 :             if( rImport.IsTableShapeSupported() )
     655           0 :                 pContext = new SdXMLTableShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes );
     656           0 :             break;
     657             : 
     658             :         }
     659             :         case XML_TOK_FRAME_PLUGIN:
     660             :         {
     661             :             // draw:plugin
     662           0 :             pContext = new SdXMLPluginShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
     663           0 :             break;
     664             :         }
     665             :         case XML_TOK_FRAME_FLOATING_FRAME:
     666             :         {
     667             :             // draw:floating-frame
     668           0 :             pContext = new SdXMLFloatingFrameShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
     669           0 :             break;
     670             :         }
     671             :         case XML_TOK_FRAME_APPLET:
     672             :         {
     673             :             // draw:applet
     674           0 :             pContext = new SdXMLAppletShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
     675           0 :             break;
     676             :         }
     677             :         // add other shapes here...
     678             :         default:
     679           0 :             break;
     680             :     }
     681             : 
     682           0 :     if( pContext )
     683             :     {
     684             :         // now parse the attribute list and call the child context for each unknown attribute
     685           0 :         sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
     686           0 :         for(sal_Int16 a(0); a < nAttrCount; a++)
     687             :         {
     688           0 :             const OUString& rAttrName = xAttrList->getNameByIndex(a);
     689           0 :             OUString aLocalName;
     690           0 :             sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
     691           0 :             const OUString aValue( xAttrList->getValueByIndex(a) );
     692             : 
     693           0 :             pContext->processAttribute( nPrefix, aLocalName, aValue );
     694           0 :         }
     695             :     }
     696             : 
     697           0 :     return pContext;
     698             : }
     699             : 
     700           0 : SvXMLImportContext *XMLShapeImportHelper::CreateFrameChildContext(
     701             :     SvXMLImportContext *pThisContext,
     702             :     sal_uInt16 nPrefix,
     703             :     const OUString& rLocalName,
     704             :     const uno::Reference< xml::sax::XAttributeList>& xAttrList )
     705             : {
     706           0 :     SvXMLImportContext * pContext = NULL;
     707             : 
     708           0 :     SdXMLFrameShapeContext *pFrameContext = PTR_CAST( SdXMLFrameShapeContext, pThisContext );
     709           0 :     if( pFrameContext )
     710           0 :         pContext = pFrameContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
     711             : 
     712           0 :     return pContext;
     713             : }
     714             : 
     715             : /** this function is called whenever the implementation classes like to add this new
     716             :     shape to the given XShapes.
     717             : */
     718           0 : void XMLShapeImportHelper::addShape( uno::Reference< drawing::XShape >& rShape,
     719             :                                      const uno::Reference< xml::sax::XAttributeList >&,
     720             :                                      uno::Reference< drawing::XShapes >& rShapes)
     721             : {
     722           0 :     if( rShape.is() && rShapes.is() )
     723             :     {
     724             :         // add new shape to parent
     725           0 :         rShapes->add( rShape );
     726             :     }
     727           0 : }
     728             : 
     729             : /** this function is called whenever the implementation classes have finished importing
     730             :     a shape to the given XShapes. The shape is already inserted into its XShapes and
     731             :     all properties and styles are set.
     732             : */
     733           0 : void XMLShapeImportHelper::finishShape(
     734             :         com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape,
     735             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >&,
     736             :         com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >&)
     737             : {
     738             :     /* Set property <PositionLayoutDir>
     739             :        to <PositionInHoriL2R>, if it exists and the import states that
     740             :        the shape positioning attributes are in horizontal left-to-right
     741             :        layout. This is the case for the OpenOffice.org file format.
     742             :        This setting is done for Writer documents, because the property
     743             :        only exists at service com::sun::star::text::Shape - the Writer
     744             :        UNO service for shapes.
     745             :        The value indicates that the positioning attributes are given
     746             :        in horizontal left-to-right layout. The property is evaluated
     747             :        during the first positioning of the shape in order to convert
     748             :        the shape position given in the OpenOffice.org file format to
     749             :        the one for the OASIS Open Office file format. (#i28749#, #i36248#)
     750             :     */
     751           0 :     uno::Reference< beans::XPropertySet > xPropSet(rShape, uno::UNO_QUERY);
     752           0 :     if ( xPropSet.is() )
     753             :     {
     754           0 :         if ( mrImporter.IsShapePositionInHoriL2R() &&
     755           0 :              xPropSet->getPropertySetInfo()->hasPropertyByName(
     756           0 :                 OUString("PositionLayoutDir")) )
     757             :         {
     758           0 :             uno::Any aPosLayoutDir;
     759           0 :             aPosLayoutDir <<= text::PositionLayoutDir::PositionInHoriL2R;
     760           0 :             xPropSet->setPropertyValue(
     761             :                 OUString("PositionLayoutDir"),
     762           0 :                 aPosLayoutDir );
     763             :         }
     764           0 :     }
     765           0 : }
     766             : 
     767             : // helper functions for z-order sorting
     768             : struct ZOrderHint
     769             : {
     770             :     sal_Int32 nIs;
     771             :     sal_Int32 nShould;
     772             : 
     773           0 :     bool operator<(const ZOrderHint& rComp) const { return nShould < rComp.nShould; }
     774             : };
     775             : 
     776           0 : class ShapeSortContext
     777             : {
     778             : public:
     779             :     uno::Reference< drawing::XShapes > mxShapes;
     780             :     list<ZOrderHint>              maZOrderList;
     781             :     list<ZOrderHint>              maUnsortedList;
     782             : 
     783             :     sal_Int32                     mnCurrentZ;
     784             :     ShapeSortContext*             mpParentContext;
     785             :     const OUString                msZOrder;
     786             : 
     787             :     ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext = NULL );
     788             : 
     789             :     void moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos );
     790             : };
     791             : 
     792           0 : ShapeSortContext::ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext )
     793             : :   mxShapes( rShapes ), mnCurrentZ( 0 ), mpParentContext( pParentContext ),
     794           0 :     msZOrder("ZOrder")
     795             : {
     796           0 : }
     797             : 
     798           0 : void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos )
     799             : {
     800           0 :     uno::Any aAny( mxShapes->getByIndex( nSourcePos ) );
     801           0 :     uno::Reference< beans::XPropertySet > xPropSet;
     802           0 :     aAny >>= xPropSet;
     803             : 
     804           0 :     if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( msZOrder ) )
     805             :     {
     806           0 :         aAny <<= nDestPos;
     807           0 :         xPropSet->setPropertyValue( msZOrder, aAny );
     808             : 
     809           0 :         list<ZOrderHint>::iterator aIter = maZOrderList.begin();
     810           0 :         list<ZOrderHint>::iterator aEnd = maZOrderList.end();
     811             : 
     812           0 :         while( aIter != aEnd )
     813             :         {
     814           0 :             if( (*aIter).nIs < nSourcePos )
     815             :             {
     816             :                 DBG_ASSERT( (*aIter).nIs >= nDestPos, "Shape sorting failed" );
     817           0 :                 (*aIter).nIs++;
     818             :             }
     819           0 :             ++aIter;
     820             :         }
     821             : 
     822           0 :         aIter = maUnsortedList.begin();
     823           0 :         aEnd = maUnsortedList.end();
     824             : 
     825           0 :         while( aIter != aEnd )
     826             :         {
     827           0 :             if( (*aIter).nIs < nSourcePos )
     828             :             {
     829             :                 DBG_ASSERT( (*aIter).nIs >= nDestPos, "shape sorting failed" );
     830           0 :                 (*aIter).nIs++;
     831             :             }
     832           0 :             ++aIter;
     833             :         }
     834           0 :     }
     835           0 : }
     836             : 
     837           0 : void XMLShapeImportHelper::pushGroupForSorting( uno::Reference< drawing::XShapes >& rShapes )
     838             : {
     839           0 :     mpImpl->mpSortContext = new ShapeSortContext( rShapes, mpImpl->mpSortContext );
     840           0 : }
     841             : 
     842           0 : void XMLShapeImportHelper::popGroupAndSort()
     843             : {
     844             :     DBG_ASSERT( mpImpl->mpSortContext, "No context to sort!" );
     845           0 :     if( mpImpl->mpSortContext == NULL )
     846           0 :         return;
     847             : 
     848             :     try
     849             :     {
     850           0 :         list<ZOrderHint>& rZList = mpImpl->mpSortContext->maZOrderList;
     851           0 :         list<ZOrderHint>& rUnsortedList = mpImpl->mpSortContext->maUnsortedList;
     852             : 
     853             :         // sort shapes
     854           0 :         if( !rZList.empty() )
     855             :         {
     856             :             // only do something if we have shapes to sort
     857             : 
     858             :             // check if there are more shapes than inserted with ::shapeWithZIndexAdded()
     859             :             // This can happen if there where already shapes on the page before import
     860             :             // Since the writer may delete some of this shapes during import, we need
     861             :             // to do this here and not in our c'tor anymore
     862             : 
     863             :             // check if we have more shapes than we know of
     864           0 :             sal_Int32 nCount = mpImpl->mpSortContext->mxShapes->getCount();
     865             : 
     866           0 :             nCount -= rZList.size();
     867           0 :             nCount -= rUnsortedList.size();
     868             : 
     869           0 :             if( nCount > 0 )
     870             :             {
     871             :                 // first update offsets of added shapes
     872           0 :                 list<ZOrderHint>::iterator aIter( rZList.begin() );
     873           0 :                 while( aIter != rZList.end() )
     874           0 :                     (*aIter++).nIs += nCount;
     875             : 
     876           0 :                 aIter = rUnsortedList.begin();
     877           0 :                 while( aIter != rUnsortedList.end() )
     878           0 :                     (*aIter++).nIs += nCount;
     879             : 
     880             :                 // second add the already existing shapes in the unsorted list
     881             :                 ZOrderHint aNewHint;
     882             : 
     883           0 :                 do
     884             :                 {
     885           0 :                     nCount--;
     886             : 
     887           0 :                     aNewHint.nIs = nCount;
     888           0 :                     aNewHint.nShould = -1;
     889             : 
     890           0 :                     rUnsortedList.insert(rUnsortedList.begin(), aNewHint);
     891             :                 }
     892             :                 while( nCount );
     893             :             }
     894             : 
     895             :             // sort z ordered shapes
     896           0 :             rZList.sort();
     897             : 
     898             :             // this is the current index, all shapes before that
     899             :             // index are finished
     900           0 :             sal_Int32 nIndex = 0;
     901           0 :             while( !rZList.empty() )
     902             :             {
     903           0 :                 list<ZOrderHint>::iterator aIter( rZList.begin() );
     904             : 
     905           0 :                 while( nIndex < (*aIter).nShould && !rUnsortedList.empty() )
     906             :                 {
     907           0 :                     ZOrderHint aGapHint( *rUnsortedList.begin() );
     908           0 :                     rUnsortedList.pop_front();
     909             : 
     910           0 :                     mpImpl->mpSortContext->moveShape( aGapHint.nIs, nIndex++ );
     911             :                 }
     912             : 
     913           0 :                 if( (*aIter).nIs != nIndex )
     914           0 :                     mpImpl->mpSortContext->moveShape( (*aIter).nIs, nIndex );
     915             : 
     916           0 :                 rZList.pop_front();
     917           0 :                 nIndex++;
     918             :             }
     919             :         }
     920             :     }
     921           0 :     catch( uno::Exception& )
     922             :     {
     923             :         OSL_FAIL("exception while sorting shapes, sorting failed!");
     924             :     }
     925             : 
     926             :     // put parent on top and delete current context, were done
     927           0 :     ShapeSortContext* pContext = mpImpl->mpSortContext;
     928           0 :     mpImpl->mpSortContext = pContext->mpParentContext;
     929           0 :     delete pContext;
     930             : }
     931             : 
     932           0 : void XMLShapeImportHelper::shapeWithZIndexAdded( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >&, sal_Int32 nZIndex )
     933             : {
     934           0 :     if( mpImpl->mpSortContext)
     935             :     {
     936             :         ZOrderHint aNewHint;
     937           0 :         aNewHint.nIs = mpImpl->mpSortContext->mnCurrentZ++;
     938           0 :         aNewHint.nShould = nZIndex;
     939             : 
     940           0 :         if( nZIndex == -1 )
     941             :         {
     942             :             // don't care, so add to unsorted list
     943           0 :             mpImpl->mpSortContext->maUnsortedList.push_back(aNewHint);
     944             :         }
     945             :         else
     946             :         {
     947             :             // insert into sort list
     948           0 :             mpImpl->mpSortContext->maZOrderList.push_back(aNewHint);
     949             :         }
     950             :     }
     951           0 : }
     952             : 
     953           0 : void XMLShapeImportHelper::addShapeConnection( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rConnectorShape,
     954             :                          bool bStart,
     955             :                          const OUString& rDestShapeId,
     956             :                          sal_Int32 nDestGlueId )
     957             : {
     958           0 :     ConnectionHint aHint;
     959           0 :     aHint.mxConnector = rConnectorShape;
     960           0 :     aHint.bStart = bStart;
     961           0 :     aHint.aDestShapeId = rDestShapeId;
     962           0 :     aHint.nDestGlueId = nDestGlueId;
     963             : 
     964           0 :     mpImpl->maConnections.push_back( aHint );
     965           0 : }
     966             : 
     967           0 : void XMLShapeImportHelper::restoreConnections()
     968             : {
     969           0 :     if( !mpImpl->maConnections.empty() )
     970             :     {
     971           0 :         uno::Any aAny;
     972             : 
     973           0 :         const vector<ConnectionHint>::size_type nCount = mpImpl->maConnections.size();
     974           0 :         for( vector<ConnectionHint>::size_type i = 0; i < nCount; i++ )
     975             :         {
     976           0 :             ConnectionHint& rHint = mpImpl->maConnections[i];
     977           0 :             uno::Reference< beans::XPropertySet > xConnector( rHint.mxConnector, uno::UNO_QUERY );
     978           0 :             if( xConnector.is() )
     979             :             {
     980             :                 // #86637# remember line deltas
     981           0 :                 uno::Any aLine1Delta;
     982           0 :                 uno::Any aLine2Delta;
     983           0 :                 uno::Any aLine3Delta;
     984           0 :                 OUString aStr1("EdgeLine1Delta");
     985           0 :                 OUString aStr2("EdgeLine2Delta");
     986           0 :                 OUString aStr3("EdgeLine3Delta");
     987           0 :                 aLine1Delta = xConnector->getPropertyValue(aStr1);
     988           0 :                 aLine2Delta = xConnector->getPropertyValue(aStr2);
     989           0 :                 aLine3Delta = xConnector->getPropertyValue(aStr3);
     990             : 
     991             :                 // #86637# simply setting these values WILL force the connector to do
     992             :                 // an new layout promptly. So the line delta values have to be rescued
     993             :                 // and restored around connector changes.
     994             :                 uno::Reference< drawing::XShape > xShape(
     995           0 :                     mrImporter.getInterfaceToIdentifierMapper().getReference( rHint.aDestShapeId ), uno::UNO_QUERY );
     996           0 :                 if( xShape.is() )
     997             :                 {
     998           0 :                     aAny <<= xShape;
     999           0 :                     xConnector->setPropertyValue( rHint.bStart ? msStartShape : msEndShape, aAny );
    1000             : 
    1001           0 :                     sal_Int32 nGlueId = rHint.nDestGlueId < 4 ? rHint.nDestGlueId : getGluePointId( xShape, rHint.nDestGlueId );
    1002           0 :                     aAny <<= nGlueId;
    1003           0 :                     xConnector->setPropertyValue( rHint.bStart ? msStartGluePointIndex : msEndGluePointIndex, aAny );
    1004             :                 }
    1005             : 
    1006             :                 // #86637# restore line deltas
    1007           0 :                 xConnector->setPropertyValue(aStr1, aLine1Delta );
    1008           0 :                 xConnector->setPropertyValue(aStr2, aLine2Delta );
    1009           0 :                 xConnector->setPropertyValue(aStr3, aLine3Delta );
    1010             :             }
    1011           0 :         }
    1012           0 :         mpImpl->maConnections.clear();
    1013             :     }
    1014           0 : }
    1015             : 
    1016           0 : SvXMLImportPropertyMapper* XMLShapeImportHelper::CreateShapePropMapper( const uno::Reference< frame::XModel>& rModel, SvXMLImport& rImport )
    1017             : {
    1018           0 :     UniReference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rModel, rImport );
    1019           0 :     UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory, false );
    1020           0 :     SvXMLImportPropertyMapper* pResult = new SvXMLImportPropertyMapper( xMapper, rImport );
    1021             : 
    1022             :     // chain text attributes
    1023           0 :     pResult->ChainImportMapper( XMLTextImportHelper::CreateParaExtPropMapper( rImport ) );
    1024           0 :     return pResult;
    1025             : }
    1026             : 
    1027             : /** adds a mapping for a glue point identifier from an xml file to the identifier created after inserting
    1028             :     the new glue point into the core. The saved mappings can be retrieved by getGluePointId() */
    1029           0 : void XMLShapeImportHelper::addGluePointMapping( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape,
    1030             :                           sal_Int32 nSourceId, sal_Int32 nDestinnationId )
    1031             : {
    1032           0 :     if( mpPageContext )
    1033           0 :         mpPageContext->maShapeGluePointsMap[xShape][nSourceId] = nDestinnationId;
    1034           0 : }
    1035             : 
    1036             : /** find mapping for given DestinationID. This allows to extract the original draw:id imported with a draw:glue-point */
    1037           0 : sal_Int32 XMLShapeImportHelper::findGluePointMapping(
    1038             :     const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape,
    1039             :     sal_Int32 nDestinnationId ) const
    1040             : {
    1041           0 :     if( mpPageContext )
    1042             :     {
    1043           0 :         ShapeGluePointsMap::iterator aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
    1044             : 
    1045           0 :         if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
    1046             :         {
    1047           0 :             GluePointIdMap::iterator aShapeIdIter = (*aShapeIter).second.begin();
    1048           0 :             GluePointIdMap::iterator aShapeIdEnd  = (*aShapeIter).second.end();
    1049             : 
    1050           0 :             while ( aShapeIdIter != aShapeIdEnd )
    1051             :             {
    1052           0 :                 if ( (*aShapeIdIter).second == nDestinnationId )
    1053             :                 {
    1054           0 :                     return (*aShapeIdIter).first;
    1055             :                 }
    1056             : 
    1057           0 :                 ++aShapeIdIter;
    1058             :             }
    1059             :         }
    1060             :     }
    1061             : 
    1062           0 :     return -1;
    1063             : }
    1064             : 
    1065             : /** moves all current DestinationId's by n */
    1066           0 : void XMLShapeImportHelper::moveGluePointMapping( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, const sal_Int32 n )
    1067             : {
    1068           0 :     if( mpPageContext )
    1069             :     {
    1070           0 :         ShapeGluePointsMap::iterator aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
    1071           0 :         if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
    1072             :         {
    1073           0 :             GluePointIdMap::iterator aShapeIdIter = (*aShapeIter).second.begin();
    1074           0 :             GluePointIdMap::iterator aShapeIdEnd  = (*aShapeIter).second.end();
    1075           0 :             while ( aShapeIdIter != aShapeIdEnd )
    1076             :             {
    1077           0 :                 if ( (*aShapeIdIter).second != -1 )
    1078           0 :                     (*aShapeIdIter).second += n;
    1079           0 :                 ++aShapeIdIter;
    1080             :             }
    1081             :         }
    1082             :     }
    1083           0 : }
    1084             : 
    1085             : /** retrieves a mapping for a glue point identifier from the current xml file to the identifier created after
    1086             :     inserting the new glue point into the core. The mapping must be initialized first with addGluePointMapping() */
    1087           0 : sal_Int32 XMLShapeImportHelper::getGluePointId( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, sal_Int32 nSourceId )
    1088             : {
    1089           0 :     if( mpPageContext )
    1090             :     {
    1091           0 :         ShapeGluePointsMap::iterator aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
    1092           0 :         if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
    1093             :         {
    1094           0 :             GluePointIdMap::iterator aIdIter = (*aShapeIter).second.find(nSourceId);
    1095           0 :             if( aIdIter != (*aShapeIter).second.end() )
    1096           0 :                 return (*aIdIter).second;
    1097             :         }
    1098             :     }
    1099             : 
    1100           0 :     return -1;
    1101             : }
    1102             : 
    1103             : /** this method must be calling before the first shape is imported for the given page */
    1104           0 : void XMLShapeImportHelper::startPage( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes )
    1105             : {
    1106           0 :     XMLShapeImportPageContextImpl* pOldContext = mpPageContext;
    1107           0 :     mpPageContext = new XMLShapeImportPageContextImpl();
    1108           0 :     mpPageContext->mpNext = pOldContext;
    1109           0 :     mpPageContext->mxShapes = rShapes;
    1110           0 : }
    1111             : 
    1112             : /** this method must be calling after the last shape is imported for the given page */
    1113           0 : void XMLShapeImportHelper::endPage( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >&
    1114             : #ifdef DBG_UTIL
    1115             : rShapes
    1116             : #endif
    1117             : )
    1118             : {
    1119             :     DBG_ASSERT( mpPageContext && (mpPageContext->mxShapes == rShapes), "wrong call to endPage(), no startPage called or wrong page" );
    1120           0 :     if( NULL == mpPageContext )
    1121           0 :         return;
    1122             : 
    1123           0 :     restoreConnections();
    1124             : 
    1125           0 :     XMLShapeImportPageContextImpl* pNextContext = mpPageContext->mpNext;
    1126           0 :     delete mpPageContext;
    1127           0 :     mpPageContext = pNextContext;
    1128             : }
    1129             : 
    1130             : // #88546#
    1131             : /** defines if the import should increment the progress bar or not */
    1132           0 : void XMLShapeImportHelper::enableHandleProgressBar( bool bEnable )
    1133             : {
    1134           0 :     mpImpl->mbHandleProgressBar = bEnable;
    1135           0 : }
    1136             : 
    1137           0 : bool XMLShapeImportHelper::IsHandleProgressBarEnabled() const
    1138             : {
    1139           0 :     return mpImpl->mbHandleProgressBar;
    1140             : }
    1141             : 
    1142             : /** queries the capability of the current model to create presentation shapes */
    1143           0 : bool XMLShapeImportHelper::IsPresentationShapesSupported()
    1144             : {
    1145           0 :     return mpImpl->mbIsPresentationShapesSupported;
    1146             : }
    1147             : 
    1148           0 : const rtl::Reference< XMLTableImport >& XMLShapeImportHelper::GetShapeTableImport()
    1149             : {
    1150           0 :     if( !mxShapeTableImport.is() )
    1151             :     {
    1152           0 :         rtl::Reference< XMLPropertyHandlerFactory > xFactory( new XMLSdPropHdlFactory( mrImporter.GetModel(), mrImporter ) );
    1153           0 :         rtl::Reference< XMLPropertySetMapper > xPropertySetMapper( new XMLShapePropertySetMapper( xFactory.get(), false ) );
    1154           0 :         mxShapeTableImport = new XMLTableImport( mrImporter, xPropertySetMapper, xFactory );
    1155             :     }
    1156             : 
    1157           0 :     return mxShapeTableImport;
    1158             : }
    1159             : 
    1160           0 : void SvXMLShapeContext::setHyperlink( const OUString& rHyperlink )
    1161             : {
    1162           0 :     msHyperlink = rHyperlink;
    1163           0 : }
    1164             : 
    1165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10