bump product version to 4.1.6.2
[LibreOffice.git] / chart2 / source / model / inc / XMLFilter.hxx
blobad8e32f35f194715143bfa00f10cd05b9cde95cb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef CHART2_XMLFILTER_HXX
20 #define CHART2_XMLFILTER_HXX
22 #include <cppuhelper/implbase4.hxx>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include <com/sun/star/document/XFilter.hpp>
25 #include <com/sun/star/document/XImporter.hpp>
26 #include <com/sun/star/document/XExporter.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
29 #include <com/sun/star/io/XActiveDataSource.hpp>
30 #include <com/sun/star/xml/sax/XWriter.hpp>
31 #include <osl/mutex.hxx>
33 // for APPHELPER_... macros
34 #include "ServiceMacros.hxx"
36 namespace com { namespace sun { namespace star {
37 namespace embed
39 class XStorage;
41 namespace xml { namespace sax
43 class XParser;
45 namespace document
47 class XGraphicObjectResolver;
49 }}}
51 namespace chart
54 class XMLFilter : public
55 ::cppu::WeakImplHelper4<
56 ::com::sun::star::document::XFilter,
57 ::com::sun::star::document::XExporter,
58 ::com::sun::star::document::XImporter,
59 ::com::sun::star::lang::XServiceInfo >
61 public:
62 explicit XMLFilter( ::com::sun::star::uno::Reference<
63 ::com::sun::star::uno::XComponentContext > const & xContext );
64 virtual ~XMLFilter();
66 /// establish methods for factory instatiation
67 APPHELPER_SERVICE_FACTORY_HELPER( XMLFilter )
68 /// XServiceInfo declarations
69 APPHELPER_XSERVICEINFO_DECL()
71 protected:
72 // ____ XFilter ____
73 virtual sal_Bool SAL_CALL filter(
74 const ::com::sun::star::uno::Sequence<
75 ::com::sun::star::beans::PropertyValue >& aDescriptor )
76 throw (::com::sun::star::uno::RuntimeException);
77 virtual void SAL_CALL cancel()
78 throw (::com::sun::star::uno::RuntimeException);
80 // ____ XImporter ____
81 virtual void SAL_CALL setTargetDocument(
82 const ::com::sun::star::uno::Reference<
83 ::com::sun::star::lang::XComponent >& Document )
84 throw (::com::sun::star::lang::IllegalArgumentException,
85 ::com::sun::star::uno::RuntimeException);
87 // ____ XExporter ____
88 virtual void SAL_CALL setSourceDocument(
89 const ::com::sun::star::uno::Reference<
90 ::com::sun::star::lang::XComponent >& Document )
91 throw (::com::sun::star::lang::IllegalArgumentException,
92 ::com::sun::star::uno::RuntimeException);
94 inline OUString getDocumentHandler() const { return m_sDocumentHandler; }
95 inline void setDocumentHandler(const OUString& _sDocumentHandler) { m_sDocumentHandler = _sDocumentHandler; }
97 virtual OUString getMediaType(bool _bOasis);
99 /** fills the oasis flag only when a filtername was set
101 * \param _rMediaDescriptor
102 * \param _rOutOASIS
104 virtual void isOasisFormat(const ::com::sun::star::uno::Sequence<
105 ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor, bool & _rOutOASIS );
107 private:
108 // methods
110 /// @return a warning code, or 0 for successful operation
111 sal_Int32 impl_Import( const ::com::sun::star::uno::Reference<
112 ::com::sun::star::lang::XComponent > & xDocumentComp,
113 const ::com::sun::star::uno::Sequence<
114 ::com::sun::star::beans::PropertyValue > & aMediaDescriptor );
115 /// @return a warning code, or 0 for successful operation
116 sal_Int32 impl_ImportStream(
117 const OUString & rStreamName,
118 const OUString & rServiceName,
119 const ::com::sun::star::uno::Reference<
120 ::com::sun::star::embed::XStorage > & xStorage,
121 const ::com::sun::star::uno::Reference<
122 ::com::sun::star::xml::sax::XParser > & xParser,
123 const ::com::sun::star::uno::Reference<
124 ::com::sun::star::lang::XMultiComponentFactory > & xFactory,
125 const ::com::sun::star::uno::Reference<
126 ::com::sun::star::document::XGraphicObjectResolver > & xGraphicObjectResolver,
127 ::com::sun::star::uno::Reference<
128 ::com::sun::star::beans::XPropertySet >& xPropSet );
130 /// @return a warning code, or 0 for successful operation
131 sal_Int32 impl_Export( const ::com::sun::star::uno::Reference<
132 ::com::sun::star::lang::XComponent > & xDocumentComp,
133 const ::com::sun::star::uno::Sequence<
134 ::com::sun::star::beans::PropertyValue > & aMediaDescriptor );
135 /// @return a warning code, or 0 for successful operation
136 sal_Int32 impl_ExportStream(
137 const OUString & rStreamName,
138 const OUString & rServiceName,
139 const ::com::sun::star::uno::Reference<
140 ::com::sun::star::embed::XStorage > & xStorage,
141 const ::com::sun::star::uno::Reference<
142 ::com::sun::star::xml::sax::XWriter >& xActiveDataSource,
143 const ::com::sun::star::uno::Reference<
144 ::com::sun::star::lang::XMultiServiceFactory > & xFactory,
145 const ::com::sun::star::uno::Sequence<
146 ::com::sun::star::uno::Any > & rFilterProperties );
148 // members
149 ::com::sun::star::uno::Reference<
150 ::com::sun::star::uno::XComponentContext > m_xContext;
151 ::com::sun::star::uno::Reference<
152 ::com::sun::star::lang::XComponent > m_xTargetDoc;
153 ::com::sun::star::uno::Reference<
154 ::com::sun::star::lang::XComponent > m_xSourceDoc;
155 OUString m_sDocumentHandler; // when set it will be set as doc handler
157 volatile bool m_bCancelOperation;
158 ::osl::Mutex m_aMutex;
161 // =============================================================================
162 class XMLReportFilterHelper : public XMLFilter
164 virtual void isOasisFormat(const ::com::sun::star::uno::Sequence<
165 ::com::sun::star::beans::PropertyValue >& _rMediaDescriptor, bool & _rOutOASIS );
166 public:
167 explicit XMLReportFilterHelper( ::com::sun::star::uno::Reference<
168 ::com::sun::star::uno::XComponentContext > const & _xContext )
169 :XMLFilter(_xContext)
171 /// establish methods for factory instatiation
172 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL create(
173 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext) throw(::com::sun::star::uno::Exception)
175 return (::cppu::OWeakObject *)new XMLReportFilterHelper( xContext );
177 static OUString getImplementationName_Static()
179 return OUString( "com.sun.star.comp.chart2.report.XMLFilter" );
181 protected:
182 virtual OUString SAL_CALL
183 getImplementationName()
184 throw( ::com::sun::star::uno::RuntimeException )
186 return getImplementationName_Static();
188 // ____ XImporter ____
189 virtual void SAL_CALL setTargetDocument(
190 const ::com::sun::star::uno::Reference<
191 ::com::sun::star::lang::XComponent >& Document )
192 throw (::com::sun::star::lang::IllegalArgumentException,
193 ::com::sun::star::uno::RuntimeException)
195 setDocumentHandler( "com.sun.star.comp.report.ImportDocumentHandler" );
196 XMLFilter::setTargetDocument(Document);
199 // ____ XExporter ____
200 virtual void SAL_CALL setSourceDocument(
201 const ::com::sun::star::uno::Reference<
202 ::com::sun::star::lang::XComponent >& Document )
203 throw (::com::sun::star::lang::IllegalArgumentException,
204 ::com::sun::star::uno::RuntimeException)
206 setDocumentHandler( "com.sun.star.comp.report.ExportDocumentHandler" );
207 XMLFilter::setSourceDocument(Document);
210 virtual OUString getMediaType(bool _bOasis);
213 } // namespace chart
215 // CHART2_XMLFILTER_HXX
216 #endif
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */