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  * Copyright (C) 2009, 2011 Alonso Laurent (alonso@loria.fr)
00004  * Copyright (C) 2006, 2007 Andrew Ziem
00005  * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00006  * Copyright (C) 2004 Marc Maurer (uwog@uwog.net)
00007  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
00022  *
00023  * For further information visit http://libwps.sourceforge.net
00024  */
00025 
00026 /* "This product is not manufactured, approved, or supported by
00027  * Corel Corporation or Corel Corporation Limited."
00028  */
00029 
00030 #ifndef WPS4_TEXT_H
00031 #define WPS4_TEXT_H
00032 
00033 #include <ostream>
00034 #include <vector>
00035 
00036 #include "WPSEntry.h"
00037 #include "WPSDebug.h"
00038 
00039 class WPS4Parser;
00040 namespace WPS4TextInternal
00041 {
00042 struct DataFOD;
00043 struct Font;
00044 struct Paragraph;
00045 struct State;
00046 }
00047 
00048 typedef class WPSContentListener WPS4ContentListener;
00049 typedef shared_ptr<WPS4ContentListener> WPS4ContentListenerPtr;
00050 
00070 class WPS4Text
00071 {
00072         friend class WPS4Parser;
00073 
00074 public:
00076         WPS4Text(WPS4Parser &parser, WPXInputStreamPtr &input);
00077 
00079         ~WPS4Text();
00080 
00082         void setListener(WPS4ContentListenerPtr &listen)
00083         {
00084                 m_listener = listen;
00085         }
00086 
00088         int numPages() const;
00089 
00090 
00092         void flushExtra();
00093 
00094 protected:
00096         WPSEntry getHeaderEntry() const;
00097 
00099         WPSEntry getFooterEntry() const;
00100 
00102         WPSEntry getMainTextEntry() const;
00103 
00105         WPSEntry getAllTextEntry() const;
00106 
00108         bool readText(WPSEntry const &entry);
00109 
00111         bool readEntries();
00113         bool readStructures();
00114 
00115 protected:
00116         //----------------------------------------
00117         // FDP parsing
00118         //----------------------------------------
00119 
00122         bool findFDPStructures(int which);
00125         bool findFDPStructuresByHand(int which);
00126 
00127         //----------------------------------------
00128         // PLC parsing, setting
00129         //----------------------------------------
00130 
00135         typedef bool (WPS4Text::* FDPParser) (long endPos, int &id, std::string &mess);
00136 
00142         bool readFDP(WPSEntry const &entry,
00143                      std::vector<WPS4TextInternal::DataFOD> &fods, FDPParser parser);
00144 
00152         typedef bool (WPS4Text::* DataParser)
00153         (long bot, long eot, int id, long endPos, std::string &mess);
00154 
00161         bool readPLC(WPSEntry const &zone,
00162                      std::vector<long> &textPtrs, std::vector<long> &listValues,
00163                      DataParser parser = 0L);
00164 
00166         bool defDataParser (long bot, long eot, int id, long endPos, std::string &mess);
00167 
00169         bool readFontNames(WPSEntry const &entry);
00170 
00172         bool readFont(long endPos, int &id, std::string &mess);
00176         void setProperty(WPS4TextInternal::Font const &font);
00177 
00179         bool readParagraph(long endPos, int &id, std::string &mess);
00183         void setProperty(WPS4TextInternal::Paragraph const &para);
00184 
00186         bool readDosLink(WPSEntry const &entry);
00187 
00189         bool objectDataParser (long bot, long eot, int id,
00190                                long endPos, std::string &mess);
00191 
00193         bool readFootNotes(WPSEntry const &ftnD, WPSEntry const &ftnP);
00194 
00196         bool footNotesDataParser (long bot, long eot, int id, long endPos, std::string &mess);
00197 
00199         bool bkmkDataParser (long bot, long eot, int id, long endPos, std::string &mess);
00200 
00202         bool dttmDataParser (long bot, long eot, int id, long endPos, std::string &mess);
00203 
00204 protected:
00206         int version() const;
00207 
00209         libwps::DebugFile &ascii()
00210         {
00211                 return m_asciiFile;
00212         }
00213 protected:
00215         WPXInputStreamPtr m_input;
00216 
00218         WPS4Parser &m_mainParser;
00219 
00221         WPS4ContentListenerPtr m_listener;
00222 
00224         mutable shared_ptr<WPS4TextInternal::State> m_state;
00225 
00227         libwps::DebugFile &m_asciiFile;
00228 };
00229 #endif
00230 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */