ClarisWksDocument.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 /*
00035  * Document data used by the Claris Works parser
00036  *
00037  */
00038 #ifndef CLARIS_WKS_DOCUMENT
00039 #  define CLARIS_WKS_DOCUMENT
00040 
00041 #include <vector>
00042 
00043 #include "libmwaw_internal.hxx"
00044 
00045 #include "MWAWPosition.hxx"
00046 
00047 #include "ClarisWksStruct.hxx"
00048 
00049 class MWAWSection;
00050 
00051 namespace ClarisWksDocumentInternal
00052 {
00053 class SubDocument;
00054 
00055 struct State;
00056 }
00057 
00058 class ClarisWksParser;
00059 class ClarisWksBMParser;
00060 class ClarisWksPRParser;
00061 class ClarisWksSSParser;
00062 
00063 class ClarisWksDatabase;
00064 class ClarisWksGraph;
00065 class ClarisWksStyleManager;
00066 class ClarisWksPresentation;
00067 class ClarisWksSpreadsheet;
00068 class ClarisWksTable;
00069 class ClarisWksText;
00070 
00072 class ClarisWksDocument
00073 {
00074 public:
00075   friend class ClarisWksParser;
00076   friend class ClarisWksBMParser;
00077   friend class ClarisWksPRParser;
00078   friend class ClarisWksSSParser;
00079   friend class ClarisWksDocumentInternal::SubDocument;
00081   ClarisWksDocument(MWAWParser &parser);
00083   ~ClarisWksDocument();
00084 
00086   bool checkHeader(MWAWHeader *header, bool strict=false);
00087 
00089   bool createZones();
00090 
00092   int numPages() const;
00094   MWAWVec2i getDocumentPages();
00096   double getTextHeight() const;
00098   MWAWVec2f getPageLeftTop() const;
00100   void updatePageSpanList(std::vector<MWAWPageSpan> &spanList);
00102   void updatePageSpanList(std::vector<MWAWPageSpan> &spanList, MWAWPageSpan &master);
00103 
00105   MWAWSection getMainSection() const;
00107   shared_ptr<ClarisWksStruct::DSET> getZone(int zId) const;
00109   void updateChildPositions();
00111   void newPage(int page, bool softBreak=false);
00113   std::vector<int> const &getMainZonesList() const;
00115   void forceParsed(int zoneId);
00117   bool canSendZoneAsGraphic(int number) const;
00119   bool sendZone(int zoneId, MWAWListenerPtr listener=MWAWListenerPtr(), MWAWPosition pos=MWAWPosition());
00121   void sendFootnote(int zoneId);
00122 
00124   MWAWParser &getMainParser()
00125   {
00126     return *m_parser;
00127   }
00129   shared_ptr<ClarisWksStyleManager> getStyleManager()
00130   {
00131     return m_styleManager;
00132   }
00134   shared_ptr<ClarisWksDatabase> getDatabaseParser()
00135   {
00136     return m_databaseParser;
00137   }
00139   shared_ptr<ClarisWksGraph> getGraphParser()
00140   {
00141     return m_graphParser;
00142   }
00144   shared_ptr<ClarisWksPresentation> getPresentationParser()
00145   {
00146     return m_presentationParser;
00147   }
00149   shared_ptr<ClarisWksSpreadsheet> getSpreadsheetParser()
00150   {
00151     return m_spreadsheetParser;
00152   }
00154   shared_ptr<ClarisWksTable> getTableParser()
00155   {
00156     return m_tableParser;
00157   }
00159   shared_ptr<ClarisWksText> getTextParser()
00160   {
00161     return m_textParser;
00162   }
00163 
00165   bool readZone();
00167   bool readDocHeader();
00169   bool readDocInfo();
00171   bool readPrintInfo();
00172 
00173   // THE NAMED ENTRY
00174 
00176   bool readEndTable(long &eof);
00177 
00178   /* sequence of plist of printer : in v6 */
00179   bool readCPRT(MWAWEntry const &entry);
00180 
00181   /* read the list of mark */
00182   bool readMARKList(MWAWEntry const &entry);
00183   /* read a URL mark */
00184   bool readURL(long endPos);
00185   /* read a bookmark mark */
00186   bool readBookmark(long endPos);
00187   /* read a document mark */
00188   bool readDocumentMark(long endPos);
00189   /* read a end mark */
00190   bool readEndMark(long endPos);
00191 
00192   /* read the document summary */
00193   bool readDSUM(MWAWEntry const &entry, bool inHeader);
00194   /* SNAP (in v6) : size[4]/size[2] picture... */
00195   bool readSNAP(MWAWEntry const &entry);
00196   /* read the temporary file name ? */
00197   bool readTNAM(MWAWEntry const &entry);
00198 
00199   //
00200   // low level
00201   //
00202 
00206   shared_ptr<ClarisWksStruct::DSET> readDSET(bool &complete);
00208   void typeMainZones();
00210   int typeMainZonesRec(int zId, ClarisWksStruct::DSET::Position type, int maxHeight);
00212   bool exploreZonesGraph();
00214   bool exploreZonesGraphRec(int zId, std::set<int> &notDoneList);
00216   void cleanZonesGraph();
00217 
00219   bool readStructCellZone(char const *zoneName, bool hasEntete, std::vector<MWAWVec2i> &res);
00220   /* read a list of string zone */
00221   bool readStringList(char const *zoneName, bool hasEntete, std::vector<std::string> &res);
00222 
00224   bool readZoneA();
00226   void checkOrdering(std::vector<int16_t> &vec16, std::vector<int32_t> &vec32) const;
00227 
00228 
00229 protected:
00231   MWAWPageSpan getFinalPageSpan() const;
00233   shared_ptr<ClarisWksDocumentInternal::State> m_state;
00234 public:
00236   shared_ptr<MWAWParserState> m_parserState;
00237 
00238 protected:
00240   MWAWParser *m_parser;
00242   shared_ptr<ClarisWksStyleManager> m_styleManager;
00243 
00245   shared_ptr<ClarisWksDatabase> m_databaseParser;
00247   shared_ptr<ClarisWksGraph> m_graphParser;
00249   shared_ptr<ClarisWksPresentation> m_presentationParser;
00251   shared_ptr<ClarisWksSpreadsheet> m_spreadsheetParser;
00253   shared_ptr<ClarisWksTable> m_tableParser;
00255   shared_ptr<ClarisWksText> m_textParser;
00256 
00257   //
00258   // the callback
00259   //
00260 
00262   typedef void (MWAWParser::* NewPage)(int page, bool softBreak);
00264   typedef void (MWAWParser::* SendFootnote)(int zoneId);
00265 
00267   NewPage m_newPage;
00269   SendFootnote m_sendFootnote;
00270 
00271 private:
00272   ClarisWksDocument(ClarisWksDocument const &orig);
00273   ClarisWksDocument operator=(ClarisWksDocument const &orig);
00274 };
00275 
00276 #endif
00277 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: