MsWks4Text.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 MS_WKS4_TEXT
# define MS_WKS4_TEXT
#include <vector>
#include "MWAWEntry.hxx"
#include "MWAWDebug.hxx"
#include "MWAWInputStream.hxx"
namespace MsWks4TextInternal
{
struct Font;
struct Paragraph;
struct State;
}
class MsWksDocument;
class MsWks4Zone;
class MsWks4Text
{
friend class MsWks4Zone;
protected:
struct DataFOD;
typedef bool (MsWks4Text::* FDPParser)(MWAWInputStreamPtr &input, long endPos,
int &id, std::string &mess);
public:
explicit MsWks4Text(MsWksDocument &document);
~MsWks4Text();
void setDefault(MWAWFont const &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 (MsWks4Text::* 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 = &MsWks4Text::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(MsWks4TextInternal::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:
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:
MsWks4Text(MsWks4Text const &orig) = delete;
MsWks4Text &operator=(MsWks4Text const &orig) = delete;
protected:
MWAWParser *m_mainParser;
MWAWParserStatePtr m_parserState;
MsWksDocument &m_document;
MWAWEntry m_textPositions;
mutable std::shared_ptr<MsWks4TextInternal::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:
MWAWDebug.hxx
MWAWEntry.hxx
MWAWInputStream.hxx
MWAWEntry
basic class to store an entry in a file This contained :
Definition MWAWEntry.hxx:47
MWAWFont
Class to store font.
Definition MWAWFont.hxx:44
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition MWAWParser.hxx:100
MsWks4Text::m_FDPPs
std::vector< MWAWEntry const * > m_FDPPs
the list of FDPP entries
Definition MsWks4Text.hxx:263
MsWks4Text::readPLC
bool readPLC(MWAWInputStreamPtr input, MWAWEntry const &entry, std::vector< long > &textPtrs, std::vector< long > &listValues, DataParser parser=&MsWks4Text::defDataParser)
reads a PLC (Pointer List Composant ?) in zone entry
Definition MsWks4Text.cxx:918
MsWks4Text::MsWks4Text
MsWks4Text(MsWks4Text const &orig)=delete
MsWks4Text::m_FODsList
std::vector< DataFOD > m_FODsList
the list of a FOD
Definition MsWks4Text.hxx:258
MsWks4Text::ftntDataParser
bool ftntDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the footnote position : FTNT
Definition MsWks4Text.cxx:1645
MsWks4Text::m_FDPCs
std::vector< MWAWEntry const * > m_FDPCs
the list of FDPC entries
Definition MsWks4Text.hxx:261
MsWks4Text::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition MsWks4Text.hxx:246
MsWks4Text::~MsWks4Text
~MsWks4Text()
destructor
Definition MsWks4Text.cxx:543
MsWks4Text::findFDPStructures
bool findFDPStructures(MWAWInputStreamPtr &input, int which)
Fills the vector of (FDPCs/FDPPs) paragraph/characters strutures.
Definition MsWks4Text.cxx:1811
MsWks4Text::m_mainParser
MWAWParser * m_mainParser
the main parser;
Definition MsWks4Text.hxx:244
MsWks4Text::flushNote
void flushNote(int noteId)
sends to the listener the text which corresponds to noteId
MsWks4Text::readStructures
bool readStructures(MWAWInputStreamPtr input, bool mainOle)
finds and parses all structures which correspond to the text
Definition MsWks4Text.cxx:572
MsWks4Text::readFont
bool readFont(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
reads a font properties
Definition MsWks4Text.cxx:1207
MsWks4Text::setDefault
void setDefault(MWAWFont const &font)
sets the default font
Definition MsWks4Text.cxx:1201
MsWks4Text::readParagraph
bool readParagraph(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
reads a paragraph properties
Definition MsWks4Text.cxx:1400
MsWks4Text::setProperty
void setProperty(MsWks4TextInternal::Paragraph const &tabs)
sends a paragraph properties to the listener
Definition MsWks4Text.cxx:1392
MsWks4Text::eobjDataParser
bool eobjDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the object position : EOBJ
Definition MsWks4Text.cxx:1613
MsWks4Text::pgdDataParser
bool pgdDataParser(MWAWInputStreamPtr input, long endPos, long, long, int id, std::string &mess)
parses the pagebreak positin entries : PGD
Definition MsWks4Text.cxx:1688
MsWks4Text::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 MsWks4Text.cxx:1899
MsWks4Text::m_state
std::shared_ptr< MsWks4TextInternal::State > m_state
the internal state
Definition MsWks4Text.hxx:255
MsWks4Text::MsWks4Zone
friend class MsWks4Zone
Definition MsWks4Text.hxx:66
MsWks4Text::operator=
MsWks4Text & operator=(MsWks4Text const &orig)=delete
MsWks4Text::findFDPStructuresByHand
bool findFDPStructuresByHand(MWAWInputStreamPtr &input, int which)
Fills the vector of (FDPCs/FDPPs) paragraph/characters strutures, a function to call when the normal ...
Definition MsWks4Text.cxx:1877
MsWks4Text::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 MsWks4Text.hxx:135
MsWks4Text::defDataParser
bool defDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
the default parser (does nothing)
Definition MsWks4Text.cxx:1106
MsWks4Text::readText
bool readText(MWAWInputStreamPtr input, MWAWEntry const &entry, bool mainOle)
reads a text section and send it to the listener
Definition MsWks4Text.cxx:713
MsWks4Text::numPages
int numPages() const
returns the number of pages
Definition MsWks4Text.cxx:550
MsWks4Text::toknDataParser
bool toknDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the field properties entries : TOKN.
Definition MsWks4Text.cxx:1714
MsWks4Text::DataParser
bool(MsWks4Text::* DataParser)(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
definition of the plc data parser (low level)
Definition MsWks4Text.hxx:116
MsWks4Text::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 MsWks4Text.cxx:2055
MsWks4Text::readFontNames
bool readFontNames(MWAWInputStreamPtr input, MWAWEntry const &entry)
reads the font names entry : FONT
Definition MsWks4Text.cxx:1130
MsWks4Text::flushExtra
void flushExtra(MWAWInputStreamPtr)
sends the data which have not been sent: actually do nothing
Definition MsWks4Text.hxx:91
MsWks4Text::readFootNote
bool readFootNote(MWAWInputStreamPtr input, int id)
sends the text which corresponds to footnote id to the listner
Definition MsWks4Text.cxx:678
MsWks4Text::m_textPositions
MWAWEntry m_textPositions
an entry which corresponds to the complete text zone
Definition MsWks4Text.hxx:252
MsWks4Text::FDPParser
bool(MsWks4Text::* FDPParser)(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
callback when a new attribute is found in an FDPP/FDPC entry
Definition MsWks4Text.hxx:75
MsWks4Text::m_document
MsWksDocument & m_document
the main document
Definition MsWks4Text.hxx:249
MsWks4Text::MsWks4Text
MsWks4Text(MsWksDocument &document)
constructor
Definition MsWks4Text.cxx:529
MsWks4Zone
The class which parses the main zones of a mac MS Works document v4.
Definition MsWks4Zone.hxx:74
MsWksDocument
the main class to read/store generic data of a MsWorks document v1-v3
Definition MsWksDocument.hxx:69
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition libmwaw_internal.hxx:557
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition libmwaw_internal.hxx:551
MsWks4TextInternal
Internal: the structures of a MsWks4Text.
Definition MsWks4Text.cxx:71
MsWks4TextInternal::Font
Internal: class to store a font properties.
Definition MsWks4Text.cxx:198
MsWks4TextInternal::Paragraph
Internal: class to store a paragraph properties.
Definition MsWks4Text.cxx:254
MsWks4TextInternal::State
Internal: the state of a MsWks4Text.
Definition MsWks4Text.cxx:455
MsWks4Text::DataFOD
structure which retrieves data information which correspond to a text position
Definition MsWks4Text.hxx:211
MsWks4Text::DataFOD::m_pos
long m_pos
the offset position of the text modified by this attribute
Definition MsWks4Text.hxx:232
MsWks4Text::DataFOD::DataFOD
DataFOD()
the constructor
Definition MsWks4Text.hxx:221
MsWks4Text::DataFOD::m_defPos
long m_defPos
the offset position of the definition of the attribute in the file
Definition MsWks4Text.hxx:234
MsWks4Text::DataFOD::Type
Type
different type which can be associated to a text position
Definition MsWks4Text.hxx:218
MsWks4Text::DataFOD::ATTR_UNKN
@ ATTR_UNKN
Definition MsWks4Text.hxx:218
MsWks4Text::DataFOD::ATTR_PARAG
@ ATTR_PARAG
Definition MsWks4Text.hxx:218
MsWks4Text::DataFOD::ATTR_PLC
@ ATTR_PLC
Definition MsWks4Text.hxx:218
MsWks4Text::DataFOD::ATTR_TEXT
@ ATTR_TEXT
Definition MsWks4Text.hxx:218
MsWks4Text::DataFOD::m_type
Type m_type
the type of the attribute
Definition MsWks4Text.hxx:230
MsWks4Text::DataFOD::m_id
int m_id
an identificator (which must be unique by category)
Definition MsWks4Text.hxx:236