Branch libreoffice-5-0-4
[LibreOffice.git] / include / oox / export / shapes.hxx
blobc979b3fae015114ad28a35c5686c5fcdc677cb8e
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 <oox/dllapi.h>
24 #include <com/sun/star/uno/XReference.hpp>
25 #include <oox/export/drawingml.hxx>
26 #include <sax/fshelper.hxx>
27 #include <vcl/mapmod.hxx>
28 #include <tools/fract.hxx>
29 #include <unordered_map>
31 namespace com { namespace sun { namespace star {
32 namespace beans {
33 class XPropertySet;
35 namespace drawing {
36 class XShape;
37 class XShapes;
39 }}}
41 namespace oox { namespace drawingml {
43 class OOX_DLLPUBLIC ShapeExport : public DrawingML {
45 private:
46 static int mnEmbeddeDocumentCounter;
47 struct ShapeCheck
49 bool operator()( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& s1, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& s2 ) const
51 return s1 == s2;
55 struct ShapeHash
57 size_t operator()( const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > ) const;
60 public:
61 typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32, ShapeHash, ShapeCheck> ShapeHashMap;
63 protected:
64 sal_Int32 mnShapeIdMax, mnPictureIdMax;
66 void WriteGraphicObjectShapePart( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const Graphic *pGraphic=NULL );
68 private:
69 sal_Int32 mnXmlNamespace;
70 Fraction maFraction;
71 MapMode maMapModeSrc, maMapModeDest;
73 ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& ) const;
75 ShapeHashMap maShapeMap;
76 ShapeHashMap* mpShapeMap;
77 OUString m_presetWarp;
79 public:
81 ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, ShapeHashMap* pShapeMap = NULL, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 );
82 virtual ~ShapeExport() {}
84 static bool NonEmptyText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface );
86 ShapeExport&
87 WriteBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, bool bClosed );
88 ShapeExport&
89 WriteClosedBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
90 ShapeExport&
91 WriteConnectorShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
92 ShapeExport&
93 WriteCustomShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
94 ShapeExport&
95 WriteEllipseShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
96 ShapeExport&
97 WriteGraphicObjectShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
98 ShapeExport&
99 WriteGroupShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
100 ShapeExport&
101 WriteLineShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
102 ShapeExport&
103 WriteNonVisualDrawingProperties( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const char* sName );
104 virtual ShapeExport&
105 WriteNonVisualProperties( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
106 ShapeExport&
107 WriteOpenBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
108 ShapeExport&
109 WriteRectangleShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
112 * Write the DrawingML for a particular shape.
114 * <p>This is the member function you want. It performs the type lookup and
115 * invokes the appropriate corresponding Write*() method for the specific
116 * type.</p>
118 * <p>To write an XShape, XShape::getShapeType() is called to determine
119 * the shape type, and the corresponding method in this table is
120 * invoked:</p>
122 * <table>
123 * <tr><th>Shape Type</th><th>Method</th></tr>
124 * <tr><td><tt>com.sun.star.drawing.ClosedBezierShape</tt></td> <td>ShapeExport::WriteClosedBezierShape</td></tr>
125 * <tr><td><tt>com.sun.star.drawing.CustomShape</tt></td> <td>ShapeExport::WriteCustomShape</td></tr>
126 * <tr><td><tt>com.sun.star.drawing.EllipseShape</tt></td> <td>ShapeExport::WriteEllipseShape</td></tr>
127 * <tr><td><tt>com.sun.star.drawing.GraphicObjectShape</tt></td> <td>ShapeExport::WriteGraphicObjectShape</td></tr>
128 * <tr><td><tt>com.sun.star.drawing.LineShape</tt></td> <td>ShapeExport::WriteLineShape</td></tr>
129 * <tr><td><tt>com.sun.star.drawing.OpenBezierShape</tt></td> <td>ShapeExport::WriteOpenBezierShape</td></tr>
130 * <tr><td><tt>com.sun.star.drawing.RectangleShape</tt></td> <td>ShapeExport::WriteRectangleShape</td></tr>
131 * <tr><td><tt>com.sun.star.drawing.TableShape</tt></td> <td>ShapeExport::WriteTableShape</td></tr>
132 * <tr><td><tt>com.sun.star.drawing.TextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
133 * <tr><td><tt>com.sun.star.presentation.DateTimeShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
134 * <tr><td><tt>com.sun.star.presentation.FooterShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
135 * <tr><td><tt>com.sun.star.presentation.HeaderShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
136 * <tr><td><tt>com.sun.star.presentation.NotesShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
137 * <tr><td><tt>com.sun.star.presentation.OutlinerShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
138 * <tr><td><tt>com.sun.star.presentation.SlideNumberShape</tt></td><td>ShapeExport::WriteTextShape</td></tr>
139 * <tr><td><tt>com.sun.star.presentation.TitleTextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
140 * </table>
142 * <p>If the shape type is not recognized, then
143 * <tt>ShapeExport::WriteUnknownShape</tt> is called.</p>
145 * @param xShape The shape to export as DrawingML.
146 * @return <tt>*this</tt>
148 ShapeExport&
149 WriteShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
150 ShapeExport&
151 WriteTextBox( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface, sal_Int32 nXmlNamespace );
152 virtual ShapeExport&
153 WriteTextShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
154 ShapeExport&
155 WriteTableShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
156 ShapeExport&
157 WriteOLE2Shape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
158 virtual ShapeExport&
159 WriteUnknownShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
161 void WriteTable( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape );
163 void WriteTableCellProperties(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet);
165 void WriteTableCellBorders(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet);
167 sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape );
168 sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ::oox::core::XmlFilterBase* pFB );
169 sal_Int32 GetShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape );
170 static sal_Int32 GetShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ShapeHashMap* pShapeMap );
175 #endif // INCLUDED_OOX_EXPORT_SHAPES_HXX
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */