RagTime5Parser.hxx Source File documentation

RagTime5Parser.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 RAG_TIME_5_PARSER
35 # define RAG_TIME_5_PARSER
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
47 #include "RagTime5StructManager.hxx"
48 #include "RagTime5ClusterManager.hxx"
49
50 namespace RagTime5ParserInternal
51 {
52 struct DocInfoFieldParser;
53 struct State;
54 class SubDocument;
55 }
56
57 class RagTime5Chart;
58 class RagTime5Graph;
59 class RagTime5Layout;
60 class RagTime5Pipeline;
61 class RagTime5Spreadsheet;
62 class RagTime5StructManager;
63 class RagTime5StyleManager;
64 class RagTime5Text;
65 class RagTime5Zone;
66 class RagTime5ClusterManager;
67
73 class RagTime5Parser final : public MWAWTextParser
74 {
75 friend class RagTime5Chart;
76 friend class RagTime5Graph;
77 friend class RagTime5Layout;
78 friend class RagTime5Pipeline;
79 friend class RagTime5Spreadsheet;
80 friend class RagTime5Text;
81 friend class RagTime5ClusterManager;
82 friend struct RagTime5ParserInternal::DocInfoFieldParser;
83 friend class RagTime5StyleManager;
84 friend class RagTime5ParserInternal::SubDocument;
85
86 public:
88 RagTime5Parser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
90 ~RagTime5Parser() final;
91
93 bool checkHeader(MWAWHeader *header, bool strict=false) final;
94
95 // the main parse function
96 void parse(librevenge::RVNGTextInterface *documentInterface) final;
97
98 protected:
100 void init();
101
102 //
103 // interface
104 //
105
107 std::shared_ptr<RagTime5Zone> getDataZone(int dataId) const;
109 RagTime5ClusterManager::Cluster::Type getClusterType(int zId) const;
111 RagTime5ClusterManager::Cluster::Type getPipelineContainerType(int pipelineId) const;
112
114 std::shared_ptr<RagTime5ClusterManager> getClusterManager();
116 std::shared_ptr<RagTime5StructManager> getStructManager();
118 std::shared_ptr<RagTime5StyleManager> getStyleManager();
119
121 std::shared_ptr<RagTime5ClusterManager::Cluster> readChartCluster(RagTime5Zone &zone, int zoneType);
123 std::shared_ptr<RagTime5ClusterManager::Cluster> readGraphicCluster(RagTime5Zone &zone, int zoneType);
125 std::shared_ptr<RagTime5ClusterManager::Cluster> readLayoutCluster(RagTime5Zone &zone, int zoneType);
127 std::shared_ptr<RagTime5ClusterManager::Cluster> readPipelineCluster(RagTime5Zone &zone, int zoneType);
129 std::shared_ptr<RagTime5ClusterManager::Cluster> readPictureCluster(RagTime5Zone &zone, int zoneType);
131 std::shared_ptr<RagTime5ClusterManager::Cluster> readSpreadsheetCluster(RagTime5Zone &zone, int zoneType);
133 std::shared_ptr<RagTime5ClusterManager::Cluster> readTextCluster(RagTime5Zone &zone, int zoneType);
134
136 void createDocument(librevenge::RVNGTextInterface *documentInterface);
138 bool sendZones();
140 bool send(int zoneId, MWAWListenerPtr listener, MWAWPosition const &pos, int partId=0, int part2Id=0);
141
143 void newPage(int number);
144
146 bool createZones();
148 bool findDataZones(MWAWEntry const &entry);
150 bool update(RagTime5Zone &zone);
152 bool readZoneData(RagTime5Zone &zone);
154 bool unpackZone(RagTime5Zone &zone, MWAWEntry const &entry, std::vector<unsigned char> &data);
156 bool unpackZone(RagTime5Zone &zone);
157
159 bool readZoneInfo();
161 bool readClusterZone(RagTime5Zone &zone, int type=-1);
163 bool readClusterLinkList(RagTime5Zone &zone,
164 RagTime5ClusterManager::Link const &link,
165 std::vector<RagTime5StructManager::ZoneLink> &listLinks);
167 bool readClusterLinkList(RagTime5ClusterManager::Link const &link,
168 RagTime5ClusterManager::Link const &nameLink,
169 std::vector<RagTime5StructManager::ZoneLink> &list, std::string const &name="");
170
172 bool readString(RagTime5Zone &zone, std::string &string);
174 bool readUnicodeString(RagTime5Zone &zone, std::string const &what="");
176 bool readLongListWithSize(int dataId, int fSz, std::vector<long> &list, std::string const &zoneName="");
178 bool readPositions(int posId, std::vector<long> &listPosition);
180 bool readLongList(RagTime5ClusterManager::Link const &link, std::vector<long> &list);
182 bool readUnicodeStringList(RagTime5ClusterManager::Link const &link, std::map<int, librevenge::RVNGString> &idToStringMap);
183
185 bool readDocumentVersion(RagTime5Zone &zone);
187 bool readClusterRootData(RagTime5ClusterManager::ClusterRoot &cluster);
189 bool readClusterFieldsData(RagTime5ClusterManager::Cluster &cluster);
191 bool readDocInfoClusterData(RagTime5Zone &zone, MWAWEntry const &entry);
193 bool readClusterScriptData(RagTime5ClusterManager::ClusterScript &cluster);
195 bool readScriptComment(RagTime5Zone &zone);
197 bool readClusterGProp(RagTime5ClusterManager::Cluster &cluster);
199 bool readUnknownClusterCData(RagTime5ClusterManager::Cluster &cluster);
200
202 bool readStructZone(RagTime5ClusterManager::Cluster &cluster, RagTime5StructManager::FieldParser &parser, int headerSz);
204 bool readStructData(RagTime5Zone &zone, long endPos, int n, int headerSz,
205 RagTime5StructManager::FieldParser &parser, librevenge::RVNGString const &dataName);
206
208 bool readListZone(RagTime5ClusterManager::Link const &link);
210 bool readListZone(RagTime5ClusterManager::Link const &link, RagTime5StructManager::DataParser &parser);
212 bool readFixedSizeZone(RagTime5ClusterManager::Link const &link, std::string const &name);
214 bool readFixedSizeZone(RagTime5ClusterManager::Link const &link, RagTime5StructManager::DataParser &parser);
215
217 bool checkClusterList(std::vector<RagTime5StructManager::ZoneLink> const &list);
219 bool checkClusterList(std::vector<int> const &list);
221 void flushExtra();
222
223 protected:
224
225 //
226 // data
227 //
229 std::shared_ptr<RagTime5ParserInternal::State> m_state;
231 std::shared_ptr<RagTime5Chart> m_chartParser;
233 std::shared_ptr<RagTime5Graph> m_graphParser;
235 std::shared_ptr<RagTime5Layout> m_layoutParser;
237 std::shared_ptr<RagTime5Pipeline> m_pipelineParser;
239 std::shared_ptr<RagTime5Spreadsheet> m_spreadsheetParser;
241 std::shared_ptr<RagTime5Text> m_textParser;
242
244 std::shared_ptr<RagTime5ClusterManager> m_clusterManager;
246 std::shared_ptr<RagTime5StructManager> m_structManager;
248 std::shared_ptr<RagTime5StyleManager> m_styleManager;
249 };
250 #endif
251 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
RagTime5Parser::checkClusterList
bool checkClusterList(std::vector< RagTime5StructManager::ZoneLink > const &list)
check a cluster list
Definition: RagTime5Parser.cxx:1093
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
RagTime5Parser::SubDocument
friend class RagTime5ParserInternal::SubDocument
Definition: RagTime5Parser.hxx:84
RagTime5Parser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: RagTime5Parser.cxx:2361
RagTime5Parser::readPipelineCluster
std::shared_ptr< RagTime5ClusterManager::Cluster > readPipelineCluster(RagTime5Zone &zone, int zoneType)
try to read a pipeline cluster (via the pipeline manager)
Definition: RagTime5Parser.cxx:356
RagTime5ParserInternal::DocInfoFieldParser
Internal: the helper to read doc info parse.
Definition: RagTime5Parser.cxx:72
RagTime5Parser::m_pipelineParser
std::shared_ptr< RagTime5Pipeline > m_pipelineParser
the pipeline manager
Definition: RagTime5Parser.hxx:237
RagTime5Pipeline
the main class to read the text part of RagTime 56 file
Definition: RagTime5Pipeline.hxx:72
RagTime5Parser::m_layoutParser
std::shared_ptr< RagTime5Layout > m_layoutParser
the layout manager
Definition: RagTime5Parser.hxx:235
RagTime5Parser::getPipelineContainerType
RagTime5ClusterManager::Cluster::Type getPipelineContainerType(int pipelineId) const
try to return the container&#39;s type corresponding to an id
Definition: RagTime5Parser.cxx:388
MWAWParser.hxx
RagTime5Parser::init
void init()
inits all internal variables
Definition: RagTime5Parser.cxx:305
librevenge
Definition: MWAWDocument.hxx:56
RagTime5Parser::m_structManager
std::shared_ptr< RagTime5StructManager > m_structManager
the structure manager
Definition: RagTime5Parser.hxx:246
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:549
RagTime5Parser::readScriptComment
bool readScriptComment(RagTime5Zone &zone)
try to read a script comment zone
Definition: RagTime5Parser.cxx:1441
RagTime5Parser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: RagTime5Parser.cxx:412
RagTime5Parser::readListZone
bool readListZone(RagTime5ClusterManager::Link const &link)
try to read a list zone
Definition: RagTime5Parser.cxx:1608
RagTime5Parser::readUnknownClusterCData
bool readUnknownClusterCData(RagTime5ClusterManager::Cluster &cluster)
try to read the unknown clusterC data
Definition: RagTime5Parser.cxx:1574
RagTime5Parser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: RagTime5Parser.cxx:444
RagTime5Parser::getStyleManager
std::shared_ptr< RagTime5StyleManager > getStyleManager()
returns the style manager
Definition: RagTime5Parser.cxx:336
RagTime5Parser::update
bool update(RagTime5Zone &zone)
try to update a zone: create a new input if the zone is stored in different positions, ...
Definition: RagTime5Parser.cxx:1933
RagTime5Parser::m_state
std::shared_ptr< RagTime5ParserInternal::State > m_state
the state
Definition: RagTime5Parser.hxx:229
RagTime5StructManager.hxx
RagTime5Parser::readGraphicCluster
std::shared_ptr< RagTime5ClusterManager::Cluster > readGraphicCluster(RagTime5Zone &zone, int zoneType)
try to read a graphic cluster (via the graphic manager)
Definition: RagTime5Parser.cxx:346
RagTime5Graph
the main class to read the graphic part of RagTime 56 file
Definition: RagTime5Graph.hxx:79
RagTime5Parser::m_graphParser
std::shared_ptr< RagTime5Graph > m_graphParser
the graph manager
Definition: RagTime5Parser.hxx:233
RagTime5Parser::readClusterFieldsData
bool readClusterFieldsData(RagTime5ClusterManager::Cluster &cluster)
try to read the field data
Definition: RagTime5Parser.cxx:1277
RagTime5Parser::readStructZone
bool readStructZone(RagTime5ClusterManager::Cluster &cluster, RagTime5StructManager::FieldParser &parser, int headerSz)
try to read a structured zone
Definition: RagTime5Parser.cxx:1745
RagTime5Parser::readDocumentVersion
bool readDocumentVersion(RagTime5Zone &zone)
try to read the document version zone
Definition: RagTime5Parser.cxx:2128
RagTime5StyleManager
basic class used to read/store RagTime 5/6 styles
Definition: RagTime5StyleManager.hxx:60
RagTime5Parser::getDataZone
std::shared_ptr< RagTime5Zone > getDataZone(int dataId) const
returns the zone corresponding to a data id (or 0)
Definition: RagTime5Parser.cxx:376
RagTime5Parser::readStructData
bool readStructData(RagTime5Zone &zone, long endPos, int n, int headerSz, RagTime5StructManager::FieldParser &parser, librevenge::RVNGString const &dataName)
try to read a data in a structured zone
Definition: RagTime5Parser.cxx:1841
RagTime5Parser::RagTime5Parser
RagTime5Parser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition: RagTime5Parser.cxx:286
RagTime5Parser::readZoneInfo
bool readZoneInfo()
try to read the main zone info zone and the main cluster(and child)
Definition: RagTime5Parser.cxx:619
RagTime5Zone
main zone in a RagTime v5-v6 document
Definition: RagTime5StructManager.hxx:48
RagTime5Parser::getClusterManager
std::shared_ptr< RagTime5ClusterManager > getClusterManager()
returns the cluster manager
Definition: RagTime5Parser.cxx:326
RagTime5Parser::getClusterType
RagTime5ClusterManager::Cluster::Type getClusterType(int zId) const
returns the cluster type corresponding to zone id or C_Unknown (if the zone is not a cluster or was n...
Definition: RagTime5Parser.cxx:383
RagTime5ParserInternal
Internal: the structures of a RagTime5Parser.
Definition: RagTime5Parser.cxx:69
RagTime5Parser::readUnicodeStringList
bool readUnicodeStringList(RagTime5ClusterManager::Link const &link, std::map< int, librevenge::RVNGString > &idToStringMap)
try to read a list of unicode string zone
Definition: RagTime5Parser.cxx:864
RagTime5Parser::m_styleManager
std::shared_ptr< RagTime5StyleManager > m_styleManager
the style manager
Definition: RagTime5Parser.hxx:248
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:557
RagTime5Parser::unpackZone
bool unpackZone(RagTime5Zone &zone, MWAWEntry const &entry, std::vector< unsigned char > &data)
try to unpack a zone
Definition: RagTime5Parser.cxx:1985
RagTime5Parser::readTextCluster
std::shared_ptr< RagTime5ClusterManager::Cluster > readTextCluster(RagTime5Zone &zone, int zoneType)
try to read a text cluster (via the text manager)
Definition: RagTime5Parser.cxx:371
RagTime5Spreadsheet
the main class to read the spreadsheet part of RagTime 56 file
Definition: RagTime5Spreadsheet.hxx:75
RagTime5Parser::readClusterRootData
bool readClusterRootData(RagTime5ClusterManager::ClusterRoot &cluster)
try to read the main cluster
Definition: RagTime5Parser.cxx:930
RagTime5Parser::~RagTime5Parser
~RagTime5Parser() final
destructor
Definition: RagTime5Parser.cxx:301
RagTime5Parser::readDocInfoClusterData
bool readDocInfoClusterData(RagTime5Zone &zone, MWAWEntry const &entry)
try to read the main doc info cluster data
Definition: RagTime5Parser.cxx:1288
RagTime5Parser::readClusterLinkList
bool readClusterLinkList(RagTime5Zone &zone, RagTime5ClusterManager::Link const &link, std::vector< RagTime5StructManager::ZoneLink > &listLinks)
try to read a cluster link zone
Definition: RagTime5Parser.cxx:1200
RagTime5Parser::findDataZones
bool findDataZones(MWAWEntry const &entry)
try to create the main data zones list
Definition: RagTime5Parser.cxx:2180
RagTime5Parser::m_textParser
std::shared_ptr< RagTime5Text > m_textParser
the text manager
Definition: RagTime5Parser.hxx:241
RagTime5ClusterManager
basic class used to manage RagTime 5/6 zones
Definition: RagTime5ClusterManager.hxx:58
RagTime5Parser::readClusterZone
bool readClusterZone(RagTime5Zone &zone, int type=-1)
try to read a cluster zone
Definition: RagTime5Parser.cxx:1108
RagTime5Parser::getStructManager
std::shared_ptr< RagTime5StructManager > getStructManager()
returns the structure manager
Definition: RagTime5Parser.cxx:331
RagTime5Parser::newPage
void newPage(int number)
adds a new page
Definition: RagTime5Parser.cxx:396
RagTime5Parser::readLayoutCluster
std::shared_ptr< RagTime5ClusterManager::Cluster > readLayoutCluster(RagTime5Zone &zone, int zoneType)
try to read a layout cluster (via the layout manager)
Definition: RagTime5Parser.cxx:351
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:298
RagTime5Parser::readFixedSizeZone
bool readFixedSizeZone(RagTime5ClusterManager::Link const &link, std::string const &name)
try to read a fixed size zone
Definition: RagTime5Parser.cxx:1681
RagTime5Parser::readUnicodeString
bool readUnicodeString(RagTime5Zone &zone, std::string const &what="")
try to read a unicode string zone
Definition: RagTime5Parser.cxx:838
RagTime5Parser
the main class to read a RagTime v5 file
Definition: RagTime5Parser.hxx:73
RagTime5Text
the main class to read the text part of RagTime 56 file
Definition: RagTime5Text.hxx:75
RagTime5Parser::m_chartParser
std::shared_ptr< RagTime5Chart > m_chartParser
the chart manager
Definition: RagTime5Parser.hxx:231
RagTime5Parser::readChartCluster
std::shared_ptr< RagTime5ClusterManager::Cluster > readChartCluster(RagTime5Zone &zone, int zoneType)
try to read a chart cluster (via the spreadsheet manager)
Definition: RagTime5Parser.cxx:341
RagTime5Chart
the main class to read the chart part of RagTime 56 file
Definition: RagTime5Chart.hxx:73
RagTime5Parser::readPositions
bool readPositions(int posId, std::vector< long > &listPosition)
try to read a positions zone in data
Definition: RagTime5Parser.cxx:922
MWAWInputStream.hxx
MWAWDebug.hxx
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:547
RagTime5Parser::readLongListWithSize
bool readLongListWithSize(int dataId, int fSz, std::vector< long > &list, std::string const &zoneName="")
try to read a int/long zone data
Definition: RagTime5Parser.cxx:873
RagTime5Layout
the main class to read the text part of RagTime 56 file
Definition: RagTime5Layout.hxx:72
RagTime5Parser::readZoneData
bool readZoneData(RagTime5Zone &zone)
try to read the zone data
Definition: RagTime5Parser.cxx:700
RagTime5Parser::readSpreadsheetCluster
std::shared_ptr< RagTime5ClusterManager::Cluster > readSpreadsheetCluster(RagTime5Zone &zone, int zoneType)
try to read a spreadsheet cluster (via the spreadsheet manager)
Definition: RagTime5Parser.cxx:366
RagTime5Parser::readPictureCluster
std::shared_ptr< RagTime5ClusterManager::Cluster > readPictureCluster(RagTime5Zone &zone, int zoneType)
try to read a picture cluster (via the graphic manager)
Definition: RagTime5Parser.cxx:361
RagTime5Parser::readClusterScriptData
bool readClusterScriptData(RagTime5ClusterManager::ClusterScript &cluster)
try to read the script data
Definition: RagTime5Parser.cxx:1518
RagTime5Parser::createZones
bool createZones()
finds the different objects zones
Definition: RagTime5Parser.cxx:479
RagTime5Parser::readString
bool readString(RagTime5Zone &zone, std::string &string)
try to read a string zone ( zone with id1=21,id2=23:24)
Definition: RagTime5Parser.cxx:808
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
RagTime5Parser::send
bool send(int zoneId, MWAWListenerPtr listener, MWAWPosition const &pos, int partId=0, int part2Id=0)
try to send a cluster zone (mainly unimplemented)
Definition: RagTime5Parser.cxx:2448
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
RagTime5StructManager
basic class used to store RagTime 5/6 structures
Definition: RagTime5StructManager.hxx:170
RagTime5Parser::m_spreadsheetParser
std::shared_ptr< RagTime5Spreadsheet > m_spreadsheetParser
the spreadsheet manager
Definition: RagTime5Parser.hxx:239
RagTime5Parser::m_clusterManager
std::shared_ptr< RagTime5ClusterManager > m_clusterManager
the cluster manager
Definition: RagTime5Parser.hxx:244
RagTime5ClusterManager.hxx
RagTime5Parser::flushExtra
void flushExtra()
flush unsent zone (debugging function)
Definition: RagTime5Parser.cxx:2477
RagTime5Parser::sendZones
bool sendZones()
try to send the different zones
Definition: RagTime5Parser.cxx:2432
RagTime5Parser::readLongList
bool readLongList(RagTime5ClusterManager::Link const &link, std::vector< long > &list)
try to read/get the list of long of a L_LongList
Definition: RagTime5Parser.cxx:913
RagTime5Parser::readClusterGProp
bool readClusterGProp(RagTime5ClusterManager::Cluster &cluster)
try to read the cluster with contains main graphic object properties
Definition: RagTime5Parser.cxx:1549