MWProParser.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 MW_PRO_PARSER
# define MW_PRO_PARSER
#include <list>
#include <string>
#include <vector>
#include "MWAWDebug.hxx"
#include "MWAWEntry.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWParser.hxx"
class WPXBinaryData;
namespace MWProParserInternal
{
struct State;
struct TextZoneData;
struct TextZone;
struct Token;
struct Zone;
class SubDocument;
}
class MWProStructures;
class MWProStructuresListenerState;
class MWProParser : public MWAWParser
{
friend class MWProStructures;
friend class MWProStructuresListenerState;
friend class MWProParserInternal::SubDocument;
public:
MWProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
virtual ~MWProParser();
bool checkHeader(MWAWHeader *header, bool strict=false);
// the main parse function
void parse(WPXDocumentInterface *documentInterface);
protected:
void init();
void createDocument(WPXDocumentInterface *documentInterface);
bool createZones();
bool getZoneData(WPXBinaryData &data, int blockId);
bool getFreeZoneList(int blockId, std::vector<int> &blockLists);
bool parseDataZone(int blockId, int type);
bool parseTextZone(shared_ptr<MWProParserInternal::Zone> zone);
bool readTextEntries(shared_ptr<MWProParserInternal::Zone> zone,
std::vector<MWAWEntry> &res, int textLength);
bool readTextIds(shared_ptr<MWProParserInternal::Zone> zone,
std::vector<MWProParserInternal::TextZoneData> &res,
int textLength, int type);
bool readTextTokens(shared_ptr<MWProParserInternal::Zone> zone,
std::vector<MWProParserInternal::Token> &res,
int textLength);
std::vector<int> const &getBlocksCalledByToken() const;
float pageHeight() const;
int numColumns() const;
void newPage(int number, bool softBreak=false);
//
// interface with MWProParserStructures
//
bool sendTextZone(int blockId, bool mainZone = false);
int findNumHardBreaks(int blockId);
bool sendPictureZone(int blockId, MWAWPosition const &pictPos,
WPXPropertyList extras = WPXPropertyList());
bool sendTextBoxZone(int blockId, MWAWPosition const &pos,
WPXPropertyList extras = WPXPropertyList());
bool sendEmptyFrameZone(MWAWPosition const &pos, WPXPropertyList extras);
//
// low level
//
bool readPrintInfo();
bool readDocHeader();
#ifdef DEBUG
void saveOriginal(MWAWInputStreamPtr input);
#endif
bool sendPicture(shared_ptr<MWProParserInternal::Zone> zone, MWAWPosition pictPos, WPXPropertyList const &extras);
bool sendText(shared_ptr<MWProParserInternal::TextZone> zone, bool mainZone = false);
int findNumHardBreaks(shared_ptr<MWProParserInternal::TextZone> zone);
void checkUnparsed();
protected:
//
// data
//
shared_ptr<MWProParserInternal::State> m_state;
shared_ptr<MWProStructures> m_structures;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWProStructuresListenerState
an interface to transmit the info of MWProStructures to a listener
Definition: MWProStructures.hxx:72
MWProParserInternal::SubDocument
Internal: the subdocument of a MWProParser.
Definition: MWProParser.cxx:233
MWAWHeader
a function used by MWAWDocument to store the version of document and the input
Definition: MWAWHeader.hxx:47
MWProStructures
the main class to read the structures part of MacWrite Pro file
Definition: MWProStructures.hxx:153
MWProParser::MWProParser
MWProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: MWProParser.cxx:296
MWProParser::sendTextZone
bool sendTextZone(int blockId, bool mainZone=false)
send a text box
Definition: MWProParser.cxx:1364
MWProParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: MWProParser.cxx:645
MWProParser::m_structures
shared_ptr< MWProStructures > m_structures
the structures parser
Definition: MWProParser.hxx:191
MWAWParser.hxx
MWProParser::sendText
bool sendText(shared_ptr< MWProParserInternal::TextZone > zone, bool mainZone=false)
try to send a text
Definition: MWProParser.cxx:1413
MWAWEntry.hxx
MWProParser::getBlocksCalledByToken
std::vector< int > const & getBlocksCalledByToken() const
return the list of blockid called by token.
Definition: MWProParser.cxx:349
MWProParser::parseTextZone
bool parseTextZone(shared_ptr< MWProParserInternal::Zone > zone)
parse a text zone
Definition: MWProParser.cxx:988
MWProParser::readTextIds
bool readTextIds(shared_ptr< MWProParserInternal::Zone > zone, std::vector< MWProParserInternal::TextZoneData > &res, int textLength, int type)
try to read the text id entries
Definition: MWProParser.cxx:1113
MWProParser::newPage
void newPage(int number, bool softBreak=false)
adds a new page
Definition: MWProParser.cxx:330
MWProParser::sendEmptyFrameZone
bool sendEmptyFrameZone(MWAWPosition const &pos, WPXPropertyList extras)
try to send an empty zone (can exist in MWPro1.5)
Definition: MWProParser.cxx:1315
MWProParser::getZoneData
bool getZoneData(WPXBinaryData &data, int blockId)
retrieve the data which corresponds to a zone
Definition: MWProParser.cxx:409
MWProParser
the main class to read a MacWrite II and MacWrite Pro file
Definition: MWProParser.hxx:68
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:340
MWProParser::numColumns
int numColumns() const
returns the document number of columns ( filed in MWII)
Definition: MWProParser.cxx:321
MWProParser::createZones
bool createZones()
finds the different objects zones
Definition: MWProParser.cxx:614
MWProParser::checkUnparsed
void checkUnparsed()
a debug function which can be used to save the unparsed block
Definition: MWProParser.cxx:1764
MWProParser::sendPictureZone
bool sendPictureZone(int blockId, MWAWPosition const &pictPos, WPXPropertyList extras=WPXPropertyList())
try to send a picture
Definition: MWProParser.cxx:1603
MWProParser::readDocHeader
bool readDocHeader()
try to read the doc header zone
Definition: MWProParser.cxx:772
MWProParser::getFreeZoneList
bool getFreeZoneList(int blockId, std::vector< int > &blockLists)
return the chain list of block ( used to get free blocks)
Definition: MWProParser.cxx:489
MWProParser::findNumHardBreaks
int findNumHardBreaks(int blockId)
compute the number of hard page break
Definition: MWProParser.cxx:1328
MWProParser::m_state
shared_ptr< MWProParserInternal::State > m_state
the state
Definition: MWProParser.hxx:188
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
MWProParser::parseDataZone
bool parseDataZone(int blockId, int type)
parse a data zone
Definition: MWProParser.cxx:945
MWProParser::parse
void parse(WPXDocumentInterface *documentInterface)
virtual function used to parse the input
Definition: MWProParser.cxx:358
MWAWInputStream.hxx
MWAWDebug.hxx
MWProParser::init
void init()
inits all internal variables
Definition: MWProParser.cxx:306
MWProParser::readTextEntries
bool readTextEntries(shared_ptr< MWProParserInternal::Zone > zone, std::vector< MWAWEntry > &res, int textLength)
try to read the text block entries
Definition: MWProParser.cxx:1038
MWProParser::sendPicture
bool sendPicture(shared_ptr< MWProParserInternal::Zone > zone, MWAWPosition pictPos, WPXPropertyList const &extras)
try to send a picture
Definition: MWProParser.cxx:1616
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:87
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MWProParser::sendTextBoxZone
bool sendTextBoxZone(int blockId, MWAWPosition const &pos, WPXPropertyList extras=WPXPropertyList())
send a textbox zone
Definition: MWProParser.cxx:1376
MWProParser::readPrintInfo
bool readPrintInfo()
read the print info zone
Definition: MWProParser.cxx:719
MWProParser::~MWProParser
virtual ~MWProParser()
destructor
Definition: MWProParser.cxx:302
MWProParser::createDocument
void createDocument(WPXDocumentInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MWProParser.cxx:544
MWProParser::pageHeight
float pageHeight() const
returns the page height, ie. paper size less margin (in inches)
MWProParser::readTextTokens
bool readTextTokens(shared_ptr< MWProParserInternal::Zone > zone, std::vector< MWProParserInternal::Token > &res, int textLength)
try to read the text token entries
Definition: MWProParser.cxx:1177