LibreOffice Module oox (master) 1
drawingml.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
20#ifndef INCLUDED_OOX_EXPORT_DRAWINGML_HXX
21#define INCLUDED_OOX_EXPORT_DRAWINGML_HXX
22
23#include <map>
24#include <stack>
25#include <string_view>
26#include <unordered_map>
27#include <utility>
28#include <vector>
29
30#include <com/sun/star/beans/PropertyState.hpp>
31#include <com/sun/star/uno/Any.hxx>
32#include <com/sun/star/uno/Reference.hxx>
33#include <com/sun/star/uno/Sequence.hxx>
34#include <com/sun/star/style/ParagraphAdjust.hpp>
35#include <com/sun/star/drawing/Hatch.hpp>
36#include <com/sun/star/i18n/ScriptType.hpp>
37#include <oox/dllapi.h>
39#include <oox/token/tokens.hxx>
40#include <oox/export/utils.hxx>
41#include <rtl/string.hxx>
42#include <rtl/ustring.hxx>
43#include <sal/types.h>
44#include <sax/fshelper.hxx>
45#include <svx/msdffdef.hxx>
46#include <vcl/checksum.hxx>
47#include <vcl/graph.hxx>
48#include <tools/gen.hxx>
49#include <tools/color.hxx>
50#include <vcl/mapmod.hxx>
52
53class Graphic;
55enum class SvxDateFormat;
56enum class SvxTimeFormat;
57
58namespace com::sun::star {
59namespace awt {
60 struct FontDescriptor;
61 struct Gradient;
62}
63namespace beans {
64 struct PropertyValue;
65 class XPropertySet;
66 class XPropertyState;
67}
68namespace drawing {
69 class XShape;
70 struct EnhancedCustomShapeParameterPair;
71 struct EnhancedCustomShapeParameter;
72}
73namespace graphic {
74 class XGraphic;
75}
76namespace style {
77 struct LineSpacing;
78}
79namespace text {
80 class XTextContent;
81 class XTextRange;
82 class XTextFrame;
83}
84namespace io {
85 class XOutputStream;
86}
87namespace uno {
88 class XInterface;
89}
90namespace frame {
91 class XModel;
92}
93}
94
97namespace tools { class Rectangle; }
98
99namespace tools {
100 class PolyPolygon;
101}
102
103namespace oox {
104namespace core {
105 class XmlFilterBase;
106}
107
108namespace drawingml {
109
111{
112public:
113 virtual ~URLTransformer();
114
115 virtual OUString getTransformedString(const OUString& rURL) const;
116
117 virtual bool isExternalURL(const OUString& rURL) const;
118};
119
120// Our rotation is counter-clockwise and is in 100ths of a degree.
121// drawingML rotation is clockwise and is in 60000ths of a degree.
122inline sal_Int32 ExportRotateClockwisify(Degree100 input)
123{
124 return ((21600000 - input.get() * 600) % 21600000);
125}
126
129{
130public:
131 virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
133 virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
135 virtual css::uno::Reference<css::text::XTextFrame> GetUnoTextFrame(
136 css::uno::Reference<css::drawing::XShape> xShape) = 0;
137protected:
139 virtual ~DMLTextExport() {}
140};
141
143{
144
145private:
146 static int mnImageCounter;
148 static std::map<OUString, OUString> maWdpCache;
149 static sal_Int32 mnDrawingMLCount;
150 static sal_Int32 mnVmlCount;
151 static std::stack<std::unordered_map<BitmapChecksum, OUString>> maExportGraphics;
152
157
158
159protected:
160 css::uno::Any mAny;
164 css::uno::Reference<css::drawing::XShape> m_xParent;
166
169
170 bool GetProperty( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, const OUString& aName );
171 bool GetPropertyAndState( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
172 const css::uno::Reference< css::beans::XPropertyState >& rXPropState,
173 const OUString& aName, css::beans::PropertyState& eState );
174 OUString GetFieldValue( const css::uno::Reference< css::text::XTextRange >& rRun, bool& bIsURLField );
179 static OUString GetDatetimeTypeFromDate(SvxDateFormat eDate);
184 static OUString GetDatetimeTypeFromTime(SvxTimeFormat eTime);
190 static OUString GetDatetimeTypeFromDateTime(SvxDateFormat eDate, SvxTimeFormat eTime);
191
193 void WriteMediaNonVisualProperties(const css::uno::Reference<css::drawing::XShape>& xShape);
194
195 void WriteStyleProperties( sal_Int32 nTokenId, const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
196
197 const char* GetComponentDir() const;
198 const char* GetRelationCompPrefix() const;
199
200 static bool EqualGradients( css::awt::Gradient aGradient1, css::awt::Gradient aGradient2 );
201 bool IsFontworkShape(const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
202
203 void WriteGlowEffect(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
204 void WriteSoftEdgeEffect(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
205 void WriteCustomGeometryPoint(const css::drawing::EnhancedCustomShapeParameterPair& rParamPair,
206 const EnhancedCustomShape2d& rCustomShape2d,
207 const bool bReplaceGeoWidth, const bool bReplaceGeoHeight);
208 bool WriteCustomGeometrySegment(
209 const sal_Int16 eCommand, const sal_Int32 nCount,
210 const css::uno::Sequence<css::drawing::EnhancedCustomShapeParameterPair>& rPairs,
211 sal_Int32& rnPairIndex, double& rfCurrentX, double& rfCurrentY, bool& rbCurrentValid,
212 const EnhancedCustomShape2d& rCustomShape2d,
213 const bool bReplaceGeoWidth, const bool bReplaceGeoHeight);
214
215public:
217 : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS(std::move( pFS )), mpFB( pFB ), mbIsBackgroundDark( false ), mbPlaceholder(false) {}
218 void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
219 const ::sax_fastparser::FSHelperPtr& GetFS() const { return mpFS; }
221 DocumentType GetDocumentType() const { return meDocumentType; }
223 DMLTextExport* GetTextExport() { return mpTextExport; }
224
225 void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; }
227 OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false );
228
229 void WriteColor( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
230 void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
231 void WriteColor( const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
232 void WriteColorTransformations( const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
233 void WriteGradientStop(sal_uInt16 nStop, ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT);
234 void WriteLineArrow( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, bool bLineStart );
235 void WriteConnectorConnections( sal_Int32 nStartGlueId, sal_Int32 nEndGlueId, sal_Int32 nStartID, sal_Int32 nEndID );
236
237 bool WriteCharColor(const css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
238 bool WriteFillColor(const css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
239
240 void WriteSolidFill( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
241 void WriteSolidFill( const OUString& sSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
242 void WriteSolidFill( const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
243 void WriteSolidFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
244 void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
245
246 void WriteGradientFill( css::awt::Gradient rGradient, css::awt::Gradient rTransparenceGradient,
247 const css::uno::Reference<css::beans::XPropertySet>& rXPropSet = css::uno::Reference<css::beans::XPropertySet>());
248
249 void WriteGrabBagGradientFill( const css::uno::Sequence< css::beans::PropertyValue >& aGradientStops, css::awt::Gradient rGradient);
250
251 void WriteBlipOrNormalFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
252 const OUString& rURLPropName );
253 void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
254 const OUString& sURLPropName );
255 void WriteBlipFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
256 const OUString& sURLPropName, sal_Int32 nXmlNamespace );
257
258 void WriteXGraphicBlipFill(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
259 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
260 sal_Int32 nXmlNamespace, bool bWriteMode, bool bRelPathToMedia = false);
261
262 void WritePattFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
263 void WritePattFill(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
264 const css::drawing::Hatch& rHatch);
265
266 void WriteGraphicCropProperties(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet,
267 Size const & rOriginalSize, MapMode const & rMapMode);
268
269 void WriteSrcRectXGraphic(css::uno::Reference<css::beans::XPropertySet> const & rxPropertySet,
270 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
271
272 void WriteOutline( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
273 css::uno::Reference< css::frame::XModel> const & xModel = nullptr );
274
275 void WriteXGraphicStretch(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
276 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
277
278 void WriteLinespacing(const css::style::LineSpacing& rLineSpacing, float fFirstCharHeight);
279
280 OUString WriteXGraphicBlip(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
281 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
282 bool bRelPathToMedia);
283
284 void WriteImageBrightnessContrastTransparence(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet);
285
286 void WriteXGraphicBlipMode(css::uno::Reference<css::beans::XPropertySet> const & rXPropSet,
287 css::uno::Reference<css::graphic::XGraphic> const & rxGraphic);
288
289 void WriteShapeTransformation(const css::uno::Reference< css::drawing::XShape >& rXShape,
290 sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false, bool bSuppressFlipping = false, bool bFlippedBeforeRotation = false);
291 void WriteTransformation(const css::uno::Reference< css::drawing::XShape >& xShape, const tools::Rectangle& rRectangle,
292 sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0, bool bIsGroupShape = false);
293
294 void WriteText( const css::uno::Reference< css::uno::XInterface >& rXIface, bool bBodyPr, bool bText = true, sal_Int32 nXmlNamespace = 0, bool bWritePropertiesAsLstStyles = false);
295
297 void WriteLstStyles(const css::uno::Reference<css::text::XTextContent>& rParagraph,
298 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
299 const css::uno::Reference<css::beans::XPropertySet>& rXShapePropSet);
300 void WriteParagraph( const css::uno::Reference< css::text::XTextContent >& rParagraph,
301 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight, const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
306 bool WriteParagraphProperties(const css::uno::Reference< css::text::XTextContent >& rParagraph, float fFirstCharHeight, sal_Int32 nElement);
307 void WriteParagraphNumbering(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, float fFirstCharHeight,
308 sal_Int16 nLevel );
309 void WriteParagraphTabStops(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
310 void WriteRun( const css::uno::Reference< css::text::XTextRange >& rRun,
311 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
312 const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
313 void WriteRunProperties( const css::uno::Reference< css::beans::XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect,
314 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
315 sal_Int16 nScriptType = css::i18n::ScriptType::LATIN,
316 const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet = {});
317
318 void WritePresetShape( const OString& pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList );
319 void WritePresetShape( const OString& pShape );
320 void WritePresetShape( const OString& pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, const css::beans::PropertyValue& rProp );
321 bool WriteCustomGeometry(
322 const css::uno::Reference<css::drawing::XShape>& rXShape,
323 const SdrObjCustomShape& rSdrObjCustomShape);
324 void WriteEmptyCustomGeometry();
325 void WritePolyPolygon(const css::uno::Reference<css::drawing::XShape>& rXShape,
326 const bool bClosed);
327 void WriteFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet );
328 void WriteShapeStyle( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
329 void WriteShapeEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
330 void WriteShapeEffect( std::u16string_view sName, const css::uno::Sequence< css::beans::PropertyValue >& aEffectProps );
335 void Write3DEffects(const css::uno::Reference<css::beans::XPropertySet>& rXPropSet, bool bIsText);
336 void WriteArtisticEffect( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
337 OString WriteWdpPicture( const OUString& rFileId, const css::uno::Sequence< sal_Int8 >& rPictureData );
338 void WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rXShape, int nDiagramId);
339 void writeDiagramRels(const css::uno::Sequence<css::uno::Sequence<css::uno::Any>>& xRelSeq,
340 const css::uno::Reference<css::io::XOutputStream>& xOutStream,
341 std::u16string_view sGrabBagProperyName, int nDiagramId);
342 static void WriteFromTo(const css::uno::Reference<css::drawing::XShape>& rXShape, const css::awt::Size& aPageSize,
343 const sax_fastparser::FSHelperPtr& pDrawing);
344
345 static bool IsGroupShape( const css::uno::Reference< css::drawing::XShape >& rXShape );
346 sal_Int32 getBulletMarginIndentation (const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, std::u16string_view propName);
347
348 static void ResetCounters();
349 static void ResetMlCounters();
350
351 static void PushExportGraphics();
352 static void PopExportGraphics();
353
354 static sal_Int32 getNewDrawingUniqueId() { return ++mnDrawingMLCount; }
355 static sal_Int32 getNewVMLUniqueId() { return ++mnVmlCount; }
356
357 // A Helper to decide the script type for given text in order to call WriteRunProperties.
358 static sal_Int16 GetScriptType(const OUString& rStr);
359
360 static sal_Unicode SubstituteBullet( sal_Unicode cBulletId, css::awt::FontDescriptor& rFontDesc );
361
362 static ::Color ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity );
363
364 static const char* GetAlignment( css::style::ParagraphAdjust nAlignment );
365
366 sax_fastparser::FSHelperPtr CreateOutputStream (
367 const OUString& sFullStream,
368 std::u16string_view sRelativeStream,
369 const css::uno::Reference< css::io::XOutputStream >& xParentRelation,
370 const char* sContentType,
371 const char* sRelationshipType,
372 OUString* pRelationshipId );
373
374};
375
376}
377}
378
379#endif
380
381/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface to be implemented by the parent exporter that knows how to handle shape text.
Definition: drawingml.hxx:129
virtual void WriteTextBox(css::uno::Reference< css::drawing::XShape > xShape)=0
Write the contents of the textbox that is associated to this shape.
virtual css::uno::Reference< css::text::XTextFrame > GetUnoTextFrame(css::uno::Reference< css::drawing::XShape > xShape)=0
Get textbox which belongs to the shape.
virtual void WriteOutliner(const OutlinerParaObject &rParaObj)=0
DrawingML(::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase *pFB, DocumentType eDocumentType=DOCUMENT_PPTX, DMLTextExport *pTextExport=nullptr)
Definition: drawingml.hxx:216
static std::map< OUString, OUString > maWdpCache
Definition: drawingml.hxx:148
static sal_Int32 getNewDrawingUniqueId()
Definition: drawingml.hxx:354
::oox::core::XmlFilterBase * mpFB
Definition: drawingml.hxx:162
static sal_Int32 mnDrawingMLCount
Definition: drawingml.hxx:149
void WriteGradientFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
void WriteSolidFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
DMLTextExport * GetTextExport()
The application-specific text exporter callback, if there is one.
Definition: drawingml.hxx:223
void WritePresetShape(const OString &pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, const css::beans::PropertyValue &rProp)
::sax_fastparser::FSHelperPtr mpFS
Definition: drawingml.hxx:161
static sal_Int32 mnVmlCount
Definition: drawingml.hxx:150
DocumentType meDocumentType
To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
Definition: drawingml.hxx:154
void SetFS(::sax_fastparser::FSHelperPtr pFS)
Definition: drawingml.hxx:218
void WriteGradientFill(css::awt::Gradient rGradient, css::awt::Gradient rTransparenceGradient, const css::uno::Reference< css::beans::XPropertySet > &rXPropSet=css::uno::Reference< css::beans::XPropertySet >())
const ::sax_fastparser::FSHelperPtr & GetFS() const
Definition: drawingml.hxx:219
::oox::core::XmlFilterBase * GetFB()
Definition: drawingml.hxx:220
DocumentType GetDocumentType() const
Definition: drawingml.hxx:221
void WriteBlipFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet, const OUString &sURLPropName, sal_Int32 nXmlNamespace)
void WriteColor(const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue > &aTransformations, sal_Int32 nAlpha=MAX_PERCENT)
static sal_Int32 getNewVMLUniqueId()
Definition: drawingml.hxx:355
css::uno::Reference< css::drawing::XShape > m_xParent
If set, this is the parent of the currently handled shape.
Definition: drawingml.hxx:164
void WriteBlipFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet, const OUString &sURLPropName)
void WriteSolidFill(const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue > &aTransformations, sal_Int32 nAlpha=MAX_PERCENT)
void WriteColor(const OUString &sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue > &aTransformations, sal_Int32 nAlpha=MAX_PERCENT)
void WritePattFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
void WritePattFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet, const css::drawing::Hatch &rHatch)
bool mbPlaceholder
True when exporting presentation placeholder shape.
Definition: drawingml.hxx:168
void SetBackgroundDark(bool bIsDark)
Definition: drawingml.hxx:225
static std::stack< std::unordered_map< BitmapChecksum, OUString > > maExportGraphics
Definition: drawingml.hxx:151
void WriteSolidFill(const OUString &sSchemeName, const css::uno::Sequence< css::beans::PropertyValue > &aTransformations, sal_Int32 nAlpha=MAX_PERCENT)
DMLTextExport * mpTextExport
Parent exporter, used for text callback.
Definition: drawingml.hxx:156
int nCount
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
OString sName
Definition: drawingml.cxx:4066
SvxTimeFormat
SvxDateFormat
MSO_SPT
def text(shape, orig_st)
class SAL_NO_VTABLE XPropertySet
sal_Int32 ExportRotateClockwisify(Degree100 input)
Definition: drawingml.hxx:122
const sal_Int32 MAX_PERCENT
std::shared_ptr< FastSerializerHelper > FSHelperPtr
SvStream & WritePolyPolygon(SvStream &rOStream, const tools::PolyPolygon &rPolyPoly)
UNOTOOLS_DLLPUBLIC css::uno::Any GetProperty(OUString const &url, OUString const &property)
UNDERLYING_TYPE get() const
sal_uInt16 sal_Unicode