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:

Generated on Tue Oct 22 2013 08:24:48 for libmwaw by doxygen 1.8.4