Line data Source code
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 <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 : #ifndef PPTX_EXPORT_ROTATE_CLOCKWISIFY
33 : // Our rotation is counter-clockwise and is in 100ths of a degree.
34 : // drawingML rotation is clockwise and is in 60000ths of a degree.
35 : #define PPTX_EXPORT_ROTATE_CLOCKWISIFY(input) ((21600000-input*600)%21600000)
36 : #endif
37 :
38 : class Graphic;
39 :
40 : namespace com { namespace sun { namespace star {
41 : namespace beans {
42 : class XPropertySet;
43 : class XPropertyState;
44 : }
45 : namespace drawing {
46 : class XShape;
47 : }
48 : namespace style {
49 : struct LineSpacing;
50 : }
51 : namespace text {
52 : class XTextContent;
53 : class XTextRange;
54 : }
55 : namespace io {
56 : class XOutputStream;
57 : }
58 : }}}
59 :
60 : class OutlinerParaObject;
61 :
62 : namespace oox {
63 : namespace core {
64 : class XmlFilterBase;
65 : }
66 :
67 : namespace drawingml {
68 :
69 : /// Interface to be implemented by the parent exporter that knows how to handle shape text.
70 : class OOX_DLLPUBLIC DMLTextExport
71 : {
72 : public:
73 : virtual void WriteOutliner(const OutlinerParaObject& rParaObj) = 0;
74 : protected:
75 0 : DMLTextExport() {}
76 0 : virtual ~DMLTextExport() {}
77 : };
78 :
79 0 : class OOX_DLLPUBLIC DrawingML {
80 : public:
81 : enum DocumentType { DOCUMENT_DOCX, DOCUMENT_PPTX, DOCUMENT_XLSX };
82 :
83 : private:
84 : static int mnImageCounter;
85 :
86 : /// To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
87 : DocumentType meDocumentType;
88 : /// Parent exporter, used for text callback.
89 : DMLTextExport* mpTextExport;
90 :
91 : protected:
92 : ::com::sun::star::uno::Any mAny;
93 : ::sax_fastparser::FSHelperPtr mpFS;
94 : ::oox::core::XmlFilterBase* mpFB;
95 : /// If set, this is the parent of the currently handled shape.
96 : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> m_xParent;
97 :
98 : bool GetProperty( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, const OUString& aName );
99 : bool GetPropertyAndState( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
100 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > rXPropState,
101 : const OUString& aName, ::com::sun::star::beans::PropertyState& eState );
102 : const char* GetFieldType( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun, bool& bIsField );
103 :
104 :
105 : /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
106 : OUString WriteImage( const OUString& rURL, bool bRelPathToMedia = false);
107 : void WriteStyleProperties( sal_Int32 nTokenId, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aProperties );
108 :
109 : const char* GetComponentDir();
110 : const char* GetRelationCompPrefix();
111 :
112 : bool EqualGradients( ::com::sun::star::awt::Gradient aGradient1, ::com::sun::star::awt::Gradient aGradient2 );
113 :
114 : public:
115 0 : DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 )
116 0 : : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( pFS ), mpFB( pFB ) {}
117 0 : void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
118 0 : ::sax_fastparser::FSHelperPtr GetFS() { return mpFS; }
119 0 : ::oox::core::XmlFilterBase* GetFB() { return mpFB; }
120 0 : DocumentType GetDocumentType() { return meDocumentType; }
121 :
122 : /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
123 : OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
124 :
125 : void WriteColor( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT );
126 : void WriteColor( const OUString& sColorSchemeName, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aTransformations );
127 : void WriteColorTransformations( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aTransformations );
128 : void WriteGradientStop( sal_uInt16 nStop, sal_uInt32 nColor );
129 : void WriteLineArrow( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, bool bLineStart );
130 : void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID );
131 :
132 : void WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT );
133 : void WriteSolidFill( const OUString& sSchemeName, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aTransformations );
134 : void WriteSolidFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
135 : void WriteGradientFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
136 : void WriteGradientFill( ::com::sun::star::awt::Gradient rGradient );
137 : void WriteGrabBagGradientFill( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aGradientStops, ::com::sun::star::awt::Gradient rGradient);
138 :
139 : void WriteBlipOrNormalFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
140 : const OUString& rURLPropName );
141 : void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
142 : const OUString& sBitmapURL, sal_Int32 nXmlNamespace,
143 : bool bWriteMode, bool bRelPathToMedia = false );
144 : void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
145 : const OUString& sURLPropName );
146 : void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
147 : const OUString& sURLPropName, sal_Int32 nXmlNamespace );
148 : void WritePattFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
149 : void WriteSrcRect( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, const OUString& );
150 : void WriteOutline( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
151 : void WriteStretch( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, const OUString& rURL );
152 : void WriteLinespacing( ::com::sun::star::style::LineSpacing& rLineSpacing );
153 :
154 : OUString WriteBlip( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
155 : const OUString& rURL, bool bRelPathToMedia = false , const Graphic *pGraphic=NULL );
156 : void WriteBlipMode( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, const OUString& rURL );
157 :
158 : void WriteShapeTransformation( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape,
159 : sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, bool bSuppressRotation = false );
160 : void WriteTransformation( const Rectangle& rRectangle,
161 : sal_Int32 nXmlNamespace, bool bFlipH = false, bool bFlipV = false, sal_Int32 nRotation = 0 );
162 :
163 : void WriteText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > rXIface, bool bBodyPr = true, bool bText = true, sal_Int32 nXmlNamespace = 0);
164 : void WriteParagraph( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > rParagraph );
165 : void WriteParagraphProperties( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > rParagraph );
166 : void WriteParagraphNumbering( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
167 : sal_Int16 nLevel );
168 : void WriteRun( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun );
169 : void WriteRunProperties( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rRun, bool bIsField );
170 :
171 : void WritePresetShape( const char* pShape );
172 : void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const ::com::sun::star::beans::PropertyValue& rProp );
173 : void WritePolyPolygon( const PolyPolygon& rPolyPolygon );
174 : void WriteFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet );
175 : void WriteShapeStyle( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
176 :
177 : static void ResetCounters();
178 :
179 : void GetUUID( OStringBuffer& rBuffer );
180 :
181 : static sal_Unicode SubstituteBullet( sal_Unicode cBulletId, ::com::sun::star::awt::FontDescriptor& rFontDesc );
182 :
183 : sal_uInt32 ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity );
184 :
185 : static const char* GetAlignment( sal_Int32 nAlignment );
186 :
187 : sax_fastparser::FSHelperPtr CreateOutputStream (
188 : const OUString& sFullStream,
189 : const OUString& sRelativeStream,
190 : const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xParentRelation,
191 : const char* sContentType,
192 : const char* sRelationshipType,
193 : OUString* pRelationshipId = NULL );
194 :
195 : };
196 :
197 : }
198 : }
199 :
200 : #endif
201 :
202 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|