MWAWParser.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MWAWParser.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 #ifndef MWAW_PARSER_H
35 #define MWAW_PARSER_H
36
37 #include <ostream>
38 #include <string>
39 #include <vector>
40
41 #include "MWAWDebug.hxx"
42 #include "MWAWInputStream.hxx"
43
44 #include "MWAWEntry.hxx"
45 #include "MWAWHeader.hxx"
46 #include "MWAWPageSpan.hxx"
47
49 class MWAWParserState
50 {
51 public:
53 enum Type { Graphic, Presentation, Spreadsheet, Text };
55 MWAWParserState(Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
57 ~MWAWParserState();
59 MWAWListenerPtr getMainListener();
61 Type m_type;
63 MWAWDocument::Kind m_kind;
65 MWAWInputStreamPtr m_input;
67 MWAWHeader *m_header;
69 MWAWRSRCParserPtr m_rsrcParser;
71 MWAWPageSpan m_pageSpan;
72
74 MWAWFontConverterPtr m_fontConverter;
76 MWAWGraphicListenerPtr m_graphicListener;
78 MWAWListManagerPtr m_listManager;
80 MWAWPresentationListenerPtr m_presentationListener;
82 MWAWSpreadsheetListenerPtr m_spreadsheetListener;
84 MWAWTextListenerPtr m_textListener;
86 int m_version;
87
89 libmwaw::DebugFile m_asciiFile;
90
91 private:
92 MWAWParserState(MWAWParserState const &orig);
93 MWAWParserState &operator=(MWAWParserState const &orig);
94 };
95
97 class MWAWParser
98 {
99 public:
101 virtual ~MWAWParser();
103 virtual bool checkHeader(MWAWHeader *header, bool strict=false) = 0;
104
106 int version() const
107 {
108 return m_parserState->m_version;
109 }
111 MWAWParserStatePtr getParserState()
112 {
113 return m_parserState;
114 }
116 MWAWHeader *getHeader()
117 {
118 return m_parserState->m_header;
119 }
121 MWAWInputStreamPtr &getInput()
122 {
123 return m_parserState->m_input;
124 }
126 MWAWListenerPtr getMainListener();
128 MWAWGraphicListenerPtr &getGraphicListener()
129 {
130 return m_parserState->m_graphicListener;
131 }
133 MWAWPresentationListenerPtr &getPresentationListener()
134 {
135 return m_parserState->m_presentationListener;
136 }
138 MWAWSpreadsheetListenerPtr &getSpreadsheetListener()
139 {
140 return m_parserState->m_spreadsheetListener;
141 }
143 MWAWTextListenerPtr &getTextListener()
144 {
145 return m_parserState->m_textListener;
146 }
148 MWAWFontConverterPtr &getFontConverter()
149 {
150 return m_parserState->m_fontConverter;
151 }
153 MWAWPageSpan const &getPageSpan() const
154 {
155 return m_parserState->m_pageSpan;
156 }
158 MWAWPageSpan &getPageSpan()
159 {
160 return m_parserState->m_pageSpan;
161 }
163 double getFormLength() const
164 {
165 return m_parserState->m_pageSpan.getFormLength();
166 }
168 double getFormWidth() const
169 {
170 return m_parserState->m_pageSpan.getFormWidth();
171 }
173 double getPageLength() const
174 {
175 return m_parserState->m_pageSpan.getPageLength();
176 }
178 double getPageWidth() const
179 {
180 return m_parserState->m_pageSpan.getPageWidth();
181 }
183 MWAWRSRCParserPtr &getRSRCParser()
184 {
185 return m_parserState->m_rsrcParser;
186 }
188 libmwaw::DebugFile &ascii()
189 {
190 return m_parserState->m_asciiFile;
191 }
192 protected:
194 MWAWParser(MWAWParserState::Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
196 explicit MWAWParser(MWAWParserStatePtr state) : m_parserState(state), m_asciiName("") { }
197
199 void setVersion(int vers)
200 {
201 m_parserState->m_version = vers;
202 }
204 void setGraphicListener(MWAWGraphicListenerPtr &listener);
206 void resetGraphicListener();
208 void setPresentationListener(MWAWPresentationListenerPtr &listener);
210 void resetPresentationListener();
212 void setSpreadsheetListener(MWAWSpreadsheetListenerPtr &listener);
214 void resetSpreadsheetListener();
216 void setTextListener(MWAWTextListenerPtr &listener);
218 void resetTextListener();
220 void setFontConverter(MWAWFontConverterPtr fontConverter);
222 void setAsciiName(char const *name)
223 {
224 m_asciiName = name;
225 }
227 std::string const &asciiName() const
228 {
229 return m_asciiName;
230 }
231
232 private:
234 explicit MWAWParser(const MWAWParser &);
236 MWAWParser &operator=(const MWAWParser &);
237
239 MWAWParserStatePtr m_parserState;
241 std::string m_asciiName;
242 };
243
245 class MWAWGraphicParser : public MWAWParser
246 {
247 public:
249 virtual ~MWAWGraphicParser();
251 virtual void parse(librevenge::RVNGDrawingInterface *documentInterface) = 0;
252 protected:
254 MWAWGraphicParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Graphic, input, rsrcParser, header) {}
256 explicit MWAWGraphicParser(MWAWParserStatePtr state) : MWAWParser(state) {}
257 };
258
260 class MWAWPresentationParser : public MWAWParser
261 {
262 public:
264 virtual ~MWAWPresentationParser();
266 virtual void parse(librevenge::RVNGPresentationInterface *documentInterface) = 0;
267 protected:
269 MWAWPresentationParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Presentation, input, rsrcParser, header) {}
271 explicit MWAWPresentationParser(MWAWParserStatePtr state) : MWAWParser(state) {}
272 };
273
275 class MWAWSpreadsheetParser : public MWAWParser
276 {
277 public:
279 virtual ~MWAWSpreadsheetParser();
281 virtual void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) = 0;
282 protected:
284 MWAWSpreadsheetParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Spreadsheet, input, rsrcParser, header) {}
286 explicit MWAWSpreadsheetParser(MWAWParserStatePtr state) : MWAWParser(state) {}
287 };
288
290 class MWAWTextParser : public MWAWParser
291 {
292 public:
294 virtual ~MWAWTextParser();
296 virtual void parse(librevenge::RVNGTextInterface *documentInterface) = 0;
297 protected:
299 MWAWTextParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Text, input, rsrcParser, header) {}
301 explicit MWAWTextParser(MWAWParserStatePtr state) : MWAWParser(state) {}
302 };
303
304 #endif /* MWAWPARSER_H */
305 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWListenerPtr
shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:502
MWAWParser::getSpreadsheetListener
MWAWSpreadsheetListenerPtr & getSpreadsheetListener()
returns the spreadsheet listener
Definition: MWAWParser.hxx:138
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MWAWParser::getTextListener
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition: MWAWParser.hxx:143
MWAWPresentationParser::MWAWPresentationParser
MWAWPresentationParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:271
MWAWTextParser::MWAWTextParser
MWAWTextParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:299
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:227
MWAWParserState::m_kind
MWAWDocument::Kind m_kind
the document kind
Definition: MWAWParser.hxx:63
MWAWParserState::operator=
MWAWParserState & operator=(MWAWParserState const &orig)
MWAWParser::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWParser.hxx:178
MWAWPageSpan.hxx
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
MWAWParserState::m_spreadsheetListener
MWAWSpreadsheetListenerPtr m_spreadsheetListener
the spreadsheet listener
Definition: MWAWParser.hxx:82
MWAWEntry.hxx
MWAWParserState::m_header
MWAWHeader * m_header
the header
Definition: MWAWParser.hxx:67
libmwaw::DebugFile
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:65
MWAWParser::setVersion
void setVersion(int vers)
sets the document&#39;s version
Definition: MWAWParser.hxx:199
MWAWPresentationListenerPtr
shared_ptr< MWAWPresentationListener > MWAWPresentationListenerPtr
a smart pointer of MWAWPresentationListener
Definition: libmwaw_internal.hxx:508
MWAWGraphicParser::MWAWGraphicParser
MWAWGraphicParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:254
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:183
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:153
MWAWParser::getFormLength
double getFormLength() const
returns the form length
Definition: MWAWParser.hxx:163
MWAWParser::getHeader
MWAWHeader * getHeader()
returns the header
Definition: MWAWParser.hxx:116
MWAWParser::getGraphicListener
MWAWGraphicListenerPtr & getGraphicListener()
returns the graphic listener
Definition: MWAWParser.hxx:128
MWAWParserState::MWAWParserState
MWAWParserState(Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
Constructor.
Definition: MWAWParser.cxx:44
MWAWParser::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: MWAWParser.hxx:239
MWAWParserState::m_textListener
MWAWTextListenerPtr m_textListener
the text listener
Definition: MWAWParser.hxx:84
MWAWParser::MWAWParser
MWAWParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:196
MWAWParserState::~MWAWParserState
~MWAWParserState()
destructor
Definition: MWAWParser.cxx:57
MWAWParserState::Presentation
Definition: MWAWParser.hxx:53
MWAWParser::getFontConverter
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition: MWAWParser.hxx:148
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:222
MWAWParserState
a class to define the parser state
Definition: MWAWParser.hxx:49
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:510
MWAWParserState::m_asciiFile
libmwaw::DebugFile m_asciiFile
the debug file
Definition: MWAWParser.hxx:89
MWAWParserState::m_version
int m_version
the actual version
Definition: MWAWParser.hxx:86
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:188
MWAWSpreadsheetListenerPtr
shared_ptr< MWAWSpreadsheetListener > MWAWSpreadsheetListenerPtr
a smart pointer of MWAWSpreadsheetListener
Definition: libmwaw_internal.hxx:512
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:111
MWAWParser::getPresentationListener
MWAWPresentationListenerPtr & getPresentationListener()
returns the presentation listener
Definition: MWAWParser.hxx:133
MWAWParserState::m_listManager
MWAWListManagerPtr m_listManager
the list manager
Definition: MWAWParser.hxx:78
MWAWParserState::Spreadsheet
Definition: MWAWParser.hxx:53
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:290
MWAWParserState::m_pageSpan
MWAWPageSpan m_pageSpan
the actual document size
Definition: MWAWParser.hxx:71
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:106
MWAWPresentationParser
virtual class which defines the ancestor of all presentation zone parser
Definition: MWAWParser.hxx:260
MWAWPresentationParser::MWAWPresentationParser
MWAWPresentationParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:269
MWAWParser::getPageLength
double getPageLength() const
returns the page length (form length without margin )
Definition: MWAWParser.hxx:173
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:500
MWAWGraphicParser
virtual class which defines the ancestor of all graphic zone parser
Definition: MWAWParser.hxx:245
MWAWGraphicListenerPtr
shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition: libmwaw_internal.hxx:498
MWAWInputStream.hxx
MWAWDebug.hxx
MWAWDocument::Kind
Kind
an enum to define the kind of document
Definition: MWAWDocument.hxx:80
MWAWParser::getPageSpan
MWAWPageSpan & getPageSpan()
returns the actual page dimension
Definition: MWAWParser.hxx:158
MWAWFontConverterPtr
shared_ptr< MWAWFontConverter > MWAWFontConverterPtr
a smart pointer of MWAWFontConverter
Definition: libmwaw_internal.hxx:494
MWAWParserState::Text
Definition: MWAWParser.hxx:53
MWAWParserState::Graphic
Definition: MWAWParser.hxx:53
MWAWParserState::Type
Type
the parser state type
Definition: MWAWParser.hxx:53
MWAWParser::getFormWidth
double getFormWidth() const
returns the form width
Definition: MWAWParser.hxx:168
MWAWSpreadsheetParser::MWAWSpreadsheetParser
MWAWSpreadsheetParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:286
MWAWGraphicParser::MWAWGraphicParser
MWAWGraphicParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:256
MWAWParserState::m_graphicListener
MWAWGraphicListenerPtr m_graphicListener
the graphic listener
Definition: MWAWParser.hxx:76
MWAWParser::m_asciiName
std::string m_asciiName
the debug file name
Definition: MWAWParser.hxx:241
MWAWParserState::m_rsrcParser
MWAWRSRCParserPtr m_rsrcParser
the resource parser
Definition: MWAWParser.hxx:69
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:506
MWAWSpreadsheetParser::MWAWSpreadsheetParser
MWAWSpreadsheetParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:284
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:97
MWAWParserState::m_presentationListener
MWAWPresentationListenerPtr m_presentationListener
the presentation listener
Definition: MWAWParser.hxx:80
MWAWParserState::m_type
Type m_type
the state type
Definition: MWAWParser.hxx:61
MWAWHeader.hxx
Defines MWAWHeader (document&#39;s type, version, kind)
MWAWParserState::m_fontConverter
MWAWFontConverterPtr m_fontConverter
the font converter
Definition: MWAWParser.hxx:74
MWAWParserState::m_input
MWAWInputStreamPtr m_input
the input
Definition: MWAWParser.hxx:65
MWAWPageSpan::m_pageSpan
int m_pageSpan
the number of page
Definition: MWAWPageSpan.hxx:306
MWAWSpreadsheetParser
virtual class which defines the ancestor of all spreadsheet zone parser
Definition: MWAWParser.hxx:275
MWAWParserState::getMainListener
MWAWListenerPtr getMainListener()
returns the main listener
Definition: MWAWParser.cxx:77
MWAWTextParser::MWAWTextParser
MWAWTextParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:301
MWAWTextListenerPtr
shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:516
MWAWListManagerPtr
shared_ptr< MWAWListManager > MWAWListManagerPtr
a smart pointer of MWAWListManager
Definition: libmwaw_internal.hxx:504
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:121