1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_CHART2_SOURCE_MODEL_INC_XMLFILTER_HXX
20 #define INCLUDED_CHART2_SOURCE_MODEL_INC_XMLFILTER_HXX
22 #include <cppuhelper/implbase.hxx>
23 #include <com/sun/star/document/XFilter.hpp>
24 #include <com/sun/star/document/XImporter.hpp>
25 #include <com/sun/star/document/XExporter.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/io/XActiveDataSource.hpp>
29 #include <osl/mutex.hxx>
30 #include <vcl/errcode.hxx>
32 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ class XPropertySet
; } } } }
33 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{ class XComponentContext
; } } } }
34 namespace com
{ namespace sun
{ namespace star
{ namespace xml
{ namespace sax
{ class XWriter
; } } } } }
35 namespace com
{ namespace sun
{ namespace star
{ namespace lang
{ class XMultiComponentFactory
; } } } }
37 namespace com
{ namespace sun
{ namespace star
{
42 namespace xml
{ namespace sax
48 class XGraphicStorageHandler
;
55 class XMLFilter
: public
56 ::cppu::WeakImplHelper
<
57 css::document::XFilter
,
58 css::document::XExporter
,
59 css::document::XImporter
,
60 css::lang::XServiceInfo
>
63 explicit XMLFilter( css::uno::Reference
< css::uno::XComponentContext
> const & xContext
);
64 virtual ~XMLFilter() override
;
66 /// XServiceInfo declarations
67 virtual OUString SAL_CALL
getImplementationName() override
;
68 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
69 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
73 virtual sal_Bool SAL_CALL
filter(
74 const css::uno::Sequence
< css::beans::PropertyValue
>& aDescriptor
) override
;
75 virtual void SAL_CALL
cancel() override
;
77 // ____ XImporter ____
78 virtual void SAL_CALL
setTargetDocument(
79 const css::uno::Reference
< css::lang::XComponent
>& Document
) override
;
81 // ____ XExporter ____
82 virtual void SAL_CALL
setSourceDocument(
83 const css::uno::Reference
< css::lang::XComponent
>& Document
) override
;
85 void setDocumentHandler(const OUString
& _sDocumentHandler
) { m_sDocumentHandler
= _sDocumentHandler
; }
87 virtual OUString
getMediaType(bool _bOasis
);
89 /** fills the oasis flag only when a filtername was set
91 * \param _rMediaDescriptor
94 virtual void isOasisFormat(const css::uno::Sequence
< css::beans::PropertyValue
>& _rMediaDescriptor
, bool & _rOutOASIS
);
99 /// @return a warning code, or 0 for successful operation
100 ErrCode
impl_Import( const css::uno::Reference
< css::lang::XComponent
> & xDocumentComp
,
101 const css::uno::Sequence
< css::beans::PropertyValue
> & aMediaDescriptor
);
102 /// @return a warning code, or 0 for successful operation
103 ErrCode
impl_ImportStream(
104 const OUString
& rStreamName
,
105 const OUString
& rServiceName
,
106 const css::uno::Reference
< css::embed::XStorage
> & xStorage
,
107 const css::uno::Reference
< css::xml::sax::XParser
> & xParser
,
108 const css::uno::Reference
< css::lang::XMultiComponentFactory
> & xFactory
,
109 const css::uno::Reference
<css::document::XGraphicStorageHandler
> & xGraphicStorageHandler
,
110 css::uno::Reference
< css::beans::XPropertySet
> const & xPropSet
);
112 /// @return a warning code, or 0 for successful operation
113 ErrCode
impl_Export( const css::uno::Reference
< css::lang::XComponent
> & xDocumentComp
,
114 const css::uno::Sequence
< css::beans::PropertyValue
> & aMediaDescriptor
);
115 /// @return a warning code, or 0 for successful operation
116 ErrCode
impl_ExportStream(
117 const OUString
& rStreamName
,
118 const OUString
& rServiceName
,
119 const css::uno::Reference
< css::embed::XStorage
> & xStorage
,
120 const css::uno::Reference
< css::xml::sax::XWriter
>& xActiveDataSource
,
121 const css::uno::Reference
< css::lang::XMultiServiceFactory
> & xFactory
,
122 const css::uno::Sequence
< css::uno::Any
> & rFilterProperties
);
125 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
126 css::uno::Reference
< css::lang::XComponent
> m_xTargetDoc
;
127 css::uno::Reference
< css::lang::XComponent
> m_xSourceDoc
;
129 css::uno::Sequence
<css::beans::PropertyValue
> m_aMediaDescriptor
;
131 OUString m_sDocumentHandler
; // when set it will be set as doc handler
133 volatile bool m_bCancelOperation
;
134 ::osl::Mutex m_aMutex
;
137 class XMLReportFilterHelper
: public XMLFilter
139 virtual void isOasisFormat(const css::uno::Sequence
< css::beans::PropertyValue
>& _rMediaDescriptor
,
140 bool & _rOutOASIS
) override
;
142 explicit XMLReportFilterHelper( css::uno::Reference
< css::uno::XComponentContext
> const & _xContext
)
143 :XMLFilter(_xContext
)
146 virtual OUString SAL_CALL
147 getImplementationName() override
149 return "com.sun.star.comp.chart2.report.XMLFilter";
151 // ____ XImporter ____
152 virtual void SAL_CALL
setTargetDocument(
153 const css::uno::Reference
< css::lang::XComponent
>& Document
) override
155 setDocumentHandler( "com.sun.star.comp.report.ImportDocumentHandler" );
156 XMLFilter::setTargetDocument(Document
);
159 // ____ XExporter ____
160 virtual void SAL_CALL
setSourceDocument(
161 const css::uno::Reference
< css::lang::XComponent
>& Document
) override
163 setDocumentHandler( "com.sun.star.comp.report.ExportDocumentHandler" );
164 XMLFilter::setSourceDocument(Document
);
167 virtual OUString
getMediaType(bool _bOasis
) override
;
172 // INCLUDED_CHART2_SOURCE_MODEL_INC_XMLFILTER_HXX
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */