Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / export / drawingml.hxx
blobc213ae27d83a09b72319268badd24f376e790516
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>
25 #include <com/sun/star/beans/PropertyState.hpp>
26 #include <com/sun/star/uno/Any.hxx>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <com/sun/star/style/ParagraphAdjust.hpp>
30 #include <oox/dllapi.h>
31 #include <oox/drawingml/drawingmltypes.hxx>
32 #include <oox/token/tokens.hxx>
33 #include <oox/export/utils.hxx>
34 #include <rtl/string.hxx>
35 #include <rtl/ustring.hxx>
36 #include <sal/types.h>
37 #include <sax/fshelper.hxx>
38 #include <svx/msdffdef.hxx>
39 #include <vcl/checksum.hxx>
41 #ifndef OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY
42 // Our rotation is counter-clockwise and is in 100ths of a degree.
43 // drawingML rotation is clockwise and is in 60000ths of a degree.
44 #define OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(input) ((21600000-input*600)%21600000)
45 #endif
47 class Graphic;
48 class SdrObjCustomShape;
50 namespace com { namespace sun { namespace star {
51 namespace awt {
52 struct FontDescriptor;
53 struct Gradient;
55 namespace beans {
56 struct PropertyValue;
57 class XPropertySet;
58 class XPropertyState;
60 namespace drawing {
61 class XShape;
62 struct EnhancedCustomShapeParameterPair;
63 struct EnhancedCustomShapeParameter;
65 namespace style {
66 struct LineSpacing;
68 namespace text {
69 class XTextContent;
70 class XTextRange;
72 namespace io {
73 class XOutputStream;
75 namespace uno {
76 class XInterface;
78 }}}
80 struct EscherConnectorListEntry;
81 class OutlinerParaObject;
82 namespace tools { class Rectangle; }
84 namespace tools {
85 class PolyPolygon;
88 namespace oox {
89 namespace core {
90 class XmlFilterBase;
93 namespace drawingml {
95 /// Interface to be implemented by the parent exporter that knows how to handle shape text.
96 class OOX_DLLPUBLIC DMLTextExport
98 public:
99 virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
100 /// Write the contents of the textbox that is associated to this shape.
101 virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
102 /// Look up the RelId of a graphic based on its checksum.
103 virtual OUString FindRelId(BitmapChecksum nChecksum) = 0;
104 /// Store the RelId of a graphic based on its checksum.
105 virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId) = 0;
106 protected:
107 DMLTextExport() {}
108 virtual ~DMLTextExport() {}
111 class OOX_DLLPUBLIC DrawingML
114 private:
115 static int mnImageCounter;
116 static int mnWdpImageCounter;
117 static std::map<OUString, OUString> maWdpCache;
119 /// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
120 DocumentType meDocumentType;
121 /// Parent exporter, used for text callback.
122 DMLTextExport* mpTextExport;
124 protected:
125 css::uno::Any mAny;
126 ::sax_fastparser::FSHelperPtr mpFS;
127 ::oox::core::XmlFilterBase* mpFB;
128 /// If set, this is the parent of the currently handled shape.
129 css::uno::Reference<css::drawing::XShape> m_xParent;
130 bool mbIsBackgroundDark;
132 bool GetProperty( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& aName );
133 bool GetPropertyAndState( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
134 const css::uno::Reference< css::beans::XPropertyState >& rXPropState,
135 const OUString& aName, css::beans::PropertyState& eState );
136 OUString GetFieldValue( const css::uno::Reference< css::text::XTextRange >& rRun, bool& bIsURLField );
139 /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
140 OUString WriteImage( const OUString& rURL, bool bRelPathToMedia = false);
141 void WriteStyleProperties( sal_Int32 nTokenId, const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
143 const char* GetComponentDir();
144 const char* GetRelationCompPrefix();
146 static bool EqualGradients( css::awt::Gradient aGradient1, css::awt::Gradient aGradient2 );
148 public:
149 DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB = nullptr, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = nullptr )
150 : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( pFS ), mpFB( pFB ), mbIsBackgroundDark( false ) {}
151 void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
152 const ::sax_fastparser::FSHelperPtr& GetFS() { return mpFS; }
153 ::oox::core::XmlFilterBase* GetFB() { return mpFB; }
154 DocumentType GetDocumentType() { return meDocumentType; }
155 /// The application-specific text exporter callback, if there is one.
156 DMLTextExport* GetTextExport() { return mpTextExport; }
158 void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; }
159 /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
160 OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
162 void WriteColor( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT );
163 void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations );
164 void WriteColorTransformations( const css::uno::Sequence< css::beans::PropertyValue >& aTransformations );
165 void WriteGradientStop( sal_uInt16 nStop, sal_uInt32 nColor );
166 void WriteLineArrow( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, bool bLineStart );
167 void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID );
169 void WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT );
170 void WriteSolidFill( const OUString& sSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations );
171 void WriteSolidFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
172 void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
173 void WriteGradientFill( css::awt::Gradient rGradient );
174 void WriteGrabBagGradientFill( const css::uno::Sequence< css::beans::PropertyValue >& aGradientStops, css::awt::Gradient rGradient);
176 void WriteBlipOrNormalFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
177 const OUString& rURLPropName );
178 void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
179 const OUString& sBitmapURL, sal_Int32 nXmlNamespace,
180 bool bWriteMode, bool bRelPathToMedia = false );
181 void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
182 const OUString& sURLPropName );
183 void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
184 const OUString& sURLPropName, sal_Int32 nXmlNamespace );
185 void WritePattFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
186 void WriteSrcRect( const css::uno::Reference< css::beans::XPropertySet >&, const OUString& );
187 void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
188 void WriteStretch( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL );
189 void WriteLinespacing( const css::style::LineSpacing& rLineSpacing );
191 OUString WriteBlip( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
192 const OUString& rURL, bool bRelPathToMedia = false , const Graphic *pGraphic=nullptr );
193 void WriteBlipMode( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& rURL );
195 void WriteShapeTransformation( const css::uno::Reference< css::drawing::XShape >& rXShape,
196 sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false );
197 void WriteTransformation( const tools::Rectangle& rRectangle,
198 sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0 );
200 void WriteText( const css::uno::Reference< css::uno::XInterface >& rXIface, const OUString& presetWarp, bool bBodyPr = true, bool bText = true, sal_Int32 nXmlNamespace = 0);
201 void WriteParagraph( const css::uno::Reference< css::text::XTextContent >& rParagraph,
202 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight );
203 void WriteParagraphProperties( const css::uno::Reference< css::text::XTextContent >& rParagraph );
204 void WriteParagraphNumbering( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
205 sal_Int16 nLevel );
206 void WriteRun( const css::uno::Reference< css::text::XTextRange >& rRun,
207 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight );
208 void WriteRunProperties( const css::uno::Reference< css::beans::XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect,
209 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight );
211 void WritePresetShape( const char* pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList );
212 void WritePresetShape( const char* pShape );
213 void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const css::beans::PropertyValue& rProp );
214 bool WriteCustomGeometry( const css::uno::Reference<css::drawing::XShape>& rXShape, const SdrObjCustomShape* pShape );
215 void WriteCustomGeometryPoint(const css::drawing::EnhancedCustomShapeParameterPair& rParamPair, const SdrObjCustomShape* pShape);
216 static sal_Int32 GetCustomGeometryPointValue(const css::drawing::EnhancedCustomShapeParameter& rParam, const SdrObjCustomShape* pShape);
217 void WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon );
218 void WriteFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
219 void WriteShapeStyle( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
220 void WriteShapeEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
221 void WriteShapeEffect( const OUString& sName, const css::uno::Sequence< css::beans::PropertyValue >& aEffectProps );
222 void WriteShape3DEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
223 void WriteArtisticEffect( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
224 OString WriteWdpPicture( const OUString& rFileId, const css::uno::Sequence< sal_Int8 >& rPictureData );
225 sal_Int32 getBulletMarginIndentation (const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, const OUString& propName);
227 static void ResetCounters();
229 static OString GetUUID();
231 static sal_Unicode SubstituteBullet( sal_Unicode cBulletId, css::awt::FontDescriptor& rFontDesc );
233 static sal_uInt32 ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity );
235 static const char* GetAlignment( css::style::ParagraphAdjust nAlignment );
237 sax_fastparser::FSHelperPtr CreateOutputStream (
238 const OUString& sFullStream,
239 const OUString& sRelativeStream,
240 const css::uno::Reference< css::io::XOutputStream >& xParentRelation,
241 const char* sContentType,
242 const char* sRelationshipType,
243 OUString* pRelationshipId = nullptr );
250 #endif
252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */