MWAWParser.hxx
Go to the documentation of this file.
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
/* libmwaw
* Version: MPL 2.0 / LGPLv2+
*
* The contents of this file are subject to the Mozilla Public License Version
* 2.0 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
* Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
* Copyright (C) 2006, 2007 Andrew Ziem
* Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
*
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
* in which case the provisions of the LGPLv2+ are applicable
* instead of those above.
*/
#ifndef MWAW_PARSER_H
#define MWAW_PARSER_H
#include <ostream>
#include <string>
#include <vector>
#include "MWAWDebug.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWEntry.hxx"
#include "MWAWHeader.hxx"
#include "MWAWPageSpan.hxx"
class WPXDocumentInterface;
class MWAWParserState
{
public:
// Constructor
MWAWParserState(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
~MWAWParserState();
int m_version;
MWAWInputStreamPtr m_input;
MWAWHeader *m_header;
MWAWRSRCParserPtr m_rsrcParser;
MWAWFontConverterPtr m_fontConverter;
MWAWListManagerPtr m_listManager;
MWAWContentListenerPtr m_listener;
libmwaw::DebugFile m_asciiFile;
private:
MWAWParserState(MWAWParserState const &orig);
MWAWParserState &operator=(MWAWParserState const &orig);
};
class MWAWParser
{
public:
virtual ~MWAWParser();
virtual void parse(WPXDocumentInterface *documentInterface) = 0;
virtual bool checkHeader(MWAWHeader *header, bool strict=false) = 0;
int version() const {
return m_parserState->m_version;
}
void setVersion(int vers) {
m_parserState->m_version = vers;
}
protected:
MWAWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
MWAWParser(MWAWParserStatePtr state) : m_parserState(state), m_pageSpan(), m_asciiName("") { }
MWAWParserStatePtr getParserState() {
return m_parserState;
}
MWAWHeader *getHeader() {
return m_parserState->m_header;
}
MWAWInputStreamPtr &getInput() {
return m_parserState->m_input;
}
MWAWContentListenerPtr &getListener() {
return m_parserState->m_listener;
}
MWAWPageSpan const &getPageSpan() const {
return m_pageSpan;
}
MWAWPageSpan &getPageSpan() {
return m_pageSpan;
}
double getFormLength() const {
return m_pageSpan.getFormLength();
}
double getFormWidth() const {
return m_pageSpan.getFormWidth();
}
double getPageLength() const {
return m_pageSpan.getPageLength();
}
double getPageWidth() const {
return m_pageSpan.getPageWidth();
}
MWAWRSRCParserPtr &getRSRCParser() {
return m_parserState->m_rsrcParser;
}
void setListener(MWAWContentListenerPtr &listener);
void resetListener();
MWAWFontConverterPtr &getFontConverter() {
return m_parserState->m_fontConverter;
}
void setFontConverter(MWAWFontConverterPtr fontConverter);
libmwaw::DebugFile &ascii() {
return m_parserState->m_asciiFile;
}
void setAsciiName(char const *name) {
m_asciiName = name;
}
std::string const &asciiName() const {
return m_asciiName;
}
private:
MWAWParser(const MWAWParser &);
MWAWParser &operator=(const MWAWParser &);
MWAWParserStatePtr m_parserState;
MWAWPageSpan m_pageSpan;
std::string m_asciiName;
};
#endif /* MWAWPARSER_H */
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWHeader
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
MWAWParser::parse
virtual void parse(WPXDocumentInterface *documentInterface)=0
virtual function used to parse the input
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition: MWAWParser.hxx:175
MWAWParserState::operator=
MWAWParserState & operator=(MWAWParserState const &orig)
MWAWParser::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWParser.hxx:149
MWAWPageSpan.hxx
MWAWPageSpan
A class which defines the page properties.
Definition: MWAWPageSpan.hxx:95
MWAWEntry.hxx
MWAWParserState::MWAWParserState
MWAWParserState(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
Definition: MWAWParser.cxx:40
MWAWParserState::m_header
MWAWHeader * m_header
the header
Definition: MWAWParser.hxx:64
MWAWParser::getListener
MWAWContentListenerPtr & getListener()
returns the listener
Definition: MWAWParser.hxx:125
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:67
MWAWParser::setVersion
void setVersion(int vers)
sets the works version
Definition: MWAWParser.hxx:102
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition: MWAWParser.hxx:153
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition: MWAWParser.hxx:129
MWAWParser::getFormLength
double getFormLength() const
returns the form length
Definition: MWAWParser.hxx:137
MWAWParser::getHeader
MWAWHeader * getHeader()
returns the header
Definition: MWAWParser.hxx:117
MWAWParser::resetListener
void resetListener()
resets the listener
Definition: MWAWParser.cxx:83
MWAWParser::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: MWAWParser.hxx:186
MWAWParser::setListener
void setListener(MWAWContentListenerPtr &listener)
sets the listener
Definition: MWAWParser.cxx:78
MWAWParser::MWAWParser
MWAWParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor (protected)
Definition: MWAWParser.cxx:68
MWAWParser::operator=
MWAWParser & operator=(const MWAWParser &)
private operator=: forbidden
MWAWParser::MWAWParser
MWAWParser(MWAWParserStatePtr state)
constructor using a state
Definition: MWAWParser.hxx:110
MWAWParserState::~MWAWParserState
~MWAWParserState()
destructor
Definition: MWAWParser.cxx:49
MWAWParser::getFontConverter
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition: MWAWParser.hxx:161
MWAWPageSpan::getPageLength
double getPageLength() const
returns the page length (form width without margin )
Definition: MWAWPageSpan.hxx:140
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition: MWAWParser.hxx:171
MWAWParserState
a class to define the parser state
Definition: MWAWParser.hxx:51
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:340
MWAWParserState::m_asciiFile
libmwaw::DebugFile m_asciiFile
the debug file
Definition: MWAWParser.hxx:76
MWAWParserState::m_version
int m_version
the actual version
Definition: MWAWParser.hxx:60
MWAWPageSpan::getFormWidth
double getFormWidth() const
returns the page width
Definition: MWAWPageSpan.hxx:116
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition: MWAWParser.hxx:167
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition: MWAWParser.hxx:113
MWAWParserState::m_listManager
MWAWListManagerPtr m_listManager
the list manager
Definition: MWAWParser.hxx:71
MWAWParser::version
int version() const
returns the works version
Definition: MWAWParser.hxx:98
MWAWParser::getPageLength
double getPageLength() const
returns the page length (form length without margin )
Definition: MWAWParser.hxx:145
MWAWPageSpan::getFormLength
double getFormLength() const
returns the page length
Definition: MWAWPageSpan.hxx:112
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
MWAWInputStream.hxx
MWAWDebug.hxx
MWAWParser::~MWAWParser
virtual ~MWAWParser()
virtual destructor
Definition: MWAWParser.cxx:74
MWAWParser::getPageSpan
MWAWPageSpan & getPageSpan()
returns the actual page dimension
Definition: MWAWParser.hxx:133
MWAWFontConverterPtr
shared_ptr< MWAWFontConverter > MWAWFontConverterPtr
a smart pointer of MWAWFontConverter
Definition: libmwaw_internal.hxx:334
MWAWContentListenerPtr
shared_ptr< MWAWContentListener > MWAWContentListenerPtr
a smart pointer of MWAWContentListener
Definition: libmwaw_internal.hxx:330
MWAWParser::getFormWidth
double getFormWidth() const
returns the form width
Definition: MWAWParser.hxx:141
MWAWParser::m_asciiName
std::string m_asciiName
the debug file name
Definition: MWAWParser.hxx:190
MWAWParserState::m_rsrcParser
MWAWRSRCParserPtr m_rsrcParser
the resource parser
Definition: MWAWParser.hxx:66
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:342
MWAWParser::setFontConverter
void setFontConverter(MWAWFontConverterPtr fontConverter)
sets the font convertor
Definition: MWAWParser.cxx:89
MWAWPageSpan::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition: MWAWPageSpan.hxx:144
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:87
MWAWParser::m_pageSpan
MWAWPageSpan m_pageSpan
the actual document size
Definition: MWAWParser.hxx:188
MWAWHeader.hxx
MWAWParserState::m_fontConverter
MWAWFontConverterPtr m_fontConverter
the fonct converter
Definition: MWAWParser.hxx:69
MWAWParserState::m_input
MWAWInputStreamPtr m_input
the input
Definition: MWAWParser.hxx:62
MWAWParser::checkHeader
virtual bool checkHeader(MWAWHeader *header, bool strict=false)=0
virtual function used to check if the document header is correct (or not)
MWAWParserState::m_listener
MWAWContentListenerPtr m_listener
the listener
Definition: MWAWParser.hxx:73
MWAWListManagerPtr
shared_ptr< MWAWListManager > MWAWListManagerPtr
a smart pointer of MWAWListManager
Definition: libmwaw_internal.hxx:338
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition: MWAWParser.hxx:121