Bump version to 6.4-15
[LibreOffice.git] / include / xmloff / shapeexport.hxx
blob67a57899f30c2d571c4ceb4116364e883cd5efe4
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 INCLUDED_XMLOFF_SHAPEEXPORT_HXX
20 #define INCLUDED_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 <salhelper/simplereferenceobject.hxx>
31 #include <map>
32 #include <xmloff/animexp.hxx>
33 #include <xmloff/families.hxx>
34 #include <xmloff/txtparae.hxx>
35 #include <o3tl/typed_flags_set.hxx>
37 namespace com { namespace sun { namespace star { namespace awt { struct Point; } } } }
38 namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
39 namespace com { namespace sun { namespace star { namespace drawing { class XShape; } } } }
40 namespace com { namespace sun { namespace star { namespace drawing { class XShapes; } } } }
42 class XMLTableExport;
43 class SvXMLAttributeList;
44 class XMLPropertyHandlerFactory;
46 // shape export features are bits used for the nFeature
47 // parameter of XMLShapeExport::exportShape
48 enum class XMLShapeExportFlags {
49 NONE = 0,
50 X = 0x0001,
51 Y = 0x0002,
52 POSITION = 0x0003,
53 WIDTH = 0x0004,
54 HEIGHT = 0x0008,
55 SIZE = WIDTH | HEIGHT,
56 // When setting the flag below no ignorableWhiteSpace will be called around
57 // the drawing object elements
58 NO_WS = 0x0020,
59 // When setting the flag below a callout shape is exported as office:annotation
60 ANNOTATION = 0x0040,
62 namespace o3tl
64 template<> struct typed_flags<XMLShapeExportFlags> : is_typed_flags<XMLShapeExportFlags, 0x6f> {};
67 #define SEF_DEFAULT XMLShapeExportFlags::POSITION|XMLShapeExportFlags::SIZE
69 enum XmlShapeType
71 XmlShapeTypeUnknown, // not known
73 XmlShapeTypeDrawRectangleShape, // "com.sun.star.drawing.RectangleShape"
74 XmlShapeTypeDrawEllipseShape, // "com.sun.star.drawing.EllipseShape"
75 XmlShapeTypeDrawControlShape, // "com.sun.star.drawing.ControlShape"
76 XmlShapeTypeDrawConnectorShape, // "com.sun.star.drawing.ConnectorShape"
77 XmlShapeTypeDrawMeasureShape, // "com.sun.star.drawing.MeasureShape"
78 XmlShapeTypeDrawLineShape, // "com.sun.star.drawing.LineShape"
79 XmlShapeTypeDrawPolyPolygonShape, // "com.sun.star.drawing.PolyPolygonShape"
80 XmlShapeTypeDrawPolyLineShape, // "com.sun.star.drawing.PolyLineShape"
81 XmlShapeTypeDrawOpenBezierShape, // "com.sun.star.drawing.OpenBezierShape"
82 XmlShapeTypeDrawClosedBezierShape, // "com.sun.star.drawing.ClosedBezierShape"
83 XmlShapeTypeDrawGraphicObjectShape, // "com.sun.star.drawing.GraphicObjectShape"
84 XmlShapeTypeDrawGroupShape, // "com.sun.star.drawing.GroupShape"
85 XmlShapeTypeDrawTextShape, // "com.sun.star.drawing.TextShape"
86 XmlShapeTypeDrawOLE2Shape, // "com.sun.star.drawing.OLE2Shape"
87 XmlShapeTypeDrawChartShape, // embedded com.sun.star.chart
88 XmlShapeTypeDrawSheetShape, // embedded com.sun.star.sheet
89 XmlShapeTypeDrawPageShape, // "com.sun.star.drawing.PageShape"
90 XmlShapeTypeDrawFrameShape, // "com.sun.star.drawing.FrameShape"
91 XmlShapeTypeDrawCaptionShape, // "com.sun.star.drawing.CaptionShape"
92 XmlShapeTypeDrawAppletShape, // "com.sun.star.drawing.AppletShape"
93 XmlShapeTypeDrawPluginShape, // "com.sun.star.drawing.PlugginShape"
95 XmlShapeTypeDraw3DSceneObject, // "com.sun.star.drawing.Shape3DSceneObject"
96 XmlShapeTypeDraw3DCubeObject, // "com.sun.star.drawing.Shape3DCubeObject"
97 XmlShapeTypeDraw3DSphereObject, // "com.sun.star.drawing.Shape3DSphereObject"
98 XmlShapeTypeDraw3DLatheObject, // "com.sun.star.drawing.Shape3DLatheObject"
99 XmlShapeTypeDraw3DExtrudeObject, // "com.sun.star.drawing.Shape3DExtrudeObject"
101 XmlShapeTypePresTitleTextShape, // "com.sun.star.presentation.TitleTextShape"
102 XmlShapeTypePresOutlinerShape, // "com.sun.star.presentation.OutlinerShape"
103 XmlShapeTypePresSubtitleShape, // "com.sun.star.presentation.SubtitleShape"
104 XmlShapeTypePresGraphicObjectShape, // "com.sun.star.presentation.GraphicObjectShape"
105 XmlShapeTypePresPageShape, // "com.sun.star.presentation.PageShape"
106 XmlShapeTypePresOLE2Shape, // "com.sun.star.presentation.OLE2Shape"
107 XmlShapeTypePresChartShape, // "com.sun.star.presentation.ChartShape"
108 XmlShapeTypePresSheetShape, // "com.sun.star.presentation.CalcShape"
109 XmlShapeTypePresTableShape, // "com.sun.star.presentation.TableShape"
110 XmlShapeTypePresOrgChartShape, // "com.sun.star.presentation.OrgChartShape"
111 XmlShapeTypePresNotesShape, // "com.sun.star.presentation.NotesShape"
112 XmlShapeTypeHandoutShape, // "com.sun.star.presentation.HandoutShape"
114 XmlShapeTypePresHeaderShape, // "com.sun.star.presentation.HeaderShape"
115 XmlShapeTypePresFooterShape, // "com.sun.star.presentation.FooterShape"
116 XmlShapeTypePresSlideNumberShape, // "com.sun.star.presentation.SlideNumberShape"
117 XmlShapeTypePresDateTimeShape, // "com.sun.star.presentation.DateTimeShape"
119 XmlShapeTypeDrawCustomShape, // "com.sun.star.drawing.CustomShape"
120 XmlShapeTypeDrawMediaShape, // "com.sun.star.drawing.MediaShape"
121 XmlShapeTypePresMediaShape, // "com.sun.star.presentation.MediaShape"
123 XmlShapeTypeDrawTableShape, // "com.sun.star.drawing.TableShape"
125 XmlShapeTypeNotYetSet
128 /** caches style and type info after a collectShapeAutostyle for later use in exportShape */
129 struct ImplXMLShapeExportInfo
131 OUString msStyleName;
132 OUString msTextStyleName;
133 sal_Int32 mnFamily;
134 XmlShapeType meShapeType;
136 css::uno::Reference< css::drawing::XShape > xCustomShapeReplacement;
138 ImplXMLShapeExportInfo() : mnFamily( XML_STYLE_FAMILY_SD_GRAPHICS_ID ), meShapeType( XmlShapeTypeNotYetSet ) {}
141 /** a vector for shape style and type cache information */
142 typedef std::vector< ImplXMLShapeExportInfo > ImplXMLShapeExportInfoVector;
144 /** a map to store all cache data for already collected XShapes */
145 typedef std::map< css::uno::Reference < css::drawing::XShapes >, ImplXMLShapeExportInfoVector > ShapesInfos;
147 class SvXMLExport;
148 class SvXMLExportPropertyMapper;
150 namespace basegfx
152 class B2DTuple;
153 class B2DHomMatrix;
156 class XMLOFF_DLLPUBLIC XMLShapeExport : public salhelper::SimpleReferenceObject
158 private:
160 SvXMLExport& mrExport;
161 rtl::Reference< SvXMLExportPropertyMapper > mxPropertySetMapper;
162 rtl::Reference< XMLAnimationsExporter > mxAnimationsExporter;
163 ShapesInfos maShapesInfos;
164 ShapesInfos::iterator maCurrentShapesIter;
165 bool mbExportLayer;
166 OUString msPresentationStylePrefix;
168 // #88546# possibility to switch progress bar handling on/off
169 bool mbHandleProgressBar;
171 rtl::Reference< XMLTableExport > mxShapeTableExport;
173 protected:
174 SvXMLExport& GetExport() { return mrExport; }
175 const SvXMLExport& GetExport() const { return mrExport; }
176 private:
178 SAL_DLLPRIVATE const rtl::Reference< SvXMLExportPropertyMapper >& GetPropertySetMapper() const { return mxPropertySetMapper; }
180 OUStringBuffer msBuffer;
182 SAL_DLLPRIVATE void ImpCalcShapeType(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType& eShapeType);
184 SAL_DLLPRIVATE void ImpExportNewTrans(const css::uno::Reference< css::beans::XPropertySet >& xPropSet, XMLShapeExportFlags nFeatures, css::awt::Point* pRefPoint);
185 SAL_DLLPRIVATE void ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix& rMatrix, const css::uno::Reference< css::beans::XPropertySet >& xPropSet);
186 SAL_DLLPRIVATE static void ImpExportNewTrans_DecomposeAndRefPoint(const ::basegfx::B2DHomMatrix& rMat, ::basegfx::B2DTuple& rTRScale, double& fTRShear, double& fTRRotate, ::basegfx::B2DTuple& rTRTranslate, css::awt::Point* pRefPoint);
187 SAL_DLLPRIVATE void ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple const & rTRScale, double fTRShear, double fTRRotate, ::basegfx::B2DTuple const & rTRTranslate, const XMLShapeExportFlags nFeatures);
188 SAL_DLLPRIVATE bool ImpExportPresentationAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet, const OUString& rClass );
189 SAL_DLLPRIVATE void ImpExportText( const css::uno::Reference< css::drawing::XShape >& xShape, TextPNS eExtensionNS = TextPNS::ODF );
190 SAL_DLLPRIVATE void ImpExportEvents( const css::uno::Reference< css::drawing::XShape >& xShape );
191 SAL_DLLPRIVATE void ImpExportDescription( const css::uno::Reference< css::drawing::XShape >& xShape ); // #i68101#
192 SAL_DLLPRIVATE void ImpExportGluePoints( const css::uno::Reference< css::drawing::XShape >& xShape );
193 SAL_DLLPRIVATE void ImpExportSignatureLine(const css::uno::Reference<css::drawing::XShape>& xShape);
194 SAL_DLLPRIVATE void ImpExportQRCode(const css::uno::Reference<css::drawing::XShape>& xShape);
196 // single shape exporters
197 SAL_DLLPRIVATE void ImpExportGroupShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
198 SAL_DLLPRIVATE void ImpExport3DSceneShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
199 SAL_DLLPRIVATE void ImpExportRectangleShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
200 SAL_DLLPRIVATE void ImpExportLineShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
201 SAL_DLLPRIVATE void ImpExportEllipseShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
202 SAL_DLLPRIVATE void ImpExportPolygonShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
203 SAL_DLLPRIVATE void ImpExportTextBoxShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
204 SAL_DLLPRIVATE void ImpExportGraphicObjectShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
205 SAL_DLLPRIVATE void ImpExportChartShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr, SvXMLAttributeList* pAttrList = nullptr );
206 SAL_DLLPRIVATE void ImpExportControlShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
207 SAL_DLLPRIVATE void ImpExportConnectorShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
208 SAL_DLLPRIVATE void ImpExportMeasureShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point const * pRefPoint = nullptr );
209 SAL_DLLPRIVATE void ImpExportOLE2Shape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr, SvXMLAttributeList* pAttrList = nullptr );
210 SAL_DLLPRIVATE void ImpExportPageShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
211 SAL_DLLPRIVATE void ImpExportCaptionShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
212 SAL_DLLPRIVATE void ImpExport3DShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType );
213 SAL_DLLPRIVATE void ImpExportFrameShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
214 SAL_DLLPRIVATE void ImpExportPluginShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
215 SAL_DLLPRIVATE void ImpExportAppletShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
216 SAL_DLLPRIVATE void ImpExportCustomShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
217 SAL_DLLPRIVATE void ImpExportMediaShape( const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
218 SAL_DLLPRIVATE void ImpExportTableShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
219 public:
220 XMLShapeExport(SvXMLExport& rExp, SvXMLExportPropertyMapper *pExtMapper=nullptr );
221 virtual ~XMLShapeExport() override;
223 // This method collects all automatic styles for the given XShape
224 void collectShapeAutoStyles(
225 const css::uno::Reference < css::drawing::XShape >& xShape);
227 // This method exports the given XShape
228 void exportShape(
229 const css::uno::Reference < css::drawing::XShape >& xShape,
230 XMLShapeExportFlags nFeatures = SEF_DEFAULT,
231 css::awt::Point* pRefPoint = nullptr,
232 SvXMLAttributeList* pAttrList = nullptr
235 // This method collects all automatic styles for the shapes inside the given XShapes collection
236 void collectShapesAutoStyles(
237 const css::uno::Reference < css::drawing::XShapes >& xShapes);
239 // This method exports all XShape inside the given XShapes collection
240 void exportShapes(
241 const css::uno::Reference < css::drawing::XShapes >& xShapes,
242 XMLShapeExportFlags nFeatures = SEF_DEFAULT,
243 css::awt::Point* pRefPoint = nullptr
246 /** initializes some internal structures for fast access to the given XShapes collection
248 <p>This method has to be called before you use exportShape or collectShapeAutoStyles.
249 It is automatically called if you use collectShapesAutoStyles and exportShapes.
251 @see collectShapeAutoStyles
252 @see exportShape
253 @see collectShapesAutoStyles
254 @see exportShapes
256 void seekShapes(
257 const css::uno::Reference< css::drawing::XShapes >& xShapes ) throw();
259 void exportAutoStyles();
261 /** sets a new reference to an XMLAnimationExporter.
262 If this is a non NULL reference, the animation information from all shapes given to exportShape()
263 from now on are collected.
265 void setAnimationsExporter( rtl::Reference< XMLAnimationsExporter > const & xAnimExport ) { mxAnimationsExporter = xAnimExport; }
267 /** returns the last set XMLAnimationExport */
268 const rtl::Reference< XMLAnimationsExporter >& getAnimationsExporter() const { return mxAnimationsExporter; }
270 /// returns the export property mapper for external chaining
271 static SvXMLExportPropertyMapper* CreateShapePropMapper( SvXMLExport& rExport );
273 void enableLayerExport() { mbExportLayer = true; }
275 /** defines if the export should increment the progress bar or not */
276 void enableHandleProgressBar() { mbHandleProgressBar = true; }
277 bool IsHandleProgressBarEnabled() const { return mbHandleProgressBar; }
279 void setPresentationStylePrefix( const OUString& rPrefix ) { msPresentationStylePrefix = rPrefix; }
281 /** helper for chart that adds all attributes of a 3d scene element to the export */
282 void export3DSceneAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
284 /** helper for chart that exports all lamps from the propertyset */
285 void export3DLamps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
287 /** sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format */
288 css::uno::Reference < css::drawing::XShape > checkForCustomShapeReplacement(
289 const css::uno::Reference < css::drawing::XShape >& );
291 /** helper to export the style for graphic defaults */
292 void ExportGraphicDefaults();
294 /** is called before a shape element for the given XShape is exported */
295 virtual void onExport( const css::uno::Reference < css::drawing::XShape >& xShape );
297 const rtl::Reference< XMLTableExport >& GetShapeTableExport();
300 #endif
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */