00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ 00002 00003 /* libmwaw 00004 * Version: MPL 2.0 / LGPLv2+ 00005 * 00006 * The contents of this file are subject to the Mozilla Public License Version 00007 * 2.0 (the "License"); you may not use this file except in compliance with 00008 * the License or as specified alternatively below. You may obtain a copy of 00009 * the License at http://www.mozilla.org/MPL/ 00010 * 00011 * Software distributed under the License is distributed on an "AS IS" basis, 00012 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00013 * for the specific language governing rights and limitations under the 00014 * License. 00015 * 00016 * Major Contributor(s): 00017 * Copyright (C) 2002 William Lachance (wrlach@gmail.com) 00018 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net) 00019 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch) 00020 * Copyright (C) 2006, 2007 Andrew Ziem 00021 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr) 00022 * 00023 * 00024 * All Rights Reserved. 00025 * 00026 * For minor contributions see the git repository. 00027 * 00028 * Alternatively, the contents of this file may be used under the terms of 00029 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), 00030 * in which case the provisions of the LGPLv2+ are applicable 00031 * instead of those above. 00032 */ 00033 00034 /* 00035 * Parser to WriteNow text document 00036 * 00037 */ 00038 #ifndef WN_TEXT 00039 # define WN_TEXT 00040 00041 #include <list> 00042 #include <string> 00043 #include <vector> 00044 00045 #include "libmwaw_internal.hxx" 00046 00047 #include "MWAWEntry.hxx" 00048 #include "MWAWSubDocument.hxx" 00049 00050 #include "MWAWDebug.hxx" 00051 #include "MWAWInputStream.hxx" 00052 00053 #include "MWAWParser.hxx" 00054 00055 namespace WNTextInternal 00056 { 00057 struct ContentZone; 00058 struct ContentZones; 00059 00060 struct Font; 00061 struct Paragraph; 00062 00063 struct TableData; 00064 struct Token; 00065 00066 struct Cell; 00067 00068 struct State; 00069 } 00070 00071 struct WNEntry; 00072 struct WNEntryManager; 00073 00074 class WNParser; 00075 00081 class WNText 00082 { 00083 friend class WNParser; 00084 friend struct WNTextInternal::Cell; 00085 public: 00087 WNText(WNParser &parser); 00089 virtual ~WNText(); 00090 00092 int version() const; 00093 00095 int numPages() const; 00096 00098 WNEntry getHeader() const; 00099 00101 WNEntry getFooter() const; 00102 00103 protected: 00105 bool createZones(); 00106 00108 void flushExtra(); 00109 00112 bool parseZone(WNEntry const &entry, std::vector<WNEntry> &listData); 00113 00115 shared_ptr<WNTextInternal::ContentZones> parseContent(WNEntry const &entry); 00116 00120 void sendZone(int id); 00121 00123 bool send(WNEntry const &entry); 00124 00126 bool send(std::vector<WNTextInternal::ContentZone> &listZones, 00127 std::vector<shared_ptr<WNTextInternal::ContentZones> > &footnoteList, 00128 WNTextInternal::Paragraph &ruler); 00129 00131 void setProperty(WNTextInternal::Paragraph const &ruler); 00132 00133 // 00134 // low level 00135 // 00136 00138 bool readFontNames(WNEntry const &entry); 00139 00141 bool readFont(MWAWInputStream &input, bool inStyle, WNTextInternal::Font &font); 00142 00144 bool readParagraph(MWAWInputStream &input, WNTextInternal::Paragraph &ruler); 00145 00147 bool readToken(MWAWInputStream &input, WNTextInternal::Token &token); 00148 00150 bool readTokenV2(MWAWInputStream &input, WNTextInternal::Token &token); 00151 00153 bool readTable(MWAWInputStream &input, WNTextInternal::TableData &table); 00154 00156 bool readStyles(WNEntry const &entry); 00157 00158 private: 00159 WNText(WNText const &orig); 00160 WNText &operator=(WNText const &orig); 00161 00162 protected: 00163 // 00164 // data 00165 // 00167 MWAWParserStatePtr m_parserState; 00168 00170 shared_ptr<WNTextInternal::State> m_state; 00171 00173 shared_ptr<WNEntryManager> m_entryManager; 00174 00176 WNParser *m_mainParser; 00177 }; 00178 #endif 00179 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: