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