1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _XMLFILTERADAPTOR_HXX 25 #define _XMLFILTERADAPTOR_HXX 26 27 28 #include <com/sun/star/document/XFilter.hpp> 29 #include <com/sun/star/document/XExporter.hpp> 30 #include <com/sun/star/document/XImporter.hpp> 31 #include <com/sun/star/lang/XInitialization.hpp> 32 #include <com/sun/star/lang/XServiceInfo.hpp> 33 #include <cppuhelper/implbase5.hxx> 34 35 36 37 enum FilterType 38 { 39 FILTER_IMPORT, 40 FILTER_EXPORT 41 }; 42 43 /* This component will be instantiated for both import or export. Whether it calls 44 * setSourceDocument or setTargetDocument determines which Impl function the filter 45 * member calls */ 46 47 class XmlFilterAdaptor : public cppu::WeakImplHelper5 48 49 < 50 51 com::sun::star::document::XFilter, 52 53 com::sun::star::document::XExporter, 54 55 com::sun::star::document::XImporter, 56 57 com::sun::star::lang::XInitialization, 58 59 com::sun::star::lang::XServiceInfo 60 61 > 62 63 { 64 65 protected: 66 67 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; 68 69 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc; 70 71 ::rtl::OUString msFilterName; 72 73 ::com::sun::star::uno::Sequence< ::rtl::OUString > msUserData; 74 75 ::rtl::OUString msTemplateName; 76 77 FilterType meType; 78 79 sal_Bool SAL_CALL exportImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 80 81 throw (::com::sun::star::uno::RuntimeException); 82 83 sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 84 85 throw (::com::sun::star::uno::RuntimeException); 86 87 88 89 public: 90 XmlFilterAdaptor(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & rxMSF)91 XmlFilterAdaptor( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) 92 93 : mxMSF( rxMSF ) {} 94 ~XmlFilterAdaptor()95 virtual ~XmlFilterAdaptor() {} 96 97 98 99 // XFilter 100 101 virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 102 103 throw (::com::sun::star::uno::RuntimeException); 104 105 virtual void SAL_CALL cancel( ) 106 107 throw (::com::sun::star::uno::RuntimeException); 108 109 110 111 // XExporter 112 113 virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) 114 115 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 116 117 118 119 // XImporter 120 121 virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) 122 123 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 124 125 126 127 // XInitialization 128 129 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 130 131 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 132 133 134 135 // XServiceInfo 136 137 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 138 139 throw (::com::sun::star::uno::RuntimeException); 140 141 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 142 143 throw (::com::sun::star::uno::RuntimeException); 144 145 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 146 147 throw (::com::sun::star::uno::RuntimeException); 148 149 }; 150 151 152 153 ::rtl::OUString XmlFilterAdaptor_getImplementationName() 154 155 throw ( ::com::sun::star::uno::RuntimeException ); 156 157 158 159 sal_Bool SAL_CALL XmlFilterAdaptor_supportsService( const ::rtl::OUString& ServiceName ) 160 161 throw ( ::com::sun::star::uno::RuntimeException ); 162 163 164 165 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL XmlFilterAdaptor_getSupportedServiceNames( ) 166 167 throw ( ::com::sun::star::uno::RuntimeException ); 168 169 170 171 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 172 173 SAL_CALL XmlFilterAdaptor_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) 174 175 throw ( ::com::sun::star::uno::Exception ); 176 177 178 179 #endif 180 181