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