Line data Source code
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 :
20 : #ifndef INCLUDED_FILTER_SOURCE_XMLFILTERADAPTOR_XMLFILTERADAPTOR_HXX
21 : #define INCLUDED_FILTER_SOURCE_XMLFILTERADAPTOR_XMLFILTERADAPTOR_HXX
22 :
23 :
24 : #include <com/sun/star/document/XFilter.hpp>
25 : #include <com/sun/star/document/XExporter.hpp>
26 : #include <com/sun/star/document/XImporter.hpp>
27 : #include <com/sun/star/lang/XInitialization.hpp>
28 : #include <com/sun/star/lang/XServiceInfo.hpp>
29 : #include <com/sun/star/uno/XComponentContext.hpp>
30 : #include <cppuhelper/implbase5.hxx>
31 :
32 :
33 :
34 : enum FilterType
35 : {
36 : FILTER_IMPORT,
37 : FILTER_EXPORT
38 : };
39 :
40 : /* This component will be instantiated for both import or export. Whether it calls
41 : * setSourceDocument or setTargetDocument determines which Impl function the filter
42 : * member calls */
43 :
44 : class XmlFilterAdaptor : public cppu::WeakImplHelper5
45 : <
46 : com::sun::star::document::XFilter,
47 : com::sun::star::document::XExporter,
48 : com::sun::star::document::XImporter,
49 : com::sun::star::lang::XInitialization,
50 : com::sun::star::lang::XServiceInfo
51 : >
52 : {
53 :
54 : protected:
55 :
56 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
57 :
58 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
59 :
60 : OUString msFilterName;
61 :
62 : ::com::sun::star::uno::Sequence< OUString > msUserData;
63 :
64 : OUString msTemplateName;
65 :
66 : FilterType meType;
67 :
68 : sal_Bool SAL_CALL exportImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
69 : throw (::com::sun::star::uno::RuntimeException);
70 :
71 : sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
72 : throw (::com::sun::star::uno::RuntimeException);
73 :
74 :
75 :
76 : public:
77 :
78 0 : XmlFilterAdaptor( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext)
79 : : mxContext(rxContext)
80 0 : , meType(FILTER_IMPORT)
81 : {
82 0 : }
83 :
84 0 : virtual ~XmlFilterAdaptor() {}
85 :
86 :
87 :
88 : // XFilter
89 :
90 : virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
91 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 :
93 : virtual void SAL_CALL cancel( )
94 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 :
96 :
97 :
98 : // XExporter
99 :
100 : virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
101 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 :
103 :
104 :
105 : // XImporter
106 :
107 : virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
108 :
109 : throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 :
111 :
112 :
113 : // XInitialization
114 :
115 : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
116 :
117 : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 :
119 :
120 :
121 : // XServiceInfo
122 :
123 : virtual OUString SAL_CALL getImplementationName( )
124 :
125 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 :
127 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
128 :
129 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 :
131 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
132 :
133 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 :
135 : };
136 :
137 :
138 :
139 : OUString XmlFilterAdaptor_getImplementationName()
140 :
141 : throw ( ::com::sun::star::uno::RuntimeException );
142 :
143 :
144 :
145 : sal_Bool SAL_CALL XmlFilterAdaptor_supportsService( const OUString& ServiceName )
146 :
147 : throw ( ::com::sun::star::uno::RuntimeException );
148 :
149 :
150 :
151 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL XmlFilterAdaptor_getSupportedServiceNames( )
152 :
153 : throw ( ::com::sun::star::uno::RuntimeException );
154 :
155 :
156 :
157 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
158 :
159 : SAL_CALL XmlFilterAdaptor_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
160 :
161 : throw ( ::com::sun::star::uno::Exception );
162 :
163 :
164 :
165 : #endif
166 :
167 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|