WPSTextParser.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /* libwps
00003  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Major Contributor(s):
00010  * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
00011  * Copyright (C) 2006, 2007 Andrew Ziem
00012  * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00013  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
00014  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00015  *
00016  * For minor contributions see the git repository.
00017  *
00018  * Alternatively, the contents of this file may be used under the terms
00019  * of the GNU Lesser General Public License Version 2.1 or later
00020  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00021  * applicable instead of those above.
00022  *
00023  * For further information visit http://libwps.sourceforge.net
00024  */
00025 
00026 #ifndef WPS_TEXT_PARSER_H
00027 #define WPS_TEXT_PARSER_H
00028 
00029 #include <vector>
00030 
00031 #include "libwps_internal.h"
00032 
00033 #include "WPSDebug.h"
00034 #include "WPSEntry.h"
00035 
00036 class WPSParser;
00037 
00039 class WPSTextParser
00040 {
00041 public:
00043         virtual ~WPSTextParser();
00044 
00046         int version() const;
00047 
00049         RVNGInputStreamPtr &getInput()
00050         {
00051                 return m_input;
00052         }
00053 
00054 protected:
00056         WPSTextParser(WPSParser &parser, RVNGInputStreamPtr &input);
00057 
00059         std::multimap<std::string, WPSEntry> &getNameEntryMap();
00060 
00062         std::multimap<std::string, WPSEntry> const &getNameEntryMap() const;
00063 
00064 protected:
00066         struct DataFOD
00067         {
00074                 enum Type { ATTR_TEXT, ATTR_PARAG, ATTR_PLC, ATTR_UNKN };
00075 
00077                 DataFOD() : m_type(ATTR_UNKN), m_pos(-1), m_defPos(0), m_id(-1) {}
00078 
00080                 Type m_type;
00082                 long m_pos;
00084                 long m_defPos;
00086                 int m_id;
00087         };
00088 
00091         std::vector<DataFOD> mergeSortedFODLists
00092         (std::vector<DataFOD> const &lst1, std::vector<DataFOD> const &lst2) const;
00093 
00099         typedef bool (WPSTextParser::* FDPParser)(long endPos,
00100                                                   int &id, std::string &mess);
00101 
00104         bool readFDP(WPSEntry const &entry,
00105                      std::vector<DataFOD> &fods, FDPParser parser);
00106 
00107 protected:
00109         libwps::DebugFile &ascii()
00110         {
00111                 return m_asciiFile;
00112         }
00113 
00114 private:
00116         WPSTextParser(WPSTextParser const &parser);
00118         WPSTextParser &operator=(WPSTextParser const &parser);
00119 
00120 protected:
00122         mutable int m_version;
00124         RVNGInputStreamPtr m_input;
00126         WPSParser &m_mainParser;
00128         WPSEntry m_textPositions;
00130         std::vector<DataFOD> m_FODList;
00132         libwps::DebugFile &m_asciiFile;
00133 };
00134 
00135 
00136 #endif /* WPSTEXTPARSER_H */
00137 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */