Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / export / shapes.hxx
blob5c1d7d860ca73f7a0d05f5410452d1fd0f11d5ff
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_SHAPES_HXX
21 #define INCLUDED_OOX_EXPORT_SHAPES_HXX
23 #include <cstddef>
24 #include <memory>
25 #include <unordered_map>
27 #include <com/sun/star/awt/Size.hpp>
28 #include <com/sun/star/uno/Reference.hxx>
29 #include <oox/dllapi.h>
30 #include <oox/export/drawingml.hxx>
31 #include <oox/export/utils.hxx>
32 #include <rtl/ustring.hxx>
33 #include <sal/types.h>
34 #include <sax/fshelper.hxx>
35 #include <tools/fract.hxx>
36 #include <vcl/mapmod.hxx>
38 namespace com { namespace sun { namespace star {
39 namespace beans {
40 class XPropertySet;
42 namespace drawing {
43 class XShape;
46 namespace embed {
47 class XEmbeddedObject;
49 namespace io {
50 class XInputStream;
52 namespace uno {
53 class XComponentContext;
54 class XInterface;
56 }}}
58 namespace oox {
59 namespace core {
60 class XmlFilterBase;
63 class Graphic;
65 namespace oox {
67 OOX_DLLPUBLIC css::uno::Reference<css::io::XInputStream> GetOLEObjectStream(
68 css::uno::Reference<css::uno::XComponentContext> const& xContext,
69 css::uno::Reference<css::embed::XEmbeddedObject> const& xObj,
70 OUString const& i_rProgID,
71 OUString & o_rMediaType,
72 OUString & o_rRelationType,
73 OUString & o_rSuffix,
74 const char *& o_rpProgID);
78 namespace oox { namespace drawingml {
80 class OOX_DLLPUBLIC URLTransformer
82 public:
83 virtual ~URLTransformer();
85 virtual OUString getTransformedString(const OUString& rURL) const;
87 virtual bool isExternalURL(const OUString& rURL) const;
90 class OOX_DLLPUBLIC ShapeExport : public DrawingML {
92 private:
93 int m_nEmbeddedObjects;
94 struct ShapeCheck
96 bool operator()( const css::uno::Reference< css::drawing::XShape>& s1, const css::uno::Reference< css::drawing::XShape>& s2 ) const
98 return s1 == s2;
102 struct ShapeHash
104 size_t operator()( const css::uno::Reference < css::drawing::XShape >& ) const;
107 public:
108 typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32, ShapeHash, ShapeCheck> ShapeHashMap;
110 protected:
111 sal_Int32 mnShapeIdMax, mnPictureIdMax;
113 void WriteGraphicObjectShapePart( const css::uno::Reference< css::drawing::XShape >& xShape, const Graphic *pGraphic=nullptr );
115 private:
116 sal_Int32 mnXmlNamespace;
117 Fraction maFraction;
118 MapMode maMapModeSrc, maMapModeDest;
119 std::shared_ptr<URLTransformer> mpURLTransformer;
121 css::awt::Size MapSize( const css::awt::Size& ) const;
123 ShapeHashMap maShapeMap;
124 ShapeHashMap* mpShapeMap;
125 OUString m_presetWarp;
127 public:
129 ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS,
130 ShapeHashMap* pShapeMap, ::oox::core::XmlFilterBase* pFB,
131 DocumentType eDocumentType = DOCUMENT_PPTX,
132 DMLTextExport* pTextExport = nullptr );
133 virtual ~ShapeExport() {}
135 void SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer);
137 static bool NonEmptyText( const css::uno::Reference< css::uno::XInterface >& xIface );
139 ShapeExport&
140 WritePolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape, bool bClosed );
141 ShapeExport&
142 WriteClosedPolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape );
143 ShapeExport&
144 WriteConnectorShape( const css::uno::Reference< css::drawing::XShape >& xShape );
145 ShapeExport&
146 WriteCustomShape( const css::uno::Reference< css::drawing::XShape >& xShape );
147 ShapeExport&
148 WriteEllipseShape( const css::uno::Reference< css::drawing::XShape >& xShape );
149 ShapeExport&
150 WriteGraphicObjectShape( const css::uno::Reference< css::drawing::XShape >& xShape );
151 ShapeExport&
152 WriteGroupShape( const css::uno::Reference< css::drawing::XShape >& xShape );
153 ShapeExport&
154 WriteLineShape( const css::uno::Reference< css::drawing::XShape >& xShape );
155 ShapeExport&
156 WriteNonVisualDrawingProperties( const css::uno::Reference< css::drawing::XShape >& xShape, const char* sName );
157 virtual ShapeExport&
158 WriteNonVisualProperties( const css::uno::Reference< css::drawing::XShape >& xShape );
159 ShapeExport&
160 WriteOpenPolyPolygonShape( const css::uno::Reference< css::drawing::XShape >& xShape );
161 ShapeExport&
162 WriteRectangleShape( const css::uno::Reference< css::drawing::XShape >& xShape );
165 * Write the DrawingML for a particular shape.
167 * <p>This is the member function you want. It performs the type lookup and
168 * invokes the appropriate corresponding Write*() method for the specific
169 * type.</p>
171 * <p>To write an XShape, XShape::getShapeType() is called to determine
172 * the shape type, and the corresponding method in this table is
173 * invoked:</p>
175 * <table>
176 * <tr><th>Shape Type</th><th>Method</th></tr>
177 * <tr><td><tt>com.sun.star.drawing.ClosedBezierShape</tt></td> <td>ShapeExport::WriteClosedPolyPolygonShape</td></tr>
178 * <tr><td><tt>com.sun.star.drawing.CustomShape</tt></td> <td>ShapeExport::WriteCustomShape</td></tr>
179 * <tr><td><tt>com.sun.star.drawing.EllipseShape</tt></td> <td>ShapeExport::WriteEllipseShape</td></tr>
180 * <tr><td><tt>com.sun.star.drawing.GraphicObjectShape</tt></td> <td>ShapeExport::WriteGraphicObjectShape</td></tr>
181 * <tr><td><tt>com.sun.star.drawing.LineShape</tt></td> <td>ShapeExport::WriteLineShape</td></tr>
182 * <tr><td><tt>com.sun.star.drawing.OpenBezierShape</tt></td> <td>ShapeExport::WriteOpenPolyPolygonShape</td></tr>
183 * <tr><td><tt>com.sun.star.drawing.PolyPolygonShape</tt></td> <td>ShapeExport::WriteClosedPolyPolygonShape</td></tr>
184 * <tr><td><tt>com.sun.star.drawing.PolyLineShape</tt></td> <td>ShapeExport::WriteOpenPolyPolygonShape</td></tr>
185 * <tr><td><tt>com.sun.star.drawing.RectangleShape</tt></td> <td>ShapeExport::WriteRectangleShape</td></tr>
186 * <tr><td><tt>com.sun.star.drawing.TableShape</tt></td> <td>ShapeExport::WriteTableShape</td></tr>
187 * <tr><td><tt>com.sun.star.drawing.TextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
188 * <tr><td><tt>com.sun.star.presentation.DateTimeShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
189 * <tr><td><tt>com.sun.star.presentation.FooterShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
190 * <tr><td><tt>com.sun.star.presentation.HeaderShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
191 * <tr><td><tt>com.sun.star.presentation.NotesShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
192 * <tr><td><tt>com.sun.star.presentation.OutlinerShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
193 * <tr><td><tt>com.sun.star.presentation.SlideNumberShape</tt></td><td>ShapeExport::WriteTextShape</td></tr>
194 * <tr><td><tt>com.sun.star.presentation.TitleTextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
195 * </table>
197 * <p>If the shape type is not recognized, then
198 * <tt>ShapeExport::WriteUnknownShape</tt> is called.</p>
200 * @param xShape The shape to export as DrawingML.
201 * @return <tt>*this</tt>
203 ShapeExport& WriteShape( const css::uno::Reference< css::drawing::XShape >& xShape );
204 ShapeExport& WriteTextBox( const css::uno::Reference< css::uno::XInterface >& xIface, sal_Int32 nXmlNamespace );
205 virtual ShapeExport&
206 WriteTextShape( const css::uno::Reference< css::drawing::XShape >& xShape );
207 ShapeExport&
208 WriteTableShape( const css::uno::Reference< css::drawing::XShape >& xShape );
209 void WriteMathShape(css::uno::Reference<css::drawing::XShape> const& xShape);
210 ShapeExport&
211 WriteOLE2Shape( const css::uno::Reference< css::drawing::XShape >& xShape );
212 virtual ShapeExport&
213 WriteUnknownShape( const css::uno::Reference< css::drawing::XShape >& xShape );
215 void WriteTable( const css::uno::Reference< css::drawing::XShape >& rXShape );
217 void WriteTableCellProperties(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
219 void WriteTableCellBorders(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
221 sal_Int32 GetNewShapeID( const css::uno::Reference< css::drawing::XShape >& rShape );
222 sal_Int32 GetNewShapeID( const css::uno::Reference< css::drawing::XShape >& rShape, ::oox::core::XmlFilterBase* pFB );
223 sal_Int32 GetShapeID( const css::uno::Reference< css::drawing::XShape >& rShape );
224 static sal_Int32 GetShapeID( const css::uno::Reference< css::drawing::XShape >& rShape, ShapeHashMap* pShapeMap );
229 #endif // INCLUDED_OOX_EXPORT_SHAPES_HXX
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */