Blame src/lib/ClarisWksDocument.hxx

rpm-build 6f7582
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
rpm-build 6f7582
rpm-build 6f7582
/* libmwaw
rpm-build 6f7582
* Version: MPL 2.0 / LGPLv2+
rpm-build 6f7582
*
rpm-build 6f7582
* The contents of this file are subject to the Mozilla Public License Version
rpm-build 6f7582
* 2.0 (the "License"); you may not use this file except in compliance with
rpm-build 6f7582
* the License or as specified alternatively below. You may obtain a copy of
rpm-build 6f7582
* the License at http://www.mozilla.org/MPL/
rpm-build 6f7582
*
rpm-build 6f7582
* Software distributed under the License is distributed on an "AS IS" basis,
rpm-build 6f7582
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
rpm-build 6f7582
* for the specific language governing rights and limitations under the
rpm-build 6f7582
* License.
rpm-build 6f7582
*
rpm-build 6f7582
* Major Contributor(s):
rpm-build 6f7582
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
rpm-build 6f7582
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
rpm-build 6f7582
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
rpm-build 6f7582
* Copyright (C) 2006, 2007 Andrew Ziem
rpm-build 6f7582
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
rpm-build 6f7582
*
rpm-build 6f7582
*
rpm-build 6f7582
* All Rights Reserved.
rpm-build 6f7582
*
rpm-build 6f7582
* For minor contributions see the git repository.
rpm-build 6f7582
*
rpm-build 6f7582
* Alternatively, the contents of this file may be used under the terms of
rpm-build 6f7582
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
rpm-build 6f7582
* in which case the provisions of the LGPLv2+ are applicable
rpm-build 6f7582
* instead of those above.
rpm-build 6f7582
*/
rpm-build 6f7582
rpm-build 6f7582
/*
rpm-build 6f7582
 * Document data used by the Claris Works parser
rpm-build 6f7582
 *
rpm-build 6f7582
 */
rpm-build 6f7582
#ifndef CLARIS_WKS_DOCUMENT
rpm-build 6f7582
#  define CLARIS_WKS_DOCUMENT
rpm-build 6f7582
rpm-build 6f7582
#include <vector>
rpm-build 6f7582
rpm-build 6f7582
#include "libmwaw_internal.hxx"
rpm-build 6f7582
rpm-build 6f7582
#include "MWAWParser.hxx"
rpm-build 6f7582
#include "MWAWPosition.hxx"
rpm-build 6f7582
rpm-build 6f7582
#include "ClarisWksStruct.hxx"
rpm-build 6f7582
rpm-build 6f7582
class MWAWSection;
rpm-build 6f7582
rpm-build 6f7582
namespace ClarisWksDocumentInternal
rpm-build 6f7582
{
rpm-build 6f7582
class SubDocument;
rpm-build 6f7582
rpm-build 6f7582
struct State;
rpm-build 6f7582
}
rpm-build 6f7582
rpm-build 6f7582
class ClarisWksParser;
rpm-build 6f7582
class ClarisWksBMParser;
rpm-build 6f7582
class ClarisWksPRParser;
rpm-build 6f7582
class ClarisWksSSParser;
rpm-build 6f7582
rpm-build 6f7582
class ClarisWksDatabase;
rpm-build 6f7582
class ClarisWksGraph;
rpm-build 6f7582
class ClarisWksStyleManager;
rpm-build 6f7582
class ClarisWksPresentation;
rpm-build 6f7582
class ClarisWksSpreadsheet;
rpm-build 6f7582
class ClarisWksTable;
rpm-build 6f7582
class ClarisWksText;
rpm-build 6f7582
rpm-build 6f7582
//! main document information used to create a ClarisWorks file
rpm-build 6f7582
class ClarisWksDocument
rpm-build 6f7582
{
rpm-build 6f7582
public:
rpm-build 6f7582
  friend class ClarisWksParser;
rpm-build 6f7582
  friend class ClarisWksBMParser;
rpm-build 6f7582
  friend class ClarisWksPRParser;
rpm-build 6f7582
  friend class ClarisWksSSParser;
rpm-build 6f7582
  friend class ClarisWksDocumentInternal::SubDocument;
rpm-build 6f7582
  //! constructor
rpm-build 6f7582
  explicit ClarisWksDocument(MWAWParser &parser);
rpm-build 6f7582
  //! virtual destructor
rpm-build 6f7582
  ~ClarisWksDocument();
rpm-build 6f7582
rpm-build 6f7582
  //! checks if the document header is correct (or not)
rpm-build 6f7582
  bool checkHeader(MWAWHeader *header, bool strict=false);
rpm-build 6f7582
rpm-build 6f7582
  //! finds the different objects zones
rpm-build 6f7582
  bool createZones();
rpm-build 6f7582
rpm-build 6f7582
  //! returns the document number of page
rpm-build 6f7582
  int numPages() const;
rpm-build 6f7582
  //! returns the number of expected pages ( accross pages x down page)
rpm-build 6f7582
  MWAWVec2i getDocumentPages();
rpm-build 6f7582
  /** returns the document meta data */
rpm-build 6f7582
  librevenge::RVNGPropertyList const &getDocumentMetaData() const;
rpm-build 6f7582
  //! returns the page height, ie. paper size less margin (in inches) less header/footer size
rpm-build 6f7582
  double getTextHeight() const;
rpm-build 6f7582
  //! returns the page left top point ( in inches)
rpm-build 6f7582
  MWAWVec2f getPageLeftTop() const;
rpm-build 6f7582
  /** updates the page span list */
rpm-build 6f7582
  void updatePageSpanList(std::vector<MWAWPageSpan> &spanList);
rpm-build 6f7582
  /** updates the page span list (and returns a master page)*/
rpm-build 6f7582
  void updatePageSpanList(std::vector<MWAWPageSpan> &spanList, MWAWPageSpan &master);
rpm-build 6f7582
rpm-build 6f7582
  //! returns the main document section
rpm-build 6f7582
  MWAWSection getMainSection() const;
rpm-build 6f7582
  //! return the zone corresponding to an id ( low level)
rpm-build 6f7582
  std::shared_ptr<ClarisWksStruct::DSET> getZone(int zId) const;
rpm-build 6f7582
  //! try to update the child page of each zone
rpm-build 6f7582
  void updateChildPositions();
rpm-build 6f7582
  /** send a page break */
rpm-build 6f7582
  void newPage(int page, bool softBreak=false);
rpm-build 6f7582
  /** returns the list of the main zones */
rpm-build 6f7582
  std::vector<int> const &getMainZonesList() const;
rpm-build 6f7582
  //! indicates that a zone is parser
rpm-build 6f7582
  void forceParsed(int zoneId);
rpm-build 6f7582
  //! check if we can send a zone as a graphic
rpm-build 6f7582
  bool canSendZoneAsGraphic(int number) const;
rpm-build 6f7582
  //! try to send a zone
rpm-build 6f7582
  bool sendZone(int zoneId, MWAWListenerPtr listener=MWAWListenerPtr(), MWAWPosition pos=MWAWPosition());
rpm-build 6f7582
  //! try to send a database picture
rpm-build 6f7582
  bool sendDatabasePictZone(int pictId, MWAWListenerPtr listener=MWAWListenerPtr(), MWAWPosition pos=MWAWPosition());
rpm-build 6f7582
  /** ask the main parser to create a document to send a footnote */
rpm-build 6f7582
  void sendFootnote(int zoneId);
rpm-build 6f7582
rpm-build 6f7582
  //! returns the main parser
rpm-build 6f7582
  MWAWParser &getMainParser()
rpm-build 6f7582
  {
rpm-build 6f7582
    return *m_parser;
rpm-build 6f7582
  }
rpm-build 6f7582
  //! returns the style manager
rpm-build 6f7582
  std::shared_ptr<ClarisWksStyleManager> getStyleManager()
rpm-build 6f7582
  {
rpm-build 6f7582
    return m_styleManager;
rpm-build 6f7582
  }
rpm-build 6f7582
  //! returns the database parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksDatabase> getDatabaseParser()
rpm-build 6f7582
  {
rpm-build 6f7582
    return m_databaseParser;
rpm-build 6f7582
  }
rpm-build 6f7582
  //! returns the graph parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksGraph> getGraphParser()
rpm-build 6f7582
  {
rpm-build 6f7582
    return m_graphParser;
rpm-build 6f7582
  }
rpm-build 6f7582
  //! returns the presentation parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksPresentation> getPresentationParser()
rpm-build 6f7582
  {
rpm-build 6f7582
    return m_presentationParser;
rpm-build 6f7582
  }
rpm-build 6f7582
  //! returns the spreadsheet parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksSpreadsheet> getSpreadsheetParser()
rpm-build 6f7582
  {
rpm-build 6f7582
    return m_spreadsheetParser;
rpm-build 6f7582
  }
rpm-build 6f7582
  //! returns the table parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksTable> getTableParser()
rpm-build 6f7582
  {
rpm-build 6f7582
    return m_tableParser;
rpm-build 6f7582
  }
rpm-build 6f7582
  //! returns the text parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksText> getTextParser()
rpm-build 6f7582
  {
rpm-build 6f7582
    return m_textParser;
rpm-build 6f7582
  }
rpm-build 6f7582
rpm-build 6f7582
  //! read a zone
rpm-build 6f7582
  bool readZone();
rpm-build 6f7582
  //! reads the document header
rpm-build 6f7582
  bool readDocHeader();
rpm-build 6f7582
  //! reads the document info part ( end of the header)
rpm-build 6f7582
  bool readDocInfo();
rpm-build 6f7582
  //! read the print info zone
rpm-build 6f7582
  bool readPrintInfo();
rpm-build 6f7582
rpm-build 6f7582
  // THE NAMED ENTRY
rpm-build 6f7582
rpm-build 6f7582
  //! reads the end table ( appears in v3.0 : file version ? )
rpm-build 6f7582
  bool readEndTable(long &eof;;
rpm-build 6f7582
rpm-build 6f7582
  /* sequence of plist of printer : in v6 */
rpm-build 6f7582
  bool readCPRT(MWAWEntry const &entry);
rpm-build 6f7582
rpm-build 6f7582
  /* read the list of mark */
rpm-build 6f7582
  bool readMARKList(MWAWEntry const &entry);
rpm-build 6f7582
  /* read a URL mark */
rpm-build 6f7582
  bool readURL(long endPos);
rpm-build 6f7582
  /* read a bookmark mark */
rpm-build 6f7582
  bool readBookmark(long endPos);
rpm-build 6f7582
  /* read a document mark */
rpm-build 6f7582
  bool readDocumentMark(long endPos);
rpm-build 6f7582
  /* read a end mark */
rpm-build 6f7582
  bool readEndMark(long endPos);
rpm-build 6f7582
rpm-build 6f7582
  /* read the document summary */
rpm-build 6f7582
  bool readDSUM(MWAWEntry const &entry, bool inHeader);
rpm-build 6f7582
  /* SNAP (in v6) : size[4]/size[2] picture... */
rpm-build 6f7582
  bool readSNAP(MWAWEntry const &entry);
rpm-build 6f7582
  /* read the temporary file name ? */
rpm-build 6f7582
  bool readTNAM(MWAWEntry const &entry);
rpm-build 6f7582
rpm-build 6f7582
  //
rpm-build 6f7582
  // low level
rpm-build 6f7582
  //
rpm-build 6f7582
rpm-build 6f7582
  /** reads the zone DSET
rpm-build 6f7582
rpm-build 6f7582
      \note set complete to true if we read all the zone */
rpm-build 6f7582
  std::shared_ptr<ClarisWksStruct::DSET> readDSET(bool &complete);
rpm-build 6f7582
  /** try to type the main zones */
rpm-build 6f7582
  void typeMainZones();
rpm-build 6f7582
  /** try to type the main zones recursif, returns the father id*/
rpm-build 6f7582
  int typeMainZonesRec(int zId, ClarisWksStruct::DSET::Position type, int maxHeight);
rpm-build 6f7582
  /** try to find the zone dags structure... */
rpm-build 6f7582
  bool exploreZonesGraph();
rpm-build 6f7582
  /** try to find the zone tree graph ( DSF) function*/
rpm-build 6f7582
  bool exploreZonesGraphRec(int zId, std::set<int> &notDoneList);
rpm-build 6f7582
  /** remove uneeded edge (mainly header/footer edges in main graph) */
rpm-build 6f7582
  void cleanZonesGraph();
rpm-build 6f7582
rpm-build 6f7582
  /** try to read a structured zone list of cells */
rpm-build 6f7582
  bool readStructCellZone(char const *zoneName, bool hasEntete, std::vector<MWAWVec2i> &res;;
rpm-build 6f7582
  /* read a list of string zone */
rpm-build 6f7582
  bool readStringList(char const *zoneName, bool hasEntete, std::vector<std::string> &res;;
rpm-build 6f7582
  /** try to read a structured zone list of picture definition: v5-v6 */
rpm-build 6f7582
  bool readDataLinkList();
rpm-build 6f7582
rpm-build 6f7582
  //! try to read a unknown zone which appear to be filled at least in some v2 database file
rpm-build 6f7582
  bool readZoneA();
rpm-build 6f7582
  /** small fonction used to check unusual endian ordering of a list of int16_t, int32_t*/
rpm-build 6f7582
  void checkOrdering(std::vector<int16_t> &vec16, std::vector<int32_t> &vec32) const;
rpm-build 6f7582
rpm-build 6f7582
protected:
rpm-build 6f7582
  //! returns the final page span to use for the document
rpm-build 6f7582
  MWAWPageSpan getFinalPageSpan() const;
rpm-build 6f7582
  //! the state
rpm-build 6f7582
  std::shared_ptr<ClarisWksDocumentInternal::State> m_state;
rpm-build 6f7582
public:
rpm-build 6f7582
  //! the parser state
rpm-build 6f7582
  std::shared_ptr<MWAWParserState> m_parserState;
rpm-build 6f7582
rpm-build 6f7582
protected:
rpm-build 6f7582
  //! the main parser
rpm-build 6f7582
  MWAWParser *m_parser;
rpm-build 6f7582
  //! the style manager
rpm-build 6f7582
  std::shared_ptr<ClarisWksStyleManager> m_styleManager;
rpm-build 6f7582
rpm-build 6f7582
  //! the database parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksDatabase> m_databaseParser;
rpm-build 6f7582
  //! the graph parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksGraph> m_graphParser;
rpm-build 6f7582
  //! the spreadsheet parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksPresentation> m_presentationParser;
rpm-build 6f7582
  //! the spreadsheet parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksSpreadsheet> m_spreadsheetParser;
rpm-build 6f7582
  //! the table parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksTable> m_tableParser;
rpm-build 6f7582
  //! the text parser
rpm-build 6f7582
  std::shared_ptr<ClarisWksText> m_textParser;
rpm-build 6f7582
rpm-build 6f7582
  //
rpm-build 6f7582
  // the callback
rpm-build 6f7582
  //
rpm-build 6f7582
rpm-build 6f7582
  /** callback used to send a page break */
rpm-build 6f7582
  typedef void (MWAWParser::* NewPage)(int page, bool softBreak);
rpm-build 6f7582
  //! callback used to send a footnote
rpm-build 6f7582
  typedef void (MWAWParser::* SendFootnote)(int zoneId);
rpm-build 6f7582
rpm-build 6f7582
  /** the new page callback */
rpm-build 6f7582
  NewPage m_newPage;
rpm-build 6f7582
  /** the send footnote callback */
rpm-build 6f7582
  SendFootnote m_sendFootnote;
rpm-build 6f7582
rpm-build 6f7582
private:
rpm-build 6f7582
  ClarisWksDocument(ClarisWksDocument const &orig) = delete;
rpm-build 6f7582
  ClarisWksDocument operator=(ClarisWksDocument const &orig) = delete;
rpm-build 6f7582
};
rpm-build 6f7582
rpm-build 6f7582
#endif
rpm-build 6f7582
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: