/src/libreoffice/linguistic/source/convdicxml.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <com/sun/star/util/MeasureUnit.hpp> |
23 | | #include <com/sun/star/xml/sax/XDocumentHandler.hpp> |
24 | | #include <com/sun/star/xml/sax/FastToken.hpp> |
25 | | #include <comphelper/processfactory.hxx> |
26 | | #include <xmloff/xmlexp.hxx> |
27 | | #include <xmloff/xmlimp.hxx> |
28 | | #include <xmloff/xmltoken.hxx> |
29 | | #include <xmloff/xmlnamespace.hxx> |
30 | | #include <rtl/ustring.hxx> |
31 | | |
32 | | |
33 | | class ConvDic; |
34 | | using namespace css::xml::sax; |
35 | | using namespace ::xmloff::token; |
36 | | |
37 | | |
38 | | class ConvDicXMLExport : public SvXMLExport |
39 | | { |
40 | | ConvDic &rDic; |
41 | | bool bSuccess; |
42 | | |
43 | | public: |
44 | | ConvDicXMLExport( ConvDic &rConvDic, |
45 | | const OUString &rFileName, |
46 | | css::uno::Reference< css::xml::sax::XDocumentHandler > const &rHandler) : |
47 | 0 | SvXMLExport ( comphelper::getProcessComponentContext(), u"com.sun.star.lingu2.ConvDicXMLExport"_ustr, rFileName, |
48 | 0 | css::util::MeasureUnit::CM, rHandler ), |
49 | 0 | rDic ( rConvDic ), |
50 | 0 | bSuccess ( false ) |
51 | 0 | { |
52 | 0 | } |
53 | | |
54 | | // SvXMLExport |
55 | 0 | void ExportAutoStyles_() override {} |
56 | 0 | void ExportMasterStyles_() override {} |
57 | | void ExportContent_() override; |
58 | | ErrCode exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID ) override; |
59 | | |
60 | | bool Export(); |
61 | | }; |
62 | | |
63 | | |
64 | | enum ConvDicXMLToken : sal_Int32 |
65 | | { |
66 | | TEXT_CONVERSION_DICTIONARY = FastToken::NAMESPACE | XML_NAMESPACE_TCD | XML_BLOCK_LIST, |
67 | | RIGHT_TEXT = FastToken::NAMESPACE | XML_NAMESPACE_TCD | XML_RIGHT_TEXT, |
68 | | ENTRY = FastToken::NAMESPACE | XML_NAMESPACE_TCD | XML_ENTRY, |
69 | | }; |
70 | | |
71 | | class ConvDicXMLImport : public SvXMLImport |
72 | | { |
73 | | ConvDic *pDic; // conversion dictionary to be used |
74 | | // if != NULL: whole file will be read and |
75 | | // all entries will be added to the dictionary |
76 | | // if == NULL: no entries will be added |
77 | | // but the language and conversion type will |
78 | | // still be determined! |
79 | | |
80 | | LanguageType nLanguage; // language of the dictionary |
81 | | sal_Int16 nConversionType; // conversion type the dictionary is used for |
82 | | |
83 | | public: |
84 | | |
85 | | //!! see comment for pDic member |
86 | | explicit ConvDicXMLImport( ConvDic *pConvDic ); |
87 | | |
88 | 0 | ConvDic * GetDic() { return pDic; } |
89 | 0 | LanguageType GetLanguage() const { return nLanguage; } |
90 | 0 | sal_Int16 GetConversionType() const { return nConversionType; } |
91 | | |
92 | 0 | void SetLanguage( LanguageType nLang ) { nLanguage = nLang; } |
93 | 0 | void SetConversionType( sal_Int16 nType ) { nConversionType = nType; } |
94 | | |
95 | | private: |
96 | | virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element, |
97 | | const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override; |
98 | | }; |
99 | | |
100 | | |
101 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |