NSParser.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 
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 #ifndef NS_PARSER
00035 #  define NS_PARSER
00036 
00037 #include <string>
00038 #include <vector>
00039 
00040 #include <libwpd/libwpd.h>
00041 
00042 #include "MWAWDebug.hxx"
00043 #include "MWAWInputStream.hxx"
00044 
00045 #include "NSStruct.hxx"
00046 
00047 #include "MWAWParser.hxx"
00048 
00049 namespace NSParserInternal
00050 {
00051 struct State;
00052 }
00053 
00054 class NSGraph;
00055 class NSText;
00056 
00059 class NSParser : public MWAWParser
00060 {
00061   friend struct NSStruct::RecursifData;
00062   friend class NSGraph;
00063   friend class NSText;
00064 public:
00066   NSParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00068   virtual ~NSParser();
00069 
00071   bool checkHeader(MWAWHeader *header, bool strict=false);
00072 
00073   // the main parse function
00074   void parse(WPXDocumentInterface *documentInterface);
00075 
00076 protected:
00078   void init();
00079 
00081   void createDocument(WPXDocumentInterface *documentInterface);
00082 
00084   Vec2f getPageLeftTop() const;
00086   void getColumnInfo(int &numColumns, float &colSep) const;
00088   void getFootnoteInfo(NSStruct::FootnoteInfo &fInfo) const;
00089 
00091   void newPage(int number);
00092 
00093   // variable access
00094 
00096   std::string getDateFormat(NSStruct::ZoneType zoneId, int vId) const;
00097 
00099   bool getReferenceData(NSStruct::ZoneType zoneId, int vId,
00100                         MWAWField::Type &fType,
00101                         std::string &content,
00102                         std::vector<int> &number) const;
00103 
00104   // interface with the graph parser
00105 
00107   bool sendPicture(int pictId, MWAWPosition const &pictPos,
00108                    WPXPropertyList extras = WPXPropertyList());
00109 
00110 protected:
00112   bool createZones();
00113 
00115   bool readPrintInfo(MWAWEntry const &entry);
00117   bool readCPRC(MWAWEntry const &entry);
00119   bool readPageLimit(MWAWEntry const &entry);
00120 
00122   bool readStringsList(MWAWEntry const &entry, std::vector<std::string> &list, bool simpleList);
00123 
00125   bool readINFO(MWAWEntry const &entry);
00126 
00128   bool readReference(NSStruct::RecursifData const &data);
00130   bool readVariable(NSStruct::RecursifData const &data);
00132   bool readCNTR(MWAWEntry const &entry, int zoneId);
00134   bool readNumberingReset(MWAWEntry const &entry, int zoneId);
00135 
00137   bool readSGP1(NSStruct::RecursifData const &data);
00139   bool readABBR(MWAWEntry const &entry);
00141   bool readFTA2(MWAWEntry const &entry);
00143   bool readFnSc(MWAWEntry const &entry);
00144 
00146   MWAWInputStreamPtr rsrcInput();
00147 
00149   libmwaw::DebugFile &rsrcAscii();
00150 
00151   //
00152   // data
00153   //
00155   shared_ptr<NSParserInternal::State> m_state;
00156 
00158   shared_ptr<NSGraph> m_graphParser;
00159 
00161   shared_ptr<NSText> m_textParser;
00162 };
00163 #endif
00164 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: