WPS4Text.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 WPS4_TEXT_H
00027 #define WPS4_TEXT_H
00028 
00029 #include <vector>
00030 
00031 #include "libwps_internal.h"
00032 #include "libwps_tools_win.h"
00033 
00034 #include "WPSEntry.h"
00035 #include "WPSDebug.h"
00036 #include "WPSTextParser.h"
00037 
00038 class WPS4Parser;
00039 namespace WPS4TextInternal
00040 {
00041 struct Font;
00042 struct Paragraph;
00043 struct State;
00044 }
00045 
00065 class WPS4Text : public WPSTextParser
00066 {
00067         friend class WPS4Parser;
00068 
00069 public:
00071         WPS4Text(WPS4Parser &parser, RVNGInputStreamPtr &input);
00072 
00074         ~WPS4Text();
00075 
00077         void setListener(WPSContentListenerPtr &listen)
00078         {
00079                 m_listener = listen;
00080         }
00081 
00083         int numPages() const;
00084 
00086         void flushExtra();
00087 
00088 protected:
00090         WPS4Parser &mainParser()
00091         {
00092                 return reinterpret_cast<WPS4Parser &>(m_mainParser);
00093         }
00095         WPS4Parser const &mainParser() const
00096         {
00097                 return reinterpret_cast<WPS4Parser const &>(m_mainParser);
00098         }
00099 
00101         WPS4TextInternal::Font getDefaultFont() const;
00102 
00104         WPSEntry getHeaderEntry() const;
00105 
00107         WPSEntry getFooterEntry() const;
00108 
00110         WPSEntry getMainTextEntry() const;
00111 
00113         bool readText(WPSEntry const &entry);
00114 
00116         bool readEntries();
00118         bool readStructures();
00119 
00120 protected:
00121         //----------------------------------------
00122         // FDP parsing
00123         //----------------------------------------
00124 
00127         bool findFDPStructures(int which);
00130         bool findFDPStructuresByHand(int which);
00131 
00132         //----------------------------------------
00133         // PLC parsing, setting
00134         //----------------------------------------
00135 
00143         typedef bool (WPS4Text::* DataParser)
00144         (long bot, long eot, int id, long endPos, std::string &mess);
00145 
00152         bool readPLC(WPSEntry const &zone,
00153                      std::vector<long> &textPtrs, std::vector<long> &listValues,
00154                      DataParser parser = 0L);
00155 
00157         bool defDataParser(long bot, long eot, int id, long endPos, std::string &mess);
00158 
00160         bool readFontNames(WPSEntry const &entry);
00161 
00163         bool readFont(long endPos, int &id, std::string &mess);
00164 
00166         bool readParagraph(long endPos, int &id, std::string &mess);
00167 
00169         bool readDosLink(WPSEntry const &entry);
00170 
00172         bool objectDataParser(long bot, long eot, int id,
00173                               long endPos, std::string &mess);
00174 
00176         bool readFootNotes(WPSEntry const &ftnD, WPSEntry const &ftnP);
00177 
00179         bool footNotesDataParser(long bot, long eot, int id, long endPos, std::string &mess);
00180 
00182         bool bkmkDataParser(long bot, long eot, int id, long endPos, std::string &mess);
00183 
00185         bool dttmDataParser(long bot, long eot, int id, long endPos, std::string &mess);
00186 
00187 protected:
00189         WPSContentListenerPtr m_listener;
00190 
00192         mutable shared_ptr<WPS4TextInternal::State> m_state;
00193 };
00194 #endif
00195 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */