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 namespace MWProParserInternal
51 {
52 struct State;
53 struct TextZoneData;
54 struct TextZone;
55 struct Token;
56 struct Zone;
57 class SubDocument;
58 }
59 
60 class MWProStructures;
62 
68 class MWProParser : public MWAWParser
69 {
70  friend class MWProStructures;
73 
74 public:
76  MWProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
78  virtual ~MWProParser();
79 
81  bool checkHeader(MWAWHeader *header, bool strict=false);
82 
83  // the main parse function
84  void parse(WPXDocumentInterface *documentInterface);
85 
86 protected:
88  void init();
89 
91  void createDocument(WPXDocumentInterface *documentInterface);
92 
94  bool createZones();
95 
97  bool getZoneData(WPXBinaryData &data, int blockId);
98 
100  bool getFreeZoneList(int blockId, std::vector<int> &blockLists);
101 
106  bool parseDataZone(int blockId, int type);
107 
109  bool parseTextZone(shared_ptr<MWProParserInternal::Zone> zone);
110 
112  bool readTextEntries(shared_ptr<MWProParserInternal::Zone> zone,
113  std::vector<MWAWEntry> &res, int textLength);
115  bool readTextIds(shared_ptr<MWProParserInternal::Zone> zone,
116  std::vector<MWProParserInternal::TextZoneData> &res,
117  int textLength, int type);
119  bool readTextTokens(shared_ptr<MWProParserInternal::Zone> zone,
120  std::vector<MWProParserInternal::Token> &res,
121  int textLength);
122 
125  std::vector<int> const &getBlocksCalledByToken() const;
126 
128  float pageHeight() const;
130  int numColumns() const;
131 
133  void newPage(int number, bool softBreak=false);
134 
135  //
136  // interface with MWProParserStructures
137  //
138 
140  bool sendTextZone(int blockId, bool mainZone = false);
141 
143  int findNumHardBreaks(int blockId);
144 
146  bool sendPictureZone(int blockId, MWAWPosition const &pictPos,
147  WPXPropertyList extras = WPXPropertyList());
148 
150  bool sendTextBoxZone(int blockId, MWAWPosition const &pos,
151  WPXPropertyList extras = WPXPropertyList());
152 
154  bool sendEmptyFrameZone(MWAWPosition const &pos, WPXPropertyList extras);
155 
156  //
157  // low level
158  //
159 
161  bool readPrintInfo();
162 
164  bool readDocHeader();
165 
166 #ifdef DEBUG
167 
168  void saveOriginal(MWAWInputStreamPtr input);
169 #endif
170 
172  bool sendPicture(shared_ptr<MWProParserInternal::Zone> zone, MWAWPosition pictPos, WPXPropertyList const &extras);
173 
175  bool sendText(shared_ptr<MWProParserInternal::TextZone> zone, bool mainZone = false);
176 
178  int findNumHardBreaks(shared_ptr<MWProParserInternal::TextZone> zone);
179 
181  void checkUnparsed();
182 
183 protected:
184  //
185  // data
186  //
188  shared_ptr<MWProParserInternal::State> m_state;
189 
191  shared_ptr<MWProStructures> m_structures;
192 };
193 #endif
194 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Tue May 6 2014 09:50:49 for libmwaw by doxygen 1.8.3.1