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:

Generated on Wed May 22 2013 18:12:37 for libmwaw by doxygen 1.8.1.2