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_SHAPES_HXX
21 : #define INCLUDED_OOX_EXPORT_SHAPES_HXX
22 :
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 <boost/unordered_map.hpp>
29 :
30 : namespace com { namespace sun { namespace star {
31 : namespace beans {
32 : class XPropertySet;
33 : }
34 : namespace drawing {
35 : class XShape;
36 : class XShapes;
37 : }
38 : }}}
39 :
40 : namespace oox { namespace drawingml {
41 :
42 : class OOX_DLLPUBLIC ShapeExport : public DrawingML {
43 :
44 : private:
45 : static int mnSpreadsheetCounter;
46 : struct ShapeCheck
47 : {
48 5512 : 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
49 : {
50 5512 : return s1 == s2;
51 : }
52 : };
53 :
54 : struct ShapeHash
55 : {
56 : size_t operator()( const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > ) const;
57 : };
58 :
59 : public:
60 : typedef boost::unordered_map< const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>, sal_Int32, ShapeHash, ShapeCheck> ShapeHashMap;
61 :
62 : protected:
63 : sal_Int32 mnShapeIdMax, mnPictureIdMax;
64 :
65 : void WriteGraphicObjectShapePart( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const Graphic *pGraphic=NULL );
66 :
67 : private:
68 : sal_Int32 mnXmlNamespace;
69 : Fraction maFraction;
70 : MapMode maMapModeSrc, maMapModeDest;
71 :
72 : ::com::sun::star::awt::Size MapSize( const ::com::sun::star::awt::Size& ) const;
73 :
74 : ShapeHashMap maShapeMap;
75 : ShapeHashMap* mpShapeMap;
76 : OUString m_presetWarp;
77 :
78 : public:
79 :
80 : ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, ShapeHashMap* pShapeMap = NULL, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 );
81 946 : virtual ~ShapeExport() {}
82 :
83 : static bool NonEmptyText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface );
84 :
85 : virtual ShapeExport&
86 : WriteBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, bool bClosed );
87 : virtual ShapeExport&
88 : WriteClosedBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
89 : virtual ShapeExport&
90 : WriteConnectorShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
91 : virtual ShapeExport&
92 : WriteCustomShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
93 : virtual ShapeExport&
94 : WriteEllipseShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
95 : virtual ShapeExport&
96 : WriteGraphicObjectShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
97 : virtual ShapeExport&
98 : WriteGroupShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
99 : virtual ShapeExport&
100 : WriteLineShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
101 : virtual ShapeExport&
102 : WriteNonVisualDrawingProperties( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const char* sName );
103 : virtual ShapeExport&
104 : WriteNonVisualProperties( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
105 : virtual ShapeExport&
106 : WriteOpenBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
107 : virtual ShapeExport&
108 : WriteRectangleShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
109 :
110 : /**
111 : * Write the DrawingML for a particular shape.
112 : *
113 : * <p>This is the member function you want. It performs the type lookup and
114 : * invokes the appropriate corresponding Write*() method for the specific
115 : * type.</p>
116 : *
117 : * <p>To write an XShape, XShape::getShapeType() is called to determine
118 : * the shape type, and the corresponding method in this table is
119 : * invoked:</p>
120 : *
121 : * <table>
122 : * <tr><th>Shape Type</th><th>Method</th></tr>
123 : * <tr><td><tt>com.sun.star.drawing.ClosedBezierShape</tt></td> <td>ShapeExport::WriteClosedBezierShape</td></tr>
124 : * <tr><td><tt>com.sun.star.drawing.CustomShape</tt></td> <td>ShapeExport::WriteCustomShape</td></tr>
125 : * <tr><td><tt>com.sun.star.drawing.EllipseShape</tt></td> <td>ShapeExport::WriteEllipseShape</td></tr>
126 : * <tr><td><tt>com.sun.star.drawing.GraphicObjectShape</tt></td> <td>ShapeExport::WriteGraphicObjectShape</td></tr>
127 : * <tr><td><tt>com.sun.star.drawing.LineShape</tt></td> <td>ShapeExport::WriteLineShape</td></tr>
128 : * <tr><td><tt>com.sun.star.drawing.OpenBezierShape</tt></td> <td>ShapeExport::WriteOpenBezierShape</td></tr>
129 : * <tr><td><tt>com.sun.star.drawing.RectangleShape</tt></td> <td>ShapeExport::WriteRectangleShape</td></tr>
130 : * <tr><td><tt>com.sun.star.drawing.TableShape</tt></td> <td>ShapeExport::WriteTableShape</td></tr>
131 : * <tr><td><tt>com.sun.star.drawing.TextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
132 : * <tr><td><tt>com.sun.star.presentation.DateTimeShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
133 : * <tr><td><tt>com.sun.star.presentation.FooterShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
134 : * <tr><td><tt>com.sun.star.presentation.HeaderShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
135 : * <tr><td><tt>com.sun.star.presentation.NotesShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
136 : * <tr><td><tt>com.sun.star.presentation.OutlinerShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
137 : * <tr><td><tt>com.sun.star.presentation.SlideNumberShape</tt></td><td>ShapeExport::WriteTextShape</td></tr>
138 : * <tr><td><tt>com.sun.star.presentation.TitleTextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
139 : * </table>
140 : *
141 : * <p>If the shape type is not recognized, then
142 : * <tt>ShapeExport::WriteUnknownShape</tt> is called.</p>
143 : *
144 : * @param xShape The shape to export as DrawingML.
145 : * @return <tt>*this</tt>
146 : */
147 : virtual ShapeExport&
148 : WriteShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
149 : virtual ShapeExport&
150 : WriteTextBox( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface, sal_Int32 nXmlNamespace );
151 : virtual ShapeExport&
152 : WriteTextShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
153 : virtual ShapeExport&
154 : WriteTableShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
155 : virtual ShapeExport&
156 : WriteOLE2Shape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
157 : virtual ShapeExport&
158 : WriteUnknownShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
159 :
160 : void WriteTable( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape );
161 :
162 :
163 : sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape );
164 : sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ::oox::core::XmlFilterBase* pFB );
165 : sal_Int32 GetShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape );
166 : static sal_Int32 GetShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ShapeHashMap* pShapeMap );
167 : };
168 :
169 : }}
170 :
171 : #endif // INCLUDED_OOX_EXPORT_SHAPES_HXX
172 :
173 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|