GreatWksDocument.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 GREAT_WKS_DOCUMENT
00035 #  define GREAT_WKS_DOCUMENT
00036 
00037 #include <string>
00038 #include <vector>
00039 
00040 #include <librevenge/librevenge.h>
00041 
00042 #include "MWAWCell.hxx"
00043 #include "MWAWDebug.hxx"
00044 
00045 namespace GreatWksDocumentInternal
00046 {
00047 struct State;
00048 }
00049 
00050 class GreatWksGraph;
00051 class GreatWksParser;
00052 class GreatWksDBParser;
00053 class GreatWksDRParser;
00054 class GreatWksSSParser;
00055 class GreatWksText;
00056 
00059 class GreatWksDocument
00060 {
00061   friend class GreatWksParser;
00062   friend class GreatWksDBParser;
00063   friend class GreatWksDRParser;
00064   friend class GreatWksSSParser;
00065 public:
00067   GreatWksDocument(MWAWParser &parser);
00069   virtual ~GreatWksDocument();
00070 
00072   bool checkHeader(MWAWHeader *header, bool strict=false);
00073 
00075   MWAWParser &getMainParser()
00076   {
00077     return *m_parser;
00078   }
00080   shared_ptr<GreatWksGraph> getGraphParser()
00081   {
00082     return m_graphParser;
00083   }
00085   shared_ptr<GreatWksText> getTextParser()
00086   {
00087     return m_textParser;
00088   }
00089 
00091   MWAWSection getMainSection() const;
00093   void newPage(int page);
00095   bool sendPicture(MWAWEntry const &entry, MWAWPosition pos);
00096 
00097   // interface with the graph parser
00098 
00100   bool canSendTextboxAsGraphic(MWAWEntry const &entry);
00102   bool sendTextbox(MWAWEntry const &entry, MWAWListenerPtr listener);
00103 
00104 protected:
00105 
00107   bool readRSRCZones();
00108 
00109   // formula function
00110 
00112   bool readCellInFormula(MWAWVec2i const &pos, MWAWCellContent::FormulaInstruction &instr);
00114   bool readString(long endPos, std::string &res);
00116   bool readNumber(long endPos, double &res, bool &isNan);
00118   bool readFormula(MWAWVec2i const &cPos, long endPos,
00119                    std::vector<MWAWCellContent::FormulaInstruction> &formula, std::string &error);
00120 
00121   //
00122   // low level
00123   //
00124 
00126   bool readPrintInfo(MWAWEntry const &entry);
00127 
00129   bool readWPSN(MWAWEntry const &entry);
00130 
00132   bool readARRs(MWAWEntry const &entry);
00134   bool readDaHS(MWAWEntry const &entry);
00136   bool readGrDS(MWAWEntry const &entry);
00138   bool readNxEd(MWAWEntry const &entry);
00139 
00141   MWAWInputStreamPtr rsrcInput();
00142 
00144   libmwaw::DebugFile &rsrcAscii();
00145 
00146 private:
00147   GreatWksDocument(GreatWksDocument const &orig);
00148   GreatWksDocument &operator=(GreatWksDocument const &orig);
00149 
00150   //
00151   // data
00152   //
00153 
00154 protected:
00156   shared_ptr<GreatWksDocumentInternal::State> m_state;
00157 public:
00159   shared_ptr<MWAWParserState> m_parserState;
00160 
00161 protected:
00163   MWAWParser *m_parser;
00165   shared_ptr<GreatWksGraph> m_graphParser;
00167   shared_ptr<GreatWksText> m_textParser;
00168 
00170   typedef MWAWSection(MWAWParser::* GetMainSection)() const;
00172   typedef void (MWAWParser::* NewPage)(int page);
00173 
00175   GetMainSection m_getMainSection;
00177   NewPage m_newPage;
00178 };
00179 #endif
00180 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: