MWProParser.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 #ifndef MW_PRO_PARSER
36 # define MW_PRO_PARSER
37 
38 #include <list>
39 #include <string>
40 #include <vector>
41 
42 #include "MWAWDebug.hxx"
43 #include "MWAWEntry.hxx"
44 #include "MWAWInputStream.hxx"
45 
46 #include "MWAWParser.hxx"
47 
48 class WPXBinaryData;
49 
50 class MWAWPosition;
51 
52 namespace MWProParserInternal
53 {
54 struct State;
55 struct TextZoneData;
56 struct TextZone;
57 struct Token;
58 struct Zone;
59 class SubDocument;
60 }
61 
62 class MWProStructures;
64 
70 class MWProParser : public MWAWParser
71 {
72  friend class MWProStructures;
75 
76 public:
78  MWProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
80  virtual ~MWProParser();
81 
83  bool checkHeader(MWAWHeader *header, bool strict=false);
84 
85  // the main parse function
86  void parse(WPXDocumentInterface *documentInterface);
87 
88 protected:
90  void init();
91 
93  void createDocument(WPXDocumentInterface *documentInterface);
94 
96  bool createZones();
97 
99  bool getZoneData(WPXBinaryData &data, int blockId);
100 
102  bool getFreeZoneList(int blockId, std::vector<int> &blockLists);
103 
108  bool parseDataZone(int blockId, int type);
109 
111  bool parseTextZone(shared_ptr<MWProParserInternal::Zone> zone);
112 
114  bool readTextEntries(shared_ptr<MWProParserInternal::Zone> zone,
115  std::vector<MWAWEntry> &res, int textLength);
117  bool readTextIds(shared_ptr<MWProParserInternal::Zone> zone,
118  std::vector<MWProParserInternal::TextZoneData> &res,
119  int textLength, int type);
121  bool readTextTokens(shared_ptr<MWProParserInternal::Zone> zone,
122  std::vector<MWProParserInternal::Token> &res,
123  int textLength);
124 
127  std::vector<int> const &getBlocksCalledByToken() const;
128 
130  float pageHeight() const;
132  int numColumns() const;
133 
135  void newPage(int number, bool softBreak=false);
136 
137  //
138  // interface with MWProParserStructures
139  //
140 
142  bool sendTextZone(int blockId, bool mainZone = false);
143 
145  int findNumHardBreaks(int blockId);
146 
148  bool sendPictureZone(int blockId, MWAWPosition const &pictPos,
149  WPXPropertyList extras = WPXPropertyList());
150 
152  bool sendTextBoxZone(int blockId, MWAWPosition const &pos,
153  WPXPropertyList extras = WPXPropertyList());
154 
156  bool sendEmptyFrameZone(MWAWPosition const &pos, WPXPropertyList extras);
157 
158  //
159  // low level
160  //
161 
163  bool readPrintInfo();
164 
166  bool readDocHeader();
167 
168 #ifdef DEBUG
169 
170  void saveOriginal(MWAWInputStreamPtr input);
171 #endif
172 
174  bool sendPicture(shared_ptr<MWProParserInternal::Zone> zone, MWAWPosition pictPos, WPXPropertyList const &extras);
175 
177  bool sendText(shared_ptr<MWProParserInternal::TextZone> zone, bool mainZone = false);
178 
180  int findNumHardBreaks(shared_ptr<MWProParserInternal::TextZone> zone);
181 
183  void checkUnparsed();
184 
185 protected:
186  //
187  // data
188  //
190  shared_ptr<MWProParserInternal::State> m_state;
191 
193  shared_ptr<MWProStructures> m_structures;
194 };
195 #endif
196 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

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