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 class MWAWSection;
55 
56 namespace CWParserInternal
57 {
58 struct State;
59 class SubDocument;
60 }
61 
62 class CWDatabase;
63 class CWGraph;
64 class CWPresentation;
65 class CWSpreadsheet;
66 class CWStyleManager;
67 class CWTable;
68 class CWText;
69 
75 class CWParser : public MWAWParser
76 {
78  friend class CWDatabase;
79  friend class CWGraph;
80  friend class CWPresentation;
81  friend class CWSpreadsheet;
82  friend class CWStyleManager;
83  friend class CWTable;
84  friend class CWText;
85 
86 public:
88  CWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
90  virtual ~CWParser();
91 
93  bool checkHeader(MWAWHeader *header, bool strict=false);
94 
95  // the main parse function
96  void parse(WPXDocumentInterface *documentInterface);
97 
98 protected:
100  void init();
101 
103  void createDocument(WPXDocumentInterface *documentInterface);
104 
106  bool createZones();
107 
109  CWStruct::DSET::Type getZoneType(int zId) const;
110 
112  bool exploreZonesGraph();
114  bool exploreZonesGraphRec(int zId, std::set<int> &notDoneList);
115 
117  void typeMainZones();
118 
120  int typeMainZonesRec(int zId, CWStruct::DSET::Type type, int maxHeight);
121 
123  bool readZone();
124 
126  bool readPrintInfo();
127 
129  bool readStructZone(char const *zoneName, bool hasEntete);
130 
133  bool readStructIntZone(char const *zoneName, bool hasEntete, int fSz, std::vector<int> &res);
134 
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 sendZone(int zoneId, MWAWPosition pos=MWAWPosition());
149  void sendZoneInFrame(int zoneId, MWAWPosition pos,
150  WPXPropertyList extras = WPXPropertyList(),
151  WPXPropertyList frameExtras = WPXPropertyList());
153  void forceParsed(int zoneId);
154 
156  void sendFootnote(int zoneId);
157 
159  MWAWSection getMainSection() const;
160 
161  //
162  // interface with the graph parser
163  //
164 
166  bool getColor(int colId, MWAWColor &col) const;
167 
169  float getPatternPercent(int id) const;
170 
172  void getHeaderFooterId(int &headerId, int &footerId) const;
173 
174  //
175  // low level
176  //
177 
179  bool readDocHeader();
180 
182  bool readEndTable();
183 
187  shared_ptr<CWStruct::DSET> readDSET(bool &complete);
188 
189  // THE NAMED ENTRY
190 
191  /* read the document summary */
192  bool readDSUM(MWAWEntry const &entry, bool inHeader);
193 
194  /* read the temporary file name ? */
195  bool readTNAM(MWAWEntry const &entry);
196 
197  /* SNAP (in v6) : size[4]/size[2] picture... */
198  bool readSNAP(MWAWEntry const &entry);
199 
200  /* sequence of plist of printer : in v6
201  */
202  bool readCPRT(MWAWEntry const &entry);
203 
205  void checkOrdering(std::vector<int16_t> &vec16, std::vector<int32_t> &vec32) const;
206 
207 protected:
208 
209 
210  //
211  // data
212  //
214  shared_ptr<CWParserInternal::State> m_state;
215 
218 
220  shared_ptr<CWDatabase> m_databaseParser;
221 
223  shared_ptr<CWGraph> m_graphParser;
224 
226  shared_ptr<CWPresentation> m_presentationParser;
227 
229  shared_ptr<CWSpreadsheet> m_spreadsheetParser;
230 
232  shared_ptr<CWStyleManager> m_styleManager;
233 
235  shared_ptr<CWTable> m_tableParser;
236 
238  shared_ptr<CWText> m_textParser;
239 };
240 #endif
241 // 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:1294
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:49
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:1422
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
Definition: ACText.hxx:44
a structure to store the style list and the lookup zone
Definition: CWStyleManager.hxx:64
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:1095
bool readPrintInfo()
read the print info zone
Definition: CWParser.cxx:1952
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:480
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:73
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:1515
the main class to read the text part of Claris Works file
Definition: CWText.hxx:79
void typeMainZones()
try to type the main zones
Definition: CWParser.cxx:571
the main class to read the text part of Claris Works file
Definition: CWTable.hxx:73
shared_ptr< CWGraph > m_graphParser
the graph parser
Definition: CWParser.hxx:223
shared_ptr< CWDatabase > m_databaseParser
the database parser
Definition: CWParser.hxx:220
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:783
the main class to read the graphic part of Claris Works file
Definition: CWGraph.hxx:77
Type
the document type
Definition: CWStruct.hxx:59
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: CWParser.cxx:386
the main class to read the text part of Claris Works file
Definition: CWDatabase.hxx:73
void newPage(int number)
adds a new page
Definition: CWParser.cxx:269
bool exploreZonesGraph()
try to find the zone dags structure...
Definition: CWParser.cxx:655
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:1228
the main class to read the text part of Claris Works file
Definition: CWPresentation.hxx:70
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:226
int typeMainZonesRec(int zId, CWStruct::DSET::Type type, int maxHeight)
try to type the main zones recursif, returns the father id
Definition: CWParser.cxx:627
shared_ptr< CWTable > m_tableParser
the table parser
Definition: CWParser.hxx:235
shared_ptr< CWSpreadsheet > m_spreadsheetParser
the spreadsheet parser
Definition: CWParser.hxx:229
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:990
the main class to read a Claris Works file
Definition: CWParser.hxx:75
a class which stores section properties
Definition: MWAWSection.hxx:45
bool readTNAM(MWAWEntry const &entry)
Definition: CWParser.cxx:1471
virtual ~CWParser()
destructor
Definition: CWParser.cxx:172
shared_ptr< CWParserInternal::State > m_state
the state
Definition: CWParser.hxx:214
bool exploreZonesGraphRec(int zId, std::set< int > &notDoneList)
try to find the zone tree graph ( DSF) function
Definition: CWParser.cxx:743
shared_ptr< CWStyleManager > m_styleManager
the style manager
Definition: CWParser.hxx:232
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:1367
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: CWParser.cxx:421
bool readZone()
read a zone
Definition: CWParser.cxx:880
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:98
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:217
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:1567
shared_ptr< CWText > m_textParser
the text parser
Definition: CWParser.hxx:238
void forceParsed(int zoneId)
indicate that a zone is already parsed
Definition: CWParser.cxx:375
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
Definition: MWAWParser.hxx:56

Generated for libmwaw by doxygen 1.8.5