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 "MWAWPageSpan.hxx"
48 
49 #include "MWAWPosition.hxx"
50 
51 #include "MWAWEntry.hxx"
52 #include "MWAWSubDocument.hxx"
53 
54 #include "MWAWDebug.hxx"
55 #include "MWAWInputStream.hxx"
56 
57 #include "MWAWParser.hxx"
58 
59 #include "CWStruct.hxx"
60 
61 namespace CWParserInternal
62 {
63 struct State;
64 class SubDocument;
65 }
66 
67 class CWDatabase;
68 class CWGraph;
69 class CWPresentation;
70 class CWSpreadsheet;
71 class CWStyleManager;
72 class CWTable;
73 class CWText;
74 
80 class CWParser : public MWAWParser
81 {
83  friend class CWDatabase;
84  friend class CWGraph;
85  friend class CWPresentation;
86  friend class CWSpreadsheet;
87  friend class CWStyleManager;
88  friend class CWTable;
89  friend class CWText;
90 
91 public:
93  CWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
95  virtual ~CWParser();
96 
98  bool checkHeader(MWAWHeader *header, bool strict=false);
99 
100  // the main parse function
101  void parse(WPXDocumentInterface *documentInterface);
102 
103 protected:
105  void init();
106 
108  void createDocument(WPXDocumentInterface *documentInterface);
109 
111  bool createZones();
112 
114  CWStruct::DSET::Type getZoneType(int zId) const;
115 
117  bool exploreZonesGraph();
119  bool exploreZonesGraphRec(int zId, std::set<int> &notDoneList);
120 
122  void typeMainZones();
123 
125  int typeMainZonesRec(int zId, CWStruct::DSET::Type type, int maxHeight);
126 
128  bool readZone();
129 
131  bool readPrintInfo();
132 
134  bool readStructZone(char const *zoneName, bool hasEntete);
135 
138  bool readStructIntZone(char const *zoneName, bool hasEntete, int fSz, std::vector<int> &res);
139 
141  float pageHeight() const;
143  float pageWidth() const;
145  Vec2f getPageLeftTop() const;
147  void newPage(int number);
148 
149  //
150  // interface with the text parser
151  //
152 
154  bool sendZone(int zoneId, MWAWPosition pos=MWAWPosition());
156  void sendZoneInFrame(int zoneId, MWAWPosition pos,
157  WPXPropertyList extras = WPXPropertyList(),
158  WPXPropertyList frameExtras = WPXPropertyList());
160  void forceParsed(int zoneId);
161 
163  void sendFootnote(int zoneId);
164 
166  void getColumnInfo(int &numColumns, std::vector<int> &width,
167  std::vector<int> &sepWidth) const;
168 
169  //
170  // interface with the graph parser
171  //
172 
174  bool getColor(int colId, MWAWColor &col) const;
175 
177  float getPatternPercent(int id) const;
178 
180  void getHeaderFooterId(int &headerId, int &footerId) const;
181 
182  //
183  // low level
184  //
185 
187  bool readDocHeader();
188 
190  bool readEndTable();
191 
195  shared_ptr<CWStruct::DSET> readDSET(bool &complete);
196 
197  // THE NAMED ENTRY
198 
199  /* read the document summary */
200  bool readDSUM(MWAWEntry const &entry, bool inHeader);
201 
202  /* read the temporary file name ? */
203  bool readTNAM(MWAWEntry const &entry);
204 
205  /* SNAP (in v6) : size[4]/size[2] picture... */
206  bool readSNAP(MWAWEntry const &entry);
207 
208  /* sequence of plist of printer : in v6
209  */
210  bool readCPRT(MWAWEntry const &entry);
211 
213  void checkOrdering(std::vector<int16_t> &vec16, std::vector<int32_t> &vec32) const;
214 
215 protected:
216 
217 
218  //
219  // data
220  //
222  shared_ptr<CWParserInternal::State> m_state;
223 
226 
229 
231  shared_ptr<CWDatabase> m_databaseParser;
232 
234  shared_ptr<CWGraph> m_graphParser;
235 
237  shared_ptr<CWPresentation> m_presentationParser;
238 
240  shared_ptr<CWSpreadsheet> m_spreadsheetParser;
241 
243  shared_ptr<CWStyleManager> m_styleManager;
244 
246  shared_ptr<CWTable> m_tableParser;
247 
249  shared_ptr<CWText> m_textParser;
250 };
251 #endif
252 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Tue Apr 30 2013 06:31:09 for libmwaw by doxygen 1.8.3.1