1 /* 2 * Copyright (C) 2000 by Sun Microsystems, Inc. 3 * Copyright (C) 2002-2004 William Lachance (wlach@interlog.com) 4 * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com) 5 * Copyright (C) 2004 Fridrich Strba <fridrich.strba@bluewin.ch> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 * 02111-1307, USA. 21 * 22 * Contributor(s): Martin Gallwey (gallwey@sun.com) 23 * 24 */ 25 26 /* "This product is not manufactured, approved, or supported by 27 * Corel Corporation or Corel Corporation Limited." 28 */ 29 #ifndef _WORDPERFECTIMPORTFILTER_HXX 30 #define _WORDPERFECTIMPORTFILTER_HXX 31 32 #include <com/sun/star/document/XFilter.hpp> 33 #include <com/sun/star/document/XImporter.hpp> 34 #include <com/sun/star/document/XExtendedFilterDetection.hpp> 35 #include <com/sun/star/lang/XInitialization.hpp> 36 #include <com/sun/star/lang/XServiceInfo.hpp> 37 #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 38 #include <cppuhelper/implbase5.hxx> 39 40 enum FilterType 41 { 42 FILTER_IMPORT, 43 FILTER_EXPORT 44 }; 45 /* This component will be instantiated for both import or export. Whether it calls 46 * setSourceDocument or setTargetDocument determines which Impl function the filter 47 * member calls */ 48 class WordPerfectImportFilter : public cppu::WeakImplHelper5 49 < 50 com::sun::star::document::XFilter, 51 com::sun::star::document::XImporter, 52 com::sun::star::document::XExtendedFilterDetection, 53 com::sun::star::lang::XInitialization, 54 com::sun::star::lang::XServiceInfo 55 > 56 { 57 protected: 58 // oo.org declares 59 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; 60 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc; 61 ::rtl::OUString msFilterName; 62 ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler; 63 64 FilterType meType; 65 66 sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 67 throw (::com::sun::star::uno::RuntimeException); 68 69 public: WordPerfectImportFilter(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & rxMSF)70 WordPerfectImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) 71 : mxMSF( rxMSF ) {} ~WordPerfectImportFilter()72 virtual ~WordPerfectImportFilter() {} 73 74 // XFilter 75 virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) 76 throw (::com::sun::star::uno::RuntimeException); 77 virtual void SAL_CALL cancel( ) 78 throw (::com::sun::star::uno::RuntimeException); 79 80 // XImporter 81 virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) 82 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 83 84 //XExtendedFilterDetection 85 virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor ) 86 throw( com::sun::star::uno::RuntimeException ); 87 88 // XInitialization 89 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 90 throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 91 92 // XServiceInfo 93 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 94 throw (::com::sun::star::uno::RuntimeException); 95 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 96 throw (::com::sun::star::uno::RuntimeException); 97 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 98 throw (::com::sun::star::uno::RuntimeException); 99 100 }; 101 102 ::rtl::OUString WordPerfectImportFilter_getImplementationName() 103 throw ( ::com::sun::star::uno::RuntimeException ); 104 105 sal_Bool SAL_CALL WordPerfectImportFilter_supportsService( const ::rtl::OUString& ServiceName ) 106 throw ( ::com::sun::star::uno::RuntimeException ); 107 108 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL WordPerfectImportFilter_getSupportedServiceNames( ) 109 throw ( ::com::sun::star::uno::RuntimeException ); 110 111 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > 112 SAL_CALL WordPerfectImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) 113 throw ( ::com::sun::star::uno::Exception ); 114 115 #endif 116