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 _LINGUISTIC_CONVDICXML_HXX_
21 : #define _LINGUISTIC_CONVDICXML_HXX_
22 :
23 : #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
24 : #include <com/sun/star/util/XFlushable.hpp>
25 : #include <com/sun/star/util/MeasureUnit.hpp>
26 : #include <com/sun/star/lang/XServiceInfo.hpp>
27 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
28 : #include <comphelper/processfactory.hxx>
29 : #include <xmloff/xmlexp.hxx>
30 : #include <xmloff/xmlimp.hxx>
31 : #include <cppuhelper/implbase3.hxx>
32 : #include <cppuhelper/interfacecontainer.h>
33 : #include <rtl/ustring.hxx>
34 : #include "linguistic/misc.hxx"
35 : #include "defs.hxx"
36 :
37 :
38 : class ConvDic;
39 :
40 :
41 : class ConvDicXMLExport : public SvXMLExport
42 : {
43 : ConvDic &rDic;
44 : sal_Bool bSuccess;
45 :
46 : public:
47 0 : ConvDicXMLExport( ConvDic &rConvDic,
48 : const OUString &rFileName,
49 : com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > &rHandler) :
50 : SvXMLExport ( comphelper::getProcessComponentContext(), rFileName,
51 : ::com::sun::star::util::MeasureUnit::CM, rHandler ),
52 : rDic ( rConvDic ),
53 0 : bSuccess ( sal_False )
54 : {
55 0 : }
56 0 : virtual ~ConvDicXMLExport()
57 0 : {
58 0 : }
59 :
60 : // XServiceInfo (override parent method)
61 : OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
62 :
63 : // SvXMLExport
64 0 : void _ExportAutoStyles() {}
65 0 : void _ExportMasterStyles() {}
66 : void _ExportContent();
67 : sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass );
68 :
69 : sal_Bool Export();
70 : };
71 :
72 :
73 : class ConvDicXMLImport : public SvXMLImport
74 : {
75 : ConvDic *pDic; // conversion dictionary to be used
76 : // if != NULL: whole file will be read and
77 : // all entries will be added to the dictionary
78 : // if == NULL: no entries will be added
79 : // but the language and conversion type will
80 : // still be determined!
81 :
82 : sal_Int16 nLanguage; // language of the dictionary
83 : sal_Int16 nConversionType; // conversion type the dictionary is used for
84 : sal_Bool bSuccess;
85 :
86 : public:
87 :
88 : //!! see comment for pDic member
89 0 : ConvDicXMLImport( ConvDic *pConvDic, const OUString /*&rFileName*/ ) :
90 : SvXMLImport ( comphelper::getProcessComponentContext(), IMPORT_ALL ),
91 0 : pDic ( pConvDic )
92 : {
93 0 : nLanguage = LANGUAGE_NONE;
94 0 : nConversionType = -1;
95 0 : bSuccess = sal_False;
96 0 : }
97 :
98 0 : virtual ~ConvDicXMLImport() throw ()
99 0 : {
100 0 : }
101 :
102 : // XServiceInfo (override parent method)
103 : OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
104 :
105 : virtual void SAL_CALL startDocument(void) throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
106 : virtual void SAL_CALL endDocument(void) throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
107 :
108 : virtual SvXMLImportContext * CreateContext(
109 : sal_uInt16 nPrefix, const OUString &rLocalName,
110 : const com::sun::star::uno::Reference < com::sun::star::xml::sax::XAttributeList > &rxAttrList );
111 :
112 0 : ConvDic * GetDic() { return pDic; }
113 0 : sal_Int16 GetLanguage() const { return nLanguage; }
114 0 : sal_Int16 GetConversionType() const { return nConversionType; }
115 : sal_Bool GetSuccess() const { return bSuccess; }
116 :
117 0 : void SetLanguage( sal_Int16 nLang ) { nLanguage = nLang; }
118 0 : void SetConversionType( sal_Int16 nType ) { nConversionType = nType; }
119 : };
120 :
121 :
122 : #endif
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|