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