WPS8Text.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) 2006, 2007 Andrew Ziem
00011  * Copyright (C) 2003-2005 William Lachance (william.lachance@sympatico.ca)
00012  * Copyright (C) 2003 Marc Maurer (uwog@uwog.net)
00013  *
00014  * For minor contributions see the git repository.
00015  *
00016  * Alternatively, the contents of this file may be used under the terms
00017  * of the GNU Lesser General Public License Version 2.1 or later
00018  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00019  * applicable instead of those above.
00020  */
00021 
00022 #ifndef WPS8_TEXT_H
00023 #define WPS8_TEXT_H
00024 
00025 #include <vector>
00026 
00027 #include "libwps_internal.h"
00028 
00029 #include "WPSDebug.h"
00030 
00031 #include "WPSTextParser.h"
00032 
00033 namespace WPS8Struct
00034 {
00035 struct FileData;
00036 }
00037 
00038 namespace WPS8TextInternal
00039 {
00040 struct State;
00041 class SubDocument;
00042 }
00043 
00044 class WPS8Parser;
00045 class WPS8TextStyle;
00046 
00047 class WPS8Text : public WPSTextParser
00048 {
00049         friend class WPS8TextInternal::SubDocument;
00050         friend class WPS8Parser;
00051         friend class WPS8TextStyle;
00052 public:
00053         WPS8Text(WPS8Parser &parser);
00054         ~WPS8Text();
00055 
00057         void setListener(WPSContentListenerPtr &listen);
00058 
00060         int numPages() const;
00061 
00063         void flushExtra();
00064 
00066         bool readStructures();
00067 
00069         int getNumTextZones() const;
00070 
00076         int getTextZoneType(int typeId) const;
00077 
00079         WPSEntry getHeaderEntry() const;
00080 
00082         WPSEntry getFooterEntry() const;
00083 
00085         WPSEntry getTextEntry() const;
00086 
00088         WPSEntry getEntry(int strsId) const;
00089 
00091         void readText(WPSEntry const &entry);
00092 
00094         void readTextInCell(int strsId, int cellId);
00095 
00096 protected:
00098         WPS8Parser &mainParser()
00099         {
00100                 return reinterpret_cast<WPS8Parser &>(m_mainParser);
00101         }
00103         WPS8Parser const &mainParser() const
00104         {
00105                 return reinterpret_cast<WPS8Parser const &>(m_mainParser);
00106         }
00107 
00108         //
00109         // interface with WPS8TextStyle
00110         //
00112         bool readFont(long endPos, int &id, std::string &mess);
00113 
00115         bool readParagraph(long endPos, int &id, std::string &mess);
00116 
00117         //
00118         // String+text functions
00119         //
00121         bool readString(RVNGInputStreamPtr input, long page_size,
00122                         librevenge::RVNGString &res);
00124         long readUTF16LE(RVNGInputStreamPtr input, long endPos, uint16_t firstC);
00125 
00129         bool readNotes(WPSEntry const &entry);
00130 
00134         void createNotesCorrespondance();
00135 
00136         //----------------------------------------
00137         // PLC parsing, setting
00138         //----------------------------------------
00139 
00146         typedef bool (WPS8Text::* DataParser)
00147         (long bot, long eot, int id, WPS8Struct::FileData const &data,
00148          std::string &mess);
00153         typedef bool (WPS8Text::* EndDataParser)
00154         (long endPos, std::vector<long> const &textPtrs);
00162         bool readPLC(WPSEntry const &entry,
00163                      std::vector<long> &textPtrs, std::vector<long> &listValues,
00164                      DataParser parser = &WPS8Text::defDataParser,
00165                      EndDataParser endParser = 0L);
00167         bool defDataParser
00168         (long , long , int , WPS8Struct::FileData const &data, std::string &mess);
00170         bool textZonesDataParser(long bot, long eot, int nId,
00171                                  WPS8Struct::FileData const &data,
00172                                  std::string &mess);
00173         // object
00175         bool objectDataParser(long bot, long eot, int id,
00176                               WPS8Struct::FileData const &data, std::string &mess);
00177         // field type
00179         bool tokenEndDataParser(long endPage, std::vector<long> const &textPtrs);
00182         bool bmktEndDataParser(long endPage, std::vector<long> const &textPtrs);
00183 
00184 protected:
00186         WPSContentListenerPtr m_listener;
00188         shared_ptr<WPS8TextStyle> m_styleParser;
00190         mutable shared_ptr<WPS8TextInternal::State> m_state;
00191 protected:
00192 };
00193 
00194 
00195 #endif /* WPS8_TEXT_H */
00196 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */