RagTime5Parser.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 RagTime5Graph;
58 class RagTime5Spreadsheet;
59 class RagTime5StructManager;
60 class RagTime5Text;
61 class RagTime5Zone;
62 class RagTime5ClusterManager;
63
69 class RagTime5Parser : public MWAWTextParser
70 {
71 friend class RagTime5Graph;
72 friend class RagTime5Spreadsheet;
73 friend class RagTime5Text;
74 friend class RagTime5ClusterManager;
75 friend struct RagTime5ParserInternal::DocInfoFieldParser;
76 friend class RagTime5ParserInternal::SubDocument;
77
78 public:
80 RagTime5Parser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
82 virtual ~RagTime5Parser();
83
85 bool checkHeader(MWAWHeader *header, bool strict=false);
86
87 // the main parse function
88 void parse(librevenge::RVNGTextInterface *documentInterface);
89
90 protected:
92 void init();
93
94 //
95 // interface
96 //
97
99 shared_ptr<RagTime5ClusterManager> getClusterManager();
101 shared_ptr<RagTime5StructManager> getStructManager();
102
104 bool readChartCluster(RagTime5Zone &zone, int zoneType);
106 bool readGraphicCluster(RagTime5Zone &zone, int zoneType);
108 bool readPictureCluster(RagTime5Zone &zone, int zoneType);
110 bool readSpreadsheetCluster(RagTime5Zone &zone, int zoneType);
112 bool readTextCluster(RagTime5Zone &zone, int zoneType);
113
115 void createDocument(librevenge::RVNGTextInterface *documentInterface);
117 bool sendZones();
118
120 void newPage(int number);
121
123 bool createZones();
125 bool findDataZones(MWAWEntry const &entry);
127 shared_ptr<RagTime5Zone> getDataZone(int dataId) const;
129 bool update(RagTime5Zone &zone);
131 bool readZoneData(RagTime5Zone &zone);
133 bool unpackZone(RagTime5Zone &zone, MWAWEntry const &entry, std::vector<unsigned char> &data);
135 bool unpackZone(RagTime5Zone &zone);
136
138 bool readClusterZones();
140 bool readClusterZone(RagTime5Zone &zone, int type=-1);
142 bool readClusterLinkList(RagTime5Zone &zone,
143 RagTime5ClusterManager::Link const &link);
145 bool readClusterLinkList(RagTime5ClusterManager::Link const &link,
146 RagTime5ClusterManager::Link const &nameLink,
147 std::vector<int> &list, std::string const &name="");
148
150 bool readString(RagTime5Zone &zone, std::string &string);
152 bool readUnicodeString(RagTime5Zone &zone);
154 bool readLongListWithSize(int dataId, int fSz, std::vector<long> &list, std::string const &zoneName="");
156 bool readPositions(int posId, std::vector<long> &listPosition);
158 bool readLongList(RagTime5ClusterManager::Link const &link, std::vector<long> &list);
160 bool readUnicodeStringList(RagTime5ClusterManager::Link const &link, std::map<int, librevenge::RVNGString> &idToStringMap);
161
163 bool readDocumentVersion(RagTime5Zone &zone);
165 bool readClusterRootData(RagTime5ClusterManager::ClusterRoot &cluster);
167 bool readFormats(RagTime5ClusterManager::Cluster &cluster);
169 bool readClusterFieldsData(RagTime5ClusterManager::Cluster &cluster);
171 bool readClusterLayoutData(RagTime5ClusterManager::ClusterLayout &cluster);
173 bool readClusterPipelineData(RagTime5ClusterManager::Cluster &cluster);
175 bool readDocInfoClusterData(RagTime5Zone &zone, MWAWEntry const &entry);
177 bool readClusterScriptData(RagTime5ClusterManager::ClusterScript &cluster);
179 bool readUnknownClusterBData(RagTime5ClusterManager::Cluster &cluster);
181 bool readUnknownClusterCData(RagTime5ClusterManager::Cluster &cluster);
182
184 bool readStructZone(RagTime5ClusterManager::Cluster &cluster, RagTime5StructManager::FieldParser &parser, int headerSz);
186 bool readStructData(RagTime5Zone &zone, long endPos, int n, int headerSz,
187 RagTime5StructManager::FieldParser &parser, librevenge::RVNGString const &dataName);
189 bool readStructMainZone(RagTime5Zone &zone);
190
192 bool readListZone(RagTime5ClusterManager::Link const &link);
194 bool readListZone(RagTime5ClusterManager::Link const &link, RagTime5StructManager::DataParser &parser);
196 bool readFixedSizeZone(RagTime5ClusterManager::Link const &link, std::string const &name);
198 bool readFixedSizeZone(RagTime5ClusterManager::Link const &link, RagTime5StructManager::DataParser &parser);
199
201 bool checkClusterList(std::vector<int> const &list);
203 void flushExtra();
204
205 protected:
206
207 //
208 // data
209 //
211 shared_ptr<RagTime5ParserInternal::State> m_state;
213 shared_ptr<RagTime5Graph> m_graphParser;
215 shared_ptr<RagTime5Spreadsheet> m_spreadsheetParser;
217 shared_ptr<RagTime5Text> m_textParser;
219 shared_ptr<RagTime5StructManager> m_structManager;
221 shared_ptr<RagTime5ClusterManager> m_clusterManager;
222 };
223 #endif
224 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
RagTime5Parser::m_textParser
shared_ptr< RagTime5Text > m_textParser
the text manager
Definition: RagTime5Parser.hxx:217
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
RagTime5Parser::m_graphParser
shared_ptr< RagTime5Graph > m_graphParser
the graph manager
Definition: RagTime5Parser.hxx:213
RagTime5Parser::readSpreadsheetCluster
bool readSpreadsheetCluster(RagTime5Zone &zone, int zoneType)
try to read a spreadsheet cluster (via the spreadsheet manager)
Definition: RagTime5Parser.cxx:335
RagTime5ParserInternal::DocInfoFieldParser
Internal: the helper to read doc info parse.
Definition: RagTime5Parser.cxx:69
RagTime5Parser::readUnknownClusterBData
bool readUnknownClusterBData(RagTime5ClusterManager::Cluster &cluster)
try to read the unknown clusterB data
Definition: RagTime5Parser.cxx:1501
RagTime5Parser::readChartCluster
bool readChartCluster(RagTime5Zone &zone, int zoneType)
try to read a chart cluster (via the spreadsheet manager)
Definition: RagTime5Parser.cxx:320
RagTime5Parser::readFormats
bool readFormats(RagTime5ClusterManager::Cluster &cluster)
try to read the list of format
Definition: RagTime5Parser.cxx:1162
RagTime5Parser::parse
void parse(librevenge::RVNGTextInterface *documentInterface)
virtual function used to parse the input
Definition: RagTime5Parser.cxx:371
MWAWParser.hxx
RagTime5Parser::init
void init()
inits all internal variables
Definition: RagTime5Parser.cxx:294
RagTime5Parser::readClusterPipelineData
bool readClusterPipelineData(RagTime5ClusterManager::Cluster &cluster)
try to read the pipeline cluster data
Definition: RagTime5Parser.cxx:1451
RagTime5Parser::RagTime5Parser
RagTime5Parser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: RagTime5Parser.cxx:284
RagTime5Parser::readGraphicCluster
bool readGraphicCluster(RagTime5Zone &zone, int zoneType)
try to read a graphic cluster (via the graphic manager)
Definition: RagTime5Parser.cxx:325
RagTime5Parser::readListZone
bool readListZone(RagTime5ClusterManager::Link const &link)
try to read a list zone
Definition: RagTime5Parser.cxx:1574
RagTime5Parser::readUnknownClusterCData
bool readUnknownClusterCData(RagTime5ClusterManager::Cluster &cluster)
try to read the unknown clusterC data
Definition: RagTime5Parser.cxx:1539
RagTime5Parser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: RagTime5Parser.cxx:400
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:1956
RagTime5Parser::readClusterZones
bool readClusterZones()
try to read the different cluster zones
Definition: RagTime5Parser.cxx:798
RagTime5StructManager.hxx
RagTime5ClusterManager::ClusterScript
the cluster script ( 2/a/4002/400a zone)
Definition: RagTime5ClusterManager.hxx:305
RagTime5Graph
the main class to read the graphic part of RagTime 56 file
Definition: RagTime5Graph.hxx:75
RagTime5Parser::checkClusterList
bool checkClusterList(std::vector< int > const &list)
check a cluster list
Definition: RagTime5Parser.cxx:985
RagTime5Parser::readClusterFieldsData
bool readClusterFieldsData(RagTime5ClusterManager::Cluster &cluster)
try to read the field data
Definition: RagTime5Parser.cxx:1238
RagTime5Parser::readStructZone
bool readStructZone(RagTime5ClusterManager::Cluster &cluster, RagTime5StructManager::FieldParser &parser, int headerSz)
try to read a structured zone
Definition: RagTime5Parser.cxx:1717
RagTime5Parser::readDocumentVersion
bool readDocumentVersion(RagTime5Zone &zone)
try to read the document version zone
Definition: RagTime5Parser.cxx:2155
RagTime5Parser::m_clusterManager
shared_ptr< RagTime5ClusterManager > m_clusterManager
the cluster manager
Definition: RagTime5Parser.hxx:221
RagTime5StructManager::FieldParser
virtual class use to parse the field data
Definition: RagTime5StructManager.hxx:268
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:1867
RagTime5Parser::readClusterLinkList
bool readClusterLinkList(RagTime5Zone &zone, RagTime5ClusterManager::Link const &link)
try to read a cluster link zone
Definition: RagTime5Parser.cxx:1088
RagTime5Zone
main zone in a RagTime v5-v6 document
Definition: RagTime5StructManager.hxx:48
RagTime5ClusterManager::ClusterLayout
the layout cluster ( 4001 zone)
Definition: RagTime5ClusterManager.hxx:252
RagTime5ClusterManager::ClusterRoot
the cluster for root
Definition: RagTime5ClusterManager.hxx:268
RagTime5ParserInternal
Internal: the structures of a RagTime5Parser.
Definition: RagTime5Parser.cxx:66
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:732
RagTime5Parser::readStructMainZone
bool readStructMainZone(RagTime5Zone &zone)
try to read a main structured zone (unknown content)
Definition: RagTime5Parser.cxx:1813
RagTime5Parser::unpackZone
bool unpackZone(RagTime5Zone &zone, MWAWEntry const &entry, std::vector< unsigned char > &data)
try to unpack a zone
Definition: RagTime5Parser.cxx:2012
RagTime5ParserInternal::SubDocument
Internal: the subdocument of a RagTime5Parser.
Definition: RagTime5Parser.cxx:232
RagTime5Spreadsheet
the main class to read the spreadsheet part of RagTime 56 file
Definition: RagTime5Spreadsheet.hxx:73
RagTime5Parser::readClusterRootData
bool readClusterRootData(RagTime5ClusterManager::ClusterRoot &cluster)
try to read the main cluster
Definition: RagTime5Parser.cxx:840
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:449
RagTime5StructManager::DataParser
virtual class use to parse the unstructured data
Definition: RagTime5StructManager.hxx:301
RagTime5Parser::readPictureCluster
bool readPictureCluster(RagTime5Zone &zone, int zoneType)
try to read a picture cluster (via the graphic manager)
Definition: RagTime5Parser.cxx:330
RagTime5Parser::m_spreadsheetParser
shared_ptr< RagTime5Spreadsheet > m_spreadsheetParser
the spreadsheet manager
Definition: RagTime5Parser.hxx:215
RagTime5Parser::readDocInfoClusterData
bool readDocInfoClusterData(RagTime5Zone &zone, MWAWEntry const &entry)
try to read the main doc info cluster data
Definition: RagTime5Parser.cxx:1251
RagTime5Parser::findDataZones
bool findDataZones(MWAWEntry const &entry)
try to create the main data zones list
Definition: RagTime5Parser.cxx:2207
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:1000
RagTime5Parser::readTextCluster
bool readTextCluster(RagTime5Zone &zone, int zoneType)
try to read a text cluster (via the text manager)
Definition: RagTime5Parser.cxx:340
RagTime5Parser::newPage
void newPage(int number)
adds a new page
Definition: RagTime5Parser.cxx:355
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:284
RagTime5Parser::readFixedSizeZone
bool readFixedSizeZone(RagTime5ClusterManager::Link const &link, std::string const &name)
try to read a fixed size zone
Definition: RagTime5Parser.cxx:1648
RagTime5Parser
the main class to read a RagTime v5 file
Definition: RagTime5Parser.hxx:69
RagTime5Text
the main class to read the text part of RagTime 56 file
Definition: RagTime5Text.hxx:73
RagTime5Parser::getDataZone
shared_ptr< RagTime5Zone > getDataZone(int dataId) const
returns the zone corresponding to a data id (or 0)
Definition: RagTime5Parser.cxx:345
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:439
RagTime5Parser::readPositions
bool readPositions(int posId, std::vector< long > &listPosition)
try to read a positions zone in data
Definition: RagTime5Parser.cxx:790
RagTime5Parser::readUnicodeString
bool readUnicodeString(RagTime5Zone &zone)
try to read a unicode string zone
Definition: RagTime5Parser.cxx:709
MWAWInputStream.hxx
MWAWDebug.hxx
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:741
RagTime5Parser::readZoneData
bool readZoneData(RagTime5Zone &zone)
try to read the zone data
Definition: RagTime5Parser.cxx:601
RagTime5Parser::readClusterScriptData
bool readClusterScriptData(RagTime5ClusterManager::ClusterScript &cluster)
try to read the unknown clusterA data
Definition: RagTime5Parser.cxx:1470
RagTime5Parser::createZones
bool createZones()
finds the different objects zones
Definition: RagTime5Parser.cxx:432
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:679
RagTime5Parser::m_structManager
shared_ptr< RagTime5StructManager > m_structManager
the structure manager
Definition: RagTime5Parser.hxx:219
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:158
RagTime5Parser::getStructManager
shared_ptr< RagTime5StructManager > getStructManager()
returns the structure manager
Definition: RagTime5Parser.cxx:315
RagTime5Parser::~RagTime5Parser
virtual ~RagTime5Parser()
destructor
Definition: RagTime5Parser.cxx:290
RagTime5Parser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: RagTime5Parser.cxx:2368
RagTime5Parser::getClusterManager
shared_ptr< RagTime5ClusterManager > getClusterManager()
returns the cluster manager
Definition: RagTime5Parser.cxx:310
RagTime5ClusterManager.hxx
RagTime5Parser::flushExtra
void flushExtra()
flush unsent zone (debugging function)
Definition: RagTime5Parser.cxx:2439
RagTime5Parser::sendZones
bool sendZones()
try to send the different zones
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:781
RagTime5Parser::m_state
shared_ptr< RagTime5ParserInternal::State > m_state
the state
Definition: RagTime5Parser.hxx:211
RagTime5Parser::readClusterLayoutData
bool readClusterLayoutData(RagTime5ClusterManager::ClusterLayout &cluster)
try to read the layout cluster (type 4001)
Definition: RagTime5Parser.cxx:1404
RagTime5ClusterManager::Link
a link to a small zone (or set of zones) in RagTime 5/6 documents
Definition: RagTime5ClusterManager.hxx:100
RagTime5ClusterManager::Cluster
the cluster data
Definition: RagTime5ClusterManager.hxx:209