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: XMLFilter.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 ************************************************************************/
30 #ifndef CHART2_XMLFILTER_HXX
31 #define CHART2_XMLFILTER_HXX
33 #include <cppuhelper/implbase4.hxx>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/document/XFilter.hpp>
36 #include <com/sun/star/document/XImporter.hpp>
37 #include <com/sun/star/document/XExporter.hpp>
38 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <com/sun/star/io/XActiveDataSource.hpp>
41 #include <osl/mutex.hxx>
43 // for APPHELPER_... macros
44 #include "ServiceMacros.hxx"
46 namespace com
{ namespace sun
{ namespace star
{
51 namespace xml
{ namespace sax
57 class XGraphicObjectResolver
;
64 class XMLFilter
: public
65 ::cppu::WeakImplHelper4
<
66 ::com::sun::star::document::XFilter
,
67 ::com::sun::star::document::XExporter
,
68 ::com::sun::star::document::XImporter
,
69 ::com::sun::star::lang::XServiceInfo
>
72 explicit XMLFilter( ::com::sun::star::uno::Reference
<
73 ::com::sun::star::uno::XComponentContext
> const & xContext
);
76 /// establish methods for factory instatiation
77 APPHELPER_SERVICE_FACTORY_HELPER( XMLFilter
)
78 /// XServiceInfo declarations
79 APPHELPER_XSERVICEINFO_DECL()
83 virtual sal_Bool SAL_CALL
filter(
84 const ::com::sun::star::uno::Sequence
<
85 ::com::sun::star::beans::PropertyValue
>& aDescriptor
)
86 throw (::com::sun::star::uno::RuntimeException
);
87 virtual void SAL_CALL
cancel()
88 throw (::com::sun::star::uno::RuntimeException
);
90 // ____ XImporter ____
91 virtual void SAL_CALL
setTargetDocument(
92 const ::com::sun::star::uno::Reference
<
93 ::com::sun::star::lang::XComponent
>& Document
)
94 throw (::com::sun::star::lang::IllegalArgumentException
,
95 ::com::sun::star::uno::RuntimeException
);
97 // ____ XExporter ____
98 virtual void SAL_CALL
setSourceDocument(
99 const ::com::sun::star::uno::Reference
<
100 ::com::sun::star::lang::XComponent
>& Document
)
101 throw (::com::sun::star::lang::IllegalArgumentException
,
102 ::com::sun::star::uno::RuntimeException
);
104 inline ::rtl::OUString
getDocumentHandler() const { return m_sDocumentHandler
; }
105 inline void setDocumentHandler(const ::rtl::OUString
& _sDocumentHandler
) { m_sDocumentHandler
= _sDocumentHandler
; }
107 virtual ::rtl::OUString
getMediaType(bool _bOasis
);
109 /** fills the oasis flag only when a filtername was set
111 * \param _rMediaDescriptor
114 virtual void isOasisFormat(const ::com::sun::star::uno::Sequence
<
115 ::com::sun::star::beans::PropertyValue
>& _rMediaDescriptor
, bool & _rOutOASIS
);
120 /// @return a warning code, or 0 for successful operation
121 sal_Int32
impl_Import( const ::com::sun::star::uno::Reference
<
122 ::com::sun::star::lang::XComponent
> & xDocumentComp
,
123 const ::com::sun::star::uno::Sequence
<
124 ::com::sun::star::beans::PropertyValue
> & aMediaDescriptor
);
125 /// @return a warning code, or 0 for successful operation
126 sal_Int32
impl_ImportStream(
127 const ::rtl::OUString
& rStreamName
,
128 const ::rtl::OUString
& rServiceName
,
129 const ::com::sun::star::uno::Reference
<
130 ::com::sun::star::embed::XStorage
> & xStorage
,
131 const ::com::sun::star::uno::Reference
<
132 ::com::sun::star::xml::sax::XParser
> & xParser
,
133 const ::com::sun::star::uno::Reference
<
134 ::com::sun::star::lang::XMultiComponentFactory
> & xFactory
,
135 const ::com::sun::star::uno::Reference
<
136 ::com::sun::star::document::XGraphicObjectResolver
> & xGraphicObjectResolver
,
137 ::com::sun::star::uno::Reference
<
138 ::com::sun::star::beans::XPropertySet
>& xPropSet
);
140 /// @return a warning code, or 0 for successful operation
141 sal_Int32
impl_Export( const ::com::sun::star::uno::Reference
<
142 ::com::sun::star::lang::XComponent
> & xDocumentComp
,
143 const ::com::sun::star::uno::Sequence
<
144 ::com::sun::star::beans::PropertyValue
> & aMediaDescriptor
);
145 /// @return a warning code, or 0 for successful operation
146 sal_Int32
impl_ExportStream(
147 const ::rtl::OUString
& rStreamName
,
148 const ::rtl::OUString
& rServiceName
,
149 const ::com::sun::star::uno::Reference
<
150 ::com::sun::star::embed::XStorage
> & xStorage
,
151 const ::com::sun::star::uno::Reference
<
152 ::com::sun::star::io::XActiveDataSource
>& xActiveDataSource
,
153 const ::com::sun::star::uno::Reference
<
154 ::com::sun::star::lang::XMultiServiceFactory
> & xFactory
,
155 const ::com::sun::star::uno::Sequence
<
156 ::com::sun::star::uno::Any
> & rFilterProperties
);
159 ::com::sun::star::uno::Reference
<
160 ::com::sun::star::uno::XComponentContext
> m_xContext
;
161 ::com::sun::star::uno::Reference
<
162 ::com::sun::star::lang::XComponent
> m_xTargetDoc
;
163 ::com::sun::star::uno::Reference
<
164 ::com::sun::star::lang::XComponent
> m_xSourceDoc
;
165 ::rtl::OUString m_sDocumentHandler
; // when set it will be set as doc handler
167 volatile bool m_bCancelOperation
;
168 ::osl::Mutex m_aMutex
;
171 // =============================================================================
172 class XMLReportFilterHelper
: public XMLFilter
174 virtual void isOasisFormat(const ::com::sun::star::uno::Sequence
<
175 ::com::sun::star::beans::PropertyValue
>& _rMediaDescriptor
, bool & _rOutOASIS
);
177 explicit XMLReportFilterHelper( ::com::sun::star::uno::Reference
<
178 ::com::sun::star::uno::XComponentContext
> const & _xContext
)
179 :XMLFilter(_xContext
)
181 /// establish methods for factory instatiation
182 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
create(
183 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> const & xContext
) throw(::com::sun::star::uno::Exception
)
185 return (::cppu::OWeakObject
*)new XMLReportFilterHelper( xContext
);
187 static ::rtl::OUString
getImplementationName_Static()
189 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart2.report.XMLFilter" ));
192 virtual ::rtl::OUString SAL_CALL
193 getImplementationName()
194 throw( ::com::sun::star::uno::RuntimeException
)
196 return getImplementationName_Static();
198 // ____ XImporter ____
199 virtual void SAL_CALL
setTargetDocument(
200 const ::com::sun::star::uno::Reference
<
201 ::com::sun::star::lang::XComponent
>& Document
)
202 throw (::com::sun::star::lang::IllegalArgumentException
,
203 ::com::sun::star::uno::RuntimeException
)
205 setDocumentHandler(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ImportDocumentHandler")));
206 XMLFilter::setTargetDocument(Document
);
209 // ____ XExporter ____
210 virtual void SAL_CALL
setSourceDocument(
211 const ::com::sun::star::uno::Reference
<
212 ::com::sun::star::lang::XComponent
>& Document
)
213 throw (::com::sun::star::lang::IllegalArgumentException
,
214 ::com::sun::star::uno::RuntimeException
)
216 setDocumentHandler(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ExportDocumentHandler")));
217 XMLFilter::setSourceDocument(Document
);
220 virtual ::rtl::OUString
getMediaType(bool _bOasis
);
225 // CHART2_XMLFILTER_HXX