1*63ce064aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63ce064aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63ce064aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63ce064aSAndrew Rist * distributed with this work for additional information 6*63ce064aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63ce064aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63ce064aSAndrew Rist * "License"); you may not use this file except in compliance 9*63ce064aSAndrew Rist * with the License. You may obtain a copy of the License at 10*63ce064aSAndrew Rist * 11*63ce064aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*63ce064aSAndrew Rist * 13*63ce064aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63ce064aSAndrew Rist * software distributed under the License is distributed on an 15*63ce064aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63ce064aSAndrew Rist * KIND, either express or implied. See the License for the 17*63ce064aSAndrew Rist * specific language governing permissions and limitations 18*63ce064aSAndrew Rist * under the License. 19*63ce064aSAndrew Rist * 20*63ce064aSAndrew Rist *************************************************************/ 21*63ce064aSAndrew Rist 22*63ce064aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _LINGUISTIC_CONVDICXML_HXX_ 25cdf0e10cSrcweir #define _LINGUISTIC_CONVDICXML_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/linguistic2/XConversionDictionary.hpp> 28cdf0e10cSrcweir #include <com/sun/star/util/XFlushable.hpp> 29cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 30cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 31cdf0e10cSrcweir #include <xmloff/xmlexp.hxx> 32cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 33cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 34cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h> 35cdf0e10cSrcweir #include <tools/string.hxx> 36cdf0e10cSrcweir #include <rtl/ustring.hxx> 37cdf0e10cSrcweir #include "linguistic/misc.hxx" 38cdf0e10cSrcweir #include "defs.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir 41cdf0e10cSrcweir class ConvDic; 42cdf0e10cSrcweir 43cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 44cdf0e10cSrcweir 45cdf0e10cSrcweir class ConvDicXMLExport : public SvXMLExport 46cdf0e10cSrcweir { 47cdf0e10cSrcweir ConvDic &rDic; 48cdf0e10cSrcweir sal_Bool bSuccess; 49cdf0e10cSrcweir 50cdf0e10cSrcweir protected: 51cdf0e10cSrcweir //void ExportNodes(const SmNode *pIn, int nLevel); 52cdf0e10cSrcweir 53cdf0e10cSrcweir public: ConvDicXMLExport(ConvDic & rConvDic,const rtl::OUString & rFileName,com::sun::star::uno::Reference<com::sun::star::xml::sax::XDocumentHandler> & rHandler)54cdf0e10cSrcweir ConvDicXMLExport( ConvDic &rConvDic, 55cdf0e10cSrcweir const rtl::OUString &rFileName, 56cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > &rHandler) : 57cdf0e10cSrcweir SvXMLExport ( utl::getProcessServiceFactory(), rFileName, rHandler ), 58cdf0e10cSrcweir rDic ( rConvDic ), 59cdf0e10cSrcweir bSuccess ( sal_False ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir } ~ConvDicXMLExport()62cdf0e10cSrcweir virtual ~ConvDicXMLExport() 63cdf0e10cSrcweir { 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir // XServiceInfo (override parent method) 67cdf0e10cSrcweir ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 68cdf0e10cSrcweir 69cdf0e10cSrcweir // SvXMLExport _ExportAutoStyles()70cdf0e10cSrcweir void _ExportAutoStyles() {} _ExportMasterStyles()71cdf0e10cSrcweir void _ExportMasterStyles() {} 72cdf0e10cSrcweir void _ExportContent(); 73cdf0e10cSrcweir sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ); 74cdf0e10cSrcweir 75cdf0e10cSrcweir sal_Bool Export(); 76cdf0e10cSrcweir }; 77cdf0e10cSrcweir 78cdf0e10cSrcweir 79cdf0e10cSrcweir class ConvDicXMLImport : public SvXMLImport 80cdf0e10cSrcweir { 81cdf0e10cSrcweir ConvDic *pDic; // conversion dictionary to be used 82cdf0e10cSrcweir // if != NULL: whole file will be read and 83cdf0e10cSrcweir // all entries will be added to the dictionary 84cdf0e10cSrcweir // if == NULL: no entries will be added 85cdf0e10cSrcweir // but the language and conversion type will 86cdf0e10cSrcweir // still be determined! 87cdf0e10cSrcweir 88cdf0e10cSrcweir sal_Int16 nLanguage; // language of the dictionary 89cdf0e10cSrcweir sal_Int16 nConversionType; // conversion type the dictionary is used for 90cdf0e10cSrcweir sal_Bool bSuccess; 91cdf0e10cSrcweir 92cdf0e10cSrcweir public: 93cdf0e10cSrcweir 94cdf0e10cSrcweir //!! see comment for pDic member ConvDicXMLImport(ConvDic * pConvDic,const rtl::OUString)95cdf0e10cSrcweir ConvDicXMLImport( ConvDic *pConvDic, const rtl::OUString /*&rFileName*/ ) : 96cdf0e10cSrcweir SvXMLImport ( utl::getProcessServiceFactory(), IMPORT_ALL ), 97cdf0e10cSrcweir pDic ( pConvDic ) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir nLanguage = LANGUAGE_NONE; 100cdf0e10cSrcweir nConversionType = -1; 101cdf0e10cSrcweir bSuccess = sal_False; 102cdf0e10cSrcweir } 103cdf0e10cSrcweir ~ConvDicXMLImport()104cdf0e10cSrcweir virtual ~ConvDicXMLImport() throw () 105cdf0e10cSrcweir { 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir // XServiceInfo (override parent method) 109cdf0e10cSrcweir ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir virtual void SAL_CALL startDocument(void) throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 112cdf0e10cSrcweir virtual void SAL_CALL endDocument(void) throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir virtual SvXMLImportContext * CreateContext( 115cdf0e10cSrcweir sal_uInt16 nPrefix, const rtl::OUString &rLocalName, 116cdf0e10cSrcweir const com::sun::star::uno::Reference < com::sun::star::xml::sax::XAttributeList > &rxAttrList ); 117cdf0e10cSrcweir GetDic()118cdf0e10cSrcweir ConvDic * GetDic() { return pDic; } GetLanguage() const119cdf0e10cSrcweir sal_Int16 GetLanguage() const { return nLanguage; } GetConversionType() const120cdf0e10cSrcweir sal_Int16 GetConversionType() const { return nConversionType; } GetSuccess() const121cdf0e10cSrcweir sal_Bool GetSuccess() const { return bSuccess; } 122cdf0e10cSrcweir SetLanguage(sal_Int16 nLang)123cdf0e10cSrcweir void SetLanguage( sal_Int16 nLang ) { nLanguage = nLang; } SetConversionType(sal_Int16 nType)124cdf0e10cSrcweir void SetConversionType( sal_Int16 nType ) { nConversionType = nType; } 125cdf0e10cSrcweir }; 126cdf0e10cSrcweir 127cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 128cdf0e10cSrcweir 129cdf0e10cSrcweir #endif 130cdf0e10cSrcweir 131