- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

WPSTextParser.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3 * Version: MPL 2.0 / LGPLv2.1+
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 * Major Contributor(s):
10 * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
11 * Copyright (C) 2006, 2007 Andrew Ziem
12 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
13 * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
14 * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
15 *
16 * For minor contributions see the git repository.
17 *
18 * Alternatively, the contents of this file may be used under the terms
19 * of the GNU Lesser General Public License Version 2.1 or later
20 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
21 * applicable instead of those above.
22 *
23 * For further information visit http://libwps.sourceforge.net
24 */
25
26 #ifndef WPS_TEXT_PARSER_H
27 #define WPS_TEXT_PARSER_H
28
29 #include <vector>
30
31 #include "libwps_internal.h"
32
33 #include "WPSDebug.h"
34 #include "WPSEntry.h"
35
36 class WPSParser;
37
39 class WPSTextParser
40 {
41 public:
43 virtual ~WPSTextParser();
44
46 int version() const;
47
49 WPXInputStreamPtr &getInput()
50 {
51 return m_input;
52 }
53
54 protected:
56 WPSTextParser(WPSParser &parser, WPXInputStreamPtr &input);
57
59 std::multimap<std::string, WPSEntry> &getNameEntryMap();
60
62 std::multimap<std::string, WPSEntry> const &getNameEntryMap() const;
63
64 protected:
66 struct DataFOD
67 {
74 enum Type { ATTR_TEXT, ATTR_PARAG, ATTR_PLC, ATTR_UNKN };
75
77 DataFOD() : m_type(ATTR_UNKN), m_pos(-1), m_defPos(0), m_id(-1) {}
78
80 Type m_type;
82 long m_pos;
84 long m_defPos;
86 int m_id;
87 };
88
91 std::vector<DataFOD> mergeSortedFODLists
92 (std::vector<DataFOD> const &lst1, std::vector<DataFOD> const &lst2) const;
93
99 typedef bool (WPSTextParser::* FDPParser) (long endPos,
100 int &id, std::string &mess);
101
104 bool readFDP(WPSEntry const &entry,
105 std::vector<DataFOD> &fods, FDPParser parser);
106
107 protected:
109 libwps::DebugFile &ascii()
110 {
111 return m_asciiFile;
112 }
113
114 private:
116 WPSTextParser(WPSTextParser const &parser );
118 WPSTextParser &operator=(WPSTextParser const &parser);
119
120 protected:
122 mutable int m_version;
124 WPXInputStreamPtr m_input;
126 WPSParser &m_mainParser;
128 WPSEntry m_textPositions;
130 std::vector<DataFOD> m_FODList;
132 libwps::DebugFile &m_asciiFile;
133 };
134
135
136 #endif /* WPSTEXTPARSER_H */
137 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */