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