RagTimeParser.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 RAG_TIME_PARSER
00035 #  define RAG_TIME_PARSER
00036 
00037 #include <set>
00038 #include <vector>
00039 
00040 #include "MWAWDebug.hxx"
00041 #include "MWAWInputStream.hxx"
00042 
00043 #include "MWAWParser.hxx"
00044 
00045 namespace RagTimeParserInternal
00046 {
00047 struct Picture;
00048 struct State;
00049 class SubDocument;
00050 }
00051 
00052 class RagTimeText;
00053 class RagTimeSpreadsheet;
00054 
00060 class RagTimeParser : public MWAWTextParser
00061 {
00062   friend class RagTimeParserInternal::SubDocument;
00063   friend class RagTimeText;
00064   friend class RagTimeSpreadsheet;
00065 
00066 public:
00068   RagTimeParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
00070   virtual ~RagTimeParser();
00071 
00073   bool checkHeader(MWAWHeader *header, bool strict=false);
00074 
00075   // the main parse function
00076   void parse(librevenge::RVNGTextInterface *documentInterface);
00077 
00078 protected:
00080   void init();
00081 
00082   //
00083   // interface
00084   //
00085 
00087   bool getColor(int colId, MWAWColor &color, int listId=-1) const;
00089   bool getDateTimeFormat(int dtId, std::string &dtFormat) const;
00091   int getZoneDataFieldSize(int zId) const;
00093   int getNewZoneId();
00094 
00095   //
00096   // interface with text parser
00097   //
00098 
00100   int getFontId(int localId) const;
00102   bool getCharStyle(int charId, MWAWFont &font) const;
00104   bool readTextZone(MWAWEntry &entry, int width, MWAWColor const &fontColor=MWAWColor::black());
00105 
00107   void createDocument(librevenge::RVNGTextInterface *documentInterface);
00109   bool sendZones();
00110 
00112   void newPage(int number);
00113 
00115   bool createZones();
00116 
00118   bool findDataZones();
00120   bool readDataZoneHeader(int id, long endPos);
00122   bool findPagesZones();
00123 
00125   bool findRsrcZones();
00126 
00128   bool sendPageZone(int page);
00130   bool send(int zId);
00132   bool sendText(int zId, MWAWListenerPtr listener);
00133 
00135   bool sendPicture(int zId, MWAWPosition const &pos);
00137   bool sendBitmap(RagTimeParserInternal::Picture const &pict, MWAWPosition const &pos);
00139   bool sendBasicPicture(int zId, MWAWPosition const &pos);
00141   void flushExtra();
00142 
00145   bool readPageZone(MWAWEntry &entry);
00146 
00148   bool readPictZone(MWAWEntry &entry);
00149 
00151   bool readPictZoneV2(MWAWEntry &entry);
00152 
00153   // some rsrc zone
00154 
00156   bool readColorMapV2(MWAWEntry &entry);
00158   bool readColorsMap();
00160   bool readPrintInfo(MWAWEntry &entry, bool inRSRCFork=false);
00162   bool readLinks(MWAWEntry &entry);
00164   bool readFormatsMap();
00166   bool readMacroFormats(MWAWEntry &entry);
00168   bool readColorTable(MWAWEntry &entry);
00169 
00170   // unknown data fork zone
00171 
00173   bool readZone6(MWAWEntry &entry);
00174 
00175   // unknown rsrc fork zone
00177   bool readRsrcBeDc(MWAWEntry &entry);
00178 
00180   bool readRsrcStructured(MWAWEntry &entry);
00181 
00183   bool readRsrcBtch(MWAWEntry &entry);
00185   bool readRsrcCalc(MWAWEntry &entry);
00187   bool readRsrcfppr(MWAWEntry &entry);
00189   bool readRsrcSele(MWAWEntry &entry);
00190   // maybe FH=footer/header zone
00192   bool readRsrcFHwl(MWAWEntry &entry);
00193 protected:
00194   //
00195   // data
00196   //
00198   shared_ptr<RagTimeParserInternal::State> m_state;
00200   shared_ptr<RagTimeSpreadsheet> m_spreadsheetParser;
00202   shared_ptr<RagTimeText> m_textParser;
00203 };
00204 #endif
00205 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: