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 _OOX_EXPORT_SHAPES_HXX_
21 : #define _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 0 : 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 0 : 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, 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 :
77 : public:
78 :
79 : ShapeExport( sal_Int32 nXmlNamespace, ::sax_fastparser::FSHelperPtr pFS, ShapeHashMap* pShapeMap = NULL, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX );
80 0 : virtual ~ShapeExport() {}
81 :
82 : static sal_Bool NonEmptyText( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface );
83 :
84 : virtual ShapeExport&
85 : WriteBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, sal_Bool bClosed );
86 : virtual ShapeExport&
87 : WriteClosedBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
88 : virtual ShapeExport&
89 : WriteConnectorShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
90 : virtual ShapeExport&
91 : WriteCustomShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
92 : virtual ShapeExport&
93 : WriteEllipseShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
94 : virtual ShapeExport&
95 : WriteGraphicObjectShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
96 : virtual ShapeExport&
97 : WriteLineShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
98 : virtual ShapeExport&
99 : WriteNonVisualDrawingProperties( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, const char* sName );
100 : virtual ShapeExport&
101 : WriteNonVisualProperties( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
102 : virtual ShapeExport&
103 : WriteOpenBezierShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
104 : virtual ShapeExport&
105 : WriteRectangleShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
106 :
107 : /**
108 : * Write the DrawingML for a particular shape.
109 : *
110 : * <p>This is the member function you want. It performs the type lookup and
111 : * invokes the appropriate corresponding Write*() method for the specific
112 : * type.</p>
113 : *
114 : * <p>To write an XShape, XShape::getShapeType() is called to determine
115 : * the shape type, and the corresponding method in this table is
116 : * invoked:</p>
117 : *
118 : * <table>
119 : * <tr><th>Shape Type</th><th>Method</th></tr>
120 : * <tr><td><tt>com.sun.star.drawing.ClosedBezierShape</tt></td> <td>ShapeExport::WriteClosedBezierShape</td></tr>
121 : * <tr><td><tt>com.sun.star.drawing.CustomShape</tt></td> <td>ShapeExport::WriteCustomShape</td></tr>
122 : * <tr><td><tt>com.sun.star.drawing.EllipseShape</tt></td> <td>ShapeExport::WriteEllipseShape</td></tr>
123 : * <tr><td><tt>com.sun.star.drawing.GraphicObjectShape</tt></td> <td>ShapeExport::WriteGraphicObjectShape</td></tr>
124 : * <tr><td><tt>com.sun.star.drawing.LineShape</tt></td> <td>ShapeExport::WriteLineShape</td></tr>
125 : * <tr><td><tt>com.sun.star.drawing.OpenBezierShape</tt></td> <td>ShapeExport::WriteOpenBezierShape</td></tr>
126 : * <tr><td><tt>com.sun.star.drawing.RectangleShape</tt></td> <td>ShapeExport::WriteRectangleShape</td></tr>
127 : * <tr><td><tt>com.sun.star.drawing.TableShape</tt></td> <td>ShapeExport::WriteTableShape</td></tr>
128 : * <tr><td><tt>com.sun.star.drawing.TextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
129 : * <tr><td><tt>com.sun.star.presentation.DateTimeShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
130 : * <tr><td><tt>com.sun.star.presentation.FooterShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
131 : * <tr><td><tt>com.sun.star.presentation.HeaderShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
132 : * <tr><td><tt>com.sun.star.presentation.NotesShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
133 : * <tr><td><tt>com.sun.star.presentation.OutlinerShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
134 : * <tr><td><tt>com.sun.star.presentation.SlideNumberShape</tt></td><td>ShapeExport::WriteTextShape</td></tr>
135 : * <tr><td><tt>com.sun.star.presentation.TitleTextShape</tt></td> <td>ShapeExport::WriteTextShape</td></tr>
136 : * </table>
137 : *
138 : * <p>If the shape type is not recognized, then
139 : * <tt>ShapeExport::WriteUnknownShape</tt> is called.</p>
140 : *
141 : * @param xShape The shape to export as DrawingML.
142 : * @return <tt>*this</tt>
143 : */
144 : virtual ShapeExport&
145 : WriteShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
146 : virtual ShapeExport&
147 : WriteTextBox( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xIface, sal_Int32 nXmlNamespace );
148 : virtual ShapeExport&
149 : WriteTextShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
150 : virtual ShapeExport&
151 : WriteTableShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
152 : virtual ShapeExport&
153 : WriteOLE2Shape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
154 : virtual ShapeExport&
155 : WriteUnknownShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
156 :
157 : void WriteTable( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rXShape );
158 :
159 :
160 : sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape );
161 : sal_Int32 GetNewShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ::oox::core::XmlFilterBase* pFB );
162 : sal_Int32 GetShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape );
163 : static sal_Int32 GetShapeID( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > rShape, ShapeHashMap* pShapeMap );
164 : };
165 :
166 : }}
167 :
168 : #endif /* ndef _OOX_EXPORT_SHAPES_HXX_ */
169 :
170 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|