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 <map>
32 #include <xmloff/animexp.hxx>
33 #include <xmloff/families.hxx>
34 #include <xmloff/txtparae.hxx>
35 #include <o3tl/typed_flags_set.hxx>
36 
37 namespace com::sun::star::awt { struct Point; }
38 namespace com::sun::star::beans { class XPropertySet; }
39 namespace com::sun::star::drawing { class XShape; }
40 namespace com::sun::star::drawing { class XShapes; }
41 
42 class XMLTableExport;
43 class SvXMLAttributeList;
45 
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,
61 };
62 namespace o3tl
63 {
64  template<> struct typed_flags<XMLShapeExportFlags> : is_typed_flags<XMLShapeExportFlags, 0x6f> {};
65 }
66 
67 #define SEF_DEFAULT XMLShapeExportFlags::POSITION|XMLShapeExportFlags::SIZE
68 
70 {
71  XmlShapeTypeUnknown, // not known
72 
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"
94 
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"
100 
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"
113 
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"
118 
119  XmlShapeTypeDrawCustomShape, // "com.sun.star.drawing.CustomShape"
120  XmlShapeTypeDrawMediaShape, // "com.sun.star.drawing.MediaShape"
121  XmlShapeTypePresMediaShape, // "com.sun.star.presentation.MediaShape"
122 
123  XmlShapeTypeDrawTableShape, // "com.sun.star.drawing.TableShape"
124 
126 };
127 
130 {
131  OUString msStyleName;
132  OUString msTextStyleName;
135 
136  css::uno::Reference< css::drawing::XShape > xCustomShapeReplacement;
137 
139 };
140 
142 typedef std::vector< ImplXMLShapeExportInfo > ImplXMLShapeExportInfoVector;
143 
145 typedef std::map< css::uno::Reference < css::drawing::XShapes >, ImplXMLShapeExportInfoVector > ShapesInfos;
146 
147 class SvXMLExport;
149 
150 namespace basegfx
151 {
152  class B2DTuple;
153  class B2DHomMatrix;
154 }
155 
157 {
158 private:
159 
164  ShapesInfos::iterator maCurrentShapesIter;
167 
168  // #88546# possibility to switch progress bar handling on/off
170 
172 
173 protected:
174  SvXMLExport& GetExport() { return mrExport; }
175  const SvXMLExport& GetExport() const { return mrExport; }
176 private:
177 
178  SAL_DLLPRIVATE const rtl::Reference< SvXMLExportPropertyMapper >& GetPropertySetMapper() const { return mxPropertySetMapper; }
179 
180  OUStringBuffer msBuffer;
181 
182  SAL_DLLPRIVATE void ImpCalcShapeType(const css::uno::Reference< css::drawing::XShape >& xShape, XmlShapeType& eShapeType);
183 
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);
195 
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;
222 
223  // This method collects all automatic styles for the given XShape
224  void collectShapeAutoStyles(
225  const css::uno::Reference < css::drawing::XShape >& xShape);
226 
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
233  );
234 
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);
238 
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
244  );
245 
256  void seekShapes(
257  const css::uno::Reference< css::drawing::XShapes >& xShapes ) throw();
258 
259  void exportAutoStyles();
260 
265  void setAnimationsExporter( rtl::Reference< XMLAnimationsExporter > const & xAnimExport ) { mxAnimationsExporter = xAnimExport; }
266 
268  const rtl::Reference< XMLAnimationsExporter >& getAnimationsExporter() const { return mxAnimationsExporter; }
269 
271  static SvXMLExportPropertyMapper* CreateShapePropMapper( SvXMLExport& rExport );
272 
273  void enableLayerExport() { mbExportLayer = true; }
274 
276  void enableHandleProgressBar() { mbHandleProgressBar = true; }
277  bool IsHandleProgressBarEnabled() const { return mbHandleProgressBar; }
278 
279  void setPresentationStylePrefix( const OUString& rPrefix ) { msPresentationStylePrefix = rPrefix; }
280 
282  void export3DSceneAttributes( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
283 
285  void export3DLamps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
286 
288  css::uno::Reference < css::drawing::XShape > checkForCustomShapeReplacement(
289  const css::uno::Reference < css::drawing::XShape >& );
290 
292  void ExportGraphicDefaults();
293 
295  virtual void onExport( const css::uno::Reference < css::drawing::XShape >& xShape );
296 
297  const rtl::Reference< XMLTableExport >& GetShapeTableExport();
298 };
299 
300 #endif
301 
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setPresentationStylePrefix(const OUString &rPrefix)
const SvXMLExport & GetExport() const
ShapesInfos maShapesInfos
XmlShapeType
Definition: shapeexport.hxx:69
XmlShapeType meShapeType
css::uno::Reference< css::drawing::XShape > xCustomShapeReplacement
rtl::Reference< XMLAnimationsExporter > mxAnimationsExporter
This class is a base-class to create XMLPropertyHandler.
Definition: prhdlfac.hxx:40
#define HEIGHT
XmlStyleFamily mnFamily
XmlStyleFamily
Definition: families.hxx:47
TextPNS
Definition: txtparae.hxx:70
void enableHandleProgressBar()
defines if the export should increment the progress bar or not
void setAnimationsExporter(rtl::Reference< XMLAnimationsExporter > const &xAnimExport)
sets a new reference to an XMLAnimationExporter.
rtl::Reference< XMLTableExport > mxShapeTableExport
rtl::Reference< SvXMLExportPropertyMapper > mxPropertySetMapper
class SAL_NO_VTABLE XPropertySet
std::vector< ImplXMLShapeExportInfo > ImplXMLShapeExportInfoVector
a vector for shape style and type cache information
bool IsHandleProgressBarEnabled() const
OUStringBuffer msBuffer
#define SEF_DEFAULT
Definition: shapeexport.hxx:67
void enableLayerExport()
XMLShapeExportFlags
Definition: shapeexport.hxx:48
const sal_uInt16 WIDTH
const rtl::Reference< XMLAnimationsExporter > & getAnimationsExporter() const
returns the last set XMLAnimationExport
bool mbHandleProgressBar
ShapesInfos::iterator maCurrentShapesIter
SvXMLExport & GetExport()
css::uno::Any const SvXMLExport & rExport
Definition: ImageStyle.hxx:38
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
OUString msPresentationStylePrefix
caches style and type info after a collectShapeAutostyle for later use in exportShape ...
SvXMLExport & mrExport
std::map< css::uno::Reference< css::drawing::XShapes >, ImplXMLShapeExportInfoVector > ShapesInfos
a map to store all cache data for already collected XShapes
SAL_DLLPRIVATE const rtl::Reference< SvXMLExportPropertyMapper > & GetPropertySetMapper() const