MSK4Text.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 MSK4_TEXT
# define MSK4_TEXT
#include <vector>
#include "MWAWEntry.hxx"
#include "MWAWDebug.hxx"
#include "MWAWInputStream.hxx"
namespace MSK4TextInternal
{
struct Font;
struct Paragraph;
struct State;
}
class MSK4Zone;
class MSK4Text
{
friend class MSK4Zone;
protected:
struct DataFOD;
typedef bool (MSK4Text::* FDPParser) (MWAWInputStreamPtr &input, long endPos,
int &id, std::string &mess);
public:
MSK4Text(MSK4Zone &parser);
~MSK4Text();
void setDefault(MWAWFont &font);
int numPages() const;
void flushExtra(MWAWInputStreamPtr /*input*/) {}
protected:
bool readStructures(MWAWInputStreamPtr input, bool mainOle);
bool readText(MWAWInputStreamPtr input, MWAWEntry const &entry, bool mainOle);
bool readFootNote(MWAWInputStreamPtr input, int id);
//----------------------------------------
// PLC parsing, setting
//----------------------------------------
typedef bool (MSK4Text::* DataParser)
(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess);
bool readPLC(MWAWInputStreamPtr input, MWAWEntry const &entry,
std::vector<long> &textPtrs, std::vector<long> &listValues,
DataParser parser = &MSK4Text::defDataParser);
bool readSimplePLC(MWAWInputStreamPtr &input, MWAWEntry const &entry,
std::vector<long> &textPtrs,
std::vector<long> &listValues) {
return readPLC(input, entry, textPtrs, listValues);
}
bool defDataParser(MWAWInputStreamPtr input, long endPos,
long bot, long eot, int id, std::string &mess);
bool readFontNames(MWAWInputStreamPtr input, MWAWEntry const &entry);
bool readFont (MWAWInputStreamPtr &input, long endPos,
int &id, std::string &mess);
void setProperty(MSK4TextInternal::Paragraph const &tabs);
bool readParagraph (MWAWInputStreamPtr &input, long endPos,
int &id, std::string &mess);
bool ftntDataParser(MWAWInputStreamPtr input, long endPos,
long bot, long eot, int id, std::string &mess);
bool eobjDataParser(MWAWInputStreamPtr input, long endPos,
long bot, long eot, int id, std::string &mess);
bool toknDataParser(MWAWInputStreamPtr input, long endPos,
long bot, long eot, int id, std::string &mess);
bool pgdDataParser(MWAWInputStreamPtr input, long endPos,
long , long, int id, std::string &mess);
void flushNote(int noteId);
protected:
MSK4Zone const *mainParser() const {
return m_mainParser;
}
MSK4Zone *mainParser() {
return m_mainParser;
}
std::vector<DataFOD> mergeSortedLists
(std::vector<DataFOD> const &lst1, std::vector<DataFOD> const &lst2) const;
bool readFDP(MWAWInputStreamPtr &input, MWAWEntry const &entry,
std::vector<DataFOD> &fods, FDPParser parser);
bool findFDPStructures(MWAWInputStreamPtr &input, int which);
bool findFDPStructuresByHand(MWAWInputStreamPtr &input, int which);
protected:
struct DataFOD {
enum Type { ATTR_TEXT, ATTR_PARAG, ATTR_PLC, ATTR_UNKN };
DataFOD() : m_type(ATTR_UNKN), m_pos(-1), m_defPos(0), m_id(-1) {}
Type m_type;
long m_pos;
long m_defPos;
int m_id;
};
private:
MSK4Text(MSK4Text const &orig);
MSK4Text &operator=(MSK4Text const &orig);
protected:
MWAWParserStatePtr m_parserState;
MSK4Zone *m_mainParser;
MWAWEntry m_textPositions;
mutable shared_ptr<MSK4TextInternal::State> m_state;
std::vector<DataFOD> m_FODsList;
std::vector<MWAWEntry const *> m_FDPCs;
std::vector<MWAWEntry const *> m_FDPPs;
};
#endif
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MSK4Text::DataFOD::DataFOD
DataFOD()
the constructor
Definition: MSK4Text.hxx:228
MSK4Text::flushExtra
void flushExtra(MWAWInputStreamPtr)
sends the data which have not been sent: actually do nothing
Definition: MSK4Text.hxx:89
MSK4Text::DataFOD::m_id
int m_id
an identificator (which must be unique by category)
Definition: MSK4Text.hxx:237
MSK4Text::operator=
MSK4Text & operator=(MSK4Text const &orig)
MWAWEntry.hxx
MSK4Text::FDPParser
bool(MSK4Text::* FDPParser)(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
callback when a new attribute is found in an FDPP/FDPC entry
Definition: MSK4Text.hxx:73
MSK4Text::setDefault
void setDefault(MWAWFont &font)
sets the default font
Definition: MSK4Text.cxx:1077
MSK4Text::DataFOD::m_pos
long m_pos
the offset position of the text modified by this attribute
Definition: MSK4Text.hxx:233
MSK4Text::numPages
int numPages() const
returns the number of pages
Definition: MSK4Text.cxx:457
MSK4Text::flushNote
void flushNote(int noteId)
sends to the listener the text which corresponds to noteId
MSK4Text::readPLC
bool readPLC(MWAWInputStreamPtr input, MWAWEntry const &entry, std::vector< long > &textPtrs, std::vector< long > &listValues, DataParser parser=&MSK4Text::defDataParser)
reads a PLC (Pointer List Composant ?) in zone entry
Definition: MSK4Text.cxx:808
MSK4Text::DataFOD::ATTR_PLC
Definition: MSK4Text.hxx:225
MSK4Text::DataParser
bool(MSK4Text::* DataParser)(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
definition of the plc data parser (low level)
Definition: MSK4Text.hxx:113
MSK4Text::findFDPStructuresByHand
bool findFDPStructuresByHand(MWAWInputStreamPtr &input, int which)
Fills the vector of (FDPCs/FDPPs) paragraph/characters strutures, a function to call when the normal ...
Definition: MSK4Text.cxx:1759
MSK4Text::m_FODsList
std::vector< DataFOD > m_FODsList
the list of a FOD
Definition: MSK4Text.hxx:257
MSK4Text::readText
bool readText(MWAWInputStreamPtr input, MWAWEntry const &entry, bool mainOle)
reads a text section and send it to the listener
Definition: MSK4Text.cxx:624
MSK4Text::readSimplePLC
bool readSimplePLC(MWAWInputStreamPtr &input, MWAWEntry const &entry, std::vector< long > &textPtrs, std::vector< long > &listValues)
reads a PLC (Pointer List Composant ?) in zone entry
Definition: MSK4Text.hxx:132
MSK4Text::ftntDataParser
bool ftntDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the footnote position : FTNT
Definition: MSK4Text.cxx:1521
MSK4Text::readParagraph
bool readParagraph(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
reads a paragraph properties
Definition: MSK4Text.cxx:1276
MSK4Text::readFDP
bool readFDP(MWAWInputStreamPtr &input, MWAWEntry const &entry, std::vector< DataFOD > &fods, FDPParser parser)
parses a FDPP or a FDPC entry (which contains a list of ATTR_TEXT/ATTR_PARAG with their definition ) ...
Definition: MSK4Text.cxx:1781
MSK4Text::m_textPositions
MWAWEntry m_textPositions
an entry which corresponds to the complete text zone
Definition: MSK4Text.hxx:251
MSK4Text::m_mainParser
MSK4Zone * m_mainParser
the main parser
Definition: MSK4Text.hxx:248
MSK4Text::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: MSK4Text.hxx:245
MSK4Text::mainParser
MSK4Zone * mainParser()
returns the main parser
Definition: MSK4Text.hxx:184
MSK4Text::eobjDataParser
bool eobjDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the object position : EOBJ
Definition: MSK4Text.cxx:1489
MSK4Text::~MSK4Text
~MSK4Text()
destructor
Definition: MSK4Text.cxx:451
MSK4Text::mergeSortedLists
std::vector< DataFOD > mergeSortedLists(std::vector< DataFOD > const &lst1, std::vector< DataFOD > const &lst2) const
function which takes two sorted list of attribute (by text position).
Definition: MSK4Text.cxx:1937
MSK4Text::defDataParser
bool defDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
the default parser (does nothing)
Definition: MSK4Text.cxx:988
MSK4Text::mainParser
MSK4Zone const * mainParser() const
returns the main parser
Definition: MSK4Text.hxx:180
MSK4Text::MSK4Text
MSK4Text(MSK4Zone &parser)
constructor
Definition: MSK4Text.cxx:444
MSK4Text::m_state
shared_ptr< MSK4TextInternal::State > m_state
the internal state
Definition: MSK4Text.hxx:254
MSK4Zone
The class which parses the main zones of a mac MS Works document v4.
Definition: MSK4Zone.hxx:76
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:336
MSK4Text::readFontNames
bool readFontNames(MWAWInputStreamPtr input, MWAWEntry const &entry)
reads the font names entry : FONT
Definition: MSK4Text.cxx:1012
MSK4Text::DataFOD::ATTR_PARAG
Definition: MSK4Text.hxx:225
MWAWInputStream.hxx
MWAWDebug.hxx
MSK4Text::DataFOD::Type
Type
different type which can be associated to a text position
Definition: MSK4Text.hxx:225
MSK4Text::DataFOD
structure which retrieves data information which correspond to a text position
Definition: MSK4Text.hxx:218
MSK4Text::DataFOD::ATTR_TEXT
Definition: MSK4Text.hxx:225
MSK4Text::readFont
bool readFont(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
reads a font properties
Definition: MSK4Text.cxx:1083
MSK4Text::DataFOD::m_defPos
long m_defPos
the offset position of the definition of the attribute in the file
Definition: MSK4Text.hxx:235
MSK4Text::readStructures
bool readStructures(MWAWInputStreamPtr input, bool mainOle)
finds and parses all structures which correspond to the text
Definition: MSK4Text.cxx:480
MWAWParserStatePtr
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:342
MSK4Text::pgdDataParser
bool pgdDataParser(MWAWInputStreamPtr input, long endPos, long, long, int id, std::string &mess)
parses the pagebreak positin entries : PGD
Definition: MSK4Text.cxx:1564
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
MSK4Text::m_FDPPs
std::vector< MWAWEntry const * > m_FDPPs
the list of FDPP entries
Definition: MSK4Text.hxx:262
MSK4Text::setProperty
void setProperty(MSK4TextInternal::Paragraph const &tabs)
sends a paragraph properties to the listener
Definition: MSK4Text.cxx:1268
MSK4Text::toknDataParser
bool toknDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the field properties entries : TOKN.
Definition: MSK4Text.cxx:1590
MSK4Text
The class which parses text zones in a mac MS Works document v4.
Definition: MSK4Text.hxx:63
MSK4Text::m_FDPCs
std::vector< MWAWEntry const * > m_FDPCs
the list of FDPC entries
Definition: MSK4Text.hxx:260
MSK4Text::DataFOD::m_type
Type m_type
the type of the attribute
Definition: MSK4Text.hxx:231
MSK4Text::readFootNote
bool readFootNote(MWAWInputStreamPtr input, int id)
sends the text which corresponds to footnote id to the listner
Definition: MSK4Text.cxx:589
MSK4TextInternal::Paragraph
Internal: class to store a paragraph properties.
Definition: MSK4Text.cxx:221
MSK4Text::DataFOD::ATTR_UNKN
Definition: MSK4Text.hxx:225
MSK4Text::findFDPStructures
bool findFDPStructures(MWAWInputStreamPtr &input, int which)
Fills the vector of (FDPCs/FDPPs) paragraph/characters strutures.
Definition: MSK4Text.cxx:1686