Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SVGFILTER_HXX
30 : : #define SVGFILTER_HXX
31 : :
32 : : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
33 : : #include <com/sun/star/drawing/XMasterPageTarget.hpp>
34 : : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
35 : : #include <com/sun/star/container/XNamed.hpp>
36 : :
37 : : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
38 : : #include <com/sun/star/presentation/XPresentationSupplier.hpp>
39 : : #include <com/sun/star/document/XFilter.hpp>
40 : : #include <com/sun/star/document/XImporter.hpp>
41 : : #include <com/sun/star/document/XExporter.hpp>
42 : : #include <com/sun/star/document/XExtendedFilterDetection.hpp>
43 : : #include <com/sun/star/lang/XInitialization.hpp>
44 : : #include <com/sun/star/lang/XServiceInfo.hpp>
45 : : #include <com/sun/star/beans/XPropertySet.hpp>
46 : : #include <com/sun/star/lang/XComponent.hpp>
47 : : #include <cppuhelper/implbase4.hxx>
48 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 : : #include <com/sun/star/io/XActiveDataSource.hpp>
50 : : #include <com/sun/star/presentation/AnimationEffect.hpp>
51 : : #include <com/sun/star/presentation/AnimationSpeed.hpp>
52 : : #include <com/sun/star/presentation/ClickAction.hpp>
53 : : #include <com/sun/star/presentation/FadeEffect.hpp>
54 : : #include <com/sun/star/text/XText.hpp>
55 : : #include <com/sun/star/frame/XDesktop.hpp>
56 : : #include <com/sun/star/java/XJavaVM.hpp>
57 : : #include <com/sun/star/java/XJavaThreadRegister_11.hpp>
58 : : #include <com/sun/star/style/ParagraphAdjust.hpp>
59 : : #include <com/sun/star/drawing/FillStyle.hpp>
60 : : #include <com/sun/star/graphic/XGraphicProvider.hpp>
61 : :
62 : : #include <boost/unordered_set.hpp>
63 : : #include <boost/unordered_map.hpp>
64 : : #include <osl/diagnose.h>
65 : : #include <sal/log.hxx>
66 : : #include <rtl/process.h>
67 : : #include <basegfx/polygon/b2dpolypolygon.hxx>
68 : : #include <basegfx/polygon/b2dpolygonclipper.hxx>
69 : : #include <basegfx/polygon/b2dpolypolygontools.hxx>
70 : : #include <comphelper/processfactory.hxx>
71 : : #include <unotools/tempfile.hxx>
72 : : #include <unotools/localfilehelper.hxx>
73 : : #include <unotools/ucbstreamhelper.hxx>
74 : : #include <unotools/streamwrap.hxx>
75 : : #include <vcl/cvtgrf.hxx>
76 : : #include <vcl/svapp.hxx>
77 : : #include <vcl/outdev.hxx>
78 : : #include <vcl/metaact.hxx>
79 : : #include <svtools/grfmgr.hxx>
80 : : #include <svx/unomodel.hxx>
81 : : #include <svx/unoapi.hxx>
82 : : #include <svx/svdxcgv.hxx>
83 : : #include <svx/svdobj.hxx>
84 : : #include <xmloff/xmlexp.hxx>
85 : :
86 : : #include <cstdio>
87 : :
88 : :
89 : : using namespace ::com::sun::star::animations;
90 : : using namespace ::com::sun::star::beans;
91 : : using namespace ::com::sun::star::container;
92 : : using namespace ::com::sun::star::document;
93 : : using namespace ::com::sun::star::drawing;
94 : : using namespace ::com::sun::star::io;
95 : : using namespace ::com::sun::star::java;
96 : : using namespace ::com::sun::star::lang;
97 : : using namespace ::com::sun::star::presentation;
98 : : using namespace ::com::sun::star::style;
99 : : using namespace ::com::sun::star::text;
100 : : using namespace ::com::sun::star::uno;
101 : : using namespace ::com::sun::star::xml::sax;
102 : :
103 : : using namespace ::std;
104 : :
105 : : // -----------
106 : : // - Defines -
107 : : // -----------
108 : :
109 : : #define SVG_EXPORT_ALLPAGES ((sal_Int32)-1)
110 : :
111 : :
112 : : // -----------
113 : : // - statics -
114 : : // -----------
115 : :
116 : : // Placeholder tag used into the ImplWriteActions method to filter text placeholder fields
117 : 30 : static const ::rtl::OUString sPlaceholderTag = ::rtl::OUString::createFromAscii( "<[:isPlaceholder:]>" );
118 : :
119 : :
120 : : // -------------
121 : : // - SVGExport -
122 : : // -------------
123 : :
124 : : // #110680#
125 : : class SVGExport : public SvXMLExport
126 : : {
127 : : typedef ::std::list< ::basegfx::B2DPolyPolygon > B2DPolyPolygonList;
128 : :
129 : : public:
130 : :
131 : : SVGExport( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
132 : : const Reference< XDocumentHandler >& rxHandler,
133 : : const Sequence< PropertyValue >& rFilterData );
134 : :
135 : : virtual ~SVGExport();
136 : :
137 : : sal_Bool IsUseTinyProfile() const;
138 : : sal_Bool IsEmbedFonts() const;
139 : : sal_Bool IsUseNativeTextDecoration() const;
140 : : sal_Bool IsUseOpacity() const;
141 : :
142 : : protected:
143 : :
144 : 0 : virtual void _ExportStyles( sal_Bool /* bUsed */ ) {}
145 : 0 : virtual void _ExportAutoStyles() {}
146 : 0 : virtual void _ExportContent() {}
147 : 0 : virtual void _ExportMasterStyles() {}
148 : 0 : virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum /* eClass */ ) { return 0; }
149 : :
150 : : private:
151 : :
152 : : const Sequence< PropertyValue >& mrFilterData;
153 : :
154 : : SVGExport();
155 : : };
156 : :
157 : : // ------------------------
158 : : // - ObjectRepresentation -
159 : : // ------------------------
160 : :
161 : : class ObjectRepresentation
162 : : {
163 : : private:
164 : :
165 : : Reference< XInterface > mxObject;
166 : : GDIMetaFile* mpMtf;
167 : :
168 : : public:
169 : :
170 : : ObjectRepresentation();
171 : : ObjectRepresentation( const Reference< XInterface >& rxIf,
172 : : const GDIMetaFile& rMtf );
173 : : ObjectRepresentation( const ObjectRepresentation& rPresentation );
174 : : ~ObjectRepresentation();
175 : :
176 : : ObjectRepresentation& operator=( const ObjectRepresentation& rPresentation );
177 : : sal_Bool operator==( const ObjectRepresentation& rPresentation ) const;
178 : :
179 : : const Reference< XInterface >& GetObject() const { return mxObject; }
180 : 0 : sal_Bool HasRepresentation() const { return mpMtf != NULL; }
181 : 0 : const GDIMetaFile& GetRepresentation() const { return *mpMtf; }
182 : : };
183 : :
184 : : // -------------------
185 : : // - PagePropertySet -
186 : : // -------------------
187 : :
188 : 20 : struct PagePropertySet
189 : : {
190 : : sal_Bool bIsBackgroundVisible;
191 : : sal_Bool bAreBackgroundObjectsVisible;
192 : : sal_Bool bIsPageNumberFieldVisible;
193 : : sal_Bool bIsDateTimeFieldVisible;
194 : : sal_Bool bIsFooterFieldVisible;
195 : : sal_Bool bIsHeaderFieldVisible;
196 : : sal_Int32 nPageNumberingType;
197 : : sal_Bool bIsDateTimeFieldFixed;
198 : : sal_Int16 nPageNumber;
199 : : sal_Int32 nDateTimeFormat;
200 : : ::rtl::OUString sDateTimeText;
201 : : ::rtl::OUString sFooterText;
202 : : ::rtl::OUString sHeaderText;
203 : : };
204 : :
205 : :
206 : :
207 : : // ---------------------------
208 : : // - HashReferenceXInterface -
209 : : // ---------------------------
210 : :
211 : : struct HashReferenceXInterface
212 : : {
213 : 0 : size_t operator()( const Reference< XInterface >& rxIf ) const
214 : : {
215 : 0 : return reinterpret_cast< size_t >( rxIf.get() );
216 : : }
217 : : };
218 : :
219 : : // ---------------------------
220 : : // - HashOUString -
221 : : // ---------------------------
222 : :
223 : : struct HashOUString
224 : : {
225 : 0 : size_t operator()( const ::rtl::OUString& oustr ) const { return static_cast< size_t >( oustr.hashCode() ); }
226 : : };
227 : :
228 : : // ---------------------------
229 : : // - HashUChar -
230 : : // ---------------------------
231 : :
232 : : struct HashUChar
233 : : {
234 : 0 : size_t operator()( const sal_Unicode uchar ) const { return static_cast< size_t >( uchar ); }
235 : : };
236 : :
237 : :
238 : : // -------------
239 : : // - SVGFilter -
240 : : // -------------
241 : :
242 : : class SVGFontExport;
243 : : class SVGActionWriter;
244 : : class EditFieldInfo;
245 : :
246 : : class SVGFilter : public cppu::WeakImplHelper4 < XFilter,
247 : : XImporter,
248 : : XExporter,
249 : : XExtendedFilterDetection >
250 : : {
251 : : public:
252 : : typedef ::boost::unordered_map< Reference< XInterface >, ObjectRepresentation, HashReferenceXInterface > ObjectMap;
253 : : typedef ::boost::unordered_set< Reference< XInterface >, HashReferenceXInterface > ObjectSet;
254 : : typedef Sequence< Reference< XInterface > > ObjectSequence;
255 : : typedef Sequence< Reference< XDrawPage > > XDrawPageSequence;
256 : :
257 : : typedef ::boost::unordered_set< sal_Unicode, HashUChar > UCharSet;
258 : : typedef ::boost::unordered_map< ::rtl::OUString, UCharSet, HashOUString > UCharSetMap;
259 : : typedef ::boost::unordered_map< Reference< XInterface >, UCharSetMap, HashReferenceXInterface > UCharSetMapMap;
260 : :
261 : : private:
262 : :
263 : : Reference< XMultiServiceFactory > mxMSF;
264 : : SvXMLElementExport* mpSVGDoc;
265 : : SVGExport* mpSVGExport;
266 : : SVGFontExport* mpSVGFontExport;
267 : : SVGActionWriter* mpSVGWriter;
268 : : SdrPage* mpDefaultSdrPage;
269 : : SdrModel* mpSdrModel;
270 : : sal_Bool mbPresentation;
271 : : sal_Bool mbExportAll;
272 : : sal_Bool mbSinglePage;
273 : : sal_Int32 mnVisiblePage;
274 : : PagePropertySet mVisiblePagePropSet;
275 : : ::rtl::OUString msClipPathId;
276 : : UCharSetMapMap mTextFieldCharSets;
277 : : Reference< XInterface > mCreateOjectsCurrentMasterPage;
278 : :
279 : : ObjectMap* mpObjects;
280 : : Reference< XComponent > mxSrcDoc;
281 : : Reference< XComponent > mxDstDoc;
282 : : Reference< XDrawPage > mxDefaultPage;
283 : : Sequence< PropertyValue > maFilterData;
284 : : XDrawPageSequence mSelectedPages;
285 : : XDrawPageSequence mMasterPageTargets;
286 : :
287 : : Link maOldFieldHdl;
288 : :
289 : : sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
290 : :
291 : : sal_Bool implExport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
292 : : Reference< XDocumentHandler > implCreateExportDocumentHandler( const Reference< XOutputStream >& rxOStm );
293 : :
294 : : sal_Bool implGetPagePropSet( const Reference< XDrawPage > & rxPage );
295 : : sal_Bool implGenerateMetaData();
296 : : sal_Bool implGenerateScript();
297 : :
298 : : sal_Bool implExportDocument();
299 : : sal_Bool implExportAnimations();
300 : :
301 : : sal_Bool implExportMasterPages( const XDrawPageSequence& rxPages,
302 : : sal_Int32 nFirstPage, sal_Int32 nLastPage );
303 : : sal_Bool implExportDrawPages( const XDrawPageSequence& rxPages,
304 : : sal_Int32 nFirstPage, sal_Int32 nLastPage );
305 : : sal_Bool implExportPage( const ::rtl::OUString & sPageId,
306 : : const Reference< XDrawPage > & rxPage,
307 : : const Reference< XShapes > & xShapes,
308 : : sal_Bool bMaster );
309 : :
310 : : sal_Bool implExportShapes( const Reference< XShapes >& rxShapes );
311 : : sal_Bool implExportShape( const Reference< XShape >& rxShape );
312 : :
313 : : sal_Bool implCreateObjects();
314 : : sal_Bool implCreateObjectsFromShapes( const Reference< XShapes >& rxShapes );
315 : : sal_Bool implCreateObjectsFromShape( const Reference< XShape >& rxShape );
316 : : sal_Bool implCreateObjectsFromBackground( const Reference< XDrawPage >& rxMasterPage );
317 : :
318 : : ::rtl::OUString implGetClassFromShape( const Reference< XShape >& rxShape );
319 : : void implRegisterInterface( const Reference< XInterface >& rxIf );
320 : : const ::rtl::OUString & implGetValidIDFromInterface( const Reference< XInterface >& rxIf );
321 : : ::rtl::OUString implGetInterfaceName( const Reference< XInterface >& rxIf );
322 : : sal_Bool implLookForFirstVisiblePage();
323 : : Any implSafeGetPagePropSet( const ::rtl::OUString & sPropertyName,
324 : : const Reference< XPropertySet > & rxPropSet,
325 : : const Reference< XPropertySetInfo > & rxPropSetInfo );
326 : : DECL_LINK( CalcFieldHdl, EditFieldInfo* );
327 : :
328 : : protected:
329 : :
330 : : // XFilter
331 : : virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& rDescriptor ) throw(RuntimeException);
332 : : virtual void SAL_CALL cancel( ) throw (RuntimeException);
333 : :
334 : : // XImporter
335 : : virtual void SAL_CALL setTargetDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException);
336 : :
337 : : // XExporter
338 : : virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException);
339 : :
340 : : // XExtendedFilterDetection
341 : : virtual rtl::OUString SAL_CALL detect( Sequence< PropertyValue >& io_rDescriptor ) throw (RuntimeException);
342 : :
343 : : public:
344 : :
345 : : explicit SVGFilter( const Reference< XComponentContext >& rxCtx );
346 : : virtual ~SVGFilter();
347 : : };
348 : :
349 : : #endif // SVGFILTER_HXX
350 : :
351 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|