FWParser.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  * Parser to convert FullWrite document
36  *
37  */
38 #ifndef FP_MWAW_PARSER
39 # define FP_MWAW_PARSER
40 
41 #include <list>
42 #include <string>
43 #include <vector>
44 
45 #include <libwpd/libwpd.h>
46 
47 #include "MWAWDebug.hxx"
48 #include "MWAWEntry.hxx"
49 #include "MWAWInputStream.hxx"
50 
51 #include "MWAWParser.hxx"
52 
54 struct FWEntry : public MWAWEntry {
56  ~FWEntry();
57 
59  friend std::ostream &operator<<(std::ostream &o, FWEntry const &entry);
60 
62  void update();
64  void closeDebugFile();
65 
69  bool operator==(const FWEntry &a) const;
71  bool operator!=(const FWEntry &a) const {
72  return !operator==(a);
73  }
74 
78  int m_nextId;
80  int m_type;
82  int m_typeId;
84  int m_values[3];
86  WPXBinaryData m_data;
88  shared_ptr<libmwaw::DebugFile> m_asciiFile;
89 private:
90  FWEntry(FWEntry const &);
91  FWEntry &operator=(FWEntry const &);
92 };
93 
94 namespace FWParserInternal
95 {
96 struct DocZoneData;
97 struct State;
98 class SubDocument;
99 }
100 
101 class FWText;
102 
108 class FWParser : public MWAWParser
109 {
110  friend class FWText;
112 
113 public:
115  FWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
117  virtual ~FWParser();
118 
120  bool checkHeader(MWAWHeader *header, bool strict=false);
121 
122  // the main parse function
123  void parse(WPXDocumentInterface *documentInterface);
124 
125 protected:
127  void init();
128 
130  void createDocument(WPXDocumentInterface *documentInterface);
131 
133  bool createZones();
134 
136  bool createFileZones();
137 
139  void flushExtra();
140 
142  void newPage(int number);
143 
145  bool readDocPosition();
146 
148  bool readFileZoneFlags(shared_ptr<FWEntry> zone);
149 
151  bool readFileZonePos(shared_ptr<FWEntry> zone);
152 
154  bool readDocZoneData(shared_ptr<FWEntry> zone);
155 
157  bool readDocZoneStruct(shared_ptr<FWEntry> zone);
159  int getNumDocZoneStruct() const;
161  bool readGraphic(shared_ptr<FWEntry> zone);
162 
164  bool sendGraphic(shared_ptr<FWEntry> zone);
165 
167  bool readDocInfo(shared_ptr<FWEntry> zone);
168 
170  bool readEndDocInfo(shared_ptr<FWEntry> zone);
171 
173  bool readCitationDocInfo(shared_ptr<FWEntry> zone);
174 
176  bool readPrintInfo(shared_ptr<FWEntry> zone);
177 
178  //
179  // interface to the text parser
180  //
181 
185  void sendGraphic(int docId);
187  void sendVariable(int docId);
189  void sendReference(int docId);
191  bool send(int fileId);
192 
193  //
194  // low level
195  //
196 
198  bool readDoc1314Data(shared_ptr<FWEntry> zone, FWParserInternal::DocZoneData &doc);
200  bool readGraphicData(shared_ptr<FWEntry> zone, FWParserInternal::DocZoneData &doc);
202  bool readReferenceData(shared_ptr<FWEntry> zone);
204  bool readDocDataHeader(shared_ptr<FWEntry> zone, FWParserInternal::DocZoneData &doc);
206  bool readGenericDocData(shared_ptr<FWEntry> zone, FWParserInternal::DocZoneData &doc);
207 
208 protected:
209  //
210  // data
211  //
213  shared_ptr<FWParserInternal::State> m_state;
214 
216  shared_ptr<FWText> m_textParser;
217 };
218 #endif
219 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:49
bool readFileZoneFlags(shared_ptr< FWEntry > zone)
try to read the file zones main flags
Definition: FWParser.cxx:1963
bool readGenericDocData(shared_ptr< FWEntry > zone, FWParserInternal::DocZoneData &doc)
try to read the data of a zone which begins with a generic header
Definition: FWParser.cxx:1446
bool createFileZones()
create the file zone ( first step of create zones)
Definition: FWParser.cxx:484
friend std::ostream & operator<<(std::ostream &o, FWEntry const &entry)
operator&lt;&lt;
Definition: FWParser.cxx:2417
int getNumDocZoneStruct() const
returns the number of zone struct
Definition: FWParser.cxx:1222
bool readPrintInfo(shared_ptr< FWEntry > zone)
try read the print info zone
Definition: FWParser.cxx:953
the main class to read a FullWrite file
Definition: FWParser.hxx:108
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
Definition: ACText.hxx:44
bool readDocDataHeader(shared_ptr< FWEntry > zone, FWParserInternal::DocZoneData &doc)
try to read the data header of a classical zone
Definition: FWParser.cxx:1371
bool readCitationDocInfo(shared_ptr< FWEntry > zone)
try to read the list of citation (at the end of doc info)
Definition: FWParser.cxx:888
MWAWInputStreamPtr m_input
the input
Definition: FWParser.hxx:76
bool sendGraphic(shared_ptr< FWEntry > zone)
send a graphic to a listener (if it exists)
Definition: FWParser.cxx:1895
FWEntry & operator=(FWEntry const &)
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:67
int m_nextId
the next entry id
Definition: FWParser.hxx:78
bool readDocZoneStruct(shared_ptr< FWEntry > zone)
try to read the zone which stores the structure of zone0, ... (ie. Zone1)
Definition: FWParser.cxx:1227
~FWEntry()
Definition: FWParser.cxx:2412
shared_ptr< libmwaw::DebugFile > m_asciiFile
the debug file
Definition: FWParser.hxx:88
bool createZones()
finds the different objects zones
Definition: FWParser.cxx:517
SubDocumentType
Definition: libmwaw_internal.hxx:157
void flushExtra()
sends the data which have not yet been sent to the listener
Definition: FWParser.cxx:2392
bool readDoc1314Data(shared_ptr< FWEntry > zone, FWParserInternal::DocZoneData &doc)
try to read the data of zone 13 or 14 (unknown zone)
Definition: FWParser.cxx:1545
int m_typeId
the type id (find in FZoneFlags)
Definition: FWParser.hxx:82
WPXBinaryData m_data
the main data ( if the entry comes from several zone )
Definition: FWParser.hxx:86
libmwaw::DebugFile & getAsciiFile()
returns a reference to the ascii file
Definition: FWParser.cxx:2475
Internal and low level: a structure used to define the data of zone in Zone 0 data of a FullWrite fil...
Definition: FWParser.cxx:62
bool operator!=(const FWEntry &a) const
basic operator!=
Definition: FWParser.hxx:71
bool readGraphic(shared_ptr< FWEntry > zone)
check if a zone is a graphic zone, ...
Definition: FWParser.cxx:1812
bool readFileZonePos(shared_ptr< FWEntry > zone)
try to read the file zones position
Definition: FWParser.cxx:2059
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: FWParser.cxx:603
Type
enum to define note type
Definition: libmwaw_internal.hxx:299
Internal: the subdocument of a MWParser.
Definition: FWParser.cxx:283
void sendVariable(int docId)
try to send a variable, in pratice do nothing
Definition: FWParser.cxx:2303
shared_ptr< FWText > m_textParser
the text parser
Definition: FWParser.hxx:216
bool readDocPosition()
find the last position of the document and read data
Definition: FWParser.cxx:2195
void closeDebugFile()
write the debug file, ...
Definition: FWParser.cxx:2469
void init()
inits all internal variables
Definition: FWParser.cxx:355
FWEntry(MWAWInputStreamPtr input)
Definition: FWParser.cxx:2407
void sendReference(int docId)
try to send a reference, in pratice do nothing
Definition: FWParser.cxx:2273
shared_ptr< FWParserInternal::State > m_state
the state
Definition: FWParser.hxx:213
void sendText(int docId, libmwaw::SubDocumentType type, MWAWNote::Type which=MWAWNote::FootNote)
try to send a footnote/endnote entry
Definition: FWParser.cxx:2346
void update()
create a inputstream, ... if needed
Definition: FWParser.cxx:2446
bool operator==(const FWEntry &a) const
basic operator==
Definition: FWParser.cxx:2480
bool readReferenceData(shared_ptr< FWEntry > zone)
try to read the reference data
Definition: FWParser.cxx:1748
the definition of a zone in the file
Definition: FWParser.hxx:54
int m_values[3]
some unknown values
Definition: FWParser.hxx:84
bool readGraphicData(shared_ptr< FWEntry > zone, FWParserInternal::DocZoneData &doc)
try to read the graphic data
Definition: FWParser.cxx:1666
the main class to read the text part of writenow file
Definition: FWText.hxx:75
Definition: libmwaw_internal.hxx:299
virtual ~FWParser()
destructor
Definition: FWParser.cxx:346
int m_type
the zone type id find in DStruct
Definition: FWParser.hxx:80
bool send(int fileId)
ask the text parser to send a zone
Definition: FWParser.cxx:2380
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:98
bool readDocInfo(shared_ptr< FWEntry > zone)
try to read zone2, a zone which stores the document information zone, ...
Definition: FWParser.cxx:629
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
bool readEndDocInfo(shared_ptr< FWEntry > zone)
try to read the end of zone2 (only v2) ?
Definition: FWParser.cxx:829
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: FWParser.cxx:387
void newPage(int number)
adds a new page
Definition: FWParser.cxx:371
FWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: FWParser.cxx:340
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: FWParser.cxx:455
bool readDocZoneData(shared_ptr< FWEntry > zone)
try to read the zone containing the data of each doc zone (ie. Zone0)
Definition: FWParser.cxx:1029
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
Definition: MWAWParser.hxx:56

Generated for libmwaw by doxygen 1.8.5