]> git.lyx.org Git - features.git/blob - 3rdparty/hunspell/1.7.0/src/parsers/odfparser.cxx
Update the in-source hunspell to version 1.7.0
[features.git] / 3rdparty / hunspell / 1.7.0 / src / parsers / odfparser.cxx
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * Copyright (C) 2002-2017 Németh László
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks.
17  *
18  * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno,
19  * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád,
20  * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter,
21  * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls,
22  * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen
23  *
24  * Alternatively, the contents of this file may be used under the terms of
25  * either the GNU General Public License Version 2 or later (the "GPL"), or
26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27  * in which case the provisions of the GPL or the LGPL are applicable instead
28  * of those above. If you wish to allow use of your version of this file only
29  * under the terms of either the GPL or the LGPL, and not to allow others to
30  * use your version of this file under the terms of the MPL, indicate your
31  * decision by deleting the provisions above and replace them with the notice
32  * and other provisions required by the GPL or the LGPL. If you do not delete
33  * the provisions above, a recipient may use your version of this file under
34  * the terms of any one of the MPL, the GPL or the LGPL.
35  *
36  * ***** END LICENSE BLOCK ***** */
37
38 #include <cstdlib>
39 #include <cstring>
40 #include <cstdio>
41 #include <ctype.h>
42
43 #include "../hunspell/csutil.hxx"
44 #include "odfparser.hxx"
45
46 #ifndef W32
47 using namespace std;
48 #endif
49
50 static const char* PATTERN[][2] = {
51     {"<office:meta>", "</office:meta>"},
52     {"<office:settings>", "</office:settings>"},
53     {"<office:binary-data>", "</office:binary-data>"},
54     {"<!--", "-->"},
55     {"<[cdata[", "]]>"},  // XML comment
56     {"<", ">"}};
57
58 #define PATTERN_LEN (sizeof(PATTERN) / (sizeof(char*) * 2))
59
60 static const char* (*PATTERN2)[2] = NULL;
61
62 #define PATTERN_LEN2 0
63
64 static const char* PATTERN3[][2] = {
65     {"<text:span", ">"},   // part of the reedited words
66     {"</text:span", ">"}}; // for example, an inserted letter
67
68 #define PATTERN_LEN3 (sizeof(PATTERN3) / (sizeof(char*) * 2))
69
70 ODFParser::ODFParser(const char* wordchars)
71   : XMLParser(wordchars) {
72 }
73
74 ODFParser::ODFParser(const w_char* wordchars, int len)
75   : XMLParser(wordchars, len) {
76 }
77
78 bool ODFParser::next_token(std::string& t) {
79   return XMLParser::next_token(PATTERN, PATTERN_LEN, PATTERN2, PATTERN_LEN2, PATTERN3, PATTERN_LEN3, t);
80 }
81
82 std::string ODFParser::get_word(const std::string &tok) {
83   return XMLParser::get_word2(PATTERN3, PATTERN_LEN3, tok);
84 }
85
86 ODFParser::~ODFParser() {}