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  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:
an interface to transmit the info of MWProStructures to a listener
Definition: MWProStructures.hxx:76
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:49
the main class to read the structures part of MacWrite Pro file
Definition: MWProStructures.hxx:157
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:1369
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
Definition: ACText.hxx:44
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:193
bool sendText(shared_ptr< MWProParserInternal::TextZone > zone, bool mainZone=false)
try to send a text
Definition: MWProParser.cxx:1418
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:993
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:1118
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:1320
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:70
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:1608
bool readDocHeader()
try to read the doc header zone
Definition: MWProParser.cxx:772
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:1333
shared_ptr< MWProParserInternal::State > m_state
the state
Definition: MWProParser.hxx:190
bool parseDataZone(int blockId, int type)
parse a data zone
Definition: MWProParser.cxx:945
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:1043
bool sendPicture(shared_ptr< MWProParserInternal::Zone > zone, MWAWPosition pictPos, WPXPropertyList const &extras)
try to send a picture
Definition: MWProParser.cxx:1621
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:98
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:1381
bool readPrintInfo()
read the print info zone
Definition: MWProParser.cxx:719
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:1182
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
Definition: MWAWParser.hxx:56

Generated for libmwaw by doxygen 1.8.5