1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_XMLOFF_SHAPEIMPORT_HXX
#define INCLUDED_XMLOFF_SHAPEIMPORT_HXX
#include <sal/config.h>
#include <xmloff/dllapi.h>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/drawing/HomogenMatrix.hpp>
#include <com/sun/star/drawing/ProjectionMode.hpp>
#include <com/sun/star/drawing/ShadeMode.hpp>
#include <salhelper/simplereferenceobject.hxx>
#include <xmloff/xmlictxt.hxx>
#include <xmloff/table/XMLTableImport.hxx>
#include <basegfx/vector/b3dvector.hxx>
#include <vector>
class SvXMLImport;
class SvXMLImportContext;
class SvXMLTokenMap;
class SvXMLStylesContext;
class XMLSdPropHdlFactory;
class XMLPropertySetMapper;
class SvXMLImportPropertyMapper;
enum SdXMLGroupShapeElemTokenMap
{
XML_TOK_GROUP_GROUP,
XML_TOK_GROUP_RECT,
XML_TOK_GROUP_LINE,
XML_TOK_GROUP_CIRCLE,
XML_TOK_GROUP_ELLIPSE,
XML_TOK_GROUP_POLYGON,
XML_TOK_GROUP_POLYLINE,
XML_TOK_GROUP_PATH,
XML_TOK_GROUP_CONTROL,
XML_TOK_GROUP_CONNECTOR,
XML_TOK_GROUP_MEASURE,
XML_TOK_GROUP_PAGE,
XML_TOK_GROUP_CAPTION,
XML_TOK_GROUP_CHART,
XML_TOK_GROUP_3DSCENE,
XML_TOK_GROUP_FRAME,
XML_TOK_GROUP_CUSTOM_SHAPE,
XML_TOK_GROUP_ANNOTATION,
XML_TOK_GROUP_A,
XML_TOK_GROUP_LAST
};
enum SdXMLFrameShapeElemTokenMap
{
XML_TOK_FRAME_TEXT_BOX,
XML_TOK_FRAME_IMAGE,
XML_TOK_FRAME_OBJECT,
XML_TOK_FRAME_OBJECT_OLE,
XML_TOK_FRAME_PLUGIN,
XML_TOK_FRAME_FRAME,
XML_TOK_FRAME_FLOATING_FRAME,
XML_TOK_FRAME_APPLET,
XML_TOK_FRAME_TABLE,
XML_TOK_FRAME_LAST
};
enum SdXML3DSceneShapeElemTokenMap
{
XML_TOK_3DSCENE_3DSCENE,
XML_TOK_3DSCENE_3DCUBE,
XML_TOK_3DSCENE_3DSPHERE,
XML_TOK_3DSCENE_3DLATHE,
XML_TOK_3DSCENE_3DEXTRUDE,
XML_TOK_3DSCENE_LAST
};
enum SdXMLShapeAttrTokenMap
{
XML_TOK_SHAPE_NAME,
XML_TOK_SHAPE_DRAWSTYLE_NAME_GRAPHICS,
XML_TOK_SHAPE_PRESENTATION_CLASS,
XML_TOK_SHAPE_DRAWSTYLE_NAME_PRESENTATION,
XML_TOK_SHAPE_TRANSFORM,
XML_TOK_SHAPE_IS_PLACEHOLDER,
XML_TOK_SHAPE_IS_USER_TRANSFORMED
};
enum SdXML3DObjectAttrTokenMap
{
XML_TOK_3DOBJECT_DRAWSTYLE_NAME,
XML_TOK_3DOBJECT_TRANSFORM
};
enum SdXML3DPolygonBasedAttrTokenMap
{
XML_TOK_3DPOLYGONBASED_VIEWBOX,
XML_TOK_3DPOLYGONBASED_D
};
enum SdXML3DCubeObjectAttrTokenMap
{
XML_TOK_3DCUBEOBJ_MINEDGE,
XML_TOK_3DCUBEOBJ_MAXEDGE
};
enum SdXML3DSphereObjectAttrTokenMap
{
XML_TOK_3DSPHEREOBJ_CENTER,
XML_TOK_3DSPHEREOBJ_SIZE
};
enum SdXMLPolygonShapeAttrTokenMap
{
XML_TOK_POLYGONSHAPE_VIEWBOX,
XML_TOK_POLYGONSHAPE_POINTS
};
enum SdXMLPathShapeAttrTokenMap
{
XML_TOK_PATHSHAPE_VIEWBOX,
XML_TOK_PATHSHAPE_D
};
enum SdXML3DSceneShapeAttrTokenMap
{
XML_TOK_3DSCENESHAPE_TRANSFORM,
XML_TOK_3DSCENESHAPE_VRP,
XML_TOK_3DSCENESHAPE_VPN,
XML_TOK_3DSCENESHAPE_VUP,
XML_TOK_3DSCENESHAPE_PROJECTION,
XML_TOK_3DSCENESHAPE_DISTANCE,
XML_TOK_3DSCENESHAPE_FOCAL_LENGTH,
XML_TOK_3DSCENESHAPE_SHADOW_SLANT,
XML_TOK_3DSCENESHAPE_SHADE_MODE,
XML_TOK_3DSCENESHAPE_AMBIENT_COLOR,
XML_TOK_3DSCENESHAPE_LIGHTING_MODE
};
enum SdXML3DLightAttrTokenMap
{
XML_TOK_3DLIGHT_DIFFUSE_COLOR,
XML_TOK_3DLIGHT_DIRECTION,
XML_TOK_3DLIGHT_ENABLED,
XML_TOK_3DLIGHT_SPECULAR
};
// dr3d:3dlight context
class SdXML3DLightContext: public SvXMLImportContext
{
// local parameters which need to be read
sal_Int32 maDiffuseColor;
::basegfx::B3DVector maDirection;
bool mbEnabled;
bool mbSpecular;
public:
SdXML3DLightContext(
SvXMLImport& rImport,
sal_uInt16 nPrfx,
const OUString& rLName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
virtual ~SdXML3DLightContext();
sal_Int32 GetDiffuseColor() { return maDiffuseColor; }
const ::basegfx::B3DVector& GetDirection() { return maDirection; }
bool GetEnabled() { return mbEnabled; }
bool GetSpecular() { return mbSpecular; }
};
typedef ::std::vector< SdXML3DLightContext* > Imp3DLightList;
class SdXML3DSceneAttributesHelper
{
protected:
SvXMLImport& mrImport;
// list for local light contexts
Imp3DLightList maList;
// local parameters which need to be read
com::sun::star::drawing::HomogenMatrix mxHomMat;
bool mbSetTransform;
com::sun::star::drawing::ProjectionMode mxPrjMode;
sal_Int32 mnDistance;
sal_Int32 mnFocalLength;
sal_Int32 mnShadowSlant;
com::sun::star::drawing::ShadeMode mxShadeMode;
sal_Int32 maAmbientColor;
bool mbLightingMode;
::basegfx::B3DVector maVRP;
::basegfx::B3DVector maVPN;
::basegfx::B3DVector maVUP;
bool mbVRPUsed;
bool mbVPNUsed;
bool mbVUPUsed;
public:
SdXML3DSceneAttributesHelper( SvXMLImport& rImporter );
~SdXML3DSceneAttributesHelper();
/** creates a 3d ligth context and adds it to the internal list for later processing */
SvXMLImportContext * create3DLightContext( sal_uInt16 nPrfx, const OUString& rLName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
/** this should be called for each scene attribute */
void processSceneAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue );
/** this sets the scene attributes at this propertyset */
void setSceneAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet );
};
class SvXMLShapeContext : public SvXMLImportContext
{
protected:
com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape;
bool mbTemporaryShape;
OUString msHyperlink;
public:
SvXMLShapeContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
const OUString& rLName, bool bTemporaryShape ) : SvXMLImportContext( rImp, nPrfx, rLName ), mbTemporaryShape(bTemporaryShape) {}
TYPEINFO_OVERRIDE();
const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& getShape() const { return mxShape; }
void setHyperlink( const OUString& rHyperlink );
};
class ShapeSortContext;
struct XMLShapeImportHelperImpl;
struct XMLShapeImportPageContextImpl;
class XMLOFF_DLLPUBLIC XMLShapeImportHelper : public salhelper::SimpleReferenceObject
{
XMLShapeImportHelperImpl* mpImpl;
XMLShapeImportPageContextImpl* mpPageContext;
com::sun::star::uno::Reference< com::sun::star::frame::XModel > mxModel;
// PropertySetMappers and factory
XMLSdPropHdlFactory* mpSdPropHdlFactory;
SvXMLImportPropertyMapper* mpPropertySetMapper;
SvXMLImportPropertyMapper* mpPresPagePropsMapper;
// contexts for Style and AutoStyle import
SvXMLStylesContext* mpStylesContext;
SvXMLStylesContext* mpAutoStylesContext;
// contexts for xShape contents TokenMaps
SvXMLTokenMap* mpGroupShapeElemTokenMap;
SvXMLTokenMap* mpFrameShapeElemTokenMap;
SvXMLTokenMap* mp3DSceneShapeElemTokenMap;
SvXMLTokenMap* mp3DObjectAttrTokenMap;
SvXMLTokenMap* mp3DPolygonBasedAttrTokenMap;
SvXMLTokenMap* mp3DCubeObjectAttrTokenMap;
SvXMLTokenMap* mp3DSphereObjectAttrTokenMap;
SvXMLTokenMap* mp3DSceneShapeAttrTokenMap;
SvXMLTokenMap* mp3DLightAttrTokenMap;
SvXMLTokenMap* mpPathShapeAttrTokenMap;
SvXMLTokenMap* mpPolygonShapeAttrTokenMap;
const OUString msStartShape;
const OUString msEndShape;
const OUString msStartGluePointIndex;
const OUString msEndGluePointIndex;
rtl::Reference< XMLTableImport > mxShapeTableImport;
protected:
SvXMLImport& mrImporter;
public:
XMLShapeImportHelper( SvXMLImport& rImporter,
const com::sun::star::uno::Reference< com::sun::star::frame::XModel>& rModel,
SvXMLImportPropertyMapper *pExtMapper=0 );
virtual ~XMLShapeImportHelper();
SvXMLShapeContext* CreateGroupChildContext(
SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList,
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
bool bTemporaryShape = false);
SvXMLShapeContext* CreateFrameChildContext(
SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList,
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xFrameAttrList);
SvXMLImportContext* CreateFrameChildContext(
SvXMLImportContext *pThisContext, sal_uInt16 nPrefix, const OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
SvXMLShapeContext* Create3DSceneChildContext(
SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList,
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes);
const SvXMLTokenMap& GetGroupShapeElemTokenMap();
const SvXMLTokenMap& GetFrameShapeElemTokenMap();
const SvXMLTokenMap& Get3DSceneShapeElemTokenMap();
const SvXMLTokenMap& Get3DObjectAttrTokenMap();
const SvXMLTokenMap& Get3DPolygonBasedAttrTokenMap();
const SvXMLTokenMap& Get3DCubeObjectAttrTokenMap();
const SvXMLTokenMap& Get3DSphereObjectAttrTokenMap();
const SvXMLTokenMap& Get3DLightAttrTokenMap();
// Styles and AutoStyles contexts
SvXMLStylesContext* GetStylesContext() const { return mpStylesContext; }
void SetStylesContext(SvXMLStylesContext* pNew);
SvXMLStylesContext* GetAutoStylesContext() const { return mpAutoStylesContext; }
void SetAutoStylesContext(SvXMLStylesContext* pNew);
// get factories and mappers
SvXMLImportPropertyMapper* GetPropertySetMapper() const { return mpPropertySetMapper; }
SvXMLImportPropertyMapper* GetPresPagePropsMapper() const { return mpPresPagePropsMapper; }
// this function is called whenever the implementation classes like to add this new
// shape to the given XShapes.
virtual void addShape(
com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList,
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes);
// this function is called whenever the implementation classes have finished importing
// a shape to the given XShapes. The shape is already inserted into its XShapes and
// all properties and styles are set.
virtual void finishShape(
com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList,
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes);
// helper functions for z-order sorting
void pushGroupForSorting( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes );
void popGroupAndSort();
void shapeWithZIndexAdded( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape,
sal_Int32 nZIndex );
void addShapeConnection( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rConnectorShape,
bool bStart,
const OUString& rDestShapeId,
sal_Int32 nDestGlueId );
/** adds a mapping for a glue point identifier from an xml file to the identifier created after inserting
the new glue point into the core. The saved mappings can be retrieved by getGluePointId() */
void addGluePointMapping( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape,
sal_Int32 nSourceId, sal_Int32 nDestinnationId );
/** find mapping for given DestinationID. This allows to extract the original draw:id imported with a draw:glue-point */
sal_Int32 findGluePointMapping(
const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape,
sal_Int32 nDestinnationId ) const;
/** moves all current DestinationId's for rXShape by n */
void moveGluePointMapping( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, const sal_Int32 n );
/** retrieves a mapping for a glue point identifier from the current xml file to the identifier created after
inserting the new glue point into the core. The mapping must be initialized first with addGluePointMapping() */
sal_Int32 getGluePointId( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, sal_Int32 nSourceId );
/** this method must be calling before the first shape is imported for the given page.
Calls to this method can be nested */
void startPage( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes );
/** this method must be calling after the last shape is imported for the given page
Calls to this method can be nested */
void endPage( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes );
void restoreConnections();
/** creates a property mapper for external chaining */
static SvXMLImportPropertyMapper* CreateShapePropMapper(
const com::sun::star::uno::Reference< com::sun::star::frame::XModel>& rModel, SvXMLImport& rImport );
// #88546#
/** defines if the import should increment the progress bar or not */
void enableHandleProgressBar( bool bEnable = true );
bool IsHandleProgressBarEnabled() const;
/** queries the capability of the current model to create presentation shapes */
bool IsPresentationShapesSupported();
XMLSdPropHdlFactory* GetSdPropHdlFactory() const { return mpSdPropHdlFactory; }
const rtl::Reference< XMLTableImport >& GetShapeTableImport();
};
#endif // INCLUDED_XMLOFF_SHAPEIMPORT_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|