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 {
51 public:
55  MWAWParserState(Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
65  int m_version;
74 
85 
88 
89 private:
90  MWAWParserState(MWAWParserState const &orig);
92 };
93 
96 {
97 public:
99  virtual ~MWAWParser();
101  virtual bool checkHeader(MWAWHeader *header, bool strict=false) = 0;
102 
104  int version() const
105  {
106  return m_parserState->m_version;
107  }
110  {
111  return m_parserState;
112  }
115  {
116  return m_parserState->m_header;
117  }
120  {
121  return m_parserState->m_input;
122  }
127  {
128  return m_parserState->m_graphicListener;
129  }
132  {
133  return m_parserState->m_spreadsheetListener;
134  }
137  {
138  return m_parserState->m_textListener;
139  }
142  {
143  return m_parserState->m_fontConverter;
144  }
146  MWAWPageSpan const &getPageSpan() const
147  {
148  return m_parserState->m_pageSpan;
149  }
152  {
153  return m_parserState->m_pageSpan;
154  }
156  double getFormLength() const
157  {
158  return m_parserState->m_pageSpan.getFormLength();
159  }
161  double getFormWidth() const
162  {
163  return m_parserState->m_pageSpan.getFormWidth();
164  }
166  double getPageLength() const
167  {
168  return m_parserState->m_pageSpan.getPageLength();
169  }
171  double getPageWidth() const
172  {
173  return m_parserState->m_pageSpan.getPageWidth();
174  }
177  {
178  return m_parserState->m_rsrcParser;
179  }
182  {
183  return m_parserState->m_asciiFile;
184  }
185 protected:
190 
192  void setVersion(int vers)
193  {
194  m_parserState->m_version = vers;
195  }
199  void resetGraphicListener();
205  void setTextListener(MWAWTextListenerPtr &listener);
207  void resetTextListener();
209  void setFontConverter(MWAWFontConverterPtr fontConverter);
211  void setAsciiName(char const *name)
212  {
213  m_asciiName = name;
214  }
216  std::string const &asciiName() const
217  {
218  return m_asciiName;
219  }
220 
221 private:
223  MWAWParser(const MWAWParser &);
225  MWAWParser &operator=(const MWAWParser &);
226 
230  std::string m_asciiName;
231 };
232 
235 {
236 public:
238  virtual void parse(librevenge::RVNGDrawingInterface *documentInterface) = 0;
239 protected:
241  MWAWGraphicParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Graphic, input, rsrcParser, header) {}
244 };
245 
248 {
249 public:
251  virtual void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) = 0;
252 protected:
254  MWAWSpreadsheetParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Spreadsheet, input, rsrcParser, header) {}
257 };
258 
261 {
262 public:
264  virtual void parse(librevenge::RVNGTextInterface *documentInterface) = 0;
265 protected:
267  MWAWTextParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Text, input, rsrcParser, header) {}
270 };
271 
272 #endif /* MWAWPARSER_H */
273 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition: libmwaw_internal.hxx:382
MWAWSpreadsheetListenerPtr & getSpreadsheetListener()
returns the spreadsheet listener
Definition: MWAWParser.hxx:131
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition: MWAWParser.hxx:136
MWAWTextParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:267
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:216
MWAWDocument::Kind m_kind
the document kind
Definition: MWAWParser.hxx:63
MWAWParserState & operator=(MWAWParserState const &orig)
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWParser.hxx:171
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
MWAWSpreadsheetListenerPtr m_spreadsheetListener
the spreadsheet listener
Definition: MWAWParser.hxx:82
MWAWHeader * m_header
the header
Definition: MWAWParser.hxx:69
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:64
void setVersion(int vers)
sets the document's version
Definition: MWAWParser.hxx:192
MWAWGraphicParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:241
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:176
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:146
double getFormLength() const
returns the form length
Definition: MWAWParser.hxx:156
MWAWHeader * getHeader()
returns the header
Definition: MWAWParser.hxx:114
MWAWGraphicListenerPtr & getGraphicListener()
returns the graphic listener
Definition: MWAWParser.hxx:126
MWAWParserState(Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
Constructor.
Definition: MWAWParser.cxx:43
MWAWParserStatePtr m_parserState
the parser state
Definition: MWAWParser.hxx:228
MWAWTextListenerPtr m_textListener
the text listener
Definition: MWAWParser.hxx:84
MWAWParser & operator=(const MWAWParser &)
private operator=: forbidden
virtual void parse(librevenge::RVNGSpreadsheetInterface *documentInterface)=0
virtual function used to parse the input
MWAWParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:189
~MWAWParserState()
destructor
Definition: MWAWParser.cxx:56
MWAWListenerPtr getMainListener()
returns the main listener
Definition: MWAWParser.cxx:106
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition: MWAWParser.hxx:141
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:211
a class to define the parser state
Definition: MWAWParser.hxx:49
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:388
void resetSpreadsheetListener()
resets the listener
Definition: MWAWParser.cxx:127
libmwaw::DebugFile m_asciiFile
the debug file
Definition: MWAWParser.hxx:87
int m_version
the actual version
Definition: MWAWParser.hxx:65
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:181
shared_ptr< MWAWSpreadsheetListener > MWAWSpreadsheetListenerPtr
a smart pointer of MWAWSpreadsheetListener
Definition: libmwaw_internal.hxx:390
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:109
MWAWListManagerPtr m_listManager
the list manager
Definition: MWAWParser.hxx:80
Definition: MWAWParser.hxx:53
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:260
MWAWPageSpan m_pageSpan
the actual document size
Definition: MWAWParser.hxx:73
int version() const
returns the works version
Definition: MWAWParser.hxx:104
double getPageLength() const
returns the page length (form length without margin )
Definition: MWAWParser.hxx:166
void setSpreadsheetListener(MWAWSpreadsheetListenerPtr &listener)
sets the spreadsheet listener
Definition: MWAWParser.cxx:122
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:380
void setGraphicListener(MWAWGraphicListenerPtr &listener)
sets the graphic listener
Definition: MWAWParser.cxx:111
virtual class which defines the ancestor of all graphic zone parser
Definition: MWAWParser.hxx:234
shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition: libmwaw_internal.hxx:378
Kind
an enum to define the kind of document
Definition: MWAWDocument.hxx:76
virtual ~MWAWParser()
virtual destructor
Definition: MWAWParser.cxx:97
MWAWPageSpan & getPageSpan()
returns the actual page dimension
Definition: MWAWParser.hxx:151
shared_ptr< MWAWFontConverter > MWAWFontConverterPtr
a smart pointer of MWAWFontConverter
Definition: libmwaw_internal.hxx:374
Definition: MWAWParser.hxx:53
Definition: MWAWParser.hxx:53
Type
the parser state type
Definition: MWAWParser.hxx:53
virtual void parse(librevenge::RVNGDrawingInterface *documentInterface)=0
virtual function used to parse the input
double getFormWidth() const
returns the form width
Definition: MWAWParser.hxx:161
MWAWSpreadsheetParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:256
MWAWParser(MWAWParserState::Type type, MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.cxx:91
MWAWGraphicParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:243
MWAWGraphicListenerPtr m_graphicListener
the graphic listener
Definition: MWAWParser.hxx:78
std::string m_asciiName
the debug file name
Definition: MWAWParser.hxx:230
MWAWRSRCParserPtr m_rsrcParser
the resource parser
Definition: MWAWParser.hxx:71
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:386
void setFontConverter(MWAWFontConverterPtr fontConverter)
sets the font convertor
Definition: MWAWParser.cxx:101
MWAWSpreadsheetParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.hxx:254
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:95
Type m_type
the state type
Definition: MWAWParser.hxx:61
Defines MWAWHeader (document's type, version, kind)
MWAWFontConverterPtr m_fontConverter
the font converter
Definition: MWAWParser.hxx:76
void resetTextListener()
resets the listener
Definition: MWAWParser.cxx:138
MWAWInputStreamPtr m_input
the input
Definition: MWAWParser.hxx:67
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition: MWAWParser.cxx:133
virtual class which defines the ancestor of all spreadsheet zone parser
Definition: MWAWParser.hxx:247
virtual bool checkHeader(MWAWHeader *header, bool strict=false)=0
virtual function used to check if the document header is correct (or not)
virtual void parse(librevenge::RVNGTextInterface *documentInterface)=0
virtual function used to parse the input
void resetGraphicListener()
resets the listener
Definition: MWAWParser.cxx:116
MWAWListenerPtr getMainListener()
returns the main listener
Definition: MWAWParser.cxx:76
MWAWTextParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:269
shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:394
shared_ptr< MWAWListManager > MWAWListManagerPtr
a smart pointer of MWAWListManager
Definition: libmwaw_internal.hxx:384
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:119

Generated on Wed Jun 7 2017 22:16:22 for libmwaw by doxygen 1.8.8