LibreOffice Module chart2 (master) 1
XMLFilter.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
22#include <com/sun/star/document/XFilter.hpp>
23#include <com/sun/star/document/XImporter.hpp>
24#include <com/sun/star/document/XExporter.hpp>
25#include <com/sun/star/lang/XMultiServiceFactory.hpp>
26#include <com/sun/star/lang/XServiceInfo.hpp>
27#include <osl/mutex.hxx>
29
30namespace com::sun::star::beans { class XPropertySet; }
31namespace com::sun::star::uno { class XComponentContext; }
32namespace com::sun::star::xml::sax { class XWriter; }
33namespace com::sun::star::lang { class XMultiComponentFactory; }
34
35namespace com::sun::star {
36 namespace embed {
37 class XStorage;
38 }
39 namespace xml::sax {
40 class XFastParser;
41 }
42 namespace document {
43 class XGraphicStorageHandler;
44 }
45}
46
47namespace chart
48{
49
50class XMLFilter : public
51 ::cppu::WeakImplHelper<
52 css::document::XFilter,
53 css::document::XExporter,
54 css::document::XImporter,
55 css::lang::XServiceInfo >
56{
57public:
58 explicit XMLFilter( css::uno::Reference< css::uno::XComponentContext > const & xContext );
59 virtual ~XMLFilter() override;
60
62 virtual OUString SAL_CALL getImplementationName() override;
63 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
64 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
65
66protected:
67 // ____ XFilter ____
68 virtual sal_Bool SAL_CALL filter(
69 const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
70 virtual void SAL_CALL cancel() override;
71
72 // ____ XImporter ____
73 virtual void SAL_CALL setTargetDocument(
74 const css::uno::Reference< css::lang::XComponent >& Document ) override;
75
76 // ____ XExporter ____
77 virtual void SAL_CALL setSourceDocument(
78 const css::uno::Reference< css::lang::XComponent >& Document ) override;
79
80 void setDocumentHandler(const OUString& _sDocumentHandler) { m_sDocumentHandler = _sDocumentHandler; }
81
82 virtual OUString getMediaType(bool _bOasis);
83
89 virtual void isOasisFormat(const css::uno::Sequence< css::beans::PropertyValue >& _rMediaDescriptor, bool & _rOutOASIS );
90
91private:
92 // methods
93
95 ErrCode impl_Import( const css::uno::Reference< css::lang::XComponent > & xDocumentComp,
96 const css::uno::Sequence< css::beans::PropertyValue > & aMediaDescriptor );
99 const OUString & rStreamName,
100 const OUString & rServiceName,
101 const css::uno::Reference< css::embed::XStorage > & xStorage,
102 const css::uno::Reference< css::lang::XMultiComponentFactory > & xFactory,
103 const css::uno::Reference<css::document::XGraphicStorageHandler> & xGraphicStorageHandler,
104 css::uno::Reference< css::beans::XPropertySet > const & xPropSet );
105
107 ErrCode impl_Export( const css::uno::Reference< css::lang::XComponent > & xDocumentComp,
108 const css::uno::Sequence< css::beans::PropertyValue > & aMediaDescriptor );
111 const OUString & rStreamName,
112 const OUString & rServiceName,
113 const css::uno::Reference< css::embed::XStorage > & xStorage,
114 const css::uno::Reference< css::xml::sax::XWriter >& xActiveDataSource,
115 const css::uno::Reference< css::lang::XMultiServiceFactory > & xFactory,
116 const css::uno::Sequence< css::uno::Any > & rFilterProperties );
117
118 // members
119 css::uno::Reference< css::uno::XComponentContext > m_xContext;
120 css::uno::Reference< css::lang::XComponent > m_xTargetDoc;
121 css::uno::Reference< css::lang::XComponent > m_xSourceDoc;
122
123 css::uno::Sequence<css::beans::PropertyValue> m_aMediaDescriptor;
124
125 OUString m_sDocumentHandler; // when set it will be set as doc handler
126
127 volatile bool m_bCancelOperation;
128 ::osl::Mutex m_aMutex;
129};
130
132{
133 virtual void isOasisFormat(const css::uno::Sequence< css::beans::PropertyValue >& _rMediaDescriptor,
134 bool & _rOutOASIS ) override;
135public:
136 explicit XMLReportFilterHelper( css::uno::Reference< css::uno::XComponentContext > const & _xContext )
138 {}
139protected:
140 virtual OUString SAL_CALL
142 {
143 return "com.sun.star.comp.chart2.report.XMLFilter";
144 }
145 // ____ XImporter ____
146 virtual void SAL_CALL setTargetDocument(
147 const css::uno::Reference< css::lang::XComponent >& Document ) override
148 {
149 setDocumentHandler( "com.sun.star.comp.report.ImportDocumentHandler" );
151 }
152
153 // ____ XExporter ____
154 virtual void SAL_CALL setSourceDocument(
155 const css::uno::Reference< css::lang::XComponent >& Document ) override
156 {
157 setDocumentHandler( "com.sun.star.comp.report.ExportDocumentHandler" );
159 }
160
161 virtual OUString getMediaType(bool _bOasis) override;
162};
163
164} // namespace chart
165
166/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ErrCode impl_Import(const css::uno::Reference< css::lang::XComponent > &xDocumentComp, const css::uno::Sequence< css::beans::PropertyValue > &aMediaDescriptor)
Definition: XMLFilter.cxx:266
volatile bool m_bCancelOperation
Definition: XMLFilter.hxx:127
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: XMLFilter.cxx:731
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo declarations.
Definition: XMLFilter.cxx:726
OUString m_sDocumentHandler
Definition: XMLFilter.hxx:125
::osl::Mutex m_aMutex
Definition: XMLFilter.hxx:128
ErrCode impl_ImportStream(const OUString &rStreamName, const OUString &rServiceName, const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Reference< css::lang::XMultiComponentFactory > &xFactory, const css::uno::Reference< css::document::XGraphicStorageHandler > &xGraphicStorageHandler, css::uno::Reference< css::beans::XPropertySet > const &xPropSet)
Definition: XMLFilter.cxx:392
void setDocumentHandler(const OUString &_sDocumentHandler)
Definition: XMLFilter.hxx:80
virtual OUString getMediaType(bool _bOasis)
Definition: XMLFilter.cxx:721
virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &aDescriptor) override
Definition: XMLFilter.cxx:197
css::uno::Reference< css::lang::XComponent > m_xSourceDoc
Definition: XMLFilter.hxx:121
ErrCode impl_Export(const css::uno::Reference< css::lang::XComponent > &xDocumentComp, const css::uno::Sequence< css::beans::PropertyValue > &aMediaDescriptor)
Definition: XMLFilter.cxx:505
virtual ~XMLFilter() override
Definition: XMLFilter.cxx:193
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: XMLFilter.cxx:736
css::uno::Sequence< css::beans::PropertyValue > m_aMediaDescriptor
Definition: XMLFilter.hxx:123
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &Document) override
Definition: XMLFilter.cxx:257
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: XMLFilter.hxx:119
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &Document) override
Definition: XMLFilter.cxx:247
virtual void SAL_CALL cancel() override
Definition: XMLFilter.cxx:236
XMLFilter(css::uno::Reference< css::uno::XComponentContext > const &xContext)
Definition: XMLFilter.cxx:188
ErrCode impl_ExportStream(const OUString &rStreamName, const OUString &rServiceName, const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Reference< css::xml::sax::XWriter > &xActiveDataSource, const css::uno::Reference< css::lang::XMultiServiceFactory > &xFactory, const css::uno::Sequence< css::uno::Any > &rFilterProperties)
Definition: XMLFilter.cxx:646
css::uno::Reference< css::lang::XComponent > m_xTargetDoc
Definition: XMLFilter.hxx:120
virtual void isOasisFormat(const css::uno::Sequence< css::beans::PropertyValue > &_rMediaDescriptor, bool &_rOutOASIS)
fills the oasis flag only when a filtername was set
Definition: XMLFilter.cxx:715
XMLReportFilterHelper(css::uno::Reference< css::uno::XComponentContext > const &_xContext)
Definition: XMLFilter.hxx:136
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &Document) override
Definition: XMLFilter.hxx:146
virtual OUString getMediaType(bool _bOasis) override
Definition: XMLFilter.cxx:752
virtual OUString SAL_CALL getImplementationName() override
XServiceInfo declarations.
Definition: XMLFilter.hxx:141
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &Document) override
Definition: XMLFilter.hxx:154
virtual void isOasisFormat(const css::uno::Sequence< css::beans::PropertyValue > &_rMediaDescriptor, bool &_rOutOASIS) override
fills the oasis flag only when a filtername was set
Definition: XMLFilter.cxx:746
class SAL_NO_VTABLE XPropertySet
unsigned char sal_Bool
Reference< XComponentContext > _xContext