WNParser.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
00002 /* libmwaw
00003 * Version: MPL 2.0 / LGPLv2+
00004 *
00005 * The contents of this file are subject to the Mozilla Public License Version
00006 * 2.0 (the "License"); you may not use this file except in compliance with
00007 * the License or as specified alternatively below. You may obtain a copy of
00008 * the License at http://www.mozilla.org/MPL/
00009 *
00010 * Software distributed under the License is distributed on an "AS IS" basis,
00011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012 * for the specific language governing rights and limitations under the
00013 * License.
00014 *
00015 * Major Contributor(s):
00016 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
00017 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
00018 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00019 * Copyright (C) 2006, 2007 Andrew Ziem
00020 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
00021 *
00022 *
00023 * All Rights Reserved.
00024 *
00025 * For minor contributions see the git repository.
00026 *
00027 * Alternatively, the contents of this file may be used under the terms of
00028 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00029 * in which case the provisions of the LGPLv2+ are applicable
00030 * instead of those above.
00031 */
00032 
00033 /*
00034  * parser for WriteNow 3.0 and 4.0
00035  *
00036  * Note: WriteNow 2.0 seems very different
00037  */
00038 #ifndef WN_PARSER
00039 #  define WN_PARSER
00040 
00041 #include <list>
00042 #include <string>
00043 #include <vector>
00044 
00045 #include "MWAWDebug.hxx"
00046 #include "MWAWEntry.hxx"
00047 #include "MWAWInputStream.hxx"
00048 #include "MWAWPosition.hxx"
00049 
00050 #include "MWAWParser.hxx"
00051 
00052 namespace WNParserInternal
00053 {
00054 struct State;
00055 class SubDocument;
00056 }
00057 
00058 struct WNEntry;
00059 struct WNEntryManager;
00060 
00061 class WNText;
00062 
00068 class WNParser : public MWAWParser
00069 {
00070   friend class WNText;
00071   friend class WNParserInternal::SubDocument;
00072 
00073 public:
00075   WNParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00077   virtual ~WNParser();
00078 
00080   bool checkHeader(MWAWHeader *header, bool strict=false);
00081 
00082   // the main parse function
00083   void parse(WPXDocumentInterface *documentInterface);
00084 
00085 protected:
00087   void init();
00088 
00090   void createDocument(WPXDocumentInterface *documentInterface);
00091 
00093   bool createZones();
00094 
00096   void getColumnInfo(int &numColumns, int &width) const;
00097 
00099   void newPage(int number);
00100 
00101   /*
00102    * interface with WNText
00103    */
00105   bool getColor(int colId, MWAWColor &col) const;
00106 
00108   void sendFootnote(WNEntry const &entry);
00109 
00111   bool sendGraphic(int gId, Box2i const &bdbox);
00112 
00113   /*
00114    * interface with subdocument
00115    */
00116 
00118   void send(WNEntry const &entry);
00119 
00120   //
00121   // low level
00122   //
00123 
00125   bool readDocEntries();
00126 
00128   bool readDocEntriesV2();
00129 
00133   bool parseGraphicZone(WNEntry const &entry);
00134 
00136   bool readColorMap(WNEntry const &entry);
00137 
00139   bool readPrintInfo(WNEntry const &entry);
00140 
00142   bool readGenericUnkn(WNEntry const &entry);
00143 
00145   bool sendPicture(WNEntry const &entry, Box2i const &bdbox);
00146 
00148   WNEntry readEntry();
00149 
00151   bool checkIfPositionValid(long pos);
00152 
00153 protected:
00154   //
00155   // data
00156   //
00158   shared_ptr<WNParserInternal::State> m_state;
00159 
00161   shared_ptr<WNEntryManager> m_entryManager;
00162 
00164   shared_ptr<WNText> m_textParser;
00165 };
00166 #endif
00167 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: