WNParser.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.
*/
/*
* parser for WriteNow 3.0 and 4.0
*
* Note: WriteNow 2.0 seems very different
*/
#ifndef WN_PARSER
# define WN_PARSER
#include <list>
#include <string>
#include <vector>
#include "MWAWDebug.hxx"
#include "MWAWEntry.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWPosition.hxx"
#include "MWAWParser.hxx"
namespace WNParserInternal
{
struct State;
class SubDocument;
}
struct WNEntry;
struct WNEntryManager;
class WNText;
class WNParser : public MWAWParser
{
friend class WNText;
friend class WNParserInternal::SubDocument;
public:
WNParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
virtual ~WNParser();
bool checkHeader(MWAWHeader *header, bool strict=false);
// the main parse function
void parse(WPXDocumentInterface *documentInterface);
protected:
void init();
void createDocument(WPXDocumentInterface *documentInterface);
bool createZones();
void getColumnInfo(int &numColumns, int &width) const;
void newPage(int number);
/*
* interface with WNText
*/
bool getColor(int colId, MWAWColor &col) const;
void sendFootnote(WNEntry const &entry);
bool sendGraphic(int gId, Box2i const &bdbox);
/*
* interface with subdocument
*/
void send(WNEntry const &entry);
//
// low level
//
bool readDocEntries();
bool readDocEntriesV2();
bool parseGraphicZone(WNEntry const &entry);
bool readColorMap(WNEntry const &entry);
bool readPrintInfo(WNEntry const &entry);
bool readGenericUnkn(WNEntry const &entry);
bool sendPicture(WNEntry const &entry, Box2i const &bdbox);
WNEntry readEntry();
bool checkIfPositionValid(long pos);
protected:
//
// data
//
shared_ptr<WNParserInternal::State> m_state;
shared_ptr<WNEntryManager> m_entryManager;
shared_ptr<WNText> m_textParser;
};
#endif
// 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
WNParser::readColorMap
bool readColorMap(WNEntry const &entry)
try to read the colormap zone
Definition: WNParser.cxx:709
WNParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: WNParser.cxx:1015
MWAWParser.hxx
MWAWEntry.hxx
Box2< int >
WNParser::m_entryManager
shared_ptr< WNEntryManager > m_entryManager
the list of entry
Definition: WNParser.hxx:161
WNParser::readPrintInfo
bool readPrintInfo(WNEntry const &entry)
try to read the print info zone
Definition: WNParser.cxx:816
WNParser::checkIfPositionValid
bool checkIfPositionValid(long pos)
check if a position is inside the file
Definition: WNParser.cxx:976
WNParser::~WNParser
virtual ~WNParser()
destructor
Definition: WNParser.cxx:141
MWAWColor
the class to store a color
Definition: libmwaw_internal.hxx:161
WNParser::m_state
shared_ptr< WNParserInternal::State > m_state
the state
Definition: WNParser.hxx:158
WNParser::createZones
bool createZones()
finds the different objects zones
Definition: WNParser.cxx:317
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:340
WNParser::readGenericUnkn
bool readGenericUnkn(WNEntry const &entry)
try to read the last generic zones
Definition: WNParser.cxx:892
WNParser::parseGraphicZone
bool parseGraphicZone(WNEntry const &entry)
try to read the graphic zone (unknown + list of entries ) and to create the graphic data zone ...
Definition: WNParser.cxx:545
WNParserInternal::SubDocument
Internal: the subdocument of a WNParser.
Definition: WNParser.cxx:84
WNParser::createDocument
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: WNParser.cxx:269
WNParser::readEntry
WNEntry readEntry()
read a file entry
Definition: WNParser.cxx:990
WNParser::readDocEntriesV2
bool readDocEntriesV2()
try to read the document entries zone v2
Definition: WNParser.cxx:468
WNParser::init
void init()
inits all internal variables
Definition: WNParser.cxx:145
WNEntry
Definition: WNEntry.hxx:47
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
MWAWInputStream.hxx
MWAWDebug.hxx
WNParser::sendFootnote
void sendFootnote(WNEntry const &entry)
try to send a footnote entry
Definition: WNParser.cxx:193
WNParser::parse
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: WNParser.cxx:225
WNParser::WNParser
WNParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: WNParser.cxx:135
WNParser::newPage
void newPage(int number)
adds a new page
Definition: WNParser.cxx:171
WNParser::sendPicture
bool sendPicture(WNEntry const &entry, Box2i const &bdbox)
try to send a picture to the listener
Definition: WNParser.cxx:623
MWAWPosition.hxx
WNParser
the main class to read a WriteNow file
Definition: WNParser.hxx:68
WNParser::getColumnInfo
void getColumnInfo(int &numColumns, int &width) const
returns the columns information
Definition: WNParser.cxx:162
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:87
WNText
the main class to read the text part of writenow file
Definition: WNText.hxx:81
WNParser::send
void send(WNEntry const &entry)
try to send an entry
Definition: WNParser.cxx:201
WNParser::sendGraphic
bool sendGraphic(int gId, Box2i const &bdbox)
try to send the graphic zone
Definition: WNParser.cxx:206
WNParser::readDocEntries
bool readDocEntries()
try to read the document entries zone v3-v4
Definition: WNParser.cxx:379
WNEntryManager
the manager of the entries
Definition: WNEntry.hxx:93
WNParser::getColor
bool getColor(int colId, MWAWColor &col) const
returns the color which corresponds to colId
Definition: WNParser.cxx:184
WNParser::m_textParser
shared_ptr< WNText > m_textParser
the text parser
Definition: WNParser.hxx:164