/src/libreoffice/include/xmloff/shapeexport.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | #ifndef INCLUDED_XMLOFF_SHAPEEXPORT_HXX |
20 | | #define INCLUDED_XMLOFF_SHAPEEXPORT_HXX |
21 | | |
22 | | #include <sal/config.h> |
23 | | #include <xmloff/dllapi.h> |
24 | | #include <sal/types.h> |
25 | | |
26 | | #include <rtl/ref.hxx> |
27 | | #include <rtl/ustring.hxx> |
28 | | #include <rtl/ustrbuf.hxx> |
29 | | #include <salhelper/simplereferenceobject.hxx> |
30 | | |
31 | | #include <functional> |
32 | | #include <map> |
33 | | #include <xmloff/animexp.hxx> |
34 | | #include <xmloff/families.hxx> |
35 | | #include <xmloff/txtparae.hxx> |
36 | | #include <o3tl/typed_flags_set.hxx> |
37 | | |
38 | | namespace com::sun::star::awt { struct Point; } |
39 | | namespace com::sun::star::beans { class XPropertySet; } |
40 | | namespace com::sun::star::drawing { class XShape; } |
41 | | namespace com::sun::star::drawing { class XShapes; } |
42 | | namespace com::sun::star::lang { class XComponent; } |
43 | | |
44 | | class XMLTableExport; |
45 | | namespace comphelper { class AttributeList; } |
46 | | |
47 | | // shape export features are bits used for the nFeature |
48 | | // parameter of XMLShapeExport::exportShape |
49 | | enum class XMLShapeExportFlags { |
50 | | NONE = 0, |
51 | | X = 0x0001, |
52 | | Y = 0x0002, |
53 | | POSITION = 0x0003, |
54 | | WIDTH = 0x0004, |
55 | | HEIGHT = 0x0008, |
56 | | SIZE = WIDTH | HEIGHT, |
57 | | // When setting the flag below no ignorableWhiteSpace will be called around |
58 | | // the drawing object elements |
59 | | NO_WS = 0x0020, |
60 | | // When setting the flag below a callout shape is exported as office:annotation |
61 | | ANNOTATION = 0x0040, |
62 | | }; |
63 | | namespace o3tl |
64 | | { |
65 | | template<> struct typed_flags<XMLShapeExportFlags> : is_typed_flags<XMLShapeExportFlags, 0x6f> {}; |
66 | | } |
67 | | |
68 | 0 | #define SEF_DEFAULT XMLShapeExportFlags::POSITION|XMLShapeExportFlags::SIZE |
69 | | |
70 | | enum class XmlShapeType |
71 | | { |
72 | | Unknown, // not known |
73 | | |
74 | | DrawRectangleShape, // "com.sun.star.drawing.RectangleShape" |
75 | | DrawEllipseShape, // "com.sun.star.drawing.EllipseShape" |
76 | | DrawControlShape, // "com.sun.star.drawing.ControlShape" |
77 | | DrawConnectorShape, // "com.sun.star.drawing.ConnectorShape" |
78 | | DrawMeasureShape, // "com.sun.star.drawing.MeasureShape" |
79 | | DrawLineShape, // "com.sun.star.drawing.LineShape" |
80 | | DrawPolyPolygonShape, // "com.sun.star.drawing.PolyPolygonShape" |
81 | | DrawPolyLineShape, // "com.sun.star.drawing.PolyLineShape" |
82 | | DrawOpenBezierShape, // "com.sun.star.drawing.OpenBezierShape" |
83 | | DrawClosedBezierShape, // "com.sun.star.drawing.ClosedBezierShape" |
84 | | DrawGraphicObjectShape, // "com.sun.star.drawing.GraphicObjectShape" |
85 | | DrawGroupShape, // "com.sun.star.drawing.GroupShape" |
86 | | DrawTextShape, // "com.sun.star.drawing.TextShape" |
87 | | DrawOLE2Shape, // "com.sun.star.drawing.OLE2Shape" |
88 | | DrawChartShape, // embedded com.sun.star.chart |
89 | | DrawSheetShape, // embedded com.sun.star.sheet |
90 | | DrawPageShape, // "com.sun.star.drawing.PageShape" |
91 | | DrawFrameShape, // "com.sun.star.drawing.FrameShape" |
92 | | DrawCaptionShape, // "com.sun.star.drawing.CaptionShape" |
93 | | DrawAppletShape, // "com.sun.star.drawing.AppletShape" |
94 | | DrawPluginShape, // "com.sun.star.drawing.PlugginShape" |
95 | | |
96 | | Draw3DSceneObject, // "com.sun.star.drawing.Shape3DSceneObject" |
97 | | Draw3DCubeObject, // "com.sun.star.drawing.Shape3DCubeObject" |
98 | | Draw3DSphereObject, // "com.sun.star.drawing.Shape3DSphereObject" |
99 | | Draw3DLatheObject, // "com.sun.star.drawing.Shape3DLatheObject" |
100 | | Draw3DExtrudeObject, // "com.sun.star.drawing.Shape3DExtrudeObject" |
101 | | |
102 | | PresTitleTextShape, // "com.sun.star.presentation.TitleTextShape" |
103 | | PresOutlinerShape, // "com.sun.star.presentation.OutlinerShape" |
104 | | PresSubtitleShape, // "com.sun.star.presentation.SubtitleShape" |
105 | | PresGraphicObjectShape, // "com.sun.star.presentation.GraphicObjectShape" |
106 | | PresPageShape, // "com.sun.star.presentation.PageShape" |
107 | | PresOLE2Shape, // "com.sun.star.presentation.OLE2Shape" |
108 | | PresChartShape, // "com.sun.star.presentation.ChartShape" |
109 | | PresSheetShape, // "com.sun.star.presentation.CalcShape" |
110 | | PresTableShape, // "com.sun.star.presentation.TableShape" |
111 | | PresOrgChartShape, // "com.sun.star.presentation.OrgChartShape" |
112 | | PresNotesShape, // "com.sun.star.presentation.NotesShape" |
113 | | HandoutShape, // "com.sun.star.presentation.HandoutShape" |
114 | | |
115 | | PresHeaderShape, // "com.sun.star.presentation.HeaderShape" |
116 | | PresFooterShape, // "com.sun.star.presentation.FooterShape" |
117 | | PresSlideNumberShape, // "com.sun.star.presentation.SlideNumberShape" |
118 | | PresDateTimeShape, // "com.sun.star.presentation.DateTimeShape" |
119 | | |
120 | | DrawCustomShape, // "com.sun.star.drawing.CustomShape" |
121 | | DrawMediaShape, // "com.sun.star.drawing.MediaShape" |
122 | | PresMediaShape, // "com.sun.star.presentation.MediaShape" |
123 | | |
124 | | DrawTableShape, // "com.sun.star.drawing.TableShape" |
125 | | |
126 | | NotYetSet |
127 | | }; |
128 | | |
129 | | /** caches style and type info after a collectShapeAutostyle for later use in exportShape */ |
130 | | struct ImplXMLShapeExportInfo |
131 | | { |
132 | | OUString msStyleName; |
133 | | OUString msTextStyleName; |
134 | | XmlStyleFamily mnFamily; |
135 | | XmlShapeType meShapeType; |
136 | | |
137 | | css::uno::Reference< css::drawing::XShape > xCustomShapeReplacement; |
138 | | css::uno::Reference<css::lang::XComponent> xPDFModelReplacement; |
139 | | |
140 | 5.86k | ImplXMLShapeExportInfo() : mnFamily( XmlStyleFamily::SD_GRAPHICS_ID ), meShapeType( XmlShapeType::NotYetSet ) {} |
141 | | }; |
142 | | |
143 | | /** a vector for shape style and type cache information */ |
144 | | typedef std::map< css::uno::Reference< css::drawing::XShape >, ImplXMLShapeExportInfo > ShapeExportInfoMap; |
145 | | |
146 | | /** a map to store all cache data for already collected XShapes */ |
147 | | typedef std::map< css::uno::Reference < css::drawing::XShapes >, ShapeExportInfoMap > ShapesInfos; |
148 | | |
149 | | class SvXMLExport; |
150 | | class SvXMLExportPropertyMapper; |
151 | | |
152 | | namespace basegfx |
153 | | { |
154 | | class B2DTuple; |
155 | | class B2DHomMatrix; |
156 | | } |
157 | | |
158 | | class XMLOFF_DLLPUBLIC XMLShapeExport : public salhelper::SimpleReferenceObject |
159 | | { |
160 | | private: |
161 | | |
162 | | SvXMLExport& mrExport; |
163 | | rtl::Reference< SvXMLExportPropertyMapper > mxPropertySetMapper; |
164 | | rtl::Reference< XMLAnimationsExporter > mxAnimationsExporter; |
165 | | ShapesInfos maShapesInfos; |
166 | | ShapesInfos::iterator maCurrentShapesIter; |
167 | | bool mbExportLayer; |
168 | | OUString msPresentationStylePrefix; |
169 | | |
170 | | // #88546# possibility to switch progress bar handling on/off |
171 | | bool mbHandleProgressBar; |
172 | | |
173 | | rtl::Reference< XMLTableExport > mxShapeTableExport; |
174 | | |
175 | | protected: |
176 | 71.7k | SvXMLExport& GetExport() { return mrExport; } |
177 | 0 | const SvXMLExport& GetExport() const { return mrExport; } |
178 | | private: |
179 | | |
180 | 5.96k | SAL_DLLPRIVATE const rtl::Reference< SvXMLExportPropertyMapper >& GetPropertySetMapper() const { return mxPropertySetMapper; } |
181 | | |
182 | | OUStringBuffer msBuffer; |
183 | | |
184 | | SAL_DLLPRIVATE void ImpCalcShapeType(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType& eShapeType); |
185 | | |
186 | | SAL_DLLPRIVATE void ImpExportNewTrans(const css::uno::Reference< css::beans::XPropertySet >& xPropSet, XMLShapeExportFlags nFeatures, css::awt::Point* pRefPoint); |
187 | | SAL_DLLPRIVATE void ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix& rMatrix, const css::uno::Reference< css::beans::XPropertySet >& xPropSet); |
188 | | SAL_DLLPRIVATE static void ImpExportNewTrans_DecomposeAndRefPoint(const ::basegfx::B2DHomMatrix& rMat, ::basegfx::B2DTuple& rTRScale, double& fTRShear, double& fTRRotate, ::basegfx::B2DTuple& rTRTranslate, css::awt::Point* pRefPoint); |
189 | | SAL_DLLPRIVATE void ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple const & rTRScale, double fTRShear, double fTRRotate, ::basegfx::B2DTuple const & rTRTranslate, const XMLShapeExportFlags nFeatures); |
190 | | SAL_DLLPRIVATE bool ImpExportPresentationAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet, const OUString& rClass ); |
191 | | SAL_DLLPRIVATE void ImpExportText( const css::uno::Reference< css::drawing::XShape >& xShape, TextPNS eExtensionNS = TextPNS::ODF ); |
192 | | SAL_DLLPRIVATE void ImpExportEvents( const css::uno::Reference< css::drawing::XShape >& xShape ); |
193 | | SAL_DLLPRIVATE void ImpExportDescription( const css::uno::Reference< css::drawing::XShape >& xShape ); // #i68101# |
194 | | SAL_DLLPRIVATE void ImpExportGluePoints( const css::uno::Reference< css::drawing::XShape >& xShape ); |
195 | | SAL_DLLPRIVATE void ImpExportSignatureLine(const css::uno::Reference<css::drawing::XShape>& xShape); |
196 | | SAL_DLLPRIVATE void ImpExportQRCode(const css::uno::Reference<css::drawing::XShape>& xShape); |
197 | | |
198 | | // single shape exporters |
199 | | SAL_DLLPRIVATE void ImpExportGroupShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
200 | | SAL_DLLPRIVATE void ImpExport3DSceneShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
201 | | SAL_DLLPRIVATE void ImpExportRectangleShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
202 | | SAL_DLLPRIVATE void ImpExportLineShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
203 | | SAL_DLLPRIVATE void ImpExportEllipseShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
204 | | SAL_DLLPRIVATE void ImpExportPolygonShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
205 | | SAL_DLLPRIVATE void ImpExportTextBoxShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
206 | | SAL_DLLPRIVATE void ImpExportGraphicObjectShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
207 | | SAL_DLLPRIVATE void ImpExportChartShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr, comphelper::AttributeList* pAttrList = nullptr ); |
208 | | SAL_DLLPRIVATE void ImpExportControlShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
209 | | SAL_DLLPRIVATE void ImpExportConnectorShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
210 | | SAL_DLLPRIVATE void ImpExportMeasureShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point const * pRefPoint = nullptr ); |
211 | | SAL_DLLPRIVATE void ImpExportOLE2Shape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr, comphelper::AttributeList* pAttrList = nullptr ); |
212 | | SAL_DLLPRIVATE void ImpExportPageShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
213 | | SAL_DLLPRIVATE void ImpExportCaptionShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
214 | | SAL_DLLPRIVATE void ImpExport3DShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType ); |
215 | | SAL_DLLPRIVATE void ImpExportFrameShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
216 | | SAL_DLLPRIVATE void ImpExportPluginShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
217 | | SAL_DLLPRIVATE void ImpExportAppletShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
218 | | SAL_DLLPRIVATE void ImpExportCustomShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
219 | | SAL_DLLPRIVATE void ImpExportMediaShape( const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
220 | | SAL_DLLPRIVATE void ImpExportTableShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr ); |
221 | | public: |
222 | | XMLShapeExport(SvXMLExport& rExp, SvXMLExportPropertyMapper *pExtMapper=nullptr ); |
223 | | virtual ~XMLShapeExport() override; |
224 | | |
225 | | // This method collects all automatic styles for the given XShape |
226 | | void collectShapeAutoStyles( |
227 | | const css::uno::Reference < css::drawing::XShape >& xShape); |
228 | | |
229 | | // This method exports the given XShape |
230 | | void exportShape( |
231 | | const css::uno::Reference < css::drawing::XShape >& xShape, |
232 | | XMLShapeExportFlags nFeatures = SEF_DEFAULT, |
233 | | css::awt::Point* pRefPoint = nullptr, |
234 | | comphelper::AttributeList* pAttrList = nullptr |
235 | | ); |
236 | | |
237 | | // This method collects all automatic styles for the shapes inside the given XShapes collection |
238 | | void collectShapesAutoStyles( |
239 | | const css::uno::Reference < css::drawing::XShapes >& xShapes); |
240 | | |
241 | | // This method exports all XShape inside the given XShapes collection |
242 | | void exportShapes( |
243 | | const css::uno::Reference < css::drawing::XShapes >& xShapes, |
244 | | XMLShapeExportFlags nFeatures = SEF_DEFAULT, |
245 | | css::awt::Point* pRefPoint = nullptr |
246 | | ); |
247 | | |
248 | | /** initializes some internal structures for fast access to the given XShapes collection |
249 | | |
250 | | <p>This method has to be called before you use exportShape or collectShapeAutoStyles. |
251 | | It is automatically called if you use collectShapesAutoStyles and exportShapes. |
252 | | |
253 | | @see collectShapeAutoStyles |
254 | | @see exportShape |
255 | | @see collectShapesAutoStyles |
256 | | @see exportShapes |
257 | | */ |
258 | | void seekShapes( |
259 | | const css::uno::Reference< css::drawing::XShapes >& xShapes ) noexcept; |
260 | | |
261 | | void exportAutoStyles(); |
262 | | |
263 | | /** sets a new reference to an XMLAnimationExporter. |
264 | | If this is a non NULL reference, the animation information from all shapes given to exportShape() |
265 | | from now on are collected. |
266 | | */ |
267 | 0 | void setAnimationsExporter( rtl::Reference< XMLAnimationsExporter > const & xAnimExport ) { mxAnimationsExporter = xAnimExport; } |
268 | | |
269 | | /** returns the last set XMLAnimationExport */ |
270 | 0 | const rtl::Reference< XMLAnimationsExporter >& getAnimationsExporter() const { return mxAnimationsExporter; } |
271 | | |
272 | | /// returns the export property mapper for external chaining |
273 | | static SvXMLExportPropertyMapper* CreateShapePropMapper( SvXMLExport& rExport ); |
274 | | |
275 | 104 | void enableLayerExport() { mbExportLayer = true; } |
276 | | |
277 | | /** defines if the export should increment the progress bar or not */ |
278 | 104 | void enableHandleProgressBar() { mbHandleProgressBar = true; } |
279 | 5.83k | bool IsHandleProgressBarEnabled() const { return mbHandleProgressBar; } |
280 | | |
281 | 214 | void setPresentationStylePrefix( const OUString& rPrefix ) { msPresentationStylePrefix = rPrefix; } |
282 | | |
283 | | /** helper for chart that adds all attributes of a 3d scene element to the export */ |
284 | | void export3DSceneAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); |
285 | | |
286 | | /** helper for chart that exports all lamps from the propertyset */ |
287 | | void export3DLamps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); |
288 | | |
289 | | /** sj: replacing CustomShapes with standard objects that are also supported in OpenOffice.org format */ |
290 | | css::uno::Reference < css::drawing::XShape > checkForCustomShapeReplacement( |
291 | | const css::uno::Reference < css::drawing::XShape >& ); |
292 | | |
293 | | /** replacing PDF with drawing objects */ |
294 | | css::uno::Reference<css::lang::XComponent> checkForPDFShapeReplacement( |
295 | | const css::uno::Reference<css::drawing::XShape>& xShape); |
296 | | |
297 | | /** helper to export the style for graphic defaults */ |
298 | | void ExportGraphicDefaults(); |
299 | | |
300 | | /** is called before a shape element for the given XShape is exported */ |
301 | | virtual void onExport( const css::uno::Reference < css::drawing::XShape >& xShape ); |
302 | | |
303 | | const rtl::Reference< XMLTableExport >& GetShapeTableExport(); |
304 | | }; |
305 | | |
306 | | namespace xmloff { |
307 | | |
308 | | XMLOFF_DLLPUBLIC void FixZOrder( |
309 | | css::uno::Reference<css::drawing::XShapes> const& xShapes, |
310 | | std::function<unsigned int (css::uno::Reference<css::beans::XPropertySet> const&)> const& rGetLayer); |
311 | | |
312 | | } // namespace xmloff |
313 | | |
314 | | #endif |
315 | | |
316 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |