Bump version to 6.4-15
[LibreOffice.git] / include / oox / export / drawingml.hxx
blobfb7b7877138c4a9b545755f165958a83022c6bf3
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 .
20 #ifndef INCLUDED_OOX_EXPORT_DRAWINGML_HXX
21 #define INCLUDED_OOX_EXPORT_DRAWINGML_HXX
23 #include <map>
24 #include <vector>
26 #include <com/sun/star/beans/PropertyState.hpp>
27 #include <com/sun/star/uno/Any.hxx>
28 #include <com/sun/star/uno/Reference.hxx>
29 #include <com/sun/star/uno/Sequence.hxx>
30 #include <com/sun/star/style/ParagraphAdjust.hpp>
31 #include <com/sun/star/drawing/Hatch.hpp>
32 #include <com/sun/star/i18n/ScriptType.hpp>
33 #include <oox/dllapi.h>
34 #include <oox/drawingml/drawingmltypes.hxx>
35 #include <oox/token/tokens.hxx>
36 #include <oox/export/utils.hxx>
37 #include <rtl/string.hxx>
38 #include <rtl/ustring.hxx>
39 #include <sal/types.h>
40 #include <sax/fshelper.hxx>
41 #include <svx/msdffdef.hxx>
42 #include <vcl/checksum.hxx>
43 #include <tools/gen.hxx>
44 #include <vcl/mapmod.hxx>
46 class Graphic;
47 class SdrObjCustomShape;
49 namespace com { namespace sun { namespace star {
50 namespace awt {
51 struct FontDescriptor;
52 struct Gradient;
54 namespace beans {
55 struct PropertyValue;
56 class XPropertySet;
57 class XPropertyState;
59 namespace drawing {
60 class XShape;
61 struct EnhancedCustomShapeParameterPair;
62 struct EnhancedCustomShapeParameter;
64 namespace graphic {
65 class XGraphic;
67 namespace style {
68 struct LineSpacing;
70 namespace text {
71 class XTextContent;
72 class XTextRange;
74 namespace io {
75 class XOutputStream;
77 namespace uno {
78 class XInterface;
80 namespace frame {
81 class XModel;
83 }}}
85 struct EscherConnectorListEntry;
86 class OutlinerParaObject;
87 namespace tools { class Rectangle; }
89 namespace tools {
90 class PolyPolygon;
93 namespace oox {
94 namespace core {
95 class XmlFilterBase;
98 namespace drawingml {
100 class OOX_DLLPUBLIC URLTransformer
102 public:
103 virtual ~URLTransformer();
105 virtual OUString getTransformedString(const OUString& rURL) const;
107 virtual bool isExternalURL(const OUString& rURL) const;
110 // Our rotation is counter-clockwise and is in 100ths of a degree.
111 // drawingML rotation is clockwise and is in 60000ths of a degree.
112 template <typename T> T ExportRotateClockwisify(T input)
114 return ((21600000 - input * 600) % 21600000);
117 /// Interface to be implemented by the parent exporter that knows how to handle shape text.
118 class OOX_DLLPUBLIC DMLTextExport
120 public:
121 virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
122 /// Write the contents of the textbox that is associated to this shape.
123 virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
124 /// Look up the RelId of a graphic based on its checksum.
125 virtual OUString FindRelId(BitmapChecksum nChecksum) = 0;
126 /// Store the RelId of a graphic based on its checksum.
127 virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId) = 0;
128 protected:
129 DMLTextExport() {}
130 virtual ~DMLTextExport() {}
133 class OOX_DLLPUBLIC DrawingML
136 private:
137 static int mnImageCounter;
138 static int mnWdpImageCounter;
139 static std::map<OUString, OUString> maWdpCache;
141 /// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
142 DocumentType const meDocumentType;
143 /// Parent exporter, used for text callback.
144 DMLTextExport* mpTextExport;
146 protected:
147 css::uno::Any mAny;
148 ::sax_fastparser::FSHelperPtr mpFS;
149 ::oox::core::XmlFilterBase* mpFB;
150 /// If set, this is the parent of the currently handled shape.
151 css::uno::Reference<css::drawing::XShape> m_xParent;
152 bool mbIsBackgroundDark;
154 bool GetProperty( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& aName );
155 bool GetPropertyAndState( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
156 const css::uno::Reference< css::beans::XPropertyState >& rXPropState,
157 const OUString& aName, css::beans::PropertyState& eState );
158 OUString GetFieldValue( const css::uno::Reference< css::text::XTextRange >& rRun, bool& bIsURLField );
160 /// Output the media (including copying a video from vnd.sun.star.Package: to the output if necessary).
161 void WriteMediaNonVisualProperties(const css::uno::Reference<css::drawing::XShape>& xShape);
163 void WriteStyleProperties( sal_Int32 nTokenId, const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
165 const char* GetComponentDir() const;
166 const char* GetRelationCompPrefix() const;
168 static bool EqualGradients( css::awt::Gradient aGradient1, css::awt::Gradient aGradient2 );
170 public:
171 DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = nullptr )
172 : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( pFS ), mpFB( pFB ), mbIsBackgroundDark( false ) {}
173 void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
174 const ::sax_fastparser::FSHelperPtr& GetFS() const { return mpFS; }
175 ::oox::core::XmlFilterBase* GetFB() { return mpFB; }
176 DocumentType GetDocumentType() const { return meDocumentType; }
177 /// The application-specific text exporter callback, if there is one.
178 DMLTextExport* GetTextExport() { return mpTextExport; }
180 void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; }
181 /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
182 OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
184 void WriteColor( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
185 void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
186 void WriteColorTransformations( const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
187 void WriteGradientStop(sal_uInt16 nStop, ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT);
188 void WriteLineArrow( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, bool bLineStart );
189 void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID );
191 void WriteSolidFill( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
192 void WriteSolidFill( const OUString& sSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
193 void WriteSolidFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
194 void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
196 void WriteGradientFill( css::awt::Gradient rGradient, css::awt::Gradient rTransparenceGradient,
197 const css::uno::Reference<css::beans::XPropertySet>& rXPropSet = css::uno::Reference<css::beans::XPropertySet>());
199 void WriteGrabBagGradientFill( const css::uno::Sequence< css::beans::PropertyValue >& aGradientStops, css::awt::Gradient rGradient);
201 void WriteBlipOrNormalFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
202 const OUString& rURLPropName );
203 void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
204 const OUString& sURLPropName );
205 void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
206 const OUString& sURLPropName, sal_Int32 nXmlNamespace );
208 void WriteXGraphicBlipFill(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
209 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
210 sal_Int32 nXmlNamespace, bool bWriteMode, bool bRelPathToMedia = false);
212 void WritePattFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
213 void WritePattFill(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
214 const css::drawing::Hatch& rHatch);
216 void WriteGraphicCropProperties(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet,
217 Size const & rOriginalSize, MapMode const & rMapMode);
219 void WriteSrcRectXGraphic(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet,
220 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
222 void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
223 css::uno::Reference< css::frame::XModel> const & xModel = nullptr );
225 void WriteXGraphicStretch(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
226 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
228 void WriteLinespacing( const css::style::LineSpacing& rLineSpacing );
230 OUString WriteXGraphicBlip(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
231 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
232 bool bRelPathToMedia);
234 void WriteImageBrightnessContrastTransparence(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet);
236 void WriteXGraphicBlipMode(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
237 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
239 void WriteShapeTransformation(const css::uno::Reference< css::drawing::XShape >& rXShape,
240 sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false, bool bSuppressFlipping = false, bool bFlippedBeforeRotation = false);
241 void WriteTransformation(const tools::Rectangle& rRectangle,
242 sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0, bool bIsGroupShape = false);
244 void WriteText( const css::uno::Reference< css::uno::XInterface >& rXIface, const OUString& presetWarp, bool bBodyPr, bool bText = true, sal_Int32 nXmlNamespace = 0);
245 void WriteParagraph( const css::uno::Reference< css::text::XTextContent >& rParagraph,
246 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight );
247 void WriteParagraphProperties(const css::uno::Reference< css::text::XTextContent >& rParagraph, float fFirstCharHeight);
248 void WriteParagraphNumbering(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, float fFirstCharHeight,
249 sal_Int16 nLevel );
250 void WriteParagraphTabStops(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
251 void WriteRun( const css::uno::Reference< css::text::XTextRange >& rRun,
252 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight );
253 void WriteRunProperties( const css::uno::Reference< css::beans::XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect,
254 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight, sal_Int16 nScriptType = css::i18n::ScriptType::LATIN);
256 void WritePresetShape( const char* pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList );
257 void WritePresetShape( const char* pShape );
258 void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, const css::beans::PropertyValue& rProp );
259 bool WriteCustomGeometry(
260 const css::uno::Reference<css::drawing::XShape>& rXShape,
261 const SdrObjCustomShape& rSdrObjCustomShape);
262 void WriteCustomGeometryPoint(
263 const css::drawing::EnhancedCustomShapeParameterPair& rParamPair,
264 const SdrObjCustomShape& rSdrObjCustomShape);
265 static sal_Int32 GetCustomGeometryPointValue(
266 const css::drawing::EnhancedCustomShapeParameter& rParam,
267 const SdrObjCustomShape& rSdrObjCustomShape);
268 void WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon, const bool bClosed );
269 void WriteFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
270 void WriteShapeStyle( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
271 void WriteShapeEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
272 void WriteShapeEffect( const OUString& sName, const css::uno::Sequence< css::beans::PropertyValue >& aEffectProps );
273 void WriteShape3DEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
274 void WriteArtisticEffect( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
275 OString WriteWdpPicture( const OUString& rFileId, const css::uno::Sequence< sal_Int8 >& rPictureData );
276 void WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rXShape, int nDiagramId);
277 void writeDiagramRels(const css::uno::Sequence<css::uno::Sequence<css::uno::Any>>& xRelSeq,
278 const css::uno::Reference<css::io::XOutputStream>& xOutStream,
279 const OUString& sGrabBagProperyName, int nDiagramId);
280 static bool IsGroupShape( const css::uno::Reference< css::drawing::XShape >& rXShape );
281 static bool IsDiagram(const css::uno::Reference<css::drawing::XShape>& rXShape);
282 sal_Int32 getBulletMarginIndentation (const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, const OUString& propName);
284 static void ResetCounters();
286 // A Helper to decide the script type for given text in order to call WriteRunProperties.
287 static sal_Int16 GetScriptType(const OUString& rStr);
289 static sal_Unicode SubstituteBullet( sal_Unicode cBulletId, css::awt::FontDescriptor& rFontDesc );
291 static ::Color ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity );
293 static const char* GetAlignment( css::style::ParagraphAdjust nAlignment );
295 sax_fastparser::FSHelperPtr CreateOutputStream (
296 const OUString& sFullStream,
297 const OUString& sRelativeStream,
298 const css::uno::Reference< css::io::XOutputStream >& xParentRelation,
299 const char* sContentType,
300 const char* sRelationshipType,
301 OUString* pRelationshipId );
308 #endif
310 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */