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  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:
an interface to transmit the info of MWProStructures to a listener
Definition: MWProStructures.hxx:72
Internal: the subdocument of a MWProParser.
Definition: MWProParser.cxx:233
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
the main class to read the structures part of MacWrite Pro file
Definition: MWProStructures.hxx:153
MWProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: MWProParser.cxx:296
bool sendTextZone(int blockId, bool mainZone=false)
send a text box
Definition: MWProParser.cxx:1372
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: MWProParser.cxx:645
shared_ptr< MWProStructures > m_structures
the structures parser
Definition: MWProParser.hxx:191
bool sendText(shared_ptr< MWProParserInternal::TextZone > zone, bool mainZone=false)
try to send a text
Definition: MWProParser.cxx:1421
std::vector< int > const & getBlocksCalledByToken() const
return the list of blockid called by token.
Definition: MWProParser.cxx:349
bool parseTextZone(shared_ptr< MWProParserInternal::Zone > zone)
parse a text zone
Definition: MWProParser.cxx:996
bool readTextIds(shared_ptr< MWProParserInternal::Zone > zone, std::vector< MWProParserInternal::TextZoneData > &res, int textLength, int type)
try to read the text id entries
Definition: MWProParser.cxx:1121
void newPage(int number, bool softBreak=false)
adds a new page
Definition: MWProParser.cxx:330
bool sendEmptyFrameZone(MWAWPosition const &pos, WPXPropertyList extras)
try to send an empty zone (can exist in MWPro1.5)
Definition: MWProParser.cxx:1323
bool getZoneData(WPXBinaryData &data, int blockId)
retrieve the data which corresponds to a zone
Definition: MWProParser.cxx:409
the main class to read a MacWrite II and MacWrite Pro file
Definition: MWProParser.hxx:68
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:354
int numColumns() const
returns the document number of columns ( filed in MWII)
Definition: MWProParser.cxx:321
bool createZones()
finds the different objects zones
Definition: MWProParser.cxx:614
void checkUnparsed()
a debug function which can be used to save the unparsed block
Definition: MWProParser.cxx:1772
bool sendPictureZone(int blockId, MWAWPosition const &pictPos, WPXPropertyList extras=WPXPropertyList())
try to send a picture
Definition: MWProParser.cxx:1611
bool readDocHeader()
try to read the doc header zone
Definition: MWProParser.cxx:780
bool getFreeZoneList(int blockId, std::vector< int > &blockLists)
return the chain list of block ( used to get free blocks)
Definition: MWProParser.cxx:489
int findNumHardBreaks(int blockId)
compute the number of hard page break
Definition: MWProParser.cxx:1336
shared_ptr< MWProParserInternal::State > m_state
the state
Definition: MWProParser.hxx:188
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:348
bool parseDataZone(int blockId, int type)
parse a data zone
Definition: MWProParser.cxx:953
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: MWProParser.cxx:358
void init()
inits all internal variables
Definition: MWProParser.cxx:306
bool readTextEntries(shared_ptr< MWProParserInternal::Zone > zone, std::vector< MWAWEntry > &res, int textLength)
try to read the text block entries
Definition: MWProParser.cxx:1046
bool sendPicture(shared_ptr< MWProParserInternal::Zone > zone, MWAWPosition pictPos, WPXPropertyList const &extras)
try to send a picture
Definition: MWProParser.cxx:1624
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:89
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
bool sendTextBoxZone(int blockId, MWAWPosition const &pos, WPXPropertyList extras=WPXPropertyList())
send a textbox zone
Definition: MWProParser.cxx:1384
bool readPrintInfo()
read the print info zone
Definition: MWProParser.cxx:727
virtual ~MWProParser()
destructor
Definition: MWProParser.cxx:302
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MWProParser.cxx:544
float pageHeight() const
returns the page height, ie. paper size less margin (in inches)
bool readTextTokens(shared_ptr< MWProParserInternal::Zone > zone, std::vector< MWProParserInternal::Token > &res, int textLength)
try to read the text token entries
Definition: MWProParser.cxx:1185

Generated on Tue Mar 10 2015 17:32:09 for libmwaw by doxygen 1.8.5