bump product version to 4.1.6.2
[LibreOffice.git] / include / xmloff / shapeexport.hxx
blob8dfaa0f89d5eb372ca6ac43af1299db801e97a6f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _XMLOFF_SHAPEEXPORT_HXX_
20 #define _XMLOFF_SHAPEEXPORT_HXX_
22 #include "sal/config.h"
23 #include "xmloff/dllapi.h"
24 #include "sal/types.h"
26 #include <rtl/ref.hxx>
27 #include <rtl/ustring.hxx>
28 #include <rtl/ustrbuf.hxx>
29 #include <xmloff/uniref.hxx>
31 #include <com/sun/star/drawing/XShape.hpp>
32 #include <com/sun/star/drawing/XShapes.hpp>
33 #include <com/sun/star/awt/Point.hpp>
34 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <map>
37 #include <xmloff/xmlprmap.hxx>
38 #include <xmloff/xmlexppr.hxx>
39 #include <xmloff/animexp.hxx>
40 #include <xmloff/families.hxx>
42 #include "xmloff/table/XMLTableExport.hxx"
44 // shape export features are bits used for the nFeature
45 // parameter of XMLShapeExport::exportShape
47 #define SEF_EXPORT_X 0x0001
48 #define SEF_EXPORT_Y 0x0002
49 #define SEF_EXPORT_POSITION 0x0003
51 #define SEF_EXPORT_WIDTH 0x0004
52 #define SEF_EXPORT_HEIGHT 0x0008
53 #define SEF_EXPORT_SIZE 0x000c
55 // when you set this flag a chart does NOT export its own data as table element
56 #define SEF_EXPORT_NO_CHART_DATA 0x0010
58 // When setting the flag below no ignorableWhiteSpace will be called around
59 // the drawing object elements
60 #define SEF_EXPORT_NO_WS 0x0020
62 // When setting the flag below a callout shape is exported as office:annotation
63 #define SEF_EXPORT_ANNOTATION 0x0040
65 #define SEF_DEFAULT SEF_EXPORT_POSITION|SEF_EXPORT_SIZE
67 enum XmlShapeType
69 XmlShapeTypeUnknown, // not known
71 XmlShapeTypeDrawRectangleShape, // "com.sun.star.drawing.RectangleShape"
72 XmlShapeTypeDrawEllipseShape, // "com.sun.star.drawing.EllipseShape"
73 XmlShapeTypeDrawControlShape, // "com.sun.star.drawing.ControlShape"
74 XmlShapeTypeDrawConnectorShape, // "com.sun.star.drawing.ConnectorShape"
75 XmlShapeTypeDrawMeasureShape, // "com.sun.star.drawing.MeasureShape"
76 XmlShapeTypeDrawLineShape, // "com.sun.star.drawing.LineShape"
77 XmlShapeTypeDrawPolyPolygonShape, // "com.sun.star.drawing.PolyPolygonShape"
78 XmlShapeTypeDrawPolyLineShape, // "com.sun.star.drawing.PolyLineShape"
79 XmlShapeTypeDrawOpenBezierShape, // "com.sun.star.drawing.OpenBezierShape"
80 XmlShapeTypeDrawClosedBezierShape, // "com.sun.star.drawing.ClosedBezierShape"
81 XmlShapeTypeDrawGraphicObjectShape, // "com.sun.star.drawing.GraphicObjectShape"
82 XmlShapeTypeDrawGroupShape, // "com.sun.star.drawing.GroupShape"
83 XmlShapeTypeDrawTextShape, // "com.sun.star.drawing.TextShape"
84 XmlShapeTypeDrawOLE2Shape, // "com.sun.star.drawing.OLE2Shape"
85 XmlShapeTypeDrawChartShape, // embedded com.sun.star.chart
86 XmlShapeTypeDrawSheetShape, // embedded com.sun.star.sheet
87 XmlShapeTypeDrawPageShape, // "com.sun.star.drawing.PageShape"
88 XmlShapeTypeDrawFrameShape, // "com.sun.star.drawing.FrameShape"
89 XmlShapeTypeDrawCaptionShape, // "com.sun.star.drawing.CaptionShape"
90 XmlShapeTypeDrawAppletShape, // "com.sun.star.drawing.AppletShape"
91 XmlShapeTypeDrawPluginShape, // "com.sun.star.drawing.PlugginShape"
93 XmlShapeTypeDraw3DSceneObject, // "com.sun.star.drawing.Shape3DSceneObject"
94 XmlShapeTypeDraw3DCubeObject, // "com.sun.star.drawing.Shape3DCubeObject"
95 XmlShapeTypeDraw3DSphereObject, // "com.sun.star.drawing.Shape3DSphereObject"
96 XmlShapeTypeDraw3DLatheObject, // "com.sun.star.drawing.Shape3DLatheObject"
97 XmlShapeTypeDraw3DExtrudeObject, // "com.sun.star.drawing.Shape3DExtrudeObject"
99 XmlShapeTypePresTitleTextShape, // "com.sun.star.presentation.TitleTextShape"
100 XmlShapeTypePresOutlinerShape, // "com.sun.star.presentation.OutlinerShape"
101 XmlShapeTypePresSubtitleShape, // "com.sun.star.presentation.SubtitleShape"
102 XmlShapeTypePresGraphicObjectShape, // "com.sun.star.presentation.GraphicObjectShape"
103 XmlShapeTypePresPageShape, // "com.sun.star.presentation.PageShape"
104 XmlShapeTypePresOLE2Shape, // "com.sun.star.presentation.OLE2Shape"
105 XmlShapeTypePresChartShape, // "com.sun.star.presentation.ChartShape"
106 XmlShapeTypePresSheetShape, // "com.sun.star.presentation.CalcShape"
107 XmlShapeTypePresTableShape, // "com.sun.star.presentation.TableShape"
108 XmlShapeTypePresOrgChartShape, // "com.sun.star.presentation.OrgChartShape"
109 XmlShapeTypePresNotesShape, // "com.sun.star.presentation.NotesShape"
110 XmlShapeTypeHandoutShape, // "com.sun.star.presentation.HandoutShape"
112 XmlShapeTypePresHeaderShape, // "com.sun.star.presentation.HeaderShape"
113 XmlShapeTypePresFooterShape, // "com.sun.star.presentation.FooterShape"
114 XmlShapeTypePresSlideNumberShape, // "com.sun.star.presentation.SlideNumberShape"
115 XmlShapeTypePresDateTimeShape, // "com.sun.star.presentation.DateTimeShape"
117 XmlShapeTypeDrawCustomShape, // "com.sun.star.drawing.CustomShape"
118 XmlShapeTypeDrawMediaShape, // "com.sun.star.drawing.MediaShape"
119 XmlShapeTypePresMediaShape, // "com.sun.star.presentation.MediaShape"
121 XmlShapeTypeDrawTableShape, // "com.sun.star.drawing.TableShape"
123 XmlShapeTypeNotYetSet
126 /** caches style and type info after a collectShapeAutostyle for later use in exportShape */
127 struct ImplXMLShapeExportInfo
129 OUString msStyleName;
130 OUString msTextStyleName;
131 sal_Int32 mnFamily;
132 XmlShapeType meShapeType;
134 com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xCustomShapeReplacement;
136 ImplXMLShapeExportInfo() : mnFamily( XML_STYLE_FAMILY_SD_GRAPHICS_ID ), meShapeType( XmlShapeTypeNotYetSet ) {}
139 /** a vector for shape style and type cache information */
140 typedef std::vector< ImplXMLShapeExportInfo > ImplXMLShapeExportInfoVector;
142 /** a map to store all cache data for already collected XShapes */
143 typedef std::map< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes >, ImplXMLShapeExportInfoVector > ShapesInfos;
145 //////////////////////////////////////////////////////////////////////////////
146 // predeclarations
148 class SvXMLExport;
149 class SvXMLExportPropertyMapper;
151 namespace basegfx
153 class B2DTuple;
154 class B2DHomMatrix;
155 } // end of namespace basegfx
157 class XMLOFF_DLLPUBLIC XMLShapeExport : public UniRefBase
159 private:
161 SvXMLExport& mrExport;
162 UniReference< XMLPropertyHandlerFactory > mxSdPropHdlFactory;
163 UniReference< SvXMLExportPropertyMapper > mxPropertySetMapper;
164 UniReference< XMLAnimationsExporter > mxAnimationsExporter;
165 sal_Int32 mnNextUniqueShapeId;
166 ShapesInfos maShapesInfos;
167 ShapesInfos::iterator maCurrentShapesIter;
168 sal_Bool mbExportLayer;
169 ImplXMLShapeExportInfoVector maShapeInfos;
170 ImplXMLShapeExportInfoVector::iterator maCurrentInfo;
171 OUString msPresentationStylePrefix;
173 // #88546# possibility to swich progress bar handling on/off
174 sal_Bool mbHandleProgressBar;
176 rtl::Reference< XMLTableExport > mxShapeTableExport;
178 protected:
179 SvXMLExport& GetExport() { return mrExport; }
180 const SvXMLExport& GetExport() const { return mrExport; }
181 private:
183 SAL_DLLPRIVATE UniReference< SvXMLExportPropertyMapper > GetPropertySetMapper() const { return mxPropertySetMapper; }
185 const OUString msZIndex;
186 const OUString msPrintable;
187 const OUString msVisible;
189 const OUString msEmptyPres;
190 const OUString msModel;
191 const OUString msStartShape;
192 const OUString msEndShape;
193 const OUString msOnClick;
194 const OUString msEventType;
195 const OUString msPresentation;
196 const OUString msMacroName;
197 const OUString msScript;
198 const OUString msLibrary;
199 const OUString msClickAction;
200 const OUString msBookmark;
201 const OUString msEffect;
202 const OUString msPlayFull;
203 const OUString msVerb;
204 const OUString msSoundURL;
205 const OUString msSpeed;
206 const OUString msStarBasic;
208 OUStringBuffer msBuffer;
210 SAL_DLLPRIVATE void ImpCalcShapeType(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType& eShapeType);
212 SAL_DLLPRIVATE void ImpExportNewTrans(const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet, sal_Int32 nFeatures, com::sun::star::awt::Point* pRefPoint);
213 SAL_DLLPRIVATE void ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix& rMatrix, const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet);
214 SAL_DLLPRIVATE void ImpExportNewTrans_DecomposeAndRefPoint(const ::basegfx::B2DHomMatrix& rMat, ::basegfx::B2DTuple& rTRScale, double& fTRShear, double& fTRRotate, ::basegfx::B2DTuple& rTRTranslate, com::sun::star::awt::Point* pRefPoint);
215 SAL_DLLPRIVATE void ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple& rTRScale, double fTRShear, double fTRRotate, ::basegfx::B2DTuple& rTRTranslate, const sal_Int32 nFeatures);
216 SAL_DLLPRIVATE sal_Bool ImpExportPresentationAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet, const OUString& rClass );
217 SAL_DLLPRIVATE void ImpExportText( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
218 SAL_DLLPRIVATE void ImpExportEvents( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
219 SAL_DLLPRIVATE void ImpExportDescription( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape ); // #i68101#
220 SAL_DLLPRIVATE void ImpExportGluePoints( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape );
222 // single shape exporters
223 SAL_DLLPRIVATE void ImpExportGroupShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
224 SAL_DLLPRIVATE void ImpExport3DSceneShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
225 SAL_DLLPRIVATE void ImpExportRectangleShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
226 SAL_DLLPRIVATE void ImpExportLineShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
227 SAL_DLLPRIVATE void ImpExportEllipseShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
228 SAL_DLLPRIVATE void ImpExportPolygonShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
229 SAL_DLLPRIVATE void ImpExportTextBoxShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
230 SAL_DLLPRIVATE void ImpExportGraphicObjectShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
231 SAL_DLLPRIVATE void ImpExportChartShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL, SvXMLAttributeList* pAttrList = NULL );
232 SAL_DLLPRIVATE void ImpExportControlShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
233 SAL_DLLPRIVATE void ImpExportConnectorShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
234 SAL_DLLPRIVATE void ImpExportMeasureShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
235 SAL_DLLPRIVATE void ImpExportOLE2Shape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL, SvXMLAttributeList* pAttrList = NULL );
236 SAL_DLLPRIVATE void ImpExportPageShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
237 SAL_DLLPRIVATE void ImpExportCaptionShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
238 SAL_DLLPRIVATE void ImpExport3DShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
239 SAL_DLLPRIVATE void ImpExportFrameShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
240 SAL_DLLPRIVATE void ImpExportPluginShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
241 SAL_DLLPRIVATE void ImpExportAppletShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
242 SAL_DLLPRIVATE void ImpExportCustomShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
243 SAL_DLLPRIVATE void ImpExportMediaShape( const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
244 SAL_DLLPRIVATE void ImpExportTableShape(const com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, XmlShapeType eShapeType, sal_Int32 nFeatures = SEF_DEFAULT, com::sun::star::awt::Point* pRefPoint = NULL );
245 public:
246 XMLShapeExport(SvXMLExport& rExp, SvXMLExportPropertyMapper *pExtMapper=0 );
247 virtual ~XMLShapeExport();
249 // This method collects all automatic styles for the given XShape
250 void collectShapeAutoStyles(
251 const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape);
253 // This method exports the given XShape
254 void exportShape(
255 const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape,
256 sal_Int32 nFeatures = SEF_DEFAULT,
257 com::sun::star::awt::Point* pRefPoint = NULL,
258 SvXMLAttributeList* pAttrList = NULL
261 // This method collects all automatic styles for the shapes inside the given XShapes collection
262 void collectShapesAutoStyles(
263 const com::sun::star::uno::Reference < com::sun::star::drawing::XShapes >& xShapes);
265 // This method exports all XShape inside the given XShapes collection
266 void exportShapes(
267 const com::sun::star::uno::Reference < com::sun::star::drawing::XShapes >& xShapes,
268 sal_Int32 nFeatures = SEF_DEFAULT,
269 com::sun::star::awt::Point* pRefPoint = NULL
272 /** initializes some internal structures for fast access to the given XShapes collection
274 <p>This method has to be called before you use exportShape or collectShapeAutoStyles.
275 It is automaticly called if you use collectShapesAutoStyles and exportShapes.
277 @see collectShapeAutoStyles
278 @see exportShape
279 @see collectShapesAutoStyles
280 @see exportShapes
282 void seekShapes(
283 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& xShapes ) throw();
285 void exportAutoStyles();
287 /** sets a new reference to an XMLAnimationExporter.
288 If this is a non NULL reference, the animation information from all shapes given to exportShape()
289 from now on are collected.
291 void setAnimationsExporter( UniReference< XMLAnimationsExporter > xAnimExport ) { mxAnimationsExporter = xAnimExport; }
293 /** returns the last set XMLAnimationExport */
294 UniReference< XMLAnimationsExporter > getAnimationsExporter() const { return mxAnimationsExporter; }
296 /// returns the export property mapper for external chaining
297 static SvXMLExportPropertyMapper* CreateShapePropMapper( SvXMLExport& rExport );
299 void enableLayerExport( sal_Bool bEnable = sal_True ) { mbExportLayer = bEnable; }
300 sal_Bool IsLayerExportEnabled() const { return mbExportLayer; }
302 // #88546#
303 /** defines if the export should increment the progress bar or not */
304 void enableHandleProgressBar( sal_Bool bEnable = sal_True ) { mbHandleProgressBar = bEnable; }
305 sal_Bool IsHandleProgressBarEnabled() const { return mbHandleProgressBar; }
307 void setPresentationStylePrefix( const OUString& rPrefix ) { msPresentationStylePrefix = rPrefix; }
309 /** helper for chart that adds all attributes of a 3d scene element to the export */
310 void export3DSceneAttributes( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet );
312 /** helper for chart that exports all lamps from the propertyset */
313 void export3DLamps( const com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet >& xPropSet );
315 /** sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format */
316 com::sun::star::uno::Reference < com::sun::star::drawing::XShape > checkForCustomShapeReplacement(
317 const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& );
319 /** helper to export the style for graphic defaults */
320 void ExportGraphicDefaults();
322 /** is called before a shape element for the given XShape is exported */
323 virtual void onExport( const com::sun::star::uno::Reference < com::sun::star::drawing::XShape >& xShape );
325 const rtl::Reference< XMLTableExport >& GetShapeTableExport();
329 #endif
331 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */