CWParser.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 /*
35  * Parser to Claris Works text document
36  *
37  */
38 #ifndef CW_MWAW_PARSER
39 # define CW_MWAW_PARSER
40 
41 #include <set>
42 #include <string>
43 #include <vector>
44 
45 #include <libwpd/libwpd.h>
46 
47 #include "MWAWEntry.hxx"
48 #include "MWAWPosition.hxx"
49 
50 #include "MWAWParser.hxx"
51 
52 #include "CWStruct.hxx"
53 
54 namespace CWParserInternal
55 {
56 struct State;
57 class SubDocument;
58 }
59 
60 class CWDatabase;
61 class CWGraph;
62 class CWPresentation;
63 class CWSpreadsheet;
64 class CWStyleManager;
65 class CWTable;
66 class CWText;
67 
73 class CWParser : public MWAWParser
74 {
76  friend class CWDatabase;
77  friend class CWGraph;
78  friend class CWPresentation;
79  friend class CWSpreadsheet;
80  friend class CWStyleManager;
81  friend class CWTable;
82  friend class CWText;
83 
84 public:
86  CWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
88  virtual ~CWParser();
89 
91  bool checkHeader(MWAWHeader *header, bool strict=false);
92 
93  // the main parse function
94  void parse(WPXDocumentInterface *documentInterface);
95 
96 protected:
98  void init();
99 
101  void createDocument(WPXDocumentInterface *documentInterface);
102 
104  bool createZones();
105 
107  shared_ptr<CWStruct::DSET> getZone(int zId) const;
108 
110  bool exploreZonesGraph();
112  bool exploreZonesGraphRec(int zId, std::set<int> &notDoneList);
113 
115  void typeMainZones();
116 
118  int typeMainZonesRec(int zId, CWStruct::DSET::Type type, int maxHeight);
119 
121  bool readZone();
122 
124  bool readPrintInfo();
125 
127  bool readStructZone(char const *zoneName, bool hasEntete);
128 
131  bool readStructIntZone(char const *zoneName, bool hasEntete, int fSz, std::vector<int> &res);
132 
134  Vec2i getDocumentPages() const;
136  double getTextHeight() const;
138  Vec2f getPageLeftTop() const;
140  void newPage(int number);
141 
142  //
143  // interface with the text parser
144  //
145 
147  bool canSendZoneAsGraphic(int number) const;
149  bool sendZone(int zoneId, bool asGraphic, MWAWPosition pos=MWAWPosition());
151  void forceParsed(int zoneId);
152 
154  void sendFootnote(int zoneId);
155 
157  MWAWSection getMainSection() const;
158 
159  //
160  // interface with the graph parser
161  //
162 
164  void getHeaderFooterId(int &headerId, int &footerId) const;
165 
166  //
167  // low level
168  //
169 
171  bool readDocHeader();
172 
174  bool readDocInfo();
175 
177  bool readEndTable();
178 
182  shared_ptr<CWStruct::DSET> readDSET(bool &complete);
183 
184  // THE NAMED ENTRY
185 
186  /* read the document summary */
187  bool readDSUM(MWAWEntry const &entry, bool inHeader);
188 
189  /* read the temporary file name ? */
190  bool readTNAM(MWAWEntry const &entry);
191 
192  /* SNAP (in v6) : size[4]/size[2] picture... */
193  bool readSNAP(MWAWEntry const &entry);
194 
195  /* sequence of plist of printer : in v6
196  */
197  bool readCPRT(MWAWEntry const &entry);
198 
200  void checkOrdering(std::vector<int16_t> &vec16, std::vector<int32_t> &vec32) const;
201 
202 protected:
203 
204 
205  //
206  // data
207  //
209  shared_ptr<CWParserInternal::State> m_state;
210 
213 
215  shared_ptr<CWDatabase> m_databaseParser;
216 
218  shared_ptr<CWGraph> m_graphParser;
219 
221  shared_ptr<CWPresentation> m_presentationParser;
222 
224  shared_ptr<CWSpreadsheet> m_spreadsheetParser;
225 
227  shared_ptr<CWStyleManager> m_styleManager;
228 
230  shared_ptr<CWTable> m_tableParser;
231 
233  shared_ptr<CWText> m_textParser;
234 };
235 #endif
236 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
bool readStructIntZone(char const *zoneName, bool hasEntete, int fSz, std::vector< int > &res)
try to read a int structured zone where fSz to the int size: 1(int8), 2(int16), 4(int32) ...
Definition: CWParser.cxx:1312
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
void getHeaderFooterId(int &headerId, int &footerId) const
returns the header/footer id
Definition: CWParser.cxx:219
bool readDSUM(MWAWEntry const &entry, bool inHeader)
Definition: CWParser.cxx:1440
a structure to store the style list and the lookup zone
Definition: CWStyleManager.hxx:59
shared_ptr< CWStruct::DSET > readDSET(bool &complete)
reads the zone DSET
Definition: CWParser.cxx:1116
bool readPrintInfo()
read the print info zone
Definition: CWParser.cxx:2012
CWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: CWParser.cxx:159
Internal: the subdocument of a CWParser.
Definition: CWParser.cxx:104
bool createZones()
finds the different objects zones
Definition: CWParser.cxx:493
the main class to read the text part of Claris Works file
Definition: CWSpreadsheet.hxx:70
void checkOrdering(std::vector< int16_t > &vec16, std::vector< int32_t > &vec32) const
small fonction used to check unusual endian ordering of a list of int16_t, int32_t ...
Definition: CWParser.cxx:225
bool readCPRT(MWAWEntry const &entry)
Definition: CWParser.cxx:1533
the main class to read the text part of Claris Works file
Definition: CWText.hxx:75
void typeMainZones()
try to type the main zones
Definition: CWParser.cxx:584
the main class to read the text part of Claris Works file
Definition: CWTable.hxx:69
shared_ptr< CWGraph > m_graphParser
the graph parser
Definition: CWParser.hxx:218
shared_ptr< CWDatabase > m_databaseParser
the database parser
Definition: CWParser.hxx:215
bool readEndTable()
reads the end table ( appears in v3.0 : file version ? )
Definition: CWParser.cxx:798
the main class to read the graphic part of Claris Works file
Definition: CWGraph.hxx:75
Type
the document type
Definition: CWStruct.hxx:59
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: CWParser.cxx:390
the main class to read the text part of Claris Works file
Definition: CWDatabase.hxx:70
bool readDocInfo()
reads the document info part ( end of the header)
Definition: CWParser.cxx:1941
void newPage(int number)
adds a new page
Definition: CWParser.cxx:259
Vec2i getDocumentPages() const
returns the number of expected pages ( accross pages x down page)
Definition: CWParser.cxx:194
bool exploreZonesGraph()
try to find the zone dags structure...
Definition: CWParser.cxx:669
shared_ptr< CWStruct::DSET > getZone(int zId) const
return the zone corresponding to an id ( low level)
Definition: CWParser.cxx:210
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:354
MWAWSection getMainSection() const
returns the columns information
Definition: CWParser.cxx:339
Vec2f getPageLeftTop() const
returns the page left top point ( in inches)
Definition: CWParser.cxx:204
bool readStructZone(char const *zoneName, bool hasEntete)
try to read a structured zone
Definition: CWParser.cxx:1249
the main class to read the text part of Claris Works file
Definition: CWPresentation.hxx:67
void sendFootnote(int zoneId)
creates a document to send a footnote
Definition: CWParser.cxx:371
shared_ptr< CWPresentation > m_presentationParser
the spreadsheet parser
Definition: CWParser.hxx:221
int typeMainZonesRec(int zId, CWStruct::DSET::Type type, int maxHeight)
try to type the main zones recursif, returns the father id
Definition: CWParser.cxx:641
shared_ptr< CWTable > m_tableParser
the table parser
Definition: CWParser.hxx:230
shared_ptr< CWSpreadsheet > m_spreadsheetParser
the spreadsheet parser
Definition: CWParser.hxx:224
void init()
inits all internal variables
Definition: CWParser.cxx:171
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: CWParser.cxx:1010
bool sendZone(int zoneId, bool asGraphic, MWAWPosition pos=MWAWPosition())
send a zone
Definition: CWParser.cxx:297
the main class to read a Claris Works file
Definition: CWParser.hxx:73
a class which stores section properties
Definition: MWAWSection.hxx:45
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:348
bool readTNAM(MWAWEntry const &entry)
Definition: CWParser.cxx:1489
virtual ~CWParser()
destructor
Definition: CWParser.cxx:167
shared_ptr< CWParserInternal::State > m_state
the state
Definition: CWParser.hxx:209
bool exploreZonesGraphRec(int zId, std::set< int > &notDoneList)
try to find the zone tree graph ( DSF) function
Definition: CWParser.cxx:757
shared_ptr< CWStyleManager > m_styleManager
the style manager
Definition: CWParser.hxx:227
bool readSNAP(MWAWEntry const &entry)
Definition: CWParser.cxx:1385
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: CWParser.cxx:434
bool readZone()
read a zone
Definition: CWParser.cxx:895
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:89
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
bool m_pageSpanSet
a flag to know if pageSpan is filled
Definition: CWParser.hxx:212
bool canSendZoneAsGraphic(int number) const
check if we can send a zone as a graphic
Definition: CWParser.cxx:275
double getTextHeight() const
returns the page height, ie. paper size less margin (in inches) less header/footer size ...
Definition: CWParser.cxx:199
bool readDocHeader()
reads the document header
Definition: CWParser.cxx:1585
shared_ptr< CWText > m_textParser
the text parser
Definition: CWParser.hxx:233
void forceParsed(int zoneId)
indicate that a zone is already parsed
Definition: CWParser.cxx:379

Generated on Tue Mar 10 2015 17:32:08 for libmwaw by doxygen 1.8.5