1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svgfilter.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <com/sun/star/drawing/XMasterPageTarget.hpp>
35 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
36 #include <com/sun/star/container/XNamed.hpp>
37 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
38 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
39 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
40 #include <com/sun/star/document/XFilter.hpp>
41 #include <com/sun/star/document/XImporter.hpp>
42 #include <com/sun/star/document/XExporter.hpp>
43 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
44 #include <com/sun/star/lang/XInitialization.hpp>
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/lang/XComponent.hpp>
48 #include <cppuhelper/implbase4.hxx>
49 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
50 #include <com/sun/star/io/XActiveDataSource.hpp>
51 #include <com/sun/star/presentation/AnimationEffect.hpp>
52 #include <com/sun/star/presentation/AnimationSpeed.hpp>
53 #include <com/sun/star/presentation/ClickAction.hpp>
54 #include <com/sun/star/presentation/FadeEffect.hpp>
55 #include <com/sun/star/text/XText.hpp>
56 #include <com/sun/star/frame/XDesktop.hpp>
57 #include <com/sun/star/java/XJavaVM.hpp>
58 #include <com/sun/star/java/XJavaThreadRegister_11.hpp>
59 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
62 #include <osl/diagnose.h>
63 #include <rtl/process.h>
64 #include <tools/debug.hxx>
65 #include <comphelper/processfactory.hxx>
66 #include <unotools/tempfile.hxx>
67 #include <unotools/localfilehelper.hxx>
68 #include <unotools/ucbstreamhelper.hxx>
69 #include <unotools/streamwrap.hxx>
70 #include <vcl/cvtgrf.hxx>
71 #include <vcl/svapp.hxx>
72 #include <vcl/outdev.hxx>
73 #include <vcl/metaact.hxx>
74 #include <goodies/grfmgr.hxx>
75 #include <svx/unomodel.hxx>
76 #include <svx/unoapi.hxx>
77 #include <svx/svdxcgv.hxx>
78 #include <svx/svdobj.hxx>
79 #include <xmloff/xmlexp.hxx>
81 #include "svgfilter.hxx"
82 #include "svgscript.hxx"
84 using namespace ::com::sun::star::uno
;
85 using namespace ::com::sun::star::container
;
86 using namespace ::com::sun::star::lang
;
87 using namespace ::com::sun::star::beans
;
88 using namespace ::com::sun::star::java
;
89 using namespace ::com::sun::star::drawing
;
90 using namespace ::com::sun::star::presentation
;
91 using namespace ::com::sun::star::document
;
92 using namespace ::com::sun::star::text
;
93 using namespace ::com::sun::star::io
;
94 using namespace ::com::sun::star::xml::sax
;
95 using namespace ::std
;
101 #define SVG_EXPORT_ALLPAGES ((sal_Int32)-1)
108 class SVGExport
: public SvXMLExport
116 virtual void _ExportMeta() {}
117 virtual void _ExportStyles( BOOL
/* bUsed */ ) {}
118 virtual void _ExportAutoStyles() {}
119 virtual void _ExportContent() {}
120 virtual void _ExportMasterStyles() {}
121 virtual sal_uInt32
exportDoc( enum ::xmloff::token::XMLTokenEnum
/* eClass */ ) { return 0; }
126 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xServiceFactory
,
127 const Reference
< XDocumentHandler
>& rxHandler
);
128 virtual ~SVGExport();
131 // ------------------------
132 // - ObjectRepresentation -
133 // ------------------------
135 class ObjectRepresentation
139 Reference
< XInterface
> mxObject
;
144 ObjectRepresentation();
145 ObjectRepresentation( const Reference
< XInterface
>& rxIf
,
146 const GDIMetaFile
& rMtf
);
147 ObjectRepresentation( const ObjectRepresentation
& rPresentation
);
148 ~ObjectRepresentation();
150 ObjectRepresentation
& operator=( const ObjectRepresentation
& rPresentation
);
151 bool operator==( const ObjectRepresentation
& rPresentation
) const;
153 const Reference
< XInterface
>& GetObject() const { return mxObject
; }
154 sal_Bool
HasRepresentation() const { return mpMtf
!= NULL
; }
155 const GDIMetaFile
& GetRepresentation() const { return *mpMtf
; }
158 // ---------------------------
159 // - HashReferenceXInterface -
160 // ---------------------------
162 struct HashReferenceXInterface
164 size_t operator()( const Reference
< XInterface
>& rxIf
) const { return reinterpret_cast< size_t >( rxIf
.get() ); }
172 class SVGActionWriter
;
175 class SVGFilter
: public cppu::WeakImplHelper4
< XFilter
,
178 XExtendedFilterDetection
>
180 typedef ::std::hash_map
< Reference
< XInterface
>, ObjectRepresentation
, HashReferenceXInterface
> ObjectMap
;
184 Reference
< XMultiServiceFactory
> mxMSF
;
185 SvXMLElementExport
* mpSVGDoc
;
186 SVGExport
* mpSVGExport
;
187 SVGFontExport
* mpSVGFontExport
;
188 SVGActionWriter
* mpSVGWriter
;
189 SdrPage
* mpDefaultSdrPage
;
190 SdrModel
* mpSdrModel
;
191 sal_Bool mbPresentation
;
193 ObjectMap
* mpObjects
;
194 Reference
< XComponent
> mxSrcDoc
;
195 Reference
< XComponent
> mxDstDoc
;
196 Reference
< XDrawPage
> mxDefaultPage
;
199 sal_Bool
implImport( const Sequence
< PropertyValue
>& rDescriptor
) throw (RuntimeException
);
201 sal_Bool
implExport( const Sequence
< PropertyValue
>& rDescriptor
) throw (RuntimeException
);
202 Reference
< XDocumentHandler
> implCreateExportDocumentHandler( const Reference
< XOutputStream
>& rxOStm
);
204 sal_Bool
implGenerateMetaData( const Reference
< XDrawPages
>& rxMasterPages
,
205 const Reference
< XDrawPages
>& rxDrawPages
);
206 sal_Bool
implGenerateScript( const Reference
< XDrawPages
>& rxMasterPages
,
207 const Reference
< XDrawPages
>& rxDrawPages
);
209 sal_Bool
implExportDocument( const Reference
< XDrawPages
>& rxMasterPages
,
210 const Reference
< XDrawPages
>& rxDrawPages
,
211 sal_Int32 nPageToExport
);
213 sal_Bool
implExportPages( const Reference
< XDrawPages
>& rxPages
,
214 sal_Int32 nFirstPage
, sal_Int32 nLastPage
,
215 sal_Int32 nVisiblePage
, sal_Bool bMaster
);
217 sal_Bool
implExportShapes( const Reference
< XShapes
>& rxShapes
);
218 sal_Bool
implExportShape( const Reference
< XShape
>& rxShape
);
220 sal_Bool
implCreateObjects( const Reference
< XDrawPages
>& rxMasterPages
,
221 const Reference
< XDrawPages
>& rxDrawPages
,
222 sal_Int32 nPageToExport
);
223 sal_Bool
implCreateObjectsFromShapes( const Reference
< XShapes
>& rxShapes
);
224 sal_Bool
implCreateObjectsFromShape( const Reference
< XShape
>& rxShape
);
225 sal_Bool
implCreateObjectsFromBackground( const Reference
< XDrawPage
>& rxMasterPage
);
227 ::rtl::OUString
implGetDescriptionFromShape( const Reference
< XShape
>& rxShape
);
228 ::rtl::OUString
implGetValidIDFromInterface( const Reference
< XInterface
>& rxIf
);
230 DECL_LINK( CalcFieldHdl
, EditFieldInfo
* );
235 virtual sal_Bool SAL_CALL
filter( const Sequence
< PropertyValue
>& rDescriptor
) throw(RuntimeException
);
236 virtual void SAL_CALL
cancel( ) throw (RuntimeException
);
239 virtual void SAL_CALL
setTargetDocument( const Reference
< XComponent
>& xDoc
) throw(IllegalArgumentException
, RuntimeException
);
242 virtual void SAL_CALL
setSourceDocument( const Reference
< XComponent
>& xDoc
) throw(IllegalArgumentException
, RuntimeException
);
244 // XExtendedFilterDetection
245 virtual rtl::OUString SAL_CALL
detect( Sequence
< PropertyValue
>& io_rDescriptor
) throw (RuntimeException
);
249 explicit SVGFilter( const Reference
< XComponentContext
>& rxCtx
);
250 virtual ~SVGFilter();
253 // -----------------------------------------------------------------------------
255 ::rtl::OUString
SVGFilter_getImplementationName ()
256 throw ( ::com::sun::star::uno::RuntimeException
);
258 // -----------------------------------------------------------------------------
260 sal_Bool SAL_CALL
SVGFilter_supportsService( const ::rtl::OUString
& ServiceName
)
261 throw ( ::com::sun::star::uno::RuntimeException
);
263 // -----------------------------------------------------------------------------
265 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
SVGFilter_getSupportedServiceNames( )
266 throw ( ::com::sun::star::uno::RuntimeException
);
268 // -----------------------------------------------------------------------------
270 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
271 SAL_CALL
SVGFilter_createInstance( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rSMgr
)
272 throw ( ::com::sun::star::uno::Exception
);
274 // -----------------------------------------------------------------------------
279 bool importSvg(SvStream
& rStream
, Graphic
& rGraphic
);
281 #endif // SVGFILTER_HXX