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 "MWAWPageSpan.hxx"
43 
44 #include "MWAWEntry.hxx"
45 #include "MWAWSubDocument.hxx"
46 
47 #include "MWAWDebug.hxx"
48 #include "MWAWInputStream.hxx"
49 
50 #include "MWAWParser.hxx"
51 
52 class WPXBinaryData;
53 
54 class MWAWPosition;
55 
56 namespace MWProParserInternal
57 {
58 struct State;
59 struct TextZoneData;
60 struct TextZone;
61 struct Token;
62 struct Zone;
63 class SubDocument;
64 }
65 
66 class MWProStructures;
68 
74 class MWProParser : public MWAWParser
75 {
76  friend class MWProStructures;
79 
80 public:
82  MWProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
84  virtual ~MWProParser();
85 
87  bool checkHeader(MWAWHeader *header, bool strict=false);
88 
89  // the main parse function
90  void parse(WPXDocumentInterface *documentInterface);
91 
92 protected:
94  void init();
95 
97  void createDocument(WPXDocumentInterface *documentInterface);
98 
100  bool createZones();
101 
103  bool getZoneData(WPXBinaryData &data, int blockId);
104 
106  bool getFreeZoneList(int blockId, std::vector<int> &blockLists);
107 
112  bool parseDataZone(int blockId, int type);
113 
115  bool parseTextZone(shared_ptr<MWProParserInternal::Zone> zone);
116 
118  bool readTextEntries(shared_ptr<MWProParserInternal::Zone> zone,
119  std::vector<MWAWEntry> &res, int textLength);
121  bool readTextIds(shared_ptr<MWProParserInternal::Zone> zone,
122  std::vector<MWProParserInternal::TextZoneData> &res,
123  int textLength, int type);
125  bool readTextTokens(shared_ptr<MWProParserInternal::Zone> zone,
126  std::vector<MWProParserInternal::Token> &res,
127  int textLength);
128 
131  std::vector<int> const &getBlocksCalledByToken() const;
132 
134  float pageHeight() const;
136  float pageWidth() const;
138  int numColumns() const;
139 
141  void newPage(int number, bool softBreak=false);
142 
143  //
144  // interface with MWProParserStructures
145  //
146 
148  bool sendTextZone(int blockId, bool mainZone = false);
149 
151  int findNumHardBreaks(int blockId);
152 
154  bool sendPictureZone(int blockId, MWAWPosition const &pictPos,
155  WPXPropertyList extras = WPXPropertyList());
156 
158  bool sendTextBoxZone(int blockId, MWAWPosition const &pos,
159  WPXPropertyList extras = WPXPropertyList());
160 
162  bool sendEmptyFrameZone(MWAWPosition const &pos, WPXPropertyList extras);
163 
164  //
165  // low level
166  //
167 
169  bool readPrintInfo();
170 
172  bool readDocHeader();
173 
174 #ifdef DEBUG
175 
176  void saveOriginal(MWAWInputStreamPtr input);
177 #endif
178 
180  bool sendPicture(shared_ptr<MWProParserInternal::Zone> zone, MWAWPosition pictPos, WPXPropertyList const &extras);
181 
183  bool sendText(shared_ptr<MWProParserInternal::TextZone> zone, bool mainZone = false);
184 
186  int findNumHardBreaks(shared_ptr<MWProParserInternal::TextZone> zone);
187 
189  void checkUnparsed();
190 
191 protected:
192  //
193  // data
194  //
196  shared_ptr<MWProParserInternal::State> m_state;
197 
199  shared_ptr<MWProStructures> m_structures;
200 
203 };
204 #endif
205 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

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