MacWrtProParser.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 MAC_WRT_PRO_PARSER
# define MAC_WRT_PRO_PARSER
#include <list>
#include <string>
#include <vector>
#include "MWAWDebug.hxx"
#include "MWAWEntry.hxx"
#include "MWAWGraphicStyle.hxx"
#include "MWAWInputStream.hxx"
#include "MWAWParser.hxx"
namespace MacWrtProParserInternal
{
struct State;
struct TextZoneData;
struct TextZone;
struct Token;
struct Zone;
class SubDocument;
}
class MacWrtProStructures;
class MacWrtProStructuresListenerState;
class MacWrtProParser final : public MWAWTextParser
{
friend class MacWrtProStructures;
friend class MacWrtProStructuresListenerState;
friend class MacWrtProParserInternal::SubDocument;
public:
MacWrtProParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
~MacWrtProParser() final;
bool checkHeader(MWAWHeader *header, bool strict=false) final;
// the main parse function
void parse(librevenge::RVNGTextInterface *documentInterface) final;
protected:
void init();
void createDocument(librevenge::RVNGTextInterface *documentInterface);
bool createZones();
std::shared_ptr<MWAWStream> getStreamForBlock(int bId);
bool getFreeZoneList(std::vector<int> &blockLists);
bool parseDataZone(int blockId, int type);
bool parseTextZone(std::shared_ptr<MacWrtProParserInternal::Zone> zone);
bool readTextEntries(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
std::vector<MWAWEntry> &res, int textLength);
bool readTextIds(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
std::vector<MacWrtProParserInternal::TextZoneData> &res,
int textLength, int type);
bool readTextTokens(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
std::vector<MacWrtProParserInternal::Token> &res,
int textLength);
std::vector<int> const &getGraphicIdCalledByToken() const;
float pageHeight() const;
int numColumns(double &sep) const;
void newPage(int number, bool softBreak=false);
bool hasTitlePage() const;
std::shared_ptr<MWAWSubDocument> getSubDocument(int blockId);
//
// interface with MacWrtProParserStructures
//
bool sendTextZone(int blockId, bool mainZone = false);
int findNumHardBreaks(int blockId);
bool sendPictureZone(int blockId, MWAWPosition const &pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
bool sendTextBoxZone(int blockId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
bool sendEmptyFrameZone(MWAWPosition const &pos, MWAWGraphicStyle const &style);
//
// low level
//
bool readPrintInfo();
bool readDocHeader();
bool sendPicture(std::shared_ptr<MacWrtProParserInternal::Zone> zone, MWAWPosition pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
bool sendText(std::shared_ptr<MacWrtProParserInternal::TextZone> zone, bool mainZone = false);
int findNumHardBreaks(std::shared_ptr<MacWrtProParserInternal::TextZone> zone);
static std::string convertDateToDebugString(unsigned date);
void checkUnparsed();
protected:
//
// data
//
std::shared_ptr<MacWrtProParserInternal::State> m_state;
std::shared_ptr<MacWrtProStructures> m_structures;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MWAWDebug.hxx
MWAWEntry.hxx
MWAWGraphicStyle.hxx
MWAWInputStream.hxx
MWAWParser.hxx
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MWAWGraphicStyle
a structure used to define a picture style
Definition MWAWGraphicStyle.hxx:48
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition MWAWHeader.hxx:57
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document.
Definition MWAWPosition.hxx:48
MWAWSubDocument
abstract class used to store a subdocument (with a comparison function)
Definition MWAWSubDocument.hxx:42
MWAWTextParser::MWAWTextParser
MWAWTextParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor (protected)
Definition MWAWParser.hxx:307
MacWrtProParserInternal::SubDocument
Internal: the subdocument of a MacWrtProParser.
Definition MacWrtProParser.cxx:255
MacWrtProParser::sendTextBoxZone
bool sendTextBoxZone(int blockId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
send a textbox zone
Definition MacWrtProParser.cxx:1378
MacWrtProParser::~MacWrtProParser
~MacWrtProParser() final
destructor
Definition MacWrtProParser.cxx:318
MacWrtProParser::readPrintInfo
bool readPrintInfo()
read the print info zone
Definition MacWrtProParser.cxx:701
MacWrtProParser::parseDataZone
bool parseDataZone(int blockId, int type)
parse a data zone
Definition MacWrtProParser.cxx:955
MacWrtProParser::pageHeight
float pageHeight() const
returns the page height, ie. paper size less margin (in inches)
MacWrtProParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition MacWrtProParser.cxx:384
MacWrtProParser::sendEmptyFrameZone
bool sendEmptyFrameZone(MWAWPosition const &pos, MWAWGraphicStyle const &style)
try to send an empty zone (can exist in MacWrtPro1.5)
Definition MacWrtProParser.cxx:1321
MacWrtProParser::readTextIds
bool readTextIds(std::shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MacWrtProParserInternal::TextZoneData > &res, int textLength, int type)
try to read the text id entries
Definition MacWrtProParser.cxx:1117
MacWrtProParser::init
void init()
inits all internal variables
Definition MacWrtProParser.cxx:322
MacWrtProParser::getStreamForBlock
std::shared_ptr< MWAWStream > getStreamForBlock(int bId)
returns a stream corresponding to a block
Definition MacWrtProParser.cxx:432
MacWrtProParser::getSubDocument
std::shared_ptr< MWAWSubDocument > getSubDocument(int blockId)
returns a subdocument corresponding to a blockid
Definition MacWrtProParser.cxx:376
MacWrtProParser::getGraphicIdCalledByToken
std::vector< int > const & getGraphicIdCalledByToken() const
return the list of graphicid called by token.
Definition MacWrtProParser.cxx:371
MacWrtProParser::parseTextZone
bool parseTextZone(std::shared_ptr< MacWrtProParserInternal::Zone > zone)
parse a text zone
Definition MacWrtProParser.cxx:993
MacWrtProParser::createZones
bool createZones()
finds the different objects zones
Definition MacWrtProParser.cxx:587
MacWrtProParser::readTextTokens
bool readTextTokens(std::shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MacWrtProParserInternal::Token > &res, int textLength)
try to read the text token entries
Definition MacWrtProParser.cxx:1182
MacWrtProParser::readDocHeader
bool readDocHeader()
try to read the doc header zone
Definition MacWrtProParser.cxx:754
MacWrtProParser::m_state
std::shared_ptr< MacWrtProParserInternal::State > m_state
the state
Definition MacWrtProParser.hxx:185
MacWrtProParser::checkUnparsed
void checkUnparsed()
a debug function which can be used to save the unparsed block
Definition MacWrtProParser.cxx:1718
MacWrtProParser::readTextEntries
bool readTextEntries(std::shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MWAWEntry > &res, int textLength)
try to read the text block entries
Definition MacWrtProParser.cxx:1043
MacWrtProParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition MacWrtProParser.cxx:621
MacWrtProParser::m_structures
std::shared_ptr< MacWrtProStructures > m_structures
the structures parser
Definition MacWrtProParser.hxx:188
MacWrtProParser::convertDateToDebugString
static std::string convertDateToDebugString(unsigned date)
convert a date in a string (for debugging)
Definition MacWrtProParser.cxx:1767
MacWrtProParser::newPage
void newPage(int number, bool softBreak=false)
adds a new page
Definition MacWrtProParser.cxx:347
MacWrtProParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition MacWrtProParser.cxx:551
MacWrtProParser::numColumns
int numColumns(double &sep) const
returns the document number of columns and the column separator width in inch( filed in MWII)
Definition MacWrtProParser.cxx:337
MacWrtProParser::sendPictureZone
bool sendPictureZone(int blockId, MWAWPosition const &pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
try to send a picture
Definition MacWrtProParser.cxx:1603
MacWrtProParser::MacWrtProStructures
friend class MacWrtProStructures
Definition MacWrtProParser.hxx:69
MacWrtProParser::findNumHardBreaks
int findNumHardBreaks(int blockId)
compute the number of hard page break
Definition MacWrtProParser.cxx:1333
MacWrtProParser::sendPicture
bool sendPicture(std::shared_ptr< MacWrtProParserInternal::Zone > zone, MWAWPosition pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
try to send a picture
Definition MacWrtProParser.cxx:1615
MacWrtProParser::MacWrtProStructuresListenerState
friend class MacWrtProStructuresListenerState
Definition MacWrtProParser.hxx:70
MacWrtProParser::sendText
bool sendText(std::shared_ptr< MacWrtProParserInternal::TextZone > zone, bool mainZone=false)
try to send a text
Definition MacWrtProParser.cxx:1420
MacWrtProParser::hasTitlePage
bool hasTitlePage() const
returns true if the document has a title page
Definition MacWrtProParser.cxx:366
MacWrtProParser::MacWrtProParser
MacWrtProParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header)
constructor
Definition MacWrtProParser.cxx:310
MacWrtProParser::getFreeZoneList
bool getFreeZoneList(std::vector< int > &blockLists)
return the chain list of block ( used to get free blocks): MWPro only
Definition MacWrtProParser.cxx:511
MacWrtProParser::sendTextZone
bool sendTextZone(int blockId, bool mainZone=false)
send a text box
Definition MacWrtProParser.cxx:1367
MacWrtProStructuresListenerState
an interface to transmit the info of MacWrtProStructures to a listener
Definition MacWrtProStructures.hxx:70
MacWrtProStructures
the main class to read the structures part of MacWrite Pro file
Definition MacWrtProStructures.hxx:136
MWAWRSRCParserPtr
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition libmwaw_internal.hxx:561
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
MacWrtProParserInternal
Internal: the structures of a MacWrtProParser.
Definition MacWrtProParser.cxx:62
librevenge
Definition MWAWDocument.hxx:57
MWAWStream
small structure use to store a stream and it debug file
Definition MWAWStream.hxx:41
MacWrtProParserInternal::State
Internal: the state of a MacWrtProParser.
Definition MacWrtProParser.cxx:217
MacWrtProParserInternal::TextZoneData
Internal: a struct used to store a text zone.
Definition MacWrtProParser.cxx:91
MacWrtProParserInternal::TextZone
Internal: a struct used to store a text zone.
Definition MacWrtProParser.cxx:189
MacWrtProParserInternal::Token
Internal: a struct used to store a text zone.
Definition MacWrtProParser.cxx:123
MacWrtProParserInternal::Zone
Internal: a struct used to store a zone.
Definition MacWrtProParser.cxx:65