update emoji autocorrect entries from po-files
[LibreOffice.git] / include / oox / export / drawingml.hxx
blobfcfb638c62957c5b8e08fe0e58c8ed1d03d195b6
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 <oox/dllapi.h>
24 #include <sax/fshelper.hxx>
25 #include <rtl/strbuf.hxx>
26 #include <com/sun/star/awt/FontDescriptor.hpp>
27 #include <com/sun/star/awt/Gradient.hpp>
28 #include <com/sun/star/uno/XReference.hpp>
29 #include <tools/poly.hxx>
30 #include <filter/msfilter/escherex.hxx>
31 #include "oox/drawingml/drawingmltypes.hxx"
32 #include <oox/token/tokens.hxx>
33 #ifndef OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY
34 // Our rotation is counter-clockwise and is in 100ths of a degree.
35 // drawingML rotation is clockwise and is in 60000ths of a degree.
36 #define OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(input) ((21600000-input*600)%21600000)
37 #endif
39 class Graphic;
41 namespace com { namespace sun { namespace star {
42 namespace beans {
43 class XPropertySet;
44 class XPropertyState;
46 namespace drawing {
47 class XShape;
49 namespace style {
50 struct LineSpacing;
52 namespace text {
53 class XTextContent;
54 class XTextRange;
56 namespace io {
57 class XOutputStream;
59 }}}
61 class OutlinerParaObject;
63 namespace oox {
64 namespace core {
65 class XmlFilterBase;
68 namespace drawingml {
70 /// Interface to be implemented by the parent exporter that knows how to handle shape text.
71 class OOX_DLLPUBLIC DMLTextExport
73 public:
74 virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
75 /// Write the contents of the textbox that is associated to this shape.
76 virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
77 /// Look up the RelId of a graphic based on its checksum.
78 virtual OUString FindRelId(BitmapChecksum nChecksum) = 0;
79 /// Store the RelId of a graphic based on its checksum.
80 virtual void CacheRelId(BitmapChecksum nChecksum, const OUString& rRelId) = 0;
81 protected:
82 DMLTextExport() {}
83 virtual ~DMLTextExport() {}
86 class OOX_DLLPUBLIC DrawingML {
87 public:
88 enum DocumentType { DOCUMENT_DOCX, DOCUMENT_PPTX, DOCUMENT_XLSX };
90 private:
91 static int mnImageCounter;
92 static int mnWdpImageCounter;
93 static std::map<OUString, OUString> maWdpCache;
95 /// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
96 DocumentType meDocumentType;
97 /// Parent exporter, used for text callback.
98 DMLTextExport* mpTextExport;
100 protected:
101 ::com::sun::star::uno::Any mAny;
102 ::sax_fastparser::FSHelperPtr mpFS;
103 ::oox::core::XmlFilterBase* mpFB;
104 /// If set, this is the parent of the currently handled shape.
105 com::sun::star::uno::Reference<com::sun::star::drawing::XShape> m_xParent;
106 bool mbIsBackgroundDark;
108 bool GetProperty( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, const OUString& aName );
109 bool GetPropertyAndState( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
110 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > rXPropState,
111 const OUString& aName, ::com::sun::star::beans::PropertyState& eState );
112 OUString GetFieldValue( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun, bool& bIsURLField );
115 /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
116 OUString WriteImage( const OUString& rURL, bool bRelPathToMedia = false);
117 void WriteStyleProperties( sal_Int32 nTokenId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProperties );
119 const char* GetComponentDir();
120 const char* GetRelationCompPrefix();
122 static bool EqualGradients( ::com::sun::star::awt::Gradient aGradient1, ::com::sun::star::awt::Gradient aGradient2 );
124 public:
125 DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 )
126 : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( pFS ), mpFB( pFB ), mbIsBackgroundDark( false ) {}
127 void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
128 ::sax_fastparser::FSHelperPtr GetFS() { return mpFS; }
129 ::oox::core::XmlFilterBase* GetFB() { return mpFB; }
130 DocumentType GetDocumentType() { return meDocumentType; }
131 /// The application-specific text exporter callback, if there is one.
132 DMLTextExport* GetTextExport() { return mpTextExport; }
134 void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; }
135 /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
136 OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
138 void WriteColor( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT );
139 void WriteColor( const OUString& sColorSchemeName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aTransformations );
140 void WriteColorTransformations( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aTransformations );
141 void WriteGradientStop( sal_uInt16 nStop, sal_uInt32 nColor );
142 void WriteLineArrow( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, bool bLineStart );
143 void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID );
145 void WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT );
146 void WriteSolidFill( const OUString& sSchemeName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aTransformations );
147 void WriteSolidFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
148 void WriteGradientFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
149 void WriteGradientFill( ::com::sun::star::awt::Gradient rGradient );
150 void WriteGrabBagGradientFill( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aGradientStops, ::com::sun::star::awt::Gradient rGradient);
152 void WriteBlipOrNormalFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
153 const OUString& rURLPropName );
154 void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
155 const OUString& sBitmapURL, sal_Int32 nXmlNamespace,
156 bool bWriteMode, bool bRelPathToMedia = false );
157 void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
158 const OUString& sURLPropName );
159 void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
160 const OUString& sURLPropName, sal_Int32 nXmlNamespace );
161 void WritePattFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
162 void WriteSrcRect( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, const OUString& );
163 void WriteOutline( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
164 void WriteStretch( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, const OUString& rURL );
165 void WriteLinespacing( ::com::sun::star::style::LineSpacing& rLineSpacing );
167 OUString WriteBlip( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
168 const OUString& rURL, bool bRelPathToMedia = false , const Graphic *pGraphic=NULL );
169 void WriteBlipMode( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, const OUString& rURL );
171 void WriteShapeTransformation( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape,
172 sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false );
173 void WriteTransformation( const Rectangle& rRectangle,
174 sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0 );
176 void WriteText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > rXIface, const OUString& presetWarp, bool bBodyPr = true, bool bText = true, sal_Int32 nXmlNamespace = 0);
177 void WriteParagraph( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > rParagraph );
178 void WriteParagraphProperties( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > rParagraph );
179 void WriteParagraphNumbering( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
180 sal_Int16 nLevel );
181 void WriteRun( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun );
182 void WriteRunProperties( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rRun, bool bIsField, sal_Int32 nElement = XML_rPr );
184 void WritePresetShape( const char* pShape );
185 void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const ::com::sun::star::beans::PropertyValue& rProp );
186 void WriteCustomGeometry( css::uno::Reference<css::drawing::XShape> rXShape );
187 void WritePolyPolygon( const tools::PolyPolygon& rPolyPolygon );
188 void WriteFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet );
189 void WriteShapeStyle( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
190 void WriteShapeEffects( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
191 void WriteShapeEffect( const OUString& sName, const css::uno::Sequence< css::beans::PropertyValue >& aEffectProps );
192 void WriteShape3DEffects( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
193 void WriteArtisticEffect( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
194 OString WriteWdpPicture( const OUString& rFileId, const ::com::sun::star::uno::Sequence< sal_Int8 >& rPictureData );
195 sal_Int32 getBulletMarginIndentation (::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,sal_Int16 nLevel, const OUString& propName);
197 static void ResetCounters();
199 static void GetUUID( OStringBuffer& rBuffer );
201 static sal_Unicode SubstituteBullet( sal_Unicode cBulletId, ::com::sun::star::awt::FontDescriptor& rFontDesc );
203 static sal_uInt32 ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity );
205 static const char* GetAlignment( sal_Int32 nAlignment );
207 sax_fastparser::FSHelperPtr CreateOutputStream (
208 const OUString& sFullStream,
209 const OUString& sRelativeStream,
210 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xParentRelation,
211 const char* sContentType,
212 const char* sRelationshipType,
213 OUString* pRelationshipId = NULL );
220 #endif
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */