LibreOffice Module xmloff (master) 1
shapeexport.hxx
Go to the documentation of this file.
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>
30
31#include <functional>
32#include <map>
33#include <xmloff/animexp.hxx>
34#include <xmloff/families.hxx>
35#include <xmloff/txtparae.hxx>
37
38namespace com::sun::star::awt { struct Point; }
39namespace com::sun::star::beans { class XPropertySet; }
40namespace com::sun::star::drawing { class XShape; }
41namespace com::sun::star::drawing { class XShapes; }
42
43class XMLTableExport;
44namespace comphelper { class AttributeList; }
46
47// shape export features are bits used for the nFeature
48// parameter of XMLShapeExport::exportShape
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};
63namespace o3tl
64{
65 template<> struct typed_flags<XMLShapeExportFlags> : is_typed_flags<XMLShapeExportFlags, 0x6f> {};
66}
67
68#define SEF_DEFAULT XMLShapeExportFlags::POSITION|XMLShapeExportFlags::SIZE
69
70enum 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
127};
128
131{
132 OUString msStyleName;
136
137 css::uno::Reference< css::drawing::XShape > xCustomShapeReplacement;
138
140};
141
143typedef std::vector< ImplXMLShapeExportInfo > ImplXMLShapeExportInfoVector;
144
146typedef std::map< css::uno::Reference < css::drawing::XShapes >, ImplXMLShapeExportInfoVector > ShapesInfos;
147
148class SvXMLExport;
150
151namespace basegfx
152{
153 class B2DTuple;
154 class B2DHomMatrix;
155}
156
158{
159private:
160
165 ShapesInfos::iterator maCurrentShapesIter;
168
169 // #88546# possibility to switch progress bar handling on/off
171
173
174protected:
175 SvXMLExport& GetExport() { return mrExport; }
176 const SvXMLExport& GetExport() const { return mrExport; }
177private:
178
179 SAL_DLLPRIVATE const rtl::Reference< SvXMLExportPropertyMapper >& GetPropertySetMapper() const { return mxPropertySetMapper; }
180
181 OUStringBuffer msBuffer;
182
183 SAL_DLLPRIVATE void ImpCalcShapeType(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType& eShapeType);
184
185 SAL_DLLPRIVATE void ImpExportNewTrans(const css::uno::Reference< css::beans::XPropertySet >& xPropSet, XMLShapeExportFlags nFeatures, css::awt::Point* pRefPoint);
186 SAL_DLLPRIVATE void ImpExportNewTrans_GetB2DHomMatrix(::basegfx::B2DHomMatrix& rMatrix, const css::uno::Reference< css::beans::XPropertySet >& xPropSet);
187 SAL_DLLPRIVATE static void ImpExportNewTrans_DecomposeAndRefPoint(const ::basegfx::B2DHomMatrix& rMat, ::basegfx::B2DTuple& rTRScale, double& fTRShear, double& fTRRotate, ::basegfx::B2DTuple& rTRTranslate, css::awt::Point* pRefPoint);
188 SAL_DLLPRIVATE void ImpExportNewTrans_FeaturesAndWrite(::basegfx::B2DTuple const & rTRScale, double fTRShear, double fTRRotate, ::basegfx::B2DTuple const & rTRTranslate, const XMLShapeExportFlags nFeatures);
189 SAL_DLLPRIVATE bool ImpExportPresentationAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet, const OUString& rClass );
190 SAL_DLLPRIVATE void ImpExportText( const css::uno::Reference< css::drawing::XShape >& xShape, TextPNS eExtensionNS = TextPNS::ODF );
191 SAL_DLLPRIVATE void ImpExportEvents( const css::uno::Reference< css::drawing::XShape >& xShape );
192 SAL_DLLPRIVATE void ImpExportDescription( const css::uno::Reference< css::drawing::XShape >& xShape ); // #i68101#
193 SAL_DLLPRIVATE void ImpExportGluePoints( const css::uno::Reference< css::drawing::XShape >& xShape );
194 SAL_DLLPRIVATE void ImpExportSignatureLine(const css::uno::Reference<css::drawing::XShape>& xShape);
195 SAL_DLLPRIVATE void ImpExportQRCode(const css::uno::Reference<css::drawing::XShape>& xShape);
196
197 // single shape exporters
198 SAL_DLLPRIVATE void ImpExportGroupShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
199 SAL_DLLPRIVATE void ImpExport3DSceneShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
200 SAL_DLLPRIVATE void ImpExportRectangleShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
201 SAL_DLLPRIVATE void ImpExportLineShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
202 SAL_DLLPRIVATE void ImpExportEllipseShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
203 SAL_DLLPRIVATE void ImpExportPolygonShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
204 SAL_DLLPRIVATE void ImpExportTextBoxShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
205 SAL_DLLPRIVATE void ImpExportGraphicObjectShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
206 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 );
207 SAL_DLLPRIVATE void ImpExportControlShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
208 SAL_DLLPRIVATE void ImpExportConnectorShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
209 SAL_DLLPRIVATE void ImpExportMeasureShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point const * pRefPoint = nullptr );
210 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 );
211 SAL_DLLPRIVATE void ImpExportPageShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
212 SAL_DLLPRIVATE void ImpExportCaptionShape(const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
213 SAL_DLLPRIVATE void ImpExport3DShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType );
214 SAL_DLLPRIVATE void ImpExportFrameShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
215 SAL_DLLPRIVATE void ImpExportPluginShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
216 SAL_DLLPRIVATE void ImpExportAppletShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
217 SAL_DLLPRIVATE void ImpExportCustomShape( const css::uno::Reference< css::drawing::XShape >& xShape, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
218 SAL_DLLPRIVATE void ImpExportMediaShape( const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
219 SAL_DLLPRIVATE void ImpExportTableShape(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType eShapeType, XMLShapeExportFlags nFeatures = SEF_DEFAULT, css::awt::Point* pRefPoint = nullptr );
220public:
221 XMLShapeExport(SvXMLExport& rExp, SvXMLExportPropertyMapper *pExtMapper=nullptr );
222 virtual ~XMLShapeExport() override;
223
224 // This method collects all automatic styles for the given XShape
225 void collectShapeAutoStyles(
226 const css::uno::Reference < css::drawing::XShape >& xShape);
227
228 // This method exports the given XShape
229 void exportShape(
230 const css::uno::Reference < css::drawing::XShape >& xShape,
232 css::awt::Point* pRefPoint = nullptr,
233 comphelper::AttributeList* pAttrList = nullptr
234 );
235
236 // This method collects all automatic styles for the shapes inside the given XShapes collection
237 void collectShapesAutoStyles(
238 const css::uno::Reference < css::drawing::XShapes >& xShapes);
239
240 // This method exports all XShape inside the given XShapes collection
241 void exportShapes(
242 const css::uno::Reference < css::drawing::XShapes >& xShapes,
244 css::awt::Point* pRefPoint = nullptr
245 );
246
257 void seekShapes(
258 const css::uno::Reference< css::drawing::XShapes >& xShapes ) noexcept;
259
260 void exportAutoStyles();
261
266 void setAnimationsExporter( rtl::Reference< XMLAnimationsExporter > const & xAnimExport ) { mxAnimationsExporter = xAnimExport; }
267
269 const rtl::Reference< XMLAnimationsExporter >& getAnimationsExporter() const { return mxAnimationsExporter; }
270
272 static SvXMLExportPropertyMapper* CreateShapePropMapper( SvXMLExport& rExport );
273
274 void enableLayerExport() { mbExportLayer = true; }
275
277 void enableHandleProgressBar() { mbHandleProgressBar = true; }
278 bool IsHandleProgressBarEnabled() const { return mbHandleProgressBar; }
279
280 void setPresentationStylePrefix( const OUString& rPrefix ) { msPresentationStylePrefix = rPrefix; }
281
283 void export3DSceneAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
284
286 void export3DLamps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
287
289 css::uno::Reference < css::drawing::XShape > checkForCustomShapeReplacement(
290 const css::uno::Reference < css::drawing::XShape >& );
291
293 void ExportGraphicDefaults();
294
296 virtual void onExport( const css::uno::Reference < css::drawing::XShape >& xShape );
297
298 const rtl::Reference< XMLTableExport >& GetShapeTableExport();
299};
300
301namespace xmloff {
302
304 css::uno::Reference<css::drawing::XShapes> const& xShapes,
305 std::function<unsigned int (css::uno::Reference<css::beans::XPropertySet> const&)> const& rGetLayer);
306
307} // namespace xmloff
308
309#endif
310
311/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class is a base-class to create XMLPropertyHandler.
Definition: prhdlfac.hxx:41
SvXMLExport & mrExport
ShapesInfos maShapesInfos
void setAnimationsExporter(rtl::Reference< XMLAnimationsExporter > const &xAnimExport)
sets a new reference to an XMLAnimationExporter.
OUString msPresentationStylePrefix
bool IsHandleProgressBarEnabled() const
bool mbHandleProgressBar
rtl::Reference< XMLTableExport > mxShapeTableExport
void enableHandleProgressBar()
defines if the export should increment the progress bar or not
void setPresentationStylePrefix(const OUString &rPrefix)
SAL_DLLPRIVATE const rtl::Reference< SvXMLExportPropertyMapper > & GetPropertySetMapper() const
rtl::Reference< SvXMLExportPropertyMapper > mxPropertySetMapper
OUStringBuffer msBuffer
ShapesInfos::iterator maCurrentShapesIter
const SvXMLExport & GetExport() const
const rtl::Reference< XMLAnimationsExporter > & getAnimationsExporter() const
returns the last set XMLAnimationExport
void enableLayerExport()
rtl::Reference< XMLAnimationsExporter > mxAnimationsExporter
SvXMLExport & GetExport()
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
XmlStyleFamily
Definition: families.hxx:50
NONE
class SAL_NO_VTABLE XPropertySet
Unknown
const sal_uInt16 WIDTH
constexpr tools::Long SIZE
void FixZOrder(uno::Reference< drawing::XShapes > const &xShapes, std::function< unsigned int(uno::Reference< beans::XPropertySet > const &)> const &rGetLayer)
#define HEIGHT
#define Y
XmlShapeType
Definition: shapeexport.hxx:71
@ DrawGraphicObjectShape
@ PresGraphicObjectShape
#define SEF_DEFAULT
Definition: shapeexport.hxx:68
std::vector< ImplXMLShapeExportInfo > ImplXMLShapeExportInfoVector
a vector for shape style and type cache information
XMLShapeExportFlags
Definition: shapeexport.hxx:49
std::map< css::uno::Reference< css::drawing::XShapes >, ImplXMLShapeExportInfoVector > ShapesInfos
a map to store all cache data for already collected XShapes
caches style and type info after a collectShapeAutostyle for later use in exportShape
XmlShapeType meShapeType
XmlStyleFamily mnFamily
css::uno::Reference< css::drawing::XShape > xCustomShapeReplacement
TextPNS
Definition: txtparae.hxx:74