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
50{
51public:
55 MWAWParserState(Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
72
89
92
93private:
96};
97
100{
101public:
103 virtual ~MWAWParser();
105 virtual bool checkHeader(MWAWHeader *header, bool strict=false) = 0;
106
108 int version() const
109 {
110 return m_parserState->m_version;
111 }
114 {
115 return m_parserState;
116 }
119 {
120 return m_parserState->m_header;
121 }
124 {
125 return m_parserState->m_input;
126 }
131 {
132 return m_parserState->m_graphicListener;
133 }
136 {
137 return m_parserState->m_presentationListener;
138 }
141 {
142 return m_parserState->m_spreadsheetListener;
143 }
146 {
147 return m_parserState->m_textListener;
148 }
151 {
152 return m_parserState->m_fontConverter;
153 }
156 {
157 return m_parserState->m_fontManager;
158 }
161 {
162 return m_parserState->m_pageSpan;
163 }
166 {
167 return m_parserState->m_pageSpan;
168 }
170 double getFormLength() const
171 {
172 return m_parserState->m_pageSpan.getFormLength();
173 }
175 double getFormWidth() const
176 {
177 return m_parserState->m_pageSpan.getFormWidth();
178 }
180 double getPageLength() const
181 {
182 return m_parserState->m_pageSpan.getPageLength();
183 }
185 double getPageWidth() const
186 {
187 return m_parserState->m_pageSpan.getPageWidth();
188 }
191 {
192 return m_parserState->m_rsrcParser;
193 }
196 {
197 return m_parserState->m_asciiFile;
198 }
199protected:
203 explicit MWAWParser(MWAWParserStatePtr state) : m_parserState(state), m_asciiName("") { }
204
206 void setVersion(int vers)
207 {
208 m_parserState->m_version = vers;
209 }
223 void setTextListener(MWAWTextListenerPtr &listener);
225 void resetTextListener();
227 void setAsciiName(char const *name)
228 {
229 m_asciiName = name;
230 }
232 std::string const &asciiName() const
233 {
234 return m_asciiName;
235 }
236
237private:
239 explicit MWAWParser(const MWAWParser &);
242
246 std::string m_asciiName;
247};
248
251{
252public:
254 virtual ~MWAWGraphicParser();
256 virtual void parse(librevenge::RVNGDrawingInterface *documentInterface) = 0;
257protected:
259 MWAWGraphicParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Graphic, input, rsrcParser, header) {}
262};
263
266{
267public:
269 virtual ~MWAWPresentationParser();
271 virtual void parse(librevenge::RVNGPresentationInterface *documentInterface) = 0;
272protected:
274 MWAWPresentationParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Presentation, input, rsrcParser, header) {}
277};
278
281{
282public:
284 virtual ~MWAWSpreadsheetParser();
286 virtual void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) = 0;
287protected:
289 MWAWSpreadsheetParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Spreadsheet, input, rsrcParser, header) {}
292};
293
296{
297public:
299 virtual ~MWAWTextParser();
301 virtual void parse(librevenge::RVNGTextInterface *documentInterface) = 0;
302protected:
304 MWAWTextParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Text, input, rsrcParser, header) {}
306 explicit MWAWTextParser(MWAWParserStatePtr state) : MWAWParser(state) {}
307};
308
309#endif /* MWAWPARSER_H */
310// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Defines MWAWHeader (document's type, version, kind)
Kind
an enum to define the kind of document
Definition: MWAWDocument.hxx:80
virtual class which defines the ancestor of all graphic zone parser
Definition: MWAWParser.hxx:251
virtual void parse(librevenge::RVNGDrawingInterface *documentInterface)=0
virtual function used to parse the input
MWAWGraphicParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:261
MWAWGraphicParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:259
virtual ~MWAWGraphicParser()
destructor
Definition: MWAWParser.cxx:161
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:96
a class to define the parser state
Definition: MWAWParser.hxx:50
MWAWPageSpan m_pageSpan
the actual document size
Definition: MWAWParser.hxx:71
Type m_type
the state type
Definition: MWAWParser.hxx:61
MWAWInputStreamPtr m_input
the input
Definition: MWAWParser.hxx:65
MWAWDocument::Kind m_kind
the document kind
Definition: MWAWParser.hxx:63
MWAWParserState(MWAWParserState const &orig)
int m_version
the actual version
Definition: MWAWParser.hxx:88
MWAWTextListenerPtr m_textListener
the text listener
Definition: MWAWParser.hxx:86
MWAWListManagerPtr m_listManager
the list manager
Definition: MWAWParser.hxx:80
MWAWRSRCParserPtr m_rsrcParser
the resource parser
Definition: MWAWParser.hxx:69
MWAWFontManagerPtr m_fontManager
the font manager
Definition: MWAWParser.hxx:76
MWAWParserState & operator=(MWAWParserState const &orig)
~MWAWParserState()
destructor
Definition: MWAWParser.cxx:59
MWAWListenerPtr getMainListener()
returns the main listener
Definition: MWAWParser.cxx:79
MWAWPresentationListenerPtr m_presentationListener
the presentation listener
Definition: MWAWParser.hxx:82
MWAWSpreadsheetListenerPtr m_spreadsheetListener
the spreadsheet listener
Definition: MWAWParser.hxx:84
MWAWParserState(Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
Constructor.
Definition: MWAWParser.cxx:45
MWAWHeader * m_header
the header
Definition: MWAWParser.hxx:67
MWAWGraphicListenerPtr m_graphicListener
the graphic listener
Definition: MWAWParser.hxx:78
libmwaw::DebugFile m_asciiFile
the debug file
Definition: MWAWParser.hxx:91
MWAWFontConverterPtr m_fontConverter
the font converter
Definition: MWAWParser.hxx:74
Type
the parser state type
Definition: MWAWParser.hxx:53
@ Spreadsheet
Definition: MWAWParser.hxx:53
@ Presentation
Definition: MWAWParser.hxx:53
@ Graphic
Definition: MWAWParser.hxx:53
@ Text
Definition: MWAWParser.hxx:53
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:100
void setSpreadsheetListener(MWAWSpreadsheetListenerPtr &listener)
sets the spreadsheet listener
Definition: MWAWParser.cxx:135
void setVersion(int vers)
sets the document's version
Definition: MWAWParser.hxx:206
double getFormWidth() const
returns the form width
Definition: MWAWParser.hxx:175
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:190
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:151
MWAWParserStatePtr m_parserState
the parser state
Definition: MWAWParser.hxx:244
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWParser(const MWAWParser &)
private copy constructor: forbidden
std::string m_asciiName
the debug file name
Definition: MWAWParser.hxx:246
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:227
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition: MWAWParser.hxx:150
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:146
void setGraphicListener(MWAWGraphicListenerPtr &listener)
sets the graphic listener
Definition: MWAWParser.cxx:113
void resetGraphicListener()
resets the listener
Definition: MWAWParser.cxx:118
void setPresentationListener(MWAWPresentationListenerPtr &listener)
sets the presentation listener
Definition: MWAWParser.cxx:124
double getPageLength() const
returns the page length (form length without margin )
Definition: MWAWParser.hxx:180
MWAWParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:203
MWAWHeader * getHeader()
returns the header
Definition: MWAWParser.hxx:118
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:232
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:195
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:160
void resetPresentationListener()
resets the listener
Definition: MWAWParser.cxx:129
MWAWParser(MWAWParserState::Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.cxx:98
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition: MWAWParser.hxx:145
double getFormLength() const
returns the form length
Definition: MWAWParser.hxx:170
MWAWPresentationListenerPtr & getPresentationListener()
returns the presentation listener
Definition: MWAWParser.hxx:135
int version() const
returns the works version
Definition: MWAWParser.hxx:108
MWAWPageSpan & getPageSpan()
returns the actual page dimension
Definition: MWAWParser.hxx:165
MWAWFontManagerPtr & getFontManager()
returns the font manager
Definition: MWAWParser.hxx:155
MWAWGraphicListenerPtr & getGraphicListener()
returns the graphic listener
Definition: MWAWParser.hxx:130
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWParser.hxx:185
virtual ~MWAWParser()
virtual destructor
Definition: MWAWParser.cxx:104
MWAWSpreadsheetListenerPtr & getSpreadsheetListener()
returns the spreadsheet listener
Definition: MWAWParser.hxx:140
void resetSpreadsheetListener()
resets the listener
Definition: MWAWParser.cxx:140
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:123
virtual bool checkHeader(MWAWHeader *header, bool strict=false)=0
virtual function used to check if the document header is correct (or not)
MWAWListenerPtr getMainListener()
returns the main listener
Definition: MWAWParser.cxx:108
MWAWParser & operator=(const MWAWParser &)
private operator=: forbidden
virtual class which defines the ancestor of all presentation zone parser
Definition: MWAWParser.hxx:266
MWAWPresentationParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:276
virtual ~MWAWPresentationParser()
destructor
Definition: MWAWParser.cxx:165
MWAWPresentationParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:274
virtual void parse(librevenge::RVNGPresentationInterface *documentInterface)=0
virtual function used to parse the input
virtual class which defines the ancestor of all spreadsheet zone parser
Definition: MWAWParser.hxx:281
virtual void parse(librevenge::RVNGSpreadsheetInterface *documentInterface)=0
virtual function used to parse the input
MWAWSpreadsheetParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:291
MWAWSpreadsheetParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:289
virtual ~MWAWSpreadsheetParser()
destructor
Definition: MWAWParser.cxx:169
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:296
MWAWTextParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:304
virtual void parse(librevenge::RVNGTextInterface *documentInterface)=0
virtual function used to parse the input
MWAWTextParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:306
virtual ~MWAWTextParser()
destructor
Definition: MWAWParser.cxx:173
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
shared_ptr< MWAWFontManager > MWAWFontManagerPtr
a smart pointer of MWAWFontManager
Definition: libmwaw_internal.hxx:499
shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:505
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:513
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:503
shared_ptr< MWAWPresentationListener > MWAWPresentationListenerPtr
a smart pointer of MWAWPresentationListener
Definition: libmwaw_internal.hxx:511
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:509
shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:519
shared_ptr< MWAWFontConverter > MWAWFontConverterPtr
a smart pointer of MWAWFontConverter
Definition: libmwaw_internal.hxx:495
shared_ptr< MWAWListManager > MWAWListManagerPtr
a smart pointer of MWAWListManager
Definition: libmwaw_internal.hxx:507
shared_ptr< MWAWSpreadsheetListener > MWAWSpreadsheetListenerPtr
a smart pointer of MWAWSpreadsheetListener
Definition: libmwaw_internal.hxx:515
shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition: libmwaw_internal.hxx:501

Generated on Wed Jan 19 2022 22:23:16 for libmwaw by doxygen 1.9.3