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 _FILTERDETECT_HXX 25 #define _FILTERDETECT_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/XExtendedFilterDetection.hpp> 31 #include <com/sun/star/document/XImporter.hpp> 32 #include <com/sun/star/lang/XInitialization.hpp> 33 #include <com/sun/star/lang/XServiceInfo.hpp> 34 #include <cppuhelper/implbase5.hxx> 35 36 #ifndef _CPPUHELPER_IMPLBASE4_HXX_ 37 #include <cppuhelper/implbase3.hxx> 38 #endif 39 40 enum FilterType 41 { 42 FILTER_IMPORT, 43 FILTER_EXPORT 44 }; 45 46 /* This component will be instantiated for both import or export. Whether it calls 47 * setSourceDocument or setTargetDocument determines which Impl function the filter 48 * member calls */ 49 class FilterDetect : public cppu::WeakImplHelper3 <com::sun::star::document::XExtendedFilterDetection, 50 com::sun::star::lang::XInitialization, 51 com::sun::star::lang::XServiceInfo> 52 { 53 protected: 54 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; 55 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc; 56 ::rtl::OUString msFilterName; 57 ::com::sun::star::uno::Sequence< ::rtl::OUString > msUserData; 58 ::rtl::OUString msTemplateName; 59 60 sal_Bool SAL_CALL exportImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 61 throw (::com::sun::star::uno::RuntimeException); 62 63 sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 64 throw (::com::sun::star::uno::RuntimeException); 65 66 public: FilterDetect(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & rxMSF)67 FilterDetect( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) 68 : mxMSF( rxMSF ) {} 69 ~FilterDetect()70 virtual ~FilterDetect() {} 71 72 //XExtendedFilterDetection 73 virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& lDescriptor ) 74 throw( com::sun::star::uno::RuntimeException ); 75 76 // XInitialization 77 78 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 79 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 80 81 // XServiceInfo 82 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 83 throw (::com::sun::star::uno::RuntimeException); 84 85 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 86 throw (::com::sun::star::uno::RuntimeException); 87 88 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 89 throw (::com::sun::star::uno::RuntimeException); 90 }; 91 92 93 ::rtl::OUString FilterDetect_getImplementationName() 94 throw ( ::com::sun::star::uno::RuntimeException ); 95 96 sal_Bool SAL_CALL FilterDetect_supportsService( const ::rtl::OUString& ServiceName ) 97 throw ( ::com::sun::star::uno::RuntimeException ); 98 99 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL FilterDetect_getSupportedServiceNames( ) 100 throw ( ::com::sun::star::uno::RuntimeException ); 101 102 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 103 SAL_CALL FilterDetect_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) 104 throw ( ::com::sun::star::uno::Exception ); 105 106 #endif 107 108