1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
25 #include <unordered_map>
27 #include <com/sun/star/awt/Size.hpp>
28 #include <com/sun/star/table/BorderLine2.hpp>
29 #include <com/sun/star/uno/Reference.hxx>
30 #include <oox/dllapi.h>
31 #include <oox/export/drawingml.hxx>
32 #include <oox/export/utils.hxx>
33 #include <rtl/ustring.hxx>
34 #include <sal/types.h>
35 #include <sax/fshelper.hxx>
36 #include <tools/fract.hxx>
37 #include <vcl/mapmod.hxx>
39 namespace com
{ namespace sun
{ namespace star
{
48 class XEmbeddedObject
;
54 class XComponentContext
;
68 OOX_DLLPUBLIC
css::uno::Reference
<css::io::XInputStream
> GetOLEObjectStream(
69 css::uno::Reference
<css::uno::XComponentContext
> const& xContext
,
70 css::uno::Reference
<css::embed::XEmbeddedObject
> const& xObj
,
71 OUString
const& i_rProgID
,
72 OUString
& o_rMediaType
,
73 OUString
& o_rRelationType
,
75 const char *& o_rpProgID
);
79 namespace oox
{ namespace drawingml
{
81 class OOX_DLLPUBLIC ShapeExport
: public DrawingML
{
84 int m_nEmbeddedObjects
;
87 typedef std::unordered_map
< css::uno::Reference
< css::drawing::XShape
>, sal_Int32
> ShapeHashMap
;
90 sal_Int32 mnShapeIdMax
, mnPictureIdMax
;
92 void WriteGraphicObjectShapePart( const css::uno::Reference
< css::drawing::XShape
>& xShape
, const Graphic
*pGraphic
=nullptr );
95 sal_Int32 mnXmlNamespace
;
96 MapMode maMapModeSrc
, maMapModeDest
;
97 std::shared_ptr
<URLTransformer
> mpURLTransformer
;
99 css::awt::Size
MapSize( const css::awt::Size
& ) const;
101 ShapeHashMap maShapeMap
;
102 ShapeHashMap
* mpShapeMap
;
103 OUString m_presetWarp
;
107 ShapeExport( sal_Int32 nXmlNamespace
, ::sax_fastparser::FSHelperPtr pFS
,
108 ShapeHashMap
* pShapeMap
, ::oox::core::XmlFilterBase
* pFB
,
109 DocumentType eDocumentType
= DOCUMENT_PPTX
,
110 DMLTextExport
* pTextExport
= nullptr );
111 virtual ~ShapeExport() {}
113 void SetURLTranslator(const std::shared_ptr
<URLTransformer
>& pTransformer
);
115 static bool NonEmptyText( const css::uno::Reference
< css::uno::XInterface
>& xIface
);
118 WritePolyPolygonShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
, bool bClosed
);
120 WriteClosedPolyPolygonShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
122 WriteConnectorShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
124 WriteCustomShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
126 WriteEllipseShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
128 WriteGraphicObjectShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
130 WriteGroupShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
132 WriteLineShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
134 WriteNonVisualDrawingProperties( const css::uno::Reference
< css::drawing::XShape
>& xShape
, const char* sName
);
136 WriteNonVisualProperties( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
138 WriteOpenPolyPolygonShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
140 WriteRectangleShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
143 * Write the DrawingML for a particular shape.
145 * <p>This is the member function you want. It performs the type lookup and
146 * invokes the appropriate corresponding Write*() method for the specific
149 * <p>To write an XShape, XShape::getShapeType() is called to determine
150 * the shape type, and the corresponding method in this table is
154 * <tr><th>Shape Type</th><th>Method</th></tr>
155 * <tr><td><tt>com.sun.star.drawing.ClosedBezierShape</tt></td> <td>ShapeExport::WriteClosedPolyPolygonShape</td></tr>
156 * <tr><td><tt>com.sun.star.drawing.CustomShape</tt></td> <td>ShapeExport::WriteCustomShape</td></tr>
157 * <tr><td><tt>com.sun.star.drawing.EllipseShape</tt></td> <td>ShapeExport::WriteEllipseShape</td></tr>
158 * <tr><td><tt>com.sun.star.drawing.GraphicObjectShape</tt></td> <td>ShapeExport::WriteGraphicObjectShape</td></tr>
159 * <tr><td><tt>com.sun.star.drawing.LineShape</tt></td> <td>ShapeExport::WriteLineShape</td></tr>
160 * <tr><td><tt>com.sun.star.drawing.OpenBezierShape</tt></td> <td>ShapeExport::WriteOpenPolyPolygonShape</td></tr>
161 * <tr><td><tt>com.sun.star.drawing.PolyPolygonShape</tt></td> <td>ShapeExport::WriteClosedPolyPolygonShape</td></tr>
162 * <tr><td><tt>com.sun.star.drawing.PolyLineShape</tt></td> <td>ShapeExport::WriteOpenPolyPolygonShape</td></tr>
163 * <tr><td><tt>com.sun.star.drawing.RectangleShape</tt></td> <td>ShapeExport::WriteRectangleShape</td></tr>
164 * <tr><td><tt>com.sun.star.drawing.TableShape</tt></td> <td>ShapeExport::WriteTableShape</td></tr>
165 * <tr><td><tt>com.sun.star.drawing.TextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
166 * <tr><td><tt>com.sun.star.presentation.DateTimeShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
167 * <tr><td><tt>com.sun.star.presentation.FooterShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
168 * <tr><td><tt>com.sun.star.presentation.HeaderShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
169 * <tr><td><tt>com.sun.star.presentation.NotesShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
170 * <tr><td><tt>com.sun.star.presentation.OutlinerShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
171 * <tr><td><tt>com.sun.star.presentation.SlideNumberShape</tt></td><td>ShapeExport::WriteTextShape</td></tr>
172 * <tr><td><tt>com.sun.star.presentation.TitleTextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
175 * <p>If the shape type is not recognized, then
176 * <tt>ShapeExport::WriteUnknownShape</tt> is called.</p>
178 * @param xShape The shape to export as DrawingML.
179 * @return <tt>*this</tt>
181 ShapeExport
& WriteShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
182 ShapeExport
& WriteTextBox( const css::uno::Reference
< css::uno::XInterface
>& xIface
, sal_Int32 nXmlNamespace
);
184 WriteTextShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
186 WriteTableShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
187 void WriteMathShape(css::uno::Reference
<css::drawing::XShape
> const& xShape
);
189 WriteOLE2Shape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
191 WriteUnknownShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
);
193 void WriteTable( const css::uno::Reference
< css::drawing::XShape
>& rXShape
);
195 void WriteTableCellProperties(const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
);
197 void WriteBorderLine(const sal_Int32 XML_line
, const css::table::BorderLine2
& rBorderLine
);
198 void WriteTableCellBorders(const css::uno::Reference
< css::beans::XPropertySet
>& rXPropSet
);
200 sal_Int32
GetNewShapeID( const css::uno::Reference
< css::drawing::XShape
>& rShape
);
201 sal_Int32
GetNewShapeID( const css::uno::Reference
< css::drawing::XShape
>& rShape
, ::oox::core::XmlFilterBase
* pFB
);
202 sal_Int32
GetShapeID( const css::uno::Reference
< css::drawing::XShape
>& rShape
);
203 static sal_Int32
GetShapeID( const css::uno::Reference
< css::drawing::XShape
>& rShape
, ShapeHashMap
* pShapeMap
);
208 #endif // INCLUDED_OOX_EXPORT_SHAPES_HXX
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */