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  CWStruct::DSET::Type getZoneType(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  double getTextHeight() const;
136  Vec2f getPageLeftTop() const;
138  void newPage(int number);
139 
140  //
141  // interface with the text parser
142  //
143 
145  bool sendZone(int zoneId, MWAWPosition pos=MWAWPosition());
147  void sendZoneInFrame(int zoneId, MWAWPosition pos,
148  WPXPropertyList extras = WPXPropertyList(),
149  WPXPropertyList frameExtras = WPXPropertyList());
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  bool getColor(int colId, MWAWColor &col) const;
165 
167  float getPatternPercent(int id) const;
168 
170  void getHeaderFooterId(int &headerId, int &footerId) const;
171 
172  //
173  // low level
174  //
175 
177  bool readDocHeader();
178 
180  bool readEndTable();
181 
185  shared_ptr<CWStruct::DSET> readDSET(bool &complete);
186 
187  // THE NAMED ENTRY
188 
189  /* read the document summary */
190  bool readDSUM(MWAWEntry const &entry, bool inHeader);
191 
192  /* read the temporary file name ? */
193  bool readTNAM(MWAWEntry const &entry);
194 
195  /* SNAP (in v6) : size[4]/size[2] picture... */
196  bool readSNAP(MWAWEntry const &entry);
197 
198  /* sequence of plist of printer : in v6
199  */
200  bool readCPRT(MWAWEntry const &entry);
201 
203  void checkOrdering(std::vector<int16_t> &vec16, std::vector<int32_t> &vec32) const;
204 
205 protected:
206 
207 
208  //
209  // data
210  //
212  shared_ptr<CWParserInternal::State> m_state;
213 
216 
218  shared_ptr<CWDatabase> m_databaseParser;
219 
221  shared_ptr<CWGraph> m_graphParser;
222 
224  shared_ptr<CWPresentation> m_presentationParser;
225 
227  shared_ptr<CWSpreadsheet> m_spreadsheetParser;
228 
230  shared_ptr<CWStyleManager> m_styleManager;
231 
233  shared_ptr<CWTable> m_tableParser;
234 
236  shared_ptr<CWText> m_textParser;
237 };
238 #endif
239 // 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:1299
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:229
bool readDSUM(MWAWEntry const &entry, bool inHeader)
Definition: CWParser.cxx:1427
a structure to store the style list and the lookup zone
Definition: CWStyleManager.hxx:60
CWStruct::DSET::Type getZoneType(int zId) const
try to return the type of a zone
Definition: CWParser.cxx:220
shared_ptr< CWStruct::DSET > readDSET(bool &complete)
reads the zone DSET
Definition: CWParser.cxx:1100
bool readPrintInfo()
read the print info zone
Definition: CWParser.cxx:1957
CWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: CWParser.cxx:164
bool sendZone(int zoneId, MWAWPosition pos=MWAWPosition())
send a zone
Definition: CWParser.cxx:285
Internal: the subdocument of a CWParser.
Definition: CWParser.cxx:100
bool createZones()
finds the different objects zones
Definition: CWParser.cxx:485
float getPatternPercent(int id) const
return the pattern percent which corresponds to an id (or -1)
Definition: CWParser.cxx:215
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:235
bool readCPRT(MWAWEntry const &entry)
Definition: CWParser.cxx:1520
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:576
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:221
shared_ptr< CWDatabase > m_databaseParser
the database parser
Definition: CWParser.hxx:218
the class to store a color
Definition: libmwaw_internal.hxx:161
bool readEndTable()
reads the end table ( appears in v3.0 : file version ? )
Definition: CWParser.cxx:788
the main class to read the graphic part of Claris Works file
Definition: CWGraph.hxx:72
Type
the document type
Definition: CWStruct.hxx:59
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: CWParser.cxx:391
the main class to read the text part of Claris Works file
Definition: CWDatabase.hxx:70
void newPage(int number)
adds a new page
Definition: CWParser.cxx:269
bool exploreZonesGraph()
try to find the zone dags structure...
Definition: CWParser.cxx:660
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:340
MWAWSection getMainSection() const
returns the columns information
Definition: CWParser.cxx:327
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:1233
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:359
shared_ptr< CWPresentation > m_presentationParser
the spreadsheet parser
Definition: CWParser.hxx:224
int typeMainZonesRec(int zId, CWStruct::DSET::Type type, int maxHeight)
try to type the main zones recursif, returns the father id
Definition: CWParser.cxx:632
shared_ptr< CWTable > m_tableParser
the table parser
Definition: CWParser.hxx:233
shared_ptr< CWSpreadsheet > m_spreadsheetParser
the spreadsheet parser
Definition: CWParser.hxx:227
void init()
inits all internal variables
Definition: CWParser.cxx:176
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: CWParser.cxx:995
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:336
bool readTNAM(MWAWEntry const &entry)
Definition: CWParser.cxx:1476
virtual ~CWParser()
destructor
Definition: CWParser.cxx:172
shared_ptr< CWParserInternal::State > m_state
the state
Definition: CWParser.hxx:212
bool exploreZonesGraphRec(int zId, std::set< int > &notDoneList)
try to find the zone tree graph ( DSF) function
Definition: CWParser.cxx:748
shared_ptr< CWStyleManager > m_styleManager
the style manager
Definition: CWParser.hxx:230
void sendZoneInFrame(int zoneId, MWAWPosition pos, WPXPropertyList extras=WPXPropertyList(), WPXPropertyList frameExtras=WPXPropertyList())
send a zone in a frame
Definition: CWParser.cxx:367
bool readSNAP(MWAWEntry const &entry)
Definition: CWParser.cxx:1372
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: CWParser.cxx:426
bool readZone()
read a zone
Definition: CWParser.cxx:885
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:87
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 getColor(int colId, MWAWColor &col) const
returns the color corresponding to colId (if possible)
Definition: CWParser.cxx:210
bool m_pageSpanSet
a flag to know if pageSpan is filled
Definition: CWParser.hxx:215
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:1572
shared_ptr< CWText > m_textParser
the text parser
Definition: CWParser.hxx:236
void forceParsed(int zoneId)
indicate that a zone is already parsed
Definition: CWParser.cxx:380

Generated on Fri May 2 2014 17:42:20 for libmwaw by doxygen 1.8.5