update emoji autocorrect entries from po-files
[LibreOffice.git] / include / xmloff / shapeexport.hxx
blob8ba396903136542f3e1cc2baa5d2b9b983643c30
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 <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>
41 #include <xmloff/txtparae.hxx>
42 #include <o3tl/typed_flags_set.hxx>
44 #include <xmloff/table/XMLTableExport.hxx>
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 = 0x000c,
56 // when you set this flag a chart does NOT export its own data as table element
57 NO_CHART_DATA = 0x0010,
58 // When setting the flag below no ignorableWhiteSpace will be called around
59 // the drawing object elements
60 NO_WS = 0x0020,
61 // When setting the flag below a callout shape is exported as office:annotation
62 ANNOTATION = 0x0040,
64 namespace o3tl
66 template<> struct typed_flags<XMLShapeExportFlags> : is_typed_flags<XMLShapeExportFlags, 0x7f> {};
69 #define SEF_DEFAULT XMLShapeExportFlags::POSITION|XMLShapeExportFlags::SIZE
71 enum XmlShapeType
73 XmlShapeTypeUnknown, // not known
75 XmlShapeTypeDrawRectangleShape, // "com.sun.star.drawing.RectangleShape"
76 XmlShapeTypeDrawEllipseShape, // "com.sun.star.drawing.EllipseShape"
77 XmlShapeTypeDrawControlShape, // "com.sun.star.drawing.ControlShape"
78 XmlShapeTypeDrawConnectorShape, // "com.sun.star.drawing.ConnectorShape"
79 XmlShapeTypeDrawMeasureShape, // "com.sun.star.drawing.MeasureShape"
80 XmlShapeTypeDrawLineShape, // "com.sun.star.drawing.LineShape"
81 XmlShapeTypeDrawPolyPolygonShape, // "com.sun.star.drawing.PolyPolygonShape"
82 XmlShapeTypeDrawPolyLineShape, // "com.sun.star.drawing.PolyLineShape"
83 XmlShapeTypeDrawOpenBezierShape, // "com.sun.star.drawing.OpenBezierShape"
84 XmlShapeTypeDrawClosedBezierShape, // "com.sun.star.drawing.ClosedBezierShape"
85 XmlShapeTypeDrawGraphicObjectShape, // "com.sun.star.drawing.GraphicObjectShape"
86 XmlShapeTypeDrawGroupShape, // "com.sun.star.drawing.GroupShape"
87 XmlShapeTypeDrawTextShape, // "com.sun.star.drawing.TextShape"
88 XmlShapeTypeDrawOLE2Shape, // "com.sun.star.drawing.OLE2Shape"
89 XmlShapeTypeDrawChartShape, // embedded com.sun.star.chart
90 XmlShapeTypeDrawSheetShape, // embedded com.sun.star.sheet
91 XmlShapeTypeDrawPageShape, // "com.sun.star.drawing.PageShape"
92 XmlShapeTypeDrawFrameShape, // "com.sun.star.drawing.FrameShape"
93 XmlShapeTypeDrawCaptionShape, // "com.sun.star.drawing.CaptionShape"
94 XmlShapeTypeDrawAppletShape, // "com.sun.star.drawing.AppletShape"
95 XmlShapeTypeDrawPluginShape, // "com.sun.star.drawing.PlugginShape"
97 XmlShapeTypeDraw3DSceneObject, // "com.sun.star.drawing.Shape3DSceneObject"
98 XmlShapeTypeDraw3DCubeObject, // "com.sun.star.drawing.Shape3DCubeObject"
99 XmlShapeTypeDraw3DSphereObject, // "com.sun.star.drawing.Shape3DSphereObject"
100 XmlShapeTypeDraw3DLatheObject, // "com.sun.star.drawing.Shape3DLatheObject"
101 XmlShapeTypeDraw3DExtrudeObject, // "com.sun.star.drawing.Shape3DExtrudeObject"
103 XmlShapeTypePresTitleTextShape, // "com.sun.star.presentation.TitleTextShape"
104 XmlShapeTypePresOutlinerShape, // "com.sun.star.presentation.OutlinerShape"
105 XmlShapeTypePresSubtitleShape, // "com.sun.star.presentation.SubtitleShape"
106 XmlShapeTypePresGraphicObjectShape, // "com.sun.star.presentation.GraphicObjectShape"
107 XmlShapeTypePresPageShape, // "com.sun.star.presentation.PageShape"
108 XmlShapeTypePresOLE2Shape, // "com.sun.star.presentation.OLE2Shape"
109 XmlShapeTypePresChartShape, // "com.sun.star.presentation.ChartShape"
110 XmlShapeTypePresSheetShape, // "com.sun.star.presentation.CalcShape"
111 XmlShapeTypePresTableShape, // "com.sun.star.presentation.TableShape"
112 XmlShapeTypePresOrgChartShape, // "com.sun.star.presentation.OrgChartShape"
113 XmlShapeTypePresNotesShape, // "com.sun.star.presentation.NotesShape"
114 XmlShapeTypeHandoutShape, // "com.sun.star.presentation.HandoutShape"
116 XmlShapeTypePresHeaderShape, // "com.sun.star.presentation.HeaderShape"
117 XmlShapeTypePresFooterShape, // "com.sun.star.presentation.FooterShape"
118 XmlShapeTypePresSlideNumberShape, // "com.sun.star.presentation.SlideNumberShape"
119 XmlShapeTypePresDateTimeShape, // "com.sun.star.presentation.DateTimeShape"
121 XmlShapeTypeDrawCustomShape, // "com.sun.star.drawing.CustomShape"
122 XmlShapeTypeDrawMediaShape, // "com.sun.star.drawing.MediaShape"
123 XmlShapeTypePresMediaShape, // "com.sun.star.presentation.MediaShape"
125 XmlShapeTypeDrawTableShape, // "com.sun.star.drawing.TableShape"
127 XmlShapeTypeNotYetSet
130 /** caches style and type info after a collectShapeAutostyle for later use in exportShape */
131 struct ImplXMLShapeExportInfo
133 OUString msStyleName;
134 OUString msTextStyleName;
135 sal_Int32 mnFamily;
136 XmlShapeType meShapeType;
138 com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xCustomShapeReplacement;
140 ImplXMLShapeExportInfo() : mnFamily( XML_STYLE_FAMILY_SD_GRAPHICS_ID ), meShapeType( XmlShapeTypeNotYetSet ) {}
143 /** a vector for shape style and type cache information */
144 typedef std::vector< ImplXMLShapeExportInfo > ImplXMLShapeExportInfoVector;
146 /** a map to store all cache data for already collected XShapes */
147 typedef std::map< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes >, ImplXMLShapeExportInfoVector > ShapesInfos;
149 class SvXMLExport;
150 class SvXMLExportPropertyMapper;
152 namespace basegfx
154 class B2DTuple;
155 class B2DHomMatrix;
158 class XMLOFF_DLLPUBLIC XMLShapeExport : public salhelper::SimpleReferenceObject
160 private:
162 SvXMLExport& mrExport;
163 rtl::Reference< XMLPropertyHandlerFactory > mxSdPropHdlFactory;
164 rtl::Reference< SvXMLExportPropertyMapper > mxPropertySetMapper;
165 rtl::Reference< XMLAnimationsExporter > mxAnimationsExporter;
166 ShapesInfos maShapesInfos;
167 ShapesInfos::iterator maCurrentShapesIter;
168 bool mbExportLayer;
169 ImplXMLShapeExportInfoVector maShapeInfos;
170 ImplXMLShapeExportInfoVector::iterator maCurrentInfo;
171 OUString msPresentationStylePrefix;
173 // #88546# possibility to swich progress bar handling on/off
174 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 rtl::Reference< 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, XMLShapeExportFlags 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 XMLShapeExportFlags nFeatures);
216 SAL_DLLPRIVATE 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, TextPNS eExtensionNS = TextPNS::ODF );
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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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, XMLShapeExportFlags 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 XMLShapeExportFlags 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 XMLShapeExportFlags 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 automatically 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( rtl::Reference< XMLAnimationsExporter > xAnimExport ) { mxAnimationsExporter = xAnimExport; }
293 /** returns the last set XMLAnimationExport */
294 rtl::Reference< XMLAnimationsExporter > getAnimationsExporter() const { return mxAnimationsExporter; }
296 /// returns the export property mapper for external chaining
297 static SvXMLExportPropertyMapper* CreateShapePropMapper( SvXMLExport& rExport );
299 void enableLayerExport( bool bEnable = true ) { mbExportLayer = bEnable; }
300 bool IsLayerExportEnabled() const { return mbExportLayer; }
302 // #88546#
303 /** defines if the export should increment the progress bar or not */
304 void enableHandleProgressBar( bool bEnable = true ) { mbHandleProgressBar = bEnable; }
305 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();
328 #endif
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */