Bump for 3.6-28
[LibreOffice.git] / chart2 / source / model / inc / XMLFilter.hxx
blob9babb138270c6199183b73911a059ac30e019b52
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
28 #ifndef CHART2_XMLFILTER_HXX
29 #define CHART2_XMLFILTER_HXX
31 #include <cppuhelper/implbase4.hxx>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/document/XFilter.hpp>
34 #include <com/sun/star/document/XImporter.hpp>
35 #include <com/sun/star/document/XExporter.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <com/sun/star/io/XActiveDataSource.hpp>
39 #include <osl/mutex.hxx>
41 // for APPHELPER_... macros
42 #include "ServiceMacros.hxx"
44 namespace com { namespace sun { namespace star {
45 namespace embed
47 class XStorage;
49 namespace xml { namespace sax
51 class XParser;
53 namespace document
55 class XGraphicObjectResolver;
57 }}}
59 namespace chart
62 class XMLFilter : public
63 ::cppu::WeakImplHelper4<
64 ::com::sun::star::document::XFilter,
65 ::com::sun::star::document::XExporter,
66 ::com::sun::star::document::XImporter,
67 ::com::sun::star::lang::XServiceInfo >
69 public:
70 explicit XMLFilter( ::com::sun::star::uno::Reference<
71 ::com::sun::star::uno::XComponentContext > const & xContext );
72 virtual ~XMLFilter();
74 /// establish methods for factory instatiation
75 APPHELPER_SERVICE_FACTORY_HELPER( XMLFilter )
76 /// XServiceInfo declarations
77 APPHELPER_XSERVICEINFO_DECL()
79 protected:
80 // ____ XFilter ____
81 virtual sal_Bool SAL_CALL filter(
82 const ::com::sun::star::uno::Sequence<
83 ::com::sun::star::beans::PropertyValue >& aDescriptor )
84 throw (::com::sun::star::uno::RuntimeException);
85 virtual void SAL_CALL cancel()
86 throw (::com::sun::star::uno::RuntimeException);
88 // ____ XImporter ____
89 virtual void SAL_CALL setTargetDocument(
90 const ::com::sun::star::uno::Reference<
91 ::com::sun::star::lang::XComponent >& Document )
92 throw (::com::sun::star::lang::IllegalArgumentException,
93 ::com::sun::star::uno::RuntimeException);
95 // ____ XExporter ____
96 virtual void SAL_CALL setSourceDocument(
97 const ::com::sun::star::uno::Reference<
98 ::com::sun::star::lang::XComponent >& Document )
99 throw (::com::sun::star::lang::IllegalArgumentException,
100 ::com::sun::star::uno::RuntimeException);
102 inline ::rtl::OUString getDocumentHandler() const { return m_sDocumentHandler; }
103 inline void setDocumentHandler(const ::rtl::OUString& _sDocumentHandler) { m_sDocumentHandler = _sDocumentHandler; }
105 virtual ::rtl::OUString getMediaType(bool _bOasis);
107 /** fills the oasis flag only when a filtername was set
109 * \param _rMediaDescriptor
110 * \param _rOutOASIS
112 virtual void isOasisFormat(const ::com::sun::star::uno::Sequence<
113 ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor, bool & _rOutOASIS );
115 private:
116 // methods
118 /// @return a warning code, or 0 for successful operation
119 sal_Int32 impl_Import( const ::com::sun::star::uno::Reference<
120 ::com::sun::star::lang::XComponent > & xDocumentComp,
121 const ::com::sun::star::uno::Sequence<
122 ::com::sun::star::beans::PropertyValue > & aMediaDescriptor );
123 /// @return a warning code, or 0 for successful operation
124 sal_Int32 impl_ImportStream(
125 const ::rtl::OUString & rStreamName,
126 const ::rtl::OUString & rServiceName,
127 const ::com::sun::star::uno::Reference<
128 ::com::sun::star::embed::XStorage > & xStorage,
129 const ::com::sun::star::uno::Reference<
130 ::com::sun::star::xml::sax::XParser > & xParser,
131 const ::com::sun::star::uno::Reference<
132 ::com::sun::star::lang::XMultiComponentFactory > & xFactory,
133 const ::com::sun::star::uno::Reference<
134 ::com::sun::star::document::XGraphicObjectResolver > & xGraphicObjectResolver,
135 ::com::sun::star::uno::Reference<
136 ::com::sun::star::beans::XPropertySet >& xPropSet );
138 /// @return a warning code, or 0 for successful operation
139 sal_Int32 impl_Export( const ::com::sun::star::uno::Reference<
140 ::com::sun::star::lang::XComponent > & xDocumentComp,
141 const ::com::sun::star::uno::Sequence<
142 ::com::sun::star::beans::PropertyValue > & aMediaDescriptor );
143 /// @return a warning code, or 0 for successful operation
144 sal_Int32 impl_ExportStream(
145 const ::rtl::OUString & rStreamName,
146 const ::rtl::OUString & rServiceName,
147 const ::com::sun::star::uno::Reference<
148 ::com::sun::star::embed::XStorage > & xStorage,
149 const ::com::sun::star::uno::Reference<
150 ::com::sun::star::io::XActiveDataSource >& xActiveDataSource,
151 const ::com::sun::star::uno::Reference<
152 ::com::sun::star::lang::XMultiServiceFactory > & xFactory,
153 const ::com::sun::star::uno::Sequence<
154 ::com::sun::star::uno::Any > & rFilterProperties );
156 // members
157 ::com::sun::star::uno::Reference<
158 ::com::sun::star::uno::XComponentContext > m_xContext;
159 ::com::sun::star::uno::Reference<
160 ::com::sun::star::lang::XComponent > m_xTargetDoc;
161 ::com::sun::star::uno::Reference<
162 ::com::sun::star::lang::XComponent > m_xSourceDoc;
163 ::rtl::OUString m_sDocumentHandler; // when set it will be set as doc handler
165 volatile bool m_bCancelOperation;
166 ::osl::Mutex m_aMutex;
169 // =============================================================================
170 class XMLReportFilterHelper : public XMLFilter
172 virtual void isOasisFormat(const ::com::sun::star::uno::Sequence<
173 ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor, bool & _rOutOASIS );
174 public:
175 explicit XMLReportFilterHelper( ::com::sun::star::uno::Reference<
176 ::com::sun::star::uno::XComponentContext > const & _xContext )
177 :XMLFilter(_xContext)
179 /// establish methods for factory instatiation
180 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL create(
181 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext) throw(::com::sun::star::uno::Exception)
183 return (::cppu::OWeakObject *)new XMLReportFilterHelper( xContext );
185 static ::rtl::OUString getImplementationName_Static()
187 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart2.report.XMLFilter" ));
189 protected:
190 virtual ::rtl::OUString SAL_CALL
191 getImplementationName()
192 throw( ::com::sun::star::uno::RuntimeException )
194 return getImplementationName_Static();
196 // ____ XImporter ____
197 virtual void SAL_CALL setTargetDocument(
198 const ::com::sun::star::uno::Reference<
199 ::com::sun::star::lang::XComponent >& Document )
200 throw (::com::sun::star::lang::IllegalArgumentException,
201 ::com::sun::star::uno::RuntimeException)
203 setDocumentHandler(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ImportDocumentHandler")));
204 XMLFilter::setTargetDocument(Document);
207 // ____ XExporter ____
208 virtual void SAL_CALL setSourceDocument(
209 const ::com::sun::star::uno::Reference<
210 ::com::sun::star::lang::XComponent >& Document )
211 throw (::com::sun::star::lang::IllegalArgumentException,
212 ::com::sun::star::uno::RuntimeException)
214 setDocumentHandler(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ExportDocumentHandler")));
215 XMLFilter::setSourceDocument(Document);
218 virtual ::rtl::OUString getMediaType(bool _bOasis);
221 } // namespace chart
223 // CHART2_XMLFILTER_HXX
224 #endif
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */