RagTime5Document.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2 
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33 
34 #ifndef RAGTIME_5_DOCUMENT
35 # define RAGTIME_5_DOCUMENT
36 
37 #include <map>
38 #include <string>
39 #include <set>
40 #include <vector>
41 
42 #include "MWAWDebug.hxx"
43 #include "MWAWInputStream.hxx"
44 
45 #include "MWAWParser.hxx"
46 
49 
51 {
52 struct DocInfoFieldParser;
53 struct State;
54 class SubDocument;
55 }
56 
57 class RagTime5Chart;
58 class RagTime5Formula;
59 class RagTime5Graph;
60 class RagTime5Layout;
61 class RagTime5Parser;
62 class RagTime5Pipeline;
63 class RagTime5SSParser;
67 class RagTime5Text;
68 class RagTime5Zone;
70 
77 {
78  friend class RagTime5Chart;
79  friend class RagTime5Formula;
80  friend class RagTime5Graph;
81  friend class RagTime5Layout;
82  friend class RagTime5Parser;
83  friend class RagTime5Pipeline;
84  friend class RagTime5Spreadsheet;
85  friend class RagTime5SSParser;
86  friend class RagTime5StructManager;
87  friend class RagTime5Text;
88  friend class RagTime5ClusterManager;
90  friend class RagTime5StyleManager;
91  friend class RagTime5DocumentInternal::SubDocument;
92 
93 public:
95  explicit RagTime5Document(MWAWParser &parser);
98 
100  bool checkHeader(MWAWHeader *header, bool strict=false);
103  {
104  return *m_parser;
105  }
106 
107 protected:
109  void init();
110 
111  //
112  // interface
113  //
114 
116  int numPages() const;
118  void updatePageSpanList(std::vector<MWAWPageSpan> &spanList);
120  librevenge::RVNGPropertyList getDocumentMetaData() const;
123  {
124  return m_parserState;
125  }
127  int version() const;
129  void setVersion(int vers);
130 
133  {
134  return getParserState()->m_asciiFile;
135  }
136 
138  std::shared_ptr<RagTime5Zone> getDataZone(int dataId) const;
140  RagTime5ClusterManager::Cluster::Type getClusterType(int zId) const;
142  RagTime5ClusterManager::Cluster::Type getPipelineContainerType(int pipelineId) const;
143 
145  std::shared_ptr<RagTime5ClusterManager> getClusterManager();
147  std::shared_ptr<RagTime5StructManager> getStructManager();
149  std::shared_ptr<RagTime5StyleManager> getStyleManager();
151  std::shared_ptr<RagTime5Formula> getFormulaParser();
153  std::shared_ptr<RagTime5Graph> getGraphParser();
155  std::shared_ptr<RagTime5Spreadsheet> getSpreadsheetParser();
156 
158  std::shared_ptr<RagTime5ClusterManager::Cluster> readButtonCluster(RagTime5Zone &zone, int zoneType);
160  std::shared_ptr<RagTime5ClusterManager::Cluster> readChartCluster(RagTime5Zone &zone, int zoneType);
162  std::shared_ptr<RagTime5ClusterManager::Cluster> readGraphicCluster(RagTime5Zone &zone, int zoneType);
164  std::shared_ptr<RagTime5ClusterManager::Cluster> readLayoutCluster(RagTime5Zone &zone, int zoneType);
166  std::shared_ptr<RagTime5ClusterManager::Cluster> readPipelineCluster(RagTime5Zone &zone, int zoneType);
168  std::shared_ptr<RagTime5ClusterManager::Cluster> readPictureCluster(RagTime5Zone &zone, int zoneType);
170  std::shared_ptr<RagTime5ClusterManager::Cluster> readSpreadsheetCluster(RagTime5Zone &zone, int zoneType);
172  std::shared_ptr<RagTime5ClusterManager::Cluster> readTextCluster(RagTime5Zone &zone, int zoneType);
173 
175  bool sendZones(MWAWListenerPtr listener);
177  bool sendSpreadsheet(MWAWListenerPtr listener);
179  bool send(int zoneId, MWAWListenerPtr listener, MWAWPosition const &pos, int partId=0, int cellId=0, double totalWidth=-1);
181  bool sendButtonZoneAsText(MWAWListenerPtr listener, int buttonId);
183  void newPage(int number, bool softBreak);
184 
186  bool createZones();
188  bool findZones(MWAWEntry const &entry);
190  bool findZonesKind();
192  bool updateZone(std::shared_ptr<RagTime5Zone> &zone);
194  bool updateZoneInput(RagTime5Zone &zone);
196  bool readZoneData(RagTime5Zone &zone);
198  bool unpackZone(RagTime5Zone &zone, MWAWEntry const &entry, std::vector<unsigned char> &data);
200  bool unpackZone(RagTime5Zone &zone);
201 
203  bool useMainZoneInfoData();
205  bool parseMainZoneInfoData(RagTime5Zone const &zone);
206 
208  bool checkIsSpreadsheet();
209 
211  bool readClusterZone(RagTime5Zone &zone, int type=-1);
213  bool readClusterLinkList(RagTime5Zone &zone,
214  RagTime5ClusterManager::Link const &link,
215  std::vector<RagTime5StructManager::ZoneLink> &listLinks);
217  bool readClusterLinkList(RagTime5ClusterManager::Link const &link,
218  std::vector<RagTime5StructManager::ZoneLink> &list, std::string const &name="");
219 
221  bool readString(RagTime5Zone &zone, std::string &string);
223  bool readUnicodeString(RagTime5Zone &zone, std::string const &what="");
225  bool readLongListWithSize(int dataId, int fSz, std::vector<long> &list, std::string const &zoneName="");
227  bool readPositions(int posId, std::vector<long> &listPosition);
229  bool readLongList(RagTime5ClusterManager::Link const &link, std::vector<long> &list);
231  bool readUnicodeStringList(RagTime5ClusterManager::NameLink const &link, std::map<int, librevenge::RVNGString> &idToStringMap);
232 
234  bool readDocumentVersion(RagTime5Zone &zone);
236  bool readClusterRootData(RagTime5ClusterManager::ClusterRoot &cluster);
238  bool readDocInfoClusterData(RagTime5Zone &zone, MWAWEntry const &entry);
240  bool readScriptComment(RagTime5Zone &zone);
242  bool readClusterGProp(RagTime5ClusterManager::Cluster &cluster);
244  bool readUnknownClusterCData(RagTime5ClusterManager::Cluster &cluster);
245 
249  bool readStructData(RagTime5Zone &zone, long endPos, int n, int headerSz,
250  RagTime5StructManager::FieldParser &parser, librevenge::RVNGString const &dataName);
251 
253  bool readListZone(RagTime5ClusterManager::Link const &link);
255  bool readListZone(RagTime5ClusterManager::Link const &link, RagTime5StructManager::DataParser &parser);
257  bool readFixedSizeZone(RagTime5ClusterManager::Link const &link, std::string const &name);
259  bool readFixedSizeZone(RagTime5ClusterManager::Link const &link, RagTime5StructManager::DataParser &parser);
260 
262  bool readChildList(RagTime5ClusterManager::Link const &link, std::vector<RagTime5StructManager::ZoneLink> &childList, bool findN=false);
264  bool checkClusterList(std::vector<RagTime5StructManager::ZoneLink> const &list);
266  bool checkClusterList(std::vector<int> const &list);
268  void flushExtra(MWAWListenerPtr listener, bool onlyCheck=false);
269 
270 protected:
271  //
272  // data
273  //
277  std::shared_ptr<MWAWParserState> m_parserState;
279  std::shared_ptr<RagTime5DocumentInternal::State> m_state;
281  std::shared_ptr<RagTime5Chart> m_chartParser;
283  std::shared_ptr<RagTime5Formula> m_formulaParser;
285  std::shared_ptr<RagTime5Graph> m_graphParser;
287  std::shared_ptr<RagTime5Layout> m_layoutParser;
289  std::shared_ptr<RagTime5Pipeline> m_pipelineParser;
291  std::shared_ptr<RagTime5Spreadsheet> m_spreadsheetParser;
293  std::shared_ptr<RagTime5Text> m_textParser;
294 
296  std::shared_ptr<RagTime5ClusterManager> m_clusterManager;
298  std::shared_ptr<RagTime5StructManager> m_structManager;
300  std::shared_ptr<RagTime5StyleManager> m_styleManager;
301 
302  //
303  // the callback
304  //
305 
307  typedef void (MWAWParser::* NewPage)(int page, bool softBreak);
309  typedef void (MWAWParser::* SendFootnote)(int zoneId);
310 
312  NewPage m_newPage;
314  SendFootnote m_sendFootnote;
315 private:
316  RagTime5Document(RagTime5Document const &)=delete;
317  RagTime5Document &operator=(RagTime5Document const &)=delete;
318 
319 };
320 #endif
321 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
std::shared_ptr< RagTime5DocumentInternal::State > m_state
the state
Definition: RagTime5Document.hxx:279
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
the main class to read the text part of RagTime 56 file
Definition: RagTime5Pipeline.hxx:72
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:557
std::shared_ptr< RagTime5StructManager > m_structManager
the structure manager
Definition: RagTime5Document.hxx:298
Internal: the helper to read doc info parse.
Definition: RagTime5Document.cxx:74
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:553
NewPage m_newPage
the new page callback
Definition: RagTime5Document.hxx:312
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:65
Internal: the structures of a RagTime5Document.
Definition: RagTime5Document.cxx:71
std::shared_ptr< RagTime5ClusterManager > m_clusterManager
the cluster manager
Definition: RagTime5Document.hxx:296
std::shared_ptr< RagTime5Chart > m_chartParser
the chart manager
Definition: RagTime5Document.hxx:281
the main class to read the graphic part of RagTime 56 file
Definition: RagTime5Graph.hxx:80
the main class to parse a RagTime 5-6 file containing only a spreadsheet
Definition: RagTime5SSParser.hxx:65
basic class used to read/store RagTime 5/6 styles
Definition: RagTime5StyleManager.hxx:60
virtual class use to parse the field data
Definition: RagTime5StructManager.hxx:353
main zone in a RagTime v5-v6 document
Definition: RagTime5StructManager.hxx:50
the cluster for root
Definition: RagTime5ClusterManager.hxx:329
std::shared_ptr< RagTime5StyleManager > m_styleManager
the style manager
Definition: RagTime5Document.hxx:300
the main class to read the spreadsheet part of RagTime 56 file
Definition: RagTime5Spreadsheet.hxx:77
std::shared_ptr< RagTime5Layout > m_layoutParser
the layout manager
Definition: RagTime5Document.hxx:287
virtual class use to parse the unstructured data
Definition: RagTime5StructManager.hxx:396
std::shared_ptr< RagTime5Text > m_textParser
the text manager
Definition: RagTime5Document.hxx:293
MWAWParserStatePtr getParserState()
returns the parser state
Definition: RagTime5Document.hxx:122
basic class used to manage RagTime 5/6 zones
Definition: RagTime5ClusterManager.hxx:58
std::shared_ptr< RagTime5Spreadsheet > m_spreadsheetParser
the spreadsheet manager
Definition: RagTime5Document.hxx:291
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: RagTime5Document.hxx:132
the main class to parse a RagTime 5-6 file
Definition: RagTime5Parser.hxx:65
the main class to read the text part of RagTime 56 file
Definition: RagTime5Text.hxx:75
SendFootnote m_sendFootnote
the send footnote callback
Definition: RagTime5Document.hxx:314
the main class to read the chart part of RagTime 56 file
Definition: RagTime5Chart.hxx:73
std::shared_ptr< RagTime5Formula > m_formulaParser
the formula manager
Definition: RagTime5Document.hxx:283
the main class to read the text part of RagTime 56 file
Definition: RagTime5Layout.hxx:72
the main class to read the formula part of RagTime 56 file
Definition: RagTime5Formula.hxx:73
Type
the cluster type
Definition: RagTime5ClusterManager.hxx:263
std::shared_ptr< MWAWParserState > m_parserState
the parser state
Definition: RagTime5Document.hxx:277
the main class to read a RagTime v5 file
Definition: RagTime5Document.hxx:76
MWAWParser & getMainParser()
returns the main parser
Definition: RagTime5Document.hxx:102
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:99
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
basic class used to store RagTime 5/6 structures
Definition: RagTime5StructManager.hxx:174
std::shared_ptr< RagTime5Pipeline > m_pipelineParser
the pipeline manager
Definition: RagTime5Document.hxx:289
std::shared_ptr< RagTime5Graph > m_graphParser
the graph manager
Definition: RagTime5Document.hxx:285
the cluster data
Definition: RagTime5ClusterManager.hxx:261
bool readStructZone(MWAWParserState &parserState, char const *zoneName, bool hasEntete)
try to read a structured zone with unknown content
Definition: ClarisWksStruct.cxx:162
MWAWParser * m_parser
the main parser
Definition: RagTime5Document.hxx:275

Generated on Sun Sep 27 2020 08:28:54 for libmwaw by doxygen 1.8.13