xref: /AOO41X/main/xmloff/source/draw/shapeimport.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/debug.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <com/sun/star/text/PositionLayoutDir.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/chart/XChartDocument.hpp>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include "unointerfacetouniqueidentifiermapper.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <list>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #ifndef _XMLOFF_SHAPEIMPORT_HXX
41*cdf0e10cSrcweir #include <xmloff/shapeimport.hxx>
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir #include <xmloff/xmltkmap.hxx>
44*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
45*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
46*cdf0e10cSrcweir #include "ximpstyl.hxx"
47*cdf0e10cSrcweir #include "ximpshap.hxx"
48*cdf0e10cSrcweir #include "sdpropls.hxx"
49*cdf0e10cSrcweir #include <xmloff/xmlprmap.hxx>
50*cdf0e10cSrcweir #include "ximp3dscene.hxx"
51*cdf0e10cSrcweir #include "ximp3dobject.hxx"
52*cdf0e10cSrcweir #include "ximpgrp.hxx"
53*cdf0e10cSrcweir #include "ximplink.hxx"
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include <map>
56*cdf0e10cSrcweir #include <vector>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir using ::rtl::OUString;
59*cdf0e10cSrcweir using ::rtl::OUStringBuffer;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir using namespace ::std;
62*cdf0e10cSrcweir using namespace ::com::sun::star;
63*cdf0e10cSrcweir using namespace ::xmloff::token;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir struct ltint32
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir   bool operator()(const sal_Int32 p, sal_Int32 q) const
70*cdf0e10cSrcweir   {
71*cdf0e10cSrcweir     return p < q;
72*cdf0e10cSrcweir   }
73*cdf0e10cSrcweir };
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir typedef std::map<sal_Int32,com::sun::star::uno::Reference< com::sun::star::drawing::XShape >,ltint32> IdShapeMap;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir struct ConnectionHint
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir 	com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxConnector;
80*cdf0e10cSrcweir 	sal_Bool  bStart;
81*cdf0e10cSrcweir 	OUString aDestShapeId;
82*cdf0e10cSrcweir 	sal_Int32 nDestGlueId;
83*cdf0e10cSrcweir };
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir struct XShapeCompareHelper
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir   bool operator()(com::sun::star::uno::Reference < com::sun::star::drawing::XShape > x1,
88*cdf0e10cSrcweir 				  com::sun::star::uno::Reference < com::sun::star::drawing::XShape > x2 ) const
89*cdf0e10cSrcweir   {
90*cdf0e10cSrcweir     return x1.get() < x2.get();
91*cdf0e10cSrcweir   }
92*cdf0e10cSrcweir };
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir /** this map store all glue point id mappings for shapes that had user defined glue points. This
95*cdf0e10cSrcweir 	is needed because on insertion the glue points will get a new and unique id */
96*cdf0e10cSrcweir typedef std::map<sal_Int32,sal_Int32,ltint32> GluePointIdMap;
97*cdf0e10cSrcweir typedef std::map< com::sun::star::uno::Reference < com::sun::star::drawing::XShape >, GluePointIdMap, XShapeCompareHelper > ShapeGluePointsMap;
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir /** this struct is created for each startPage() call and stores information that is needed during
100*cdf0e10cSrcweir 	import of shapes for one page. Since pages could be nested ( notes pages inside impress ) there
101*cdf0e10cSrcweir 	is a pointer so one can build up a stack of this structs */
102*cdf0e10cSrcweir struct XMLShapeImportPageContextImpl
103*cdf0e10cSrcweir {
104*cdf0e10cSrcweir 	ShapeGluePointsMap		maShapeGluePointsMap;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	uno::Reference < drawing::XShapes > mxShapes;
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 	struct XMLShapeImportPageContextImpl* mpNext;
109*cdf0e10cSrcweir };
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir /** this class is to enable adding members to the XMLShapeImportHelper without getting incompatible */
112*cdf0e10cSrcweir struct XMLShapeImportHelperImpl
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir 	// context for sorting shapes
115*cdf0e10cSrcweir 	ShapeSortContext*			mpSortContext;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	IdShapeMap					maShapeIds;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir 	std::vector<ConnectionHint> maConnections;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	// #88546# possibility to swich progress bar handling on/off
122*cdf0e10cSrcweir 	sal_Bool					mbHandleProgressBar;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	// stores the capability of the current model to create presentation shapes
125*cdf0e10cSrcweir 	sal_Bool					mbIsPresentationShapesSupported;
126*cdf0e10cSrcweir };
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir XMLShapeImportHelper::XMLShapeImportHelper(
131*cdf0e10cSrcweir 		SvXMLImport& rImporter,
132*cdf0e10cSrcweir 		const uno::Reference< frame::XModel>& rModel,
133*cdf0e10cSrcweir 		SvXMLImportPropertyMapper *pExtMapper )
134*cdf0e10cSrcweir :	mpPageContext(NULL),
135*cdf0e10cSrcweir 	mxModel(rModel),
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	mpPropertySetMapper(0L),
138*cdf0e10cSrcweir 	mpPresPagePropsMapper(0L),
139*cdf0e10cSrcweir 	mpStylesContext(0L),
140*cdf0e10cSrcweir 	mpAutoStylesContext(0L),
141*cdf0e10cSrcweir 	mpGroupShapeElemTokenMap(0L),
142*cdf0e10cSrcweir 	mpFrameShapeElemTokenMap(0L),
143*cdf0e10cSrcweir 	mp3DSceneShapeElemTokenMap(0L),
144*cdf0e10cSrcweir 	mp3DObjectAttrTokenMap(0L),
145*cdf0e10cSrcweir 	mp3DPolygonBasedAttrTokenMap(0L),
146*cdf0e10cSrcweir 	mp3DCubeObjectAttrTokenMap(0L),
147*cdf0e10cSrcweir 	mp3DSphereObjectAttrTokenMap(0L),
148*cdf0e10cSrcweir 	mp3DSceneShapeAttrTokenMap(0L),
149*cdf0e10cSrcweir 	mp3DLightAttrTokenMap(0L),
150*cdf0e10cSrcweir 	mpPathShapeAttrTokenMap(0L),
151*cdf0e10cSrcweir 	mpPolygonShapeAttrTokenMap(0L),
152*cdf0e10cSrcweir 	msStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape")),
153*cdf0e10cSrcweir 	msEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape")),
154*cdf0e10cSrcweir 	msStartGluePointIndex(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex")),
155*cdf0e10cSrcweir 	msEndGluePointIndex(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex")),
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 	mrImporter( rImporter )
158*cdf0e10cSrcweir {
159*cdf0e10cSrcweir 	mpImpl = new XMLShapeImportHelperImpl();
160*cdf0e10cSrcweir 	mpImpl->mpSortContext = 0;
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	// #88546# init to sal_False
163*cdf0e10cSrcweir 	mpImpl->mbHandleProgressBar = sal_False;
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 	mpSdPropHdlFactory = new XMLSdPropHdlFactory( rModel, rImporter );
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 	// set lock to avoid deletion
168*cdf0e10cSrcweir 	mpSdPropHdlFactory->acquire();
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 	// construct PropertySetMapper
171*cdf0e10cSrcweir 	UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper(mpSdPropHdlFactory);
172*cdf0e10cSrcweir 	mpPropertySetMapper = new SvXMLImportPropertyMapper( xMapper, rImporter );
173*cdf0e10cSrcweir 	// set lock to avoid deletion
174*cdf0e10cSrcweir 	mpPropertySetMapper->acquire();
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	if( pExtMapper )
177*cdf0e10cSrcweir 	{
178*cdf0e10cSrcweir 		UniReference < SvXMLImportPropertyMapper > xExtMapper( pExtMapper );
179*cdf0e10cSrcweir 		mpPropertySetMapper->ChainImportMapper( xExtMapper );
180*cdf0e10cSrcweir 	}
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir 	// chain text attributes
183*cdf0e10cSrcweir 	mpPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(rImporter));
184*cdf0e10cSrcweir 	mpPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaDefaultExtPropMapper(rImporter));
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 	// construct PresPagePropsMapper
187*cdf0e10cSrcweir 	xMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLSDPresPageProps, mpSdPropHdlFactory);
188*cdf0e10cSrcweir 	mpPresPagePropsMapper = new SvXMLImportPropertyMapper( xMapper, rImporter );
189*cdf0e10cSrcweir 	if(mpPresPagePropsMapper)
190*cdf0e10cSrcweir 	{
191*cdf0e10cSrcweir 		// set lock to avoid deletion
192*cdf0e10cSrcweir 		mpPresPagePropsMapper->acquire();
193*cdf0e10cSrcweir 	}
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir 	uno::Reference< lang::XServiceInfo > xInfo( rImporter.GetModel(), uno::UNO_QUERY );
196*cdf0e10cSrcweir 	const OUString aSName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument") );
197*cdf0e10cSrcweir 	mpImpl->mbIsPresentationShapesSupported = xInfo.is() && xInfo->supportsService( aSName );
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir XMLShapeImportHelper::~XMLShapeImportHelper()
203*cdf0e10cSrcweir {
204*cdf0e10cSrcweir 	DBG_ASSERT( mpImpl->maConnections.empty(), "XMLShapeImportHelper::restoreConnections() was not called!" );
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 	// cleanup factory, decrease refcount. Should lead to destruction.
207*cdf0e10cSrcweir 	if(mpSdPropHdlFactory)
208*cdf0e10cSrcweir 	{
209*cdf0e10cSrcweir 		mpSdPropHdlFactory->release();
210*cdf0e10cSrcweir 		mpSdPropHdlFactory = 0L;
211*cdf0e10cSrcweir 	}
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	// cleanup mapper, decrease refcount. Should lead to destruction.
214*cdf0e10cSrcweir 	if(mpPropertySetMapper)
215*cdf0e10cSrcweir 	{
216*cdf0e10cSrcweir 		mpPropertySetMapper->release();
217*cdf0e10cSrcweir 		mpPropertySetMapper = 0L;
218*cdf0e10cSrcweir 	}
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	// cleanup presPage mapper, decrease refcount. Should lead to destruction.
221*cdf0e10cSrcweir 	if(mpPresPagePropsMapper)
222*cdf0e10cSrcweir 	{
223*cdf0e10cSrcweir 		mpPresPagePropsMapper->release();
224*cdf0e10cSrcweir 		mpPresPagePropsMapper = 0L;
225*cdf0e10cSrcweir 	}
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	if(mpGroupShapeElemTokenMap) delete mpGroupShapeElemTokenMap;
228*cdf0e10cSrcweir 	if(mpFrameShapeElemTokenMap) delete mpFrameShapeElemTokenMap;
229*cdf0e10cSrcweir /*
230*cdf0e10cSrcweir 	if(mpShapeAttrTokenMap) delete mpShapeAttrTokenMap;
231*cdf0e10cSrcweir 	if(mpRectShapeAttrTokenMap) delete mpRectShapeAttrTokenMap;
232*cdf0e10cSrcweir 	if(mpLineShapeAttrTokenMap) delete mpLineShapeAttrTokenMap;
233*cdf0e10cSrcweir 	if(mpEllipseShapeAttrTokenMap) delete mpEllipseShapeAttrTokenMap;
234*cdf0e10cSrcweir 	if(mpTextBoxShapeAttrTokenMap) delete mpTextBoxShapeAttrTokenMap;
235*cdf0e10cSrcweir 	if(mpControlShapeAttrTokenMap) delete mpControlShapeAttrTokenMap;
236*cdf0e10cSrcweir 	if(mpPageShapeAttrTokenMap) delete mpPageShapeAttrTokenMap;
237*cdf0e10cSrcweir 	if(mpGraphicObjectShapeAttrTokenMap) delete mpGraphicObjectShapeAttrTokenMap;
238*cdf0e10cSrcweir */
239*cdf0e10cSrcweir 	if(mpPolygonShapeAttrTokenMap) delete mpPolygonShapeAttrTokenMap;
240*cdf0e10cSrcweir 	if(mpPathShapeAttrTokenMap) delete mpPathShapeAttrTokenMap;
241*cdf0e10cSrcweir 	if(mp3DSceneShapeElemTokenMap) delete mp3DSceneShapeElemTokenMap;
242*cdf0e10cSrcweir 	if(mp3DObjectAttrTokenMap) delete mp3DObjectAttrTokenMap;
243*cdf0e10cSrcweir 	if(mp3DPolygonBasedAttrTokenMap) delete mp3DPolygonBasedAttrTokenMap;
244*cdf0e10cSrcweir 	if(mp3DCubeObjectAttrTokenMap) delete mp3DCubeObjectAttrTokenMap;
245*cdf0e10cSrcweir 	if(mp3DSphereObjectAttrTokenMap) delete mp3DSphereObjectAttrTokenMap;
246*cdf0e10cSrcweir 	if(mp3DSceneShapeAttrTokenMap) delete mp3DSceneShapeAttrTokenMap;
247*cdf0e10cSrcweir 	if(mp3DLightAttrTokenMap) delete mp3DLightAttrTokenMap;
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	// Styles or AutoStyles context?
250*cdf0e10cSrcweir 	if(mpStylesContext)
251*cdf0e10cSrcweir 	{
252*cdf0e10cSrcweir 		mpStylesContext->Clear();
253*cdf0e10cSrcweir 		mpStylesContext->ReleaseRef();
254*cdf0e10cSrcweir 	}
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 	if(mpAutoStylesContext)
257*cdf0e10cSrcweir 	{
258*cdf0e10cSrcweir 		mpAutoStylesContext->Clear();
259*cdf0e10cSrcweir 		mpAutoStylesContext->ReleaseRef();
260*cdf0e10cSrcweir 	}
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 	delete mpImpl;
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetGroupShapeElemTokenMap()
270*cdf0e10cSrcweir {
271*cdf0e10cSrcweir 	if(!mpGroupShapeElemTokenMap)
272*cdf0e10cSrcweir     {
273*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry aGroupShapeElemTokenMap[] =
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_G,				XML_TOK_GROUP_GROUP			},
276*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_RECT,			XML_TOK_GROUP_RECT			},
277*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_LINE,			XML_TOK_GROUP_LINE			},
278*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_CIRCLE,		    XML_TOK_GROUP_CIRCLE		},
279*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_ELLIPSE,		XML_TOK_GROUP_ELLIPSE		},
280*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_POLYGON,		XML_TOK_GROUP_POLYGON		},
281*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_POLYLINE,		XML_TOK_GROUP_POLYLINE		},
282*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_PATH,			XML_TOK_GROUP_PATH			},
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_CONTROL,		XML_TOK_GROUP_CONTROL		},
285*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_CONNECTOR,		XML_TOK_GROUP_CONNECTOR		},
286*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_MEASURE,		XML_TOK_GROUP_MEASURE		},
287*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_PAGE_THUMBNAIL, XML_TOK_GROUP_PAGE			},
288*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_CAPTION,		XML_TOK_GROUP_CAPTION		},
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 	{ XML_NAMESPACE_CHART,			XML_CHART,			XML_TOK_GROUP_CHART			},
291*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_SCENE,			XML_TOK_GROUP_3DSCENE		},
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_FRAME, 			XML_TOK_GROUP_FRAME			},
294*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_CUSTOM_SHAPE,	XML_TOK_GROUP_CUSTOM_SHAPE	},
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_CUSTOM_SHAPE,	XML_TOK_GROUP_CUSTOM_SHAPE	},
297*cdf0e10cSrcweir 	{ XML_NAMESPACE_OFFICE,			XML_ANNOTATION,		XML_TOK_GROUP_ANNOTATION	},
298*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_A,				XML_TOK_GROUP_A				},
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir     XML_TOKEN_MAP_END
301*cdf0e10cSrcweir };
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir 		mpGroupShapeElemTokenMap = new SvXMLTokenMap(aGroupShapeElemTokenMap);
304*cdf0e10cSrcweir     } // if(!mpGroupShapeElemTokenMap)
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir 	return *mpGroupShapeElemTokenMap;
307*cdf0e10cSrcweir }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetFrameShapeElemTokenMap()
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir 	if(!mpFrameShapeElemTokenMap)
312*cdf0e10cSrcweir     {
313*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry aFrameShapeElemTokenMap[] =
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_TEXT_BOX,		XML_TOK_FRAME_TEXT_BOX		},
316*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_IMAGE,			XML_TOK_FRAME_IMAGE			},
317*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_OBJECT,		    XML_TOK_FRAME_OBJECT		},
318*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_OBJECT_OLE,	    XML_TOK_FRAME_OBJECT_OLE	},
319*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_PLUGIN,		    XML_TOK_FRAME_PLUGIN		},
320*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_FLOATING_FRAME, XML_TOK_FRAME_FLOATING_FRAME},
321*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_APPLET,		    XML_TOK_FRAME_APPLET		},
322*cdf0e10cSrcweir 	{ XML_NAMESPACE_TABLE,			XML_TABLE,			XML_TOK_FRAME_TABLE			},
323*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
324*cdf0e10cSrcweir };
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir 		mpFrameShapeElemTokenMap = new SvXMLTokenMap(aFrameShapeElemTokenMap);
327*cdf0e10cSrcweir     } // if(!mpFrameShapeElemTokenMap)
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 	return *mpFrameShapeElemTokenMap;
330*cdf0e10cSrcweir }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::Get3DSceneShapeElemTokenMap()
336*cdf0e10cSrcweir {
337*cdf0e10cSrcweir 	if(!mp3DSceneShapeElemTokenMap)
338*cdf0e10cSrcweir     {
339*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry a3DSceneShapeElemTokenMap[] =
340*cdf0e10cSrcweir {
341*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_SCENE,		XML_TOK_3DSCENE_3DSCENE		},
342*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_CUBE,		XML_TOK_3DSCENE_3DCUBE		},
343*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_SPHERE,	    XML_TOK_3DSCENE_3DSPHERE	},
344*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_ROTATE,	    XML_TOK_3DSCENE_3DLATHE		},
345*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_EXTRUDE,	XML_TOK_3DSCENE_3DEXTRUDE	},
346*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
347*cdf0e10cSrcweir };
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 		mp3DSceneShapeElemTokenMap = new SvXMLTokenMap(a3DSceneShapeElemTokenMap);
350*cdf0e10cSrcweir     } // if(!mp3DSceneShapeElemTokenMap)
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir 	return *mp3DSceneShapeElemTokenMap;
353*cdf0e10cSrcweir }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
356*cdf0e10cSrcweir /*
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetShapeAttrTokenMap()
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir 	if(!mpShapeAttrTokenMap)
361*cdf0e10cSrcweir     {
362*cdf0e10cSrcweir     static __FAR_DATA SvXMLTokenMapEntry aShapeAttrTokenMap[] =
363*cdf0e10cSrcweir {
364*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_NAME,				XML_TOK_SHAPE_NAME							},
365*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_STYLE_NAME,		    XML_TOK_SHAPE_DRAWSTYLE_NAME_GRAPHICS		},
366*cdf0e10cSrcweir 	{ XML_NAMESPACE_PRESENTATION,	XML_CLASS,				XML_TOK_SHAPE_PRESENTATION_CLASS			},
367*cdf0e10cSrcweir 	{ XML_NAMESPACE_PRESENTATION,	XML_STYLE_NAME,		    XML_TOK_SHAPE_DRAWSTYLE_NAME_PRESENTATION	},
368*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,			XML_TRANSFORM,			XML_TOK_SHAPE_TRANSFORM						},
369*cdf0e10cSrcweir 	{ XML_NAMESPACE_PRESENTATION,	XML_PLACEHOLDER,		XML_TOK_SHAPE_IS_PLACEHOLDER				},
370*cdf0e10cSrcweir 	{ XML_NAMESPACE_PRESENTATION,	XML_USER_TRANSFORMED,	XML_TOK_SHAPE_IS_USER_TRANSFORMED			},
371*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
372*cdf0e10cSrcweir };
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 		mpShapeAttrTokenMap = new SvXMLTokenMap(aShapeAttrTokenMap);
375*cdf0e10cSrcweir         }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 	return *mpShapeAttrTokenMap;
378*cdf0e10cSrcweir }
379*cdf0e10cSrcweir */
380*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::Get3DObjectAttrTokenMap()
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir 	if(!mp3DObjectAttrTokenMap)
386*cdf0e10cSrcweir     {
387*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry a3DObjectAttrTokenMap[] =
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,			XML_STYLE_NAME,		    XML_TOK_3DOBJECT_DRAWSTYLE_NAME		},
390*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_TRANSFORM,			XML_TOK_3DOBJECT_TRANSFORM			},
391*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
392*cdf0e10cSrcweir };
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir 		mp3DObjectAttrTokenMap = new SvXMLTokenMap(a3DObjectAttrTokenMap);
395*cdf0e10cSrcweir     } // if(!mp3DObjectAttrTokenMap)
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 	return *mp3DObjectAttrTokenMap;
398*cdf0e10cSrcweir }
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::Get3DPolygonBasedAttrTokenMap()
404*cdf0e10cSrcweir {
405*cdf0e10cSrcweir 	if(!mp3DPolygonBasedAttrTokenMap)
406*cdf0e10cSrcweir     {
407*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry a3DPolygonBasedAttrTokenMap[] =
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,			XML_VIEWBOX,			XML_TOK_3DPOLYGONBASED_VIEWBOX		},
410*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,			XML_D,					XML_TOK_3DPOLYGONBASED_D			},
411*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
412*cdf0e10cSrcweir };
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 		mp3DPolygonBasedAttrTokenMap = new SvXMLTokenMap(a3DPolygonBasedAttrTokenMap);
415*cdf0e10cSrcweir     } // if(!mp3DPolygonBasedAttrTokenMap)
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir 	return *mp3DPolygonBasedAttrTokenMap;
418*cdf0e10cSrcweir }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::Get3DCubeObjectAttrTokenMap()
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir 	if(!mp3DCubeObjectAttrTokenMap)
426*cdf0e10cSrcweir     {
427*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry a3DCubeObjectAttrTokenMap[] =
428*cdf0e10cSrcweir {
429*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_MIN_EDGE,			XML_TOK_3DCUBEOBJ_MINEDGE	},
430*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_MAX_EDGE,			XML_TOK_3DCUBEOBJ_MAXEDGE	},
431*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
432*cdf0e10cSrcweir };
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir 		mp3DCubeObjectAttrTokenMap = new SvXMLTokenMap(a3DCubeObjectAttrTokenMap);
435*cdf0e10cSrcweir     } // if(!mp3DCubeObjectAttrTokenMap)
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir 	return *mp3DCubeObjectAttrTokenMap;
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::Get3DSphereObjectAttrTokenMap()
444*cdf0e10cSrcweir {
445*cdf0e10cSrcweir 	if(!mp3DSphereObjectAttrTokenMap)
446*cdf0e10cSrcweir     {
447*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry a3DSphereObjectAttrTokenMap[] =
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_CENTER, 			XML_TOK_3DSPHEREOBJ_CENTER	},
450*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,			XML_SIZE,				XML_TOK_3DSPHEREOBJ_SIZE	},
451*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
452*cdf0e10cSrcweir };
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 		mp3DSphereObjectAttrTokenMap = new SvXMLTokenMap(a3DSphereObjectAttrTokenMap);
455*cdf0e10cSrcweir     } // if(!mp3DSphereObjectAttrTokenMap)
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	return *mp3DSphereObjectAttrTokenMap;
458*cdf0e10cSrcweir }
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
461*cdf0e10cSrcweir /*
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetRectShapeAttrTokenMap()
464*cdf0e10cSrcweir {
465*cdf0e10cSrcweir 	if(!mpRectShapeAttrTokenMap)
466*cdf0e10cSrcweir     {
467*cdf0e10cSrcweir     static __FAR_DATA SvXMLTokenMapEntry aRectShapeAttrTokenMap[] =
468*cdf0e10cSrcweir {
469*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_X,					XML_TOK_RECTSHAPE_X					},
470*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_Y,					XML_TOK_RECTSHAPE_Y					},
471*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_WIDTH,				XML_TOK_RECTSHAPE_WIDTH				},
472*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_HEIGHT,			    XML_TOK_RECTSHAPE_HEIGHT			},
473*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,	XML_CORNER_RADIUS,		XML_TOK_RECTSHAPE_CORNER_RADIUS		},
474*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
475*cdf0e10cSrcweir };
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 		mpRectShapeAttrTokenMap = new SvXMLTokenMap(aRectShapeAttrTokenMap);
478*cdf0e10cSrcweir         }
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 	return *mpRectShapeAttrTokenMap;
481*cdf0e10cSrcweir }
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetLineShapeAttrTokenMap()
487*cdf0e10cSrcweir {
488*cdf0e10cSrcweir 	if(!mpLineShapeAttrTokenMap)
489*cdf0e10cSrcweir     {
490*cdf0e10cSrcweir     static __FAR_DATA SvXMLTokenMapEntry aLineShapeAttrTokenMap[] =
491*cdf0e10cSrcweir {
492*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_X1,             XML_TOK_LINESHAPE_X1				},
493*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_Y1,				XML_TOK_LINESHAPE_Y1				},
494*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_X2,				XML_TOK_LINESHAPE_X2				},
495*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_Y2,				XML_TOK_LINESHAPE_Y2				},
496*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
497*cdf0e10cSrcweir };
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir 		mpLineShapeAttrTokenMap = new SvXMLTokenMap(aLineShapeAttrTokenMap);
500*cdf0e10cSrcweir         }
501*cdf0e10cSrcweir 
502*cdf0e10cSrcweir 	return *mpLineShapeAttrTokenMap;
503*cdf0e10cSrcweir }
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetEllipseShapeAttrTokenMap()
509*cdf0e10cSrcweir {
510*cdf0e10cSrcweir 	if(!mpEllipseShapeAttrTokenMap)
511*cdf0e10cSrcweir     {
512*cdf0e10cSrcweir     static __FAR_DATA SvXMLTokenMapEntry aEllipseShapeAttrTokenMap[] =
513*cdf0e10cSrcweir {
514*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_RX,				XML_TOK_ELLIPSESHAPE_RX				},
515*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_RY,				XML_TOK_ELLIPSESHAPE_RY				},
516*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_CX,				XML_TOK_ELLIPSESHAPE_CX				},
517*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_CY,				XML_TOK_ELLIPSESHAPE_CY				},
518*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_R,				XML_TOK_ELLIPSESHAPE_R				},
519*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
520*cdf0e10cSrcweir };
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 		mpEllipseShapeAttrTokenMap = new SvXMLTokenMap(aEllipseShapeAttrTokenMap);
523*cdf0e10cSrcweir         }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir 	return *mpEllipseShapeAttrTokenMap;
526*cdf0e10cSrcweir }
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
529*cdf0e10cSrcweir */
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetPolygonShapeAttrTokenMap()
532*cdf0e10cSrcweir {
533*cdf0e10cSrcweir 	if(!mpPolygonShapeAttrTokenMap)
534*cdf0e10cSrcweir     {
535*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry aPolygonShapeAttrTokenMap[] =
536*cdf0e10cSrcweir {
537*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_VIEWBOX,			XML_TOK_POLYGONSHAPE_VIEWBOX		},
538*cdf0e10cSrcweir 	{ XML_NAMESPACE_DRAW,	XML_POINTS, 			XML_TOK_POLYGONSHAPE_POINTS			},
539*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
540*cdf0e10cSrcweir };
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 		mpPolygonShapeAttrTokenMap = new SvXMLTokenMap(aPolygonShapeAttrTokenMap);
543*cdf0e10cSrcweir     } // if(!mpPolygonShapeAttrTokenMap)
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir 	return *mpPolygonShapeAttrTokenMap;
546*cdf0e10cSrcweir }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetPathShapeAttrTokenMap()
552*cdf0e10cSrcweir {
553*cdf0e10cSrcweir 	if(!mpPathShapeAttrTokenMap)
554*cdf0e10cSrcweir     {
555*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry aPathShapeAttrTokenMap[] =
556*cdf0e10cSrcweir {
557*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_VIEWBOX,			XML_TOK_PATHSHAPE_VIEWBOX			},
558*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_D,					XML_TOK_PATHSHAPE_D					},
559*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
560*cdf0e10cSrcweir };
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir 		mpPathShapeAttrTokenMap = new SvXMLTokenMap(aPathShapeAttrTokenMap);
563*cdf0e10cSrcweir     } // if(!mpPathShapeAttrTokenMap)
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir 	return *mpPathShapeAttrTokenMap;
566*cdf0e10cSrcweir }
567*cdf0e10cSrcweir /*
568*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetTextBoxShapeAttrTokenMap()
572*cdf0e10cSrcweir {
573*cdf0e10cSrcweir 	if(!mpTextBoxShapeAttrTokenMap)
574*cdf0e10cSrcweir     {
575*cdf0e10cSrcweir     static __FAR_DATA SvXMLTokenMapEntry aTextBoxShapeAttrTokenMap[] =
576*cdf0e10cSrcweir {
577*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_X,					XML_TOK_TEXTBOXSHAPE_X				},
578*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_Y,					XML_TOK_TEXTBOXSHAPE_Y				},
579*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_WIDTH,				XML_TOK_TEXTBOXSHAPE_WIDTH			},
580*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_HEIGHT,			    XML_TOK_TEXTBOXSHAPE_HEIGHT			},
581*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
582*cdf0e10cSrcweir };
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 		mpTextBoxShapeAttrTokenMap = new SvXMLTokenMap(aTextBoxShapeAttrTokenMap);
585*cdf0e10cSrcweir         }
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir 	return *mpTextBoxShapeAttrTokenMap;
588*cdf0e10cSrcweir }
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetControlShapeAttrTokenMap()
594*cdf0e10cSrcweir {
595*cdf0e10cSrcweir 	if(!mpControlShapeAttrTokenMap)
596*cdf0e10cSrcweir     {
597*cdf0e10cSrcweir     static __FAR_DATA SvXMLTokenMapEntry aControlShapeAttrTokenMap[] =
598*cdf0e10cSrcweir {
599*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_X,					XML_TOK_CONTROLSHAPE_X				},
600*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_Y,					XML_TOK_CONTROLSHAPE_Y				},
601*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_WIDTH,				XML_TOK_CONTROLSHAPE_WIDTH			},
602*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_HEIGHT,			    XML_TOK_CONTROLSHAPE_HEIGHT			},
603*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
604*cdf0e10cSrcweir };
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir 		mpControlShapeAttrTokenMap = new SvXMLTokenMap(aControlShapeAttrTokenMap);
607*cdf0e10cSrcweir         }
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir 	return *mpControlShapeAttrTokenMap;
610*cdf0e10cSrcweir }
611*cdf0e10cSrcweir */
612*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::Get3DSceneShapeAttrTokenMap()
616*cdf0e10cSrcweir {
617*cdf0e10cSrcweir 	if(!mp3DSceneShapeAttrTokenMap)
618*cdf0e10cSrcweir     {
619*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry a3DSceneShapeAttrTokenMap[] =
620*cdf0e10cSrcweir {
621*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_TRANSFORM,			XML_TOK_3DSCENESHAPE_TRANSFORM		},
622*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_VRP,				XML_TOK_3DSCENESHAPE_VRP			},
623*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_VPN,				XML_TOK_3DSCENESHAPE_VPN			},
624*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_VUP,				XML_TOK_3DSCENESHAPE_VUP			},
625*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_PROJECTION,		    XML_TOK_3DSCENESHAPE_PROJECTION		},
626*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_DISTANCE,			XML_TOK_3DSCENESHAPE_DISTANCE		},
627*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_FOCAL_LENGTH,		XML_TOK_3DSCENESHAPE_FOCAL_LENGTH	},
628*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_SHADOW_SLANT,		XML_TOK_3DSCENESHAPE_SHADOW_SLANT	},
629*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_SHADE_MODE,		    XML_TOK_3DSCENESHAPE_SHADE_MODE		},
630*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_AMBIENT_COLOR,		XML_TOK_3DSCENESHAPE_AMBIENT_COLOR	},
631*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_LIGHTING_MODE,		XML_TOK_3DSCENESHAPE_LIGHTING_MODE	},
632*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
633*cdf0e10cSrcweir };
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir 		mp3DSceneShapeAttrTokenMap = new SvXMLTokenMap(a3DSceneShapeAttrTokenMap);
636*cdf0e10cSrcweir     } // if(!mp3DSceneShapeAttrTokenMap)
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 	return *mp3DSceneShapeAttrTokenMap;
639*cdf0e10cSrcweir }
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::Get3DLightAttrTokenMap()
645*cdf0e10cSrcweir {
646*cdf0e10cSrcweir 	if(!mp3DLightAttrTokenMap)
647*cdf0e10cSrcweir     {
648*cdf0e10cSrcweir         static __FAR_DATA SvXMLTokenMapEntry a3DLightAttrTokenMap[] =
649*cdf0e10cSrcweir {
650*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_DIFFUSE_COLOR,		XML_TOK_3DLIGHT_DIFFUSE_COLOR		},
651*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_DIRECTION,			XML_TOK_3DLIGHT_DIRECTION			},
652*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_ENABLED,			XML_TOK_3DLIGHT_ENABLED				},
653*cdf0e10cSrcweir 	{ XML_NAMESPACE_DR3D,	XML_SPECULAR,			XML_TOK_3DLIGHT_SPECULAR			},
654*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
655*cdf0e10cSrcweir };
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir 		mp3DLightAttrTokenMap = new SvXMLTokenMap(a3DLightAttrTokenMap);
658*cdf0e10cSrcweir     } // if(!mp3DLightAttrTokenMap)
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir 	return *mp3DLightAttrTokenMap;
661*cdf0e10cSrcweir }
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
664*cdf0e10cSrcweir /*
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetPageShapeAttrTokenMap()
667*cdf0e10cSrcweir {
668*cdf0e10cSrcweir 	if(!mpPageShapeAttrTokenMap)
669*cdf0e10cSrcweir     {
670*cdf0e10cSrcweir     static __FAR_DATA SvXMLTokenMapEntry aPageShapeAttrTokenMap[] =
671*cdf0e10cSrcweir {
672*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_X,					XML_TOK_PAGESHAPE_X				},
673*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_Y,					XML_TOK_PAGESHAPE_Y				},
674*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_WIDTH,				XML_TOK_PAGESHAPE_WIDTH			},
675*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_HEIGHT,			    XML_TOK_PAGESHAPE_HEIGHT		},
676*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
677*cdf0e10cSrcweir };
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir 		mpPageShapeAttrTokenMap = new SvXMLTokenMap(aPageShapeAttrTokenMap);
680*cdf0e10cSrcweir         }
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir 	return *mpPageShapeAttrTokenMap;
683*cdf0e10cSrcweir }
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir const SvXMLTokenMap& XMLShapeImportHelper::GetGraphicObjectShapeAttrTokenMap()
689*cdf0e10cSrcweir {
690*cdf0e10cSrcweir 	if(!mpGraphicObjectShapeAttrTokenMap)
691*cdf0e10cSrcweir     {
692*cdf0e10cSrcweir     static __FAR_DATA SvXMLTokenMapEntry aGraphicObjectShapeAttrTokenMap[] =
693*cdf0e10cSrcweir {
694*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_X,					XML_TOK_GOSHAPE_X					},
695*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_Y,					XML_TOK_GOSHAPE_Y					},
696*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_WIDTH,				XML_TOK_GOSHAPE_WIDTH				},
697*cdf0e10cSrcweir 	{ XML_NAMESPACE_SVG,	XML_HEIGHT, 			XML_TOK_GOSHAPE_HEIGHT				},
698*cdf0e10cSrcweir 	{ XML_NAMESPACE_XLINK,	XML_HREF,				XML_TOK_GOSHAPE_URL					},
699*cdf0e10cSrcweir 	XML_TOKEN_MAP_END
700*cdf0e10cSrcweir };
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir 		mpGraphicObjectShapeAttrTokenMap = new SvXMLTokenMap(aGraphicObjectShapeAttrTokenMap);
703*cdf0e10cSrcweir         }
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir 	return *mpGraphicObjectShapeAttrTokenMap;
706*cdf0e10cSrcweir }
707*cdf0e10cSrcweir */
708*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir SvXMLShapeContext* XMLShapeImportHelper::Create3DSceneChildContext(
711*cdf0e10cSrcweir 	SvXMLImport& rImport,
712*cdf0e10cSrcweir 	sal_uInt16 p_nPrefix,
713*cdf0e10cSrcweir 	const OUString& rLocalName,
714*cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList>& xAttrList,
715*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes)
716*cdf0e10cSrcweir {
717*cdf0e10cSrcweir 	SdXMLShapeContext *pContext = 0L;
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir 	if(rShapes.is())
720*cdf0e10cSrcweir 	{
721*cdf0e10cSrcweir 		const SvXMLTokenMap& rTokenMap = Get3DSceneShapeElemTokenMap();
722*cdf0e10cSrcweir 		switch(rTokenMap.Get(p_nPrefix, rLocalName))
723*cdf0e10cSrcweir 		{
724*cdf0e10cSrcweir 			case XML_TOK_3DSCENE_3DSCENE:
725*cdf0e10cSrcweir 			{
726*cdf0e10cSrcweir 				// dr3d:3dscene inside dr3d:3dscene context
727*cdf0e10cSrcweir 				pContext = new SdXML3DSceneShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
728*cdf0e10cSrcweir 				break;
729*cdf0e10cSrcweir 			}
730*cdf0e10cSrcweir 			case XML_TOK_3DSCENE_3DCUBE:
731*cdf0e10cSrcweir 			{
732*cdf0e10cSrcweir 				// dr3d:3dcube inside dr3d:3dscene context
733*cdf0e10cSrcweir 				pContext = new SdXML3DCubeObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
734*cdf0e10cSrcweir 				break;
735*cdf0e10cSrcweir 			}
736*cdf0e10cSrcweir 			case XML_TOK_3DSCENE_3DSPHERE:
737*cdf0e10cSrcweir 			{
738*cdf0e10cSrcweir 				// dr3d:3dsphere inside dr3d:3dscene context
739*cdf0e10cSrcweir 				pContext = new SdXML3DSphereObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
740*cdf0e10cSrcweir 				break;
741*cdf0e10cSrcweir 			}
742*cdf0e10cSrcweir 			case XML_TOK_3DSCENE_3DLATHE:
743*cdf0e10cSrcweir 			{
744*cdf0e10cSrcweir 				// dr3d:3dlathe inside dr3d:3dscene context
745*cdf0e10cSrcweir 				pContext = new SdXML3DLatheObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
746*cdf0e10cSrcweir 				break;
747*cdf0e10cSrcweir 			}
748*cdf0e10cSrcweir 			case XML_TOK_3DSCENE_3DEXTRUDE:
749*cdf0e10cSrcweir 			{
750*cdf0e10cSrcweir 				// dr3d:3dextrude inside dr3d:3dscene context
751*cdf0e10cSrcweir 				pContext = new SdXML3DExtrudeObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False);
752*cdf0e10cSrcweir 				break;
753*cdf0e10cSrcweir 			}
754*cdf0e10cSrcweir 		}
755*cdf0e10cSrcweir 	}
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir 	// now parse the attribute list and call the child context for each unknown attribute
758*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
759*cdf0e10cSrcweir 	for(sal_Int16 a(0); a < nAttrCount; a++)
760*cdf0e10cSrcweir 	{
761*cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex(a);
762*cdf0e10cSrcweir 		OUString aLocalName;
763*cdf0e10cSrcweir 		sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
764*cdf0e10cSrcweir 		const OUString aValue( xAttrList->getValueByIndex(a) );
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir 		pContext->processAttribute( nPrefix, aLocalName, aValue );
767*cdf0e10cSrcweir 	}
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir 	return pContext;
770*cdf0e10cSrcweir }
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir void XMLShapeImportHelper::SetStylesContext(SvXMLStylesContext* pNew)
775*cdf0e10cSrcweir {
776*cdf0e10cSrcweir 	mpStylesContext = pNew;
777*cdf0e10cSrcweir 	mpStylesContext->AddRef();
778*cdf0e10cSrcweir }
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
781*cdf0e10cSrcweir 
782*cdf0e10cSrcweir void XMLShapeImportHelper::SetAutoStylesContext(SvXMLStylesContext* pNew)
783*cdf0e10cSrcweir {
784*cdf0e10cSrcweir 	mpAutoStylesContext = pNew;
785*cdf0e10cSrcweir 	mpAutoStylesContext->AddRef();
786*cdf0e10cSrcweir }
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir SvXMLShapeContext* XMLShapeImportHelper::CreateGroupChildContext(
791*cdf0e10cSrcweir 	SvXMLImport& rImport,
792*cdf0e10cSrcweir 	sal_uInt16 p_nPrefix,
793*cdf0e10cSrcweir 	const OUString& rLocalName,
794*cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList>& xAttrList,
795*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
796*cdf0e10cSrcweir     sal_Bool bTemporaryShape)
797*cdf0e10cSrcweir {
798*cdf0e10cSrcweir 	SdXMLShapeContext *pContext = 0L;
799*cdf0e10cSrcweir 
800*cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap = GetGroupShapeElemTokenMap();
801*cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir 	switch(rTokenMap.Get(p_nPrefix, rLocalName))
804*cdf0e10cSrcweir 	{
805*cdf0e10cSrcweir 		case XML_TOK_GROUP_GROUP:
806*cdf0e10cSrcweir 		{
807*cdf0e10cSrcweir 			// draw:g inside group context (RECURSIVE)
808*cdf0e10cSrcweir 			pContext = new SdXMLGroupShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape);
809*cdf0e10cSrcweir 			break;
810*cdf0e10cSrcweir 		}
811*cdf0e10cSrcweir 		case XML_TOK_GROUP_3DSCENE:
812*cdf0e10cSrcweir 		{
813*cdf0e10cSrcweir 			// dr3d:3dscene inside group context
814*cdf0e10cSrcweir 			pContext = new SdXML3DSceneShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape);
815*cdf0e10cSrcweir 			break;
816*cdf0e10cSrcweir 		}
817*cdf0e10cSrcweir 		case XML_TOK_GROUP_RECT:
818*cdf0e10cSrcweir 		{
819*cdf0e10cSrcweir 			// draw:rect inside group context
820*cdf0e10cSrcweir 			pContext = new SdXMLRectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
821*cdf0e10cSrcweir 			break;
822*cdf0e10cSrcweir 		}
823*cdf0e10cSrcweir 		case XML_TOK_GROUP_LINE:
824*cdf0e10cSrcweir 		{
825*cdf0e10cSrcweir 			// draw:line inside group context
826*cdf0e10cSrcweir 			pContext = new SdXMLLineShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
827*cdf0e10cSrcweir 			break;
828*cdf0e10cSrcweir 		}
829*cdf0e10cSrcweir 		case XML_TOK_GROUP_CIRCLE:
830*cdf0e10cSrcweir 		case XML_TOK_GROUP_ELLIPSE:
831*cdf0e10cSrcweir 		{
832*cdf0e10cSrcweir 			// draw:circle or draw:ellipse inside group context
833*cdf0e10cSrcweir 			pContext = new SdXMLEllipseShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
834*cdf0e10cSrcweir 			break;
835*cdf0e10cSrcweir 		}
836*cdf0e10cSrcweir 		case XML_TOK_GROUP_POLYGON:
837*cdf0e10cSrcweir 		case XML_TOK_GROUP_POLYLINE:
838*cdf0e10cSrcweir 		{
839*cdf0e10cSrcweir 			// draw:polygon or draw:polyline inside group context
840*cdf0e10cSrcweir 			pContext = new SdXMLPolygonShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes,
841*cdf0e10cSrcweir 				rTokenMap.Get(p_nPrefix, rLocalName) == XML_TOK_GROUP_POLYGON ? sal_True : sal_False, bTemporaryShape );
842*cdf0e10cSrcweir 			break;
843*cdf0e10cSrcweir 		}
844*cdf0e10cSrcweir 		case XML_TOK_GROUP_PATH:
845*cdf0e10cSrcweir 		{
846*cdf0e10cSrcweir 			// draw:path inside group context
847*cdf0e10cSrcweir 			pContext = new SdXMLPathShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape);
848*cdf0e10cSrcweir 			break;
849*cdf0e10cSrcweir 		}
850*cdf0e10cSrcweir 		case XML_TOK_GROUP_FRAME:
851*cdf0e10cSrcweir 		{
852*cdf0e10cSrcweir 			// text:text-box inside group context
853*cdf0e10cSrcweir 			pContext = new SdXMLFrameShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
854*cdf0e10cSrcweir 			break;
855*cdf0e10cSrcweir 		}
856*cdf0e10cSrcweir 		case XML_TOK_GROUP_CONTROL:
857*cdf0e10cSrcweir 		{
858*cdf0e10cSrcweir 			// draw:control inside group context
859*cdf0e10cSrcweir 			pContext = new SdXMLControlShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
860*cdf0e10cSrcweir 			break;
861*cdf0e10cSrcweir 		}
862*cdf0e10cSrcweir 		case XML_TOK_GROUP_CONNECTOR:
863*cdf0e10cSrcweir 		{
864*cdf0e10cSrcweir 			// draw:connector inside group context
865*cdf0e10cSrcweir 			pContext = new SdXMLConnectorShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
866*cdf0e10cSrcweir 			break;
867*cdf0e10cSrcweir 		}
868*cdf0e10cSrcweir 		case XML_TOK_GROUP_MEASURE:
869*cdf0e10cSrcweir 		{
870*cdf0e10cSrcweir 			// draw:measure inside group context
871*cdf0e10cSrcweir 			pContext = new SdXMLMeasureShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
872*cdf0e10cSrcweir 			break;
873*cdf0e10cSrcweir 		}
874*cdf0e10cSrcweir 		case XML_TOK_GROUP_PAGE:
875*cdf0e10cSrcweir 		{
876*cdf0e10cSrcweir 			// draw:page inside group context
877*cdf0e10cSrcweir 			pContext = new SdXMLPageShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
878*cdf0e10cSrcweir 			break;
879*cdf0e10cSrcweir 		}
880*cdf0e10cSrcweir 		case XML_TOK_GROUP_CAPTION:
881*cdf0e10cSrcweir         case XML_TOK_GROUP_ANNOTATION:
882*cdf0e10cSrcweir 		{
883*cdf0e10cSrcweir 			// draw:caption inside group context
884*cdf0e10cSrcweir 			pContext = new SdXMLCaptionShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
885*cdf0e10cSrcweir 			break;
886*cdf0e10cSrcweir 		}
887*cdf0e10cSrcweir 		case XML_TOK_GROUP_CHART:
888*cdf0e10cSrcweir 		{
889*cdf0e10cSrcweir 			// chart:chart inside group context
890*cdf0e10cSrcweir 			pContext = new SdXMLChartShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, bTemporaryShape );
891*cdf0e10cSrcweir 			break;
892*cdf0e10cSrcweir 		}
893*cdf0e10cSrcweir 		case XML_TOK_GROUP_CUSTOM_SHAPE:
894*cdf0e10cSrcweir 		{
895*cdf0e10cSrcweir 			// draw:customshape
896*cdf0e10cSrcweir 			pContext = new SdXMLCustomShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
897*cdf0e10cSrcweir 			break;
898*cdf0e10cSrcweir 		}
899*cdf0e10cSrcweir  		case XML_TOK_GROUP_A:
900*cdf0e10cSrcweir  		{
901*cdf0e10cSrcweir  			return new SdXMLShapeLinkContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes );
902*cdf0e10cSrcweir  		}
903*cdf0e10cSrcweir 		// add other shapes here...
904*cdf0e10cSrcweir 		default:
905*cdf0e10cSrcweir 			return new SvXMLShapeContext( rImport, p_nPrefix, rLocalName, bTemporaryShape );
906*cdf0e10cSrcweir 	}
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir 	// now parse the attribute list and call the child context for each unknown attribute
909*cdf0e10cSrcweir 	for(sal_Int16 a(0); a < nAttrCount; a++)
910*cdf0e10cSrcweir 	{
911*cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex(a);
912*cdf0e10cSrcweir 		OUString aLocalName;
913*cdf0e10cSrcweir 		sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
914*cdf0e10cSrcweir 		const OUString aValue( xAttrList->getValueByIndex(a) );
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 		pContext->processAttribute( nPrefix, aLocalName, aValue );
917*cdf0e10cSrcweir 	}
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir 	return pContext;
920*cdf0e10cSrcweir }
921*cdf0e10cSrcweir 
922*cdf0e10cSrcweir // This method is called from SdXMLFrameContext to create children of drawe:frame
923*cdf0e10cSrcweir SvXMLShapeContext* XMLShapeImportHelper::CreateFrameChildContext(
924*cdf0e10cSrcweir 	SvXMLImport& rImport,
925*cdf0e10cSrcweir 	sal_uInt16 p_nPrefix,
926*cdf0e10cSrcweir 	const OUString& rLocalName,
927*cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList>& rAttrList,
928*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
929*cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList>& rFrameAttrList)
930*cdf0e10cSrcweir {
931*cdf0e10cSrcweir 	SdXMLShapeContext *pContext = 0L;
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap = GetFrameShapeElemTokenMap();
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir 	SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList );
936*cdf0e10cSrcweir 	if( rFrameAttrList.is() )
937*cdf0e10cSrcweir 		pAttrList->AppendAttributeList( rFrameAttrList );
938*cdf0e10cSrcweir 	uno::Reference < xml::sax::XAttributeList > xAttrList = pAttrList;
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir 
941*cdf0e10cSrcweir 	switch(rTokenMap.Get(p_nPrefix, rLocalName))
942*cdf0e10cSrcweir 	{
943*cdf0e10cSrcweir 		case XML_TOK_FRAME_TEXT_BOX:
944*cdf0e10cSrcweir 		{
945*cdf0e10cSrcweir 			// text:text-box inside group context
946*cdf0e10cSrcweir 			pContext = new SdXMLTextBoxShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
947*cdf0e10cSrcweir 			break;
948*cdf0e10cSrcweir 		}
949*cdf0e10cSrcweir 		case XML_TOK_FRAME_IMAGE:
950*cdf0e10cSrcweir 		{
951*cdf0e10cSrcweir 			// office:image inside group context
952*cdf0e10cSrcweir 			pContext = new SdXMLGraphicObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
953*cdf0e10cSrcweir 			break;
954*cdf0e10cSrcweir 		}
955*cdf0e10cSrcweir 		case XML_TOK_FRAME_OBJECT:
956*cdf0e10cSrcweir 		case XML_TOK_FRAME_OBJECT_OLE:
957*cdf0e10cSrcweir 		{
958*cdf0e10cSrcweir 			// draw:object or draw:object_ole
959*cdf0e10cSrcweir 			pContext = new SdXMLObjectShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
960*cdf0e10cSrcweir 			break;
961*cdf0e10cSrcweir 		}
962*cdf0e10cSrcweir 		case XML_TOK_FRAME_TABLE:
963*cdf0e10cSrcweir 		{
964*cdf0e10cSrcweir 			// draw:object or draw:object_ole
965*cdf0e10cSrcweir 			if( rImport.IsTableShapeSupported() )
966*cdf0e10cSrcweir 				pContext = new SdXMLTableShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes );
967*cdf0e10cSrcweir 			break;
968*cdf0e10cSrcweir 
969*cdf0e10cSrcweir 		}
970*cdf0e10cSrcweir 		case XML_TOK_FRAME_PLUGIN:
971*cdf0e10cSrcweir 		{
972*cdf0e10cSrcweir 			// draw:plugin
973*cdf0e10cSrcweir 			pContext = new SdXMLPluginShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
974*cdf0e10cSrcweir 			break;
975*cdf0e10cSrcweir 		}
976*cdf0e10cSrcweir 		case XML_TOK_FRAME_FLOATING_FRAME:
977*cdf0e10cSrcweir 		{
978*cdf0e10cSrcweir 			// draw:floating-frame
979*cdf0e10cSrcweir 			pContext = new SdXMLFloatingFrameShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
980*cdf0e10cSrcweir 			break;
981*cdf0e10cSrcweir 		}
982*cdf0e10cSrcweir 		case XML_TOK_FRAME_APPLET:
983*cdf0e10cSrcweir 		{
984*cdf0e10cSrcweir 			// draw:applet
985*cdf0e10cSrcweir 			pContext = new SdXMLAppletShapeContext( rImport, p_nPrefix, rLocalName, xAttrList, rShapes, sal_False );
986*cdf0e10cSrcweir 			break;
987*cdf0e10cSrcweir 		}
988*cdf0e10cSrcweir 		// add other shapes here...
989*cdf0e10cSrcweir 		default:
990*cdf0e10cSrcweir 			break;
991*cdf0e10cSrcweir 	}
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir 	if( pContext )
994*cdf0e10cSrcweir 	{
995*cdf0e10cSrcweir 		// now parse the attribute list and call the child context for each unknown attribute
996*cdf0e10cSrcweir 		sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
997*cdf0e10cSrcweir 		for(sal_Int16 a(0); a < nAttrCount; a++)
998*cdf0e10cSrcweir 		{
999*cdf0e10cSrcweir 			const OUString& rAttrName = xAttrList->getNameByIndex(a);
1000*cdf0e10cSrcweir 			OUString aLocalName;
1001*cdf0e10cSrcweir 			sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
1002*cdf0e10cSrcweir 			const OUString aValue( xAttrList->getValueByIndex(a) );
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir 			pContext->processAttribute( nPrefix, aLocalName, aValue );
1005*cdf0e10cSrcweir 		}
1006*cdf0e10cSrcweir 	}
1007*cdf0e10cSrcweir 
1008*cdf0e10cSrcweir 	return pContext;
1009*cdf0e10cSrcweir }
1010*cdf0e10cSrcweir 
1011*cdf0e10cSrcweir SvXMLImportContext *XMLShapeImportHelper::CreateFrameChildContext(
1012*cdf0e10cSrcweir 	SvXMLImportContext *pThisContext,
1013*cdf0e10cSrcweir 	sal_uInt16 nPrefix,
1014*cdf0e10cSrcweir 	const OUString& rLocalName,
1015*cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList>& xAttrList )
1016*cdf0e10cSrcweir {
1017*cdf0e10cSrcweir 	SvXMLImportContext * pContext = NULL;
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir 	SdXMLFrameShapeContext *pFrameContext = PTR_CAST( SdXMLFrameShapeContext, pThisContext );
1020*cdf0e10cSrcweir 	if( pFrameContext )
1021*cdf0e10cSrcweir 		pContext = pFrameContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
1022*cdf0e10cSrcweir 
1023*cdf0e10cSrcweir 	return pContext;
1024*cdf0e10cSrcweir }
1025*cdf0e10cSrcweir 
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir /** this function is called whenever the implementation classes like to add this new
1028*cdf0e10cSrcweir 	shape to the given XShapes.
1029*cdf0e10cSrcweir */
1030*cdf0e10cSrcweir void XMLShapeImportHelper::addShape( uno::Reference< drawing::XShape >& rShape,
1031*cdf0e10cSrcweir 									 const uno::Reference< xml::sax::XAttributeList >&,
1032*cdf0e10cSrcweir 									 uno::Reference< drawing::XShapes >& rShapes)
1033*cdf0e10cSrcweir {
1034*cdf0e10cSrcweir 	if( rShape.is() && rShapes.is() )
1035*cdf0e10cSrcweir 	{
1036*cdf0e10cSrcweir 		// add new shape to parent
1037*cdf0e10cSrcweir 		rShapes->add( rShape );
1038*cdf0e10cSrcweir 	}
1039*cdf0e10cSrcweir }
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir /** this function is called whenever the implementation classes have finished importing
1042*cdf0e10cSrcweir 	a shape to the given XShapes. The shape is already inserted into its XShapes and
1043*cdf0e10cSrcweir 	all properties and styles are set.
1044*cdf0e10cSrcweir */
1045*cdf0e10cSrcweir void XMLShapeImportHelper::finishShape(
1046*cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape,
1047*cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >&,
1048*cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >&)
1049*cdf0e10cSrcweir {
1050*cdf0e10cSrcweir     // --> OD 2004-08-10 #i28749#, #i36248# - set property <PositionLayoutDir>
1051*cdf0e10cSrcweir     // to <PositionInHoriL2R>, if it exists and the import states that
1052*cdf0e10cSrcweir     // the shape positioning attributes are in horizontal left-to-right
1053*cdf0e10cSrcweir     // layout. This is the case for the OpenOffice.org file format.
1054*cdf0e10cSrcweir     // This setting is done for Writer documents, because the property
1055*cdf0e10cSrcweir     // only exists at service com::sun::star::text::Shape - the Writer
1056*cdf0e10cSrcweir     // UNO service for shapes.
1057*cdf0e10cSrcweir     // The value indicates that the positioning attributes are given
1058*cdf0e10cSrcweir     // in horizontal left-to-right layout. The property is evaluated
1059*cdf0e10cSrcweir     // during the first positioning of the shape in order to convert
1060*cdf0e10cSrcweir     // the shape position given in the OpenOffice.org file format to
1061*cdf0e10cSrcweir     // the one for the OASIS Open Office file format.
1062*cdf0e10cSrcweir     uno::Reference< beans::XPropertySet > xPropSet(rShape, uno::UNO_QUERY);
1063*cdf0e10cSrcweir     if ( xPropSet.is() )
1064*cdf0e10cSrcweir     {
1065*cdf0e10cSrcweir         if ( mrImporter.IsShapePositionInHoriL2R() &&
1066*cdf0e10cSrcweir              xPropSet->getPropertySetInfo()->hasPropertyByName(
1067*cdf0e10cSrcweir                 OUString(RTL_CONSTASCII_USTRINGPARAM("PositionLayoutDir"))) )
1068*cdf0e10cSrcweir         {
1069*cdf0e10cSrcweir             uno::Any aPosLayoutDir;
1070*cdf0e10cSrcweir             aPosLayoutDir <<= text::PositionLayoutDir::PositionInHoriL2R;
1071*cdf0e10cSrcweir             xPropSet->setPropertyValue(
1072*cdf0e10cSrcweir                 OUString(RTL_CONSTASCII_USTRINGPARAM("PositionLayoutDir")),
1073*cdf0e10cSrcweir                 aPosLayoutDir );
1074*cdf0e10cSrcweir         }
1075*cdf0e10cSrcweir     }
1076*cdf0e10cSrcweir     // <--
1077*cdf0e10cSrcweir }
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir // helper functions for z-order sorting
1080*cdf0e10cSrcweir struct ZOrderHint
1081*cdf0e10cSrcweir {
1082*cdf0e10cSrcweir 	sal_Int32 nIs;
1083*cdf0e10cSrcweir 	sal_Int32 nShould;
1084*cdf0e10cSrcweir 
1085*cdf0e10cSrcweir 	int operator<(const ZOrderHint& rComp) const { return nShould < rComp.nShould; }
1086*cdf0e10cSrcweir };
1087*cdf0e10cSrcweir 
1088*cdf0e10cSrcweir class ShapeSortContext
1089*cdf0e10cSrcweir {
1090*cdf0e10cSrcweir public:
1091*cdf0e10cSrcweir 	uno::Reference< drawing::XShapes > mxShapes;
1092*cdf0e10cSrcweir 	list<ZOrderHint>			  maZOrderList;
1093*cdf0e10cSrcweir 	list<ZOrderHint>			  maUnsortedList;
1094*cdf0e10cSrcweir 
1095*cdf0e10cSrcweir 	sal_Int32					  mnCurrentZ;
1096*cdf0e10cSrcweir 	ShapeSortContext*			  mpParentContext;
1097*cdf0e10cSrcweir 	const OUString				  msZOrder;
1098*cdf0e10cSrcweir 
1099*cdf0e10cSrcweir 	ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext = NULL );
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir 	void moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos );
1102*cdf0e10cSrcweir };
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir ShapeSortContext::ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext )
1105*cdf0e10cSrcweir :	mxShapes( rShapes ), mnCurrentZ( 0 ), mpParentContext( pParentContext ),
1106*cdf0e10cSrcweir 	msZOrder(RTL_CONSTASCII_USTRINGPARAM("ZOrder"))
1107*cdf0e10cSrcweir {
1108*cdf0e10cSrcweir }
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos )
1111*cdf0e10cSrcweir {
1112*cdf0e10cSrcweir 	uno::Any aAny( mxShapes->getByIndex( nSourcePos ) );
1113*cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > xPropSet;
1114*cdf0e10cSrcweir 	aAny >>= xPropSet;
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir 	if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( msZOrder ) )
1117*cdf0e10cSrcweir 	{
1118*cdf0e10cSrcweir 		aAny <<= nDestPos;
1119*cdf0e10cSrcweir 		xPropSet->setPropertyValue( msZOrder, aAny );
1120*cdf0e10cSrcweir 
1121*cdf0e10cSrcweir 		list<ZOrderHint>::iterator aIter = maZOrderList.begin();
1122*cdf0e10cSrcweir 		list<ZOrderHint>::iterator aEnd = maZOrderList.end();
1123*cdf0e10cSrcweir 
1124*cdf0e10cSrcweir 		while( aIter != aEnd )
1125*cdf0e10cSrcweir 		{
1126*cdf0e10cSrcweir 			if( (*aIter).nIs < nSourcePos )
1127*cdf0e10cSrcweir 			{
1128*cdf0e10cSrcweir 				DBG_ASSERT( (*aIter).nIs >= nDestPos, "Shape sorting failed" );
1129*cdf0e10cSrcweir 				(*aIter).nIs++;
1130*cdf0e10cSrcweir 			}
1131*cdf0e10cSrcweir 			aIter++;
1132*cdf0e10cSrcweir 		}
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir 		aIter = maUnsortedList.begin();
1135*cdf0e10cSrcweir 		aEnd = maUnsortedList.end();
1136*cdf0e10cSrcweir 
1137*cdf0e10cSrcweir 		while( aIter != aEnd )
1138*cdf0e10cSrcweir 		{
1139*cdf0e10cSrcweir 			if( (*aIter).nIs < nSourcePos )
1140*cdf0e10cSrcweir 			{
1141*cdf0e10cSrcweir 				DBG_ASSERT( (*aIter).nIs >= nDestPos, "shape sorting failed" );
1142*cdf0e10cSrcweir 				(*aIter).nIs++;
1143*cdf0e10cSrcweir 			}
1144*cdf0e10cSrcweir 			aIter++;
1145*cdf0e10cSrcweir 		}
1146*cdf0e10cSrcweir 	}
1147*cdf0e10cSrcweir }
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir void XMLShapeImportHelper::pushGroupForSorting( uno::Reference< drawing::XShapes >& rShapes )
1150*cdf0e10cSrcweir {
1151*cdf0e10cSrcweir 	mpImpl->mpSortContext = new ShapeSortContext( rShapes, mpImpl->mpSortContext );
1152*cdf0e10cSrcweir }
1153*cdf0e10cSrcweir 
1154*cdf0e10cSrcweir void XMLShapeImportHelper::popGroupAndSort()
1155*cdf0e10cSrcweir {
1156*cdf0e10cSrcweir 	DBG_ASSERT( mpImpl->mpSortContext, "No context to sort!" );
1157*cdf0e10cSrcweir 	if( mpImpl->mpSortContext == NULL )
1158*cdf0e10cSrcweir 		return;
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir 	try
1161*cdf0e10cSrcweir 	{
1162*cdf0e10cSrcweir 		list<ZOrderHint>& rZList = mpImpl->mpSortContext->maZOrderList;
1163*cdf0e10cSrcweir 		list<ZOrderHint>& rUnsortedList = mpImpl->mpSortContext->maUnsortedList;
1164*cdf0e10cSrcweir 
1165*cdf0e10cSrcweir 		// sort shapes
1166*cdf0e10cSrcweir 		if( !rZList.empty() )
1167*cdf0e10cSrcweir 		{
1168*cdf0e10cSrcweir 			// only do something if we have shapes to sort
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir 			// check if there are more shapes than inserted with ::shapeWithZIndexAdded()
1171*cdf0e10cSrcweir 			// This can happen if there where already shapes on the page before import
1172*cdf0e10cSrcweir 			// Since the writer may delete some of this shapes during import, we need
1173*cdf0e10cSrcweir 			// to do this here and not in our c'tor anymore
1174*cdf0e10cSrcweir 
1175*cdf0e10cSrcweir 			// check if we have more shapes than we know of
1176*cdf0e10cSrcweir 			sal_Int32 nCount = mpImpl->mpSortContext->mxShapes->getCount();
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir 			nCount -= rZList.size();
1179*cdf0e10cSrcweir 			nCount -= rUnsortedList.size();
1180*cdf0e10cSrcweir 
1181*cdf0e10cSrcweir 
1182*cdf0e10cSrcweir 			if( nCount > 0 )
1183*cdf0e10cSrcweir 			{
1184*cdf0e10cSrcweir 				// first update offsets of added shapes
1185*cdf0e10cSrcweir 				list<ZOrderHint>::iterator aIter( rZList.begin() );
1186*cdf0e10cSrcweir 				while( aIter != rZList.end() )
1187*cdf0e10cSrcweir 					(*aIter++).nIs += nCount;
1188*cdf0e10cSrcweir 
1189*cdf0e10cSrcweir 				aIter = rUnsortedList.begin();
1190*cdf0e10cSrcweir 				while( aIter != rUnsortedList.end() )
1191*cdf0e10cSrcweir 					(*aIter++).nIs += nCount;
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir 				// second add the already existing shapes in the unsorted list
1194*cdf0e10cSrcweir 				ZOrderHint aNewHint;
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir 				do
1197*cdf0e10cSrcweir 				{
1198*cdf0e10cSrcweir 					nCount--;
1199*cdf0e10cSrcweir 
1200*cdf0e10cSrcweir 					aNewHint.nIs = nCount;
1201*cdf0e10cSrcweir 					aNewHint.nShould = -1;
1202*cdf0e10cSrcweir 
1203*cdf0e10cSrcweir 					rUnsortedList.insert(rUnsortedList.begin(), aNewHint);
1204*cdf0e10cSrcweir 				}
1205*cdf0e10cSrcweir 				while( nCount );
1206*cdf0e10cSrcweir 			}
1207*cdf0e10cSrcweir 
1208*cdf0e10cSrcweir 			// sort z ordered shapes
1209*cdf0e10cSrcweir 			rZList.sort();
1210*cdf0e10cSrcweir 
1211*cdf0e10cSrcweir 			// this is the current index, all shapes before that
1212*cdf0e10cSrcweir 			// index are finished
1213*cdf0e10cSrcweir 			sal_Int32 nIndex = 0;
1214*cdf0e10cSrcweir 			while( !rZList.empty() )
1215*cdf0e10cSrcweir 			{
1216*cdf0e10cSrcweir 				list<ZOrderHint>::iterator aIter( rZList.begin() );
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir 				while( nIndex < (*aIter).nShould && !rUnsortedList.empty() )
1219*cdf0e10cSrcweir 				{
1220*cdf0e10cSrcweir 					ZOrderHint aGapHint( *rUnsortedList.begin() );
1221*cdf0e10cSrcweir 					rUnsortedList.pop_front();
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir 					mpImpl->mpSortContext->moveShape( aGapHint.nIs, nIndex++ );
1224*cdf0e10cSrcweir 				}
1225*cdf0e10cSrcweir 
1226*cdf0e10cSrcweir 				if( (*aIter).nIs != nIndex )
1227*cdf0e10cSrcweir 					mpImpl->mpSortContext->moveShape( (*aIter).nIs, nIndex );
1228*cdf0e10cSrcweir 
1229*cdf0e10cSrcweir 				rZList.pop_front();
1230*cdf0e10cSrcweir 				nIndex++;
1231*cdf0e10cSrcweir 			}
1232*cdf0e10cSrcweir 		}
1233*cdf0e10cSrcweir 	}
1234*cdf0e10cSrcweir 	catch( uno::Exception& )
1235*cdf0e10cSrcweir 	{
1236*cdf0e10cSrcweir 		DBG_ERROR("exception while sorting shapes, sorting failed!");
1237*cdf0e10cSrcweir 	}
1238*cdf0e10cSrcweir 
1239*cdf0e10cSrcweir 	// put parent on top and delete current context, were done
1240*cdf0e10cSrcweir 	ShapeSortContext* pContext = mpImpl->mpSortContext;
1241*cdf0e10cSrcweir 	mpImpl->mpSortContext = pContext->mpParentContext;
1242*cdf0e10cSrcweir 	delete pContext;
1243*cdf0e10cSrcweir }
1244*cdf0e10cSrcweir 
1245*cdf0e10cSrcweir void XMLShapeImportHelper::shapeWithZIndexAdded( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >&, sal_Int32 nZIndex )
1246*cdf0e10cSrcweir {
1247*cdf0e10cSrcweir 	if( mpImpl->mpSortContext)
1248*cdf0e10cSrcweir 	{
1249*cdf0e10cSrcweir 		ZOrderHint aNewHint;
1250*cdf0e10cSrcweir 		aNewHint.nIs = mpImpl->mpSortContext->mnCurrentZ++;
1251*cdf0e10cSrcweir 		aNewHint.nShould = nZIndex;
1252*cdf0e10cSrcweir 
1253*cdf0e10cSrcweir 		if( nZIndex == -1 )
1254*cdf0e10cSrcweir 		{
1255*cdf0e10cSrcweir 			// don't care, so add to unsorted list
1256*cdf0e10cSrcweir 			mpImpl->mpSortContext->maUnsortedList.push_back(aNewHint);
1257*cdf0e10cSrcweir 		}
1258*cdf0e10cSrcweir 		else
1259*cdf0e10cSrcweir 		{
1260*cdf0e10cSrcweir 			// insert into sort list
1261*cdf0e10cSrcweir 			mpImpl->mpSortContext->maZOrderList.push_back(aNewHint);
1262*cdf0e10cSrcweir 		}
1263*cdf0e10cSrcweir 	}
1264*cdf0e10cSrcweir }
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir void XMLShapeImportHelper::addShapeConnection( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rConnectorShape,
1267*cdf0e10cSrcweir 						 sal_Bool bStart,
1268*cdf0e10cSrcweir 						 const rtl::OUString& rDestShapeId,
1269*cdf0e10cSrcweir 						 sal_Int32 nDestGlueId )
1270*cdf0e10cSrcweir {
1271*cdf0e10cSrcweir 	ConnectionHint aHint;
1272*cdf0e10cSrcweir 	aHint.mxConnector = rConnectorShape;
1273*cdf0e10cSrcweir 	aHint.bStart = bStart;
1274*cdf0e10cSrcweir 	aHint.aDestShapeId = rDestShapeId;
1275*cdf0e10cSrcweir 	aHint.nDestGlueId = nDestGlueId;
1276*cdf0e10cSrcweir 
1277*cdf0e10cSrcweir 	mpImpl->maConnections.push_back( aHint );
1278*cdf0e10cSrcweir }
1279*cdf0e10cSrcweir 
1280*cdf0e10cSrcweir void XMLShapeImportHelper::restoreConnections()
1281*cdf0e10cSrcweir {
1282*cdf0e10cSrcweir 	if( !mpImpl->maConnections.empty() )
1283*cdf0e10cSrcweir 	{
1284*cdf0e10cSrcweir 		uno::Any aAny;
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir 		const vector<ConnectionHint>::size_type nCount = mpImpl->maConnections.size();
1287*cdf0e10cSrcweir 		for( vector<ConnectionHint>::size_type i = 0; i < nCount; i++ )
1288*cdf0e10cSrcweir 		{
1289*cdf0e10cSrcweir 			ConnectionHint& rHint = mpImpl->maConnections[i];
1290*cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xConnector( rHint.mxConnector, uno::UNO_QUERY );
1291*cdf0e10cSrcweir 			if( xConnector.is() )
1292*cdf0e10cSrcweir 			{
1293*cdf0e10cSrcweir 				// #86637# remember line deltas
1294*cdf0e10cSrcweir 				uno::Any aLine1Delta;
1295*cdf0e10cSrcweir 				uno::Any aLine2Delta;
1296*cdf0e10cSrcweir 				uno::Any aLine3Delta;
1297*cdf0e10cSrcweir 				OUString aStr1(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta"));
1298*cdf0e10cSrcweir 				OUString aStr2(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta"));
1299*cdf0e10cSrcweir 				OUString aStr3(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta"));
1300*cdf0e10cSrcweir 				aLine1Delta = xConnector->getPropertyValue(aStr1);
1301*cdf0e10cSrcweir 				aLine2Delta = xConnector->getPropertyValue(aStr2);
1302*cdf0e10cSrcweir 				aLine3Delta = xConnector->getPropertyValue(aStr3);
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir 				// #86637# simply setting these values WILL force the connector to do
1305*cdf0e10cSrcweir 				// an new layout promptly. So the line delta values have to be rescued
1306*cdf0e10cSrcweir 				// and restored around connector changes.
1307*cdf0e10cSrcweir 				uno::Reference< drawing::XShape > xShape(
1308*cdf0e10cSrcweir 					mrImporter.getInterfaceToIdentifierMapper().getReference( rHint.aDestShapeId ), uno::UNO_QUERY );
1309*cdf0e10cSrcweir 				if( xShape.is() )
1310*cdf0e10cSrcweir 				{
1311*cdf0e10cSrcweir 					aAny <<= xShape;
1312*cdf0e10cSrcweir 					xConnector->setPropertyValue( rHint.bStart ? msStartShape : msEndShape, aAny );
1313*cdf0e10cSrcweir 
1314*cdf0e10cSrcweir 					sal_Int32 nGlueId = rHint.nDestGlueId < 4 ? rHint.nDestGlueId : getGluePointId( xShape, rHint.nDestGlueId );
1315*cdf0e10cSrcweir 					aAny <<= nGlueId;
1316*cdf0e10cSrcweir 					xConnector->setPropertyValue( rHint.bStart ? msStartGluePointIndex : msEndGluePointIndex, aAny );
1317*cdf0e10cSrcweir 				}
1318*cdf0e10cSrcweir 
1319*cdf0e10cSrcweir 				// #86637# restore line deltas
1320*cdf0e10cSrcweir 				xConnector->setPropertyValue(aStr1, aLine1Delta );
1321*cdf0e10cSrcweir 				xConnector->setPropertyValue(aStr2, aLine2Delta );
1322*cdf0e10cSrcweir 				xConnector->setPropertyValue(aStr3, aLine3Delta );
1323*cdf0e10cSrcweir 			}
1324*cdf0e10cSrcweir 		}
1325*cdf0e10cSrcweir 		mpImpl->maConnections.clear();
1326*cdf0e10cSrcweir 	}
1327*cdf0e10cSrcweir }
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir SvXMLImportPropertyMapper* XMLShapeImportHelper::CreateShapePropMapper( const uno::Reference< frame::XModel>& rModel, SvXMLImport& rImport )
1330*cdf0e10cSrcweir {
1331*cdf0e10cSrcweir 	UniReference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rModel, rImport );
1332*cdf0e10cSrcweir 	UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory );
1333*cdf0e10cSrcweir 	SvXMLImportPropertyMapper* pResult = new SvXMLImportPropertyMapper( xMapper, rImport );
1334*cdf0e10cSrcweir 
1335*cdf0e10cSrcweir 	// chain text attributes
1336*cdf0e10cSrcweir 	pResult->ChainImportMapper( XMLTextImportHelper::CreateParaExtPropMapper( rImport ) );
1337*cdf0e10cSrcweir 	return pResult;
1338*cdf0e10cSrcweir }
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir /** creates a shape property set mapper that can be used for non shape elements.
1341*cdf0e10cSrcweir 	Only current feature is that the ShapeUserDefinedAttributes property is not included in this one. */
1342*cdf0e10cSrcweir SvXMLImportPropertyMapper* XMLShapeImportHelper::CreateExternalShapePropMapper( const uno::Reference< frame::XModel>& rModel, SvXMLImport& rImport )
1343*cdf0e10cSrcweir {
1344*cdf0e10cSrcweir 	UniReference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rModel, rImport );
1345*cdf0e10cSrcweir 	UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory, 1 );
1346*cdf0e10cSrcweir 	SvXMLImportPropertyMapper* pResult = new SvXMLImportPropertyMapper( xMapper, rImport );
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir 	// chain text attributes
1349*cdf0e10cSrcweir 	pResult->ChainImportMapper( XMLTextImportHelper::CreateParaExtPropMapper( rImport ) );
1350*cdf0e10cSrcweir 	return pResult;
1351*cdf0e10cSrcweir }
1352*cdf0e10cSrcweir 
1353*cdf0e10cSrcweir /** adds a mapping for a glue point identifier from an xml file to the identifier created after inserting
1354*cdf0e10cSrcweir 	the new glue point into the core. The saved mappings can be retrieved by getGluePointId() */
1355*cdf0e10cSrcweir void XMLShapeImportHelper::addGluePointMapping( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape,
1356*cdf0e10cSrcweir 						  sal_Int32 nSourceId, sal_Int32 nDestinnationId )
1357*cdf0e10cSrcweir {
1358*cdf0e10cSrcweir 	if( mpPageContext )
1359*cdf0e10cSrcweir 		mpPageContext->maShapeGluePointsMap[xShape][nSourceId] = nDestinnationId;
1360*cdf0e10cSrcweir }
1361*cdf0e10cSrcweir 
1362*cdf0e10cSrcweir /** moves all current DestinationId's by n */
1363*cdf0e10cSrcweir void XMLShapeImportHelper::moveGluePointMapping( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, const sal_Int32 n )
1364*cdf0e10cSrcweir {
1365*cdf0e10cSrcweir 	if( mpPageContext )
1366*cdf0e10cSrcweir 	{
1367*cdf0e10cSrcweir 		ShapeGluePointsMap::iterator aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
1368*cdf0e10cSrcweir 		if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
1369*cdf0e10cSrcweir 		{
1370*cdf0e10cSrcweir 			GluePointIdMap::iterator aShapeIdIter = (*aShapeIter).second.begin();
1371*cdf0e10cSrcweir 			GluePointIdMap::iterator aShapeIdEnd  = (*aShapeIter).second.end();
1372*cdf0e10cSrcweir 			while ( aShapeIdIter != aShapeIdEnd )
1373*cdf0e10cSrcweir 			{
1374*cdf0e10cSrcweir 				if ( (*aShapeIdIter).second != -1 )
1375*cdf0e10cSrcweir 					(*aShapeIdIter).second += n;
1376*cdf0e10cSrcweir 				aShapeIdIter++;
1377*cdf0e10cSrcweir 			}
1378*cdf0e10cSrcweir 		}
1379*cdf0e10cSrcweir 	}
1380*cdf0e10cSrcweir }
1381*cdf0e10cSrcweir 
1382*cdf0e10cSrcweir /** retrieves a mapping for a glue point identifier from the current xml file to the identifier created after
1383*cdf0e10cSrcweir 	inserting the new glue point into the core. The mapping must be initialized first with addGluePointMapping() */
1384*cdf0e10cSrcweir sal_Int32 XMLShapeImportHelper::getGluePointId( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, sal_Int32 nSourceId )
1385*cdf0e10cSrcweir {
1386*cdf0e10cSrcweir 	if( mpPageContext )
1387*cdf0e10cSrcweir 	{
1388*cdf0e10cSrcweir 		ShapeGluePointsMap::iterator aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
1389*cdf0e10cSrcweir 		if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
1390*cdf0e10cSrcweir 		{
1391*cdf0e10cSrcweir 			GluePointIdMap::iterator aIdIter = (*aShapeIter).second.find(nSourceId);
1392*cdf0e10cSrcweir 			if( aIdIter != (*aShapeIter).second.end() )
1393*cdf0e10cSrcweir 				return (*aIdIter).second;
1394*cdf0e10cSrcweir 		}
1395*cdf0e10cSrcweir 	}
1396*cdf0e10cSrcweir 
1397*cdf0e10cSrcweir 	return -1;
1398*cdf0e10cSrcweir }
1399*cdf0e10cSrcweir 
1400*cdf0e10cSrcweir /** this method must be calling before the first shape is imported for the given page */
1401*cdf0e10cSrcweir void XMLShapeImportHelper::startPage( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes )
1402*cdf0e10cSrcweir {
1403*cdf0e10cSrcweir 	XMLShapeImportPageContextImpl* pOldContext = mpPageContext;
1404*cdf0e10cSrcweir 	mpPageContext = new XMLShapeImportPageContextImpl();
1405*cdf0e10cSrcweir 	mpPageContext->mpNext = pOldContext;
1406*cdf0e10cSrcweir 	mpPageContext->mxShapes = rShapes;
1407*cdf0e10cSrcweir }
1408*cdf0e10cSrcweir 
1409*cdf0e10cSrcweir /** this method must be calling after the last shape is imported for the given page */
1410*cdf0e10cSrcweir void XMLShapeImportHelper::endPage( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >&
1411*cdf0e10cSrcweir #ifdef DBG_UTIL
1412*cdf0e10cSrcweir rShapes
1413*cdf0e10cSrcweir #endif
1414*cdf0e10cSrcweir )
1415*cdf0e10cSrcweir {
1416*cdf0e10cSrcweir 	DBG_ASSERT( mpPageContext && (mpPageContext->mxShapes == rShapes), "wrong call to endPage(), no startPage called or wrong page" );
1417*cdf0e10cSrcweir 	if( NULL == mpPageContext )
1418*cdf0e10cSrcweir 		return;
1419*cdf0e10cSrcweir 
1420*cdf0e10cSrcweir 	restoreConnections();
1421*cdf0e10cSrcweir 
1422*cdf0e10cSrcweir 	XMLShapeImportPageContextImpl* pNextContext = mpPageContext->mpNext;
1423*cdf0e10cSrcweir 	delete mpPageContext;
1424*cdf0e10cSrcweir 	mpPageContext = pNextContext;
1425*cdf0e10cSrcweir }
1426*cdf0e10cSrcweir 
1427*cdf0e10cSrcweir // #88546#
1428*cdf0e10cSrcweir /** defines if the import should increment the progress bar or not */
1429*cdf0e10cSrcweir void XMLShapeImportHelper::enableHandleProgressBar( sal_Bool bEnable )
1430*cdf0e10cSrcweir {
1431*cdf0e10cSrcweir 	mpImpl->mbHandleProgressBar = bEnable;
1432*cdf0e10cSrcweir }
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir sal_Bool XMLShapeImportHelper::IsHandleProgressBarEnabled() const
1435*cdf0e10cSrcweir {
1436*cdf0e10cSrcweir 	return mpImpl->mbHandleProgressBar;
1437*cdf0e10cSrcweir }
1438*cdf0e10cSrcweir 
1439*cdf0e10cSrcweir /** queries the capability of the current model to create presentation shapes */
1440*cdf0e10cSrcweir sal_Bool XMLShapeImportHelper::IsPresentationShapesSupported()
1441*cdf0e10cSrcweir {
1442*cdf0e10cSrcweir 	return mpImpl->mbIsPresentationShapesSupported;
1443*cdf0e10cSrcweir }
1444*cdf0e10cSrcweir 
1445*cdf0e10cSrcweir const rtl::Reference< XMLTableImport >& XMLShapeImportHelper::GetShapeTableImport()
1446*cdf0e10cSrcweir {
1447*cdf0e10cSrcweir 	if( !mxShapeTableImport.is() )
1448*cdf0e10cSrcweir 	{
1449*cdf0e10cSrcweir 		rtl::Reference< XMLPropertyHandlerFactory > xFactory( new XMLSdPropHdlFactory( mrImporter.GetModel(), mrImporter ) );
1450*cdf0e10cSrcweir 		rtl::Reference< XMLPropertySetMapper > xPropertySetMapper( new XMLShapePropertySetMapper( xFactory.get() ) );
1451*cdf0e10cSrcweir 		mxShapeTableImport = new XMLTableImport( mrImporter, xPropertySetMapper, xFactory );
1452*cdf0e10cSrcweir 	}
1453*cdf0e10cSrcweir 
1454*cdf0e10cSrcweir 	return mxShapeTableImport;
1455*cdf0e10cSrcweir }
1456*cdf0e10cSrcweir 
1457*cdf0e10cSrcweir void SvXMLShapeContext::setHyperlink( const OUString& rHyperlink )
1458*cdf0e10cSrcweir {
1459*cdf0e10cSrcweir 	msHyperlink = rHyperlink;
1460*cdf0e10cSrcweir }
1461