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 MWAWParserState
{
public:
enum Type { Graphic, Presentation, Spreadsheet, Text };
MWAWParserState(Type type, MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
~MWAWParserState();
MWAWListenerPtr getMainListener();
Type m_type;
MWAWDocument::Kind m_kind;
MWAWInputStreamPtr m_input;
MWAWHeader *m_header;
MWAWRSRCParserPtr m_rsrcParser;
MWAWPageSpan m_pageSpan;
MWAWFontConverterPtr m_fontConverter;
MWAWFontManagerPtr m_fontManager;
MWAWGraphicListenerPtr m_graphicListener;
MWAWListManagerPtr m_listManager;
MWAWPresentationListenerPtr m_presentationListener;
MWAWSpreadsheetListenerPtr m_spreadsheetListener;
MWAWTextListenerPtr m_textListener;
int m_version;
libmwaw::DebugFile m_asciiFile;
private:
MWAWParserState(MWAWParserState const &orig) = delete;
MWAWParserState &operator=(MWAWParserState const &orig) = delete;
};
class MWAWParser
{
public:
virtual ~MWAWParser();
virtual bool checkHeader(MWAWHeader *header, bool strict=false) = 0;
int version() const
{
return m_parserState->m_version;
}
MWAWParserStatePtr getParserState()
{
return m_parserState;
}
MWAWHeader *getHeader()
{
return m_parserState->m_header;
}
MWAWInputStreamPtr &getInput()
{
return m_parserState->m_input;
}
MWAWListenerPtr getMainListener();
MWAWGraphicListenerPtr &getGraphicListener()
{
return m_parserState->m_graphicListener;
}
MWAWPresentationListenerPtr &getPresentationListener()
{
return m_parserState->m_presentationListener;
}
MWAWSpreadsheetListenerPtr &getSpreadsheetListener()
{
return m_parserState->m_spreadsheetListener;
}
MWAWTextListenerPtr &getTextListener()
{
return m_parserState->m_textListener;
}
MWAWFontConverterPtr &getFontConverter()
{
return m_parserState->m_fontConverter;
}
MWAWFontManagerPtr &getFontManager()
{
return m_parserState->m_fontManager;
}
MWAWPageSpan const &getPageSpan() const
{
return m_parserState->m_pageSpan;
}
MWAWPageSpan &getPageSpan()
{
return m_parserState->m_pageSpan;
}
double getFormLength() const
{
return m_parserState->m_pageSpan.getFormLength();
}
double getFormWidth() const
{
return m_parserState->m_pageSpan.getFormWidth();
}
double getPageLength() const
{
return m_parserState->m_pageSpan.getPageLength();
}
double getPageWidth() const
{
return m_parserState->m_pageSpan.getPageWidth();
}
MWAWRSRCParserPtr &getRSRCParser()
{
return m_parserState->m_rsrcParser;
}
libmwaw::DebugFile &ascii()
{
return m_parserState->m_asciiFile;
}
protected:
MWAWParser(MWAWParserState::Type type, MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
explicit MWAWParser(MWAWParserStatePtr const &state) : m_parserState(state), m_asciiName("") { }
void setVersion(int vers)
{
m_parserState->m_version = vers;
}
void setGraphicListener(MWAWGraphicListenerPtr &listener);
void resetGraphicListener();
void setPresentationListener(MWAWPresentationListenerPtr &listener);
void resetPresentationListener();
void setSpreadsheetListener(MWAWSpreadsheetListenerPtr &listener);
void resetSpreadsheetListener();
void setTextListener(MWAWTextListenerPtr &listener);
void resetTextListener();
void setAsciiName(char const *name)
{
m_asciiName = name;
}
std::string const &asciiName() const
{
return m_asciiName;
}
private:
MWAWParser(const MWAWParser &) = delete;
MWAWParser &operator=(const MWAWParser &) = delete;
MWAWParserStatePtr m_parserState;
std::string m_asciiName;
};
class MWAWGraphicParser : public MWAWParser
{
public:
~MWAWGraphicParser() override;
virtual void parse(librevenge::RVNGDrawingInterface *documentInterface) = 0;
protected:
MWAWGraphicParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Graphic, input, rsrcParser, header) {}
explicit MWAWGraphicParser(MWAWParserStatePtr const &state)
: MWAWParser(state) {}
};
class MWAWPresentationParser : public MWAWParser
{
public:
~MWAWPresentationParser() override;
virtual void parse(librevenge::RVNGPresentationInterface *documentInterface) = 0;
protected:
MWAWPresentationParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Presentation, input, rsrcParser, header) {}
explicit MWAWPresentationParser(MWAWParserStatePtr const &state)
: MWAWParser(state) {}
};
class MWAWSpreadsheetParser : public MWAWParser
{
public:
~MWAWSpreadsheetParser() override;
virtual void parse(librevenge::RVNGSpreadsheetInterface *documentInterface) = 0;
protected:
MWAWSpreadsheetParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Spreadsheet, input, rsrcParser, header) {}
explicit MWAWSpreadsheetParser(MWAWParserStatePtr const &state)
: MWAWParser(state) {}
};
class MWAWTextParser : public MWAWParser
{
public:
~MWAWTextParser() override;
virtual void parse(librevenge::RVNGTextInterface *documentInterface) = 0;
protected:
MWAWTextParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header) : MWAWParser(MWAWParserState::Text, input, rsrcParser, header) {}
explicit MWAWTextParser(MWAWParserStatePtr const &state)
: MWAWParser(state) {}
};
#endif /* MWAWPARSER_H */
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWEntry.hxx
MWAWHeader.hxx
Defines MWAWHeader (document's type, version, kind).
MWAWInputStream.hxx
MWAWPageSpan.hxx
MWAWDocument::Kind
Kind
an enum to define the kind of document
Definition MWAWDocument.hxx:80
MWAWGraphicParser::MWAWGraphicParser
MWAWGraphicParser(MWAWParserStatePtr const &state)
constructor using a state
Definition MWAWParser.hxx:261
MWAWGraphicParser::parse
virtual void parse(librevenge::RVNGDrawingInterface *documentInterface)=0
virtual function used to parse the input
MWAWGraphicParser::MWAWGraphicParser
MWAWGraphicParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:259
MWAWGraphicParser::~MWAWGraphicParser
~MWAWGraphicParser() override
destructor
Definition MWAWParser.cxx:173
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition MWAWHeader.hxx:57
MWAWPageSpan
A class which defines the page properties.
Definition MWAWPageSpan.hxx:99
MWAWParserState
a class to define the parser state
Definition MWAWParser.hxx:50
MWAWParserState::m_pageSpan
MWAWPageSpan m_pageSpan
the actual document size
Definition MWAWParser.hxx:71
MWAWParserState::m_type
Type m_type
the state type
Definition MWAWParser.hxx:61
MWAWParserState::m_input
MWAWInputStreamPtr m_input
the input
Definition MWAWParser.hxx:65
MWAWParserState::m_kind
MWAWDocument::Kind m_kind
the document kind
Definition MWAWParser.hxx:63
MWAWParserState::m_version
int m_version
the actual version
Definition MWAWParser.hxx:88
MWAWParserState::m_textListener
MWAWTextListenerPtr m_textListener
the text listener
Definition MWAWParser.hxx:86
MWAWParserState::m_listManager
MWAWListManagerPtr m_listManager
the list manager
Definition MWAWParser.hxx:80
MWAWParserState::MWAWParserState
MWAWParserState(MWAWParserState const &orig)=delete
MWAWParserState::m_rsrcParser
MWAWRSRCParserPtr m_rsrcParser
the resource parser
Definition MWAWParser.hxx:69
MWAWParserState::m_fontManager
MWAWFontManagerPtr m_fontManager
the font manager
Definition MWAWParser.hxx:76
MWAWParserState::~MWAWParserState
~MWAWParserState()
destructor
Definition MWAWParser.cxx:71
MWAWParserState::getMainListener
MWAWListenerPtr getMainListener()
returns the main listener
Definition MWAWParser.cxx:91
MWAWParserState::MWAWParserState
MWAWParserState(Type type, MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
Constructor.
Definition MWAWParser.cxx:45
MWAWParserState::m_presentationListener
MWAWPresentationListenerPtr m_presentationListener
the presentation listener
Definition MWAWParser.hxx:82
MWAWParserState::m_spreadsheetListener
MWAWSpreadsheetListenerPtr m_spreadsheetListener
the spreadsheet listener
Definition MWAWParser.hxx:84
MWAWParserState::operator=
MWAWParserState & operator=(MWAWParserState const &orig)=delete
MWAWParserState::m_header
MWAWHeader * m_header
the header
Definition MWAWParser.hxx:67
MWAWParserState::m_graphicListener
MWAWGraphicListenerPtr m_graphicListener
the graphic listener
Definition MWAWParser.hxx:78
MWAWParserState::m_asciiFile
libmwaw::DebugFile m_asciiFile
the debug file
Definition MWAWParser.hxx:91
MWAWParserState::m_fontConverter
MWAWFontConverterPtr m_fontConverter
the font converter
Definition MWAWParser.hxx:74
MWAWParserState::Type
Type
the parser state type
Definition MWAWParser.hxx:53
MWAWParserState::Spreadsheet
@ Spreadsheet
Definition MWAWParser.hxx:53
MWAWParserState::Presentation
@ Presentation
Definition MWAWParser.hxx:53
MWAWParserState::Graphic
@ Graphic
Definition MWAWParser.hxx:53
MWAWParserState::Text
@ Text
Definition MWAWParser.hxx:53
MWAWParser::setSpreadsheetListener
void setSpreadsheetListener(MWAWSpreadsheetListenerPtr &listener)
sets the spreadsheet listener
Definition MWAWParser.cxx:147
MWAWParser::setVersion
void setVersion(int vers)
sets the document's version
Definition MWAWParser.hxx:206
MWAWParser::MWAWParser
MWAWParser(MWAWParserState::Type type, MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.cxx:110
MWAWParser::getFormWidth
double getFormWidth() const
returns the form width
Definition MWAWParser.hxx:175
MWAWParser::getRSRCParser
MWAWRSRCParserPtr & getRSRCParser()
returns the rsrc parser
Definition MWAWParser.hxx:190
MWAWParser::resetTextListener
void resetTextListener()
resets the listener
Definition MWAWParser.cxx:163
MWAWParser::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition MWAWParser.hxx:244
MWAWParser::getParserState
MWAWParserStatePtr getParserState()
returns the parser state
Definition MWAWParser.hxx:113
MWAWParser::operator=
MWAWParser & operator=(const MWAWParser &)=delete
private operator=: forbidden
MWAWParser::m_asciiName
std::string m_asciiName
the debug file name
Definition MWAWParser.hxx:246
MWAWParser::MWAWParser
MWAWParser(MWAWParserStatePtr const &state)
constructor using a state
Definition MWAWParser.hxx:203
MWAWParser::setAsciiName
void setAsciiName(char const *name)
Debugging: change the default ascii file.
Definition MWAWParser.hxx:227
MWAWParser::getFontConverter
MWAWFontConverterPtr & getFontConverter()
returns the font converter
Definition MWAWParser.hxx:150
MWAWParser::setTextListener
void setTextListener(MWAWTextListenerPtr &listener)
sets the text listener
Definition MWAWParser.cxx:158
MWAWParser::setGraphicListener
void setGraphicListener(MWAWGraphicListenerPtr &listener)
sets the graphic listener
Definition MWAWParser.cxx:125
MWAWParser::resetGraphicListener
void resetGraphicListener()
resets the listener
Definition MWAWParser.cxx:130
MWAWParser::setPresentationListener
void setPresentationListener(MWAWPresentationListenerPtr &listener)
sets the presentation listener
Definition MWAWParser.cxx:136
MWAWParser::getPageLength
double getPageLength() const
returns the page length (form length without margin )
Definition MWAWParser.hxx:180
MWAWParser::MWAWParser
MWAWParser(const MWAWParser &)=delete
private copy constructor: forbidden
MWAWParser::getHeader
MWAWHeader * getHeader()
returns the header
Definition MWAWParser.hxx:118
MWAWParser::asciiName
std::string const & asciiName() const
return the ascii file name
Definition MWAWParser.hxx:232
MWAWParser::ascii
libmwaw::DebugFile & ascii()
a DebugFile used to write what we recognize when we parse the document
Definition MWAWParser.hxx:195
MWAWParser::getPageSpan
MWAWPageSpan const & getPageSpan() const
returns the actual page dimension
Definition MWAWParser.hxx:160
MWAWParser::resetPresentationListener
void resetPresentationListener()
resets the listener
Definition MWAWParser.cxx:141
MWAWParser::getTextListener
MWAWTextListenerPtr & getTextListener()
returns the text listener
Definition MWAWParser.hxx:145
MWAWParser::getFormLength
double getFormLength() const
returns the form length
Definition MWAWParser.hxx:170
MWAWParser::getPresentationListener
MWAWPresentationListenerPtr & getPresentationListener()
returns the presentation listener
Definition MWAWParser.hxx:135
MWAWParser::version
int version() const
returns the works version
Definition MWAWParser.hxx:108
MWAWParser::getPageSpan
MWAWPageSpan & getPageSpan()
returns the actual page dimension
Definition MWAWParser.hxx:165
MWAWParser::getFontManager
MWAWFontManagerPtr & getFontManager()
returns the font manager
Definition MWAWParser.hxx:155
MWAWParser::getGraphicListener
MWAWGraphicListenerPtr & getGraphicListener()
returns the graphic listener
Definition MWAWParser.hxx:130
MWAWParser::getPageWidth
double getPageWidth() const
returns the page width (form width without margin )
Definition MWAWParser.hxx:185
MWAWParser::~MWAWParser
virtual ~MWAWParser()
virtual destructor
Definition MWAWParser.cxx:116
MWAWParser::getSpreadsheetListener
MWAWSpreadsheetListenerPtr & getSpreadsheetListener()
returns the spreadsheet listener
Definition MWAWParser.hxx:140
MWAWParser::resetSpreadsheetListener
void resetSpreadsheetListener()
resets the listener
Definition MWAWParser.cxx:152
MWAWParser::getInput
MWAWInputStreamPtr & getInput()
returns the actual input
Definition MWAWParser.hxx:123
MWAWParser::checkHeader
virtual bool checkHeader(MWAWHeader *header, bool strict=false)=0
virtual function used to check if the document header is correct (or not)
MWAWParser::getMainListener
MWAWListenerPtr getMainListener()
returns the main listener
Definition MWAWParser.cxx:120
MWAWPresentationParser::MWAWPresentationParser
MWAWPresentationParser(MWAWParserStatePtr const &state)
constructor using a state
Definition MWAWParser.hxx:277
MWAWPresentationParser::MWAWPresentationParser
MWAWPresentationParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:275
MWAWPresentationParser::~MWAWPresentationParser
~MWAWPresentationParser() override
destructor
Definition MWAWParser.cxx:177
MWAWPresentationParser::parse
virtual void parse(librevenge::RVNGPresentationInterface *documentInterface)=0
virtual function used to parse the input
MWAWSpreadsheetParser::MWAWSpreadsheetParser
MWAWSpreadsheetParser(MWAWParserStatePtr const &state)
constructor using a state
Definition MWAWParser.hxx:293
MWAWSpreadsheetParser::parse
virtual void parse(librevenge::RVNGSpreadsheetInterface *documentInterface)=0
virtual function used to parse the input
MWAWSpreadsheetParser::~MWAWSpreadsheetParser
~MWAWSpreadsheetParser() override
destructor
Definition MWAWParser.cxx:181
MWAWSpreadsheetParser::MWAWSpreadsheetParser
MWAWSpreadsheetParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:291
MWAWTextParser::parse
virtual void parse(librevenge::RVNGTextInterface *documentInterface)=0
virtual function used to parse the input
MWAWTextParser::MWAWTextParser
MWAWTextParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:307
MWAWTextParser::MWAWTextParser
MWAWTextParser(MWAWParserStatePtr const &state)
constructor using a state
Definition MWAWParser.hxx:309
MWAWTextParser::~MWAWTextParser
~MWAWTextParser() override
destructor
Definition MWAWParser.cxx:185
libmwaw::DebugFile
Definition MWAWDebug.hxx:66
MWAWPresentationListenerPtr
std::shared_ptr< MWAWPresentationListener > MWAWPresentationListenerPtr
a smart pointer of MWAWPresentationListener
Definition libmwaw_internal.hxx:559
MWAWListManagerPtr
std::shared_ptr< MWAWListManager > MWAWListManagerPtr
a smart pointer of MWAWListManager
Definition libmwaw_internal.hxx:555
MWAWGraphicListenerPtr
std::shared_ptr< MWAWGraphicListener > MWAWGraphicListenerPtr
a smart pointer of MWAWGraphicListener
Definition libmwaw_internal.hxx:549
MWAWSpreadsheetListenerPtr
std::shared_ptr< MWAWSpreadsheetListener > MWAWSpreadsheetListenerPtr
a smart pointer of MWAWSpreadsheetListener
Definition libmwaw_internal.hxx:563
MWAWFontConverterPtr
std::shared_ptr< MWAWFontConverter > MWAWFontConverterPtr
a smart pointer of MWAWFontConverter
Definition libmwaw_internal.hxx:545
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition libmwaw_internal.hxx:557
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition libmwaw_internal.hxx:561
MWAWListenerPtr
std::shared_ptr< MWAWListener > MWAWListenerPtr
a smart pointer of MWAWListener
Definition libmwaw_internal.hxx:553
MWAWFontManagerPtr
std::shared_ptr< MWAWFontManager > MWAWFontManagerPtr
a smart pointer of MWAWFontManager
Definition libmwaw_internal.hxx:547
MWAWTextListenerPtr
std::shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition libmwaw_internal.hxx:567
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551