MsWks4Text.hxx Source File documentation

MsWks4Text.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
2
3 /* libmwaw
4 * Version: MPL 2.0 / LGPLv2+
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 2.0 (the "License"); you may not use this file except in compliance with
8 * the License or as specified alternatively below. You may obtain a copy of
9 * the License at http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Major Contributor(s):
17 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
18 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
19 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
20 * Copyright (C) 2006, 2007 Andrew Ziem
21 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
22 *
23 *
24 * All Rights Reserved.
25 *
26 * For minor contributions see the git repository.
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
30 * in which case the provisions of the LGPLv2+ are applicable
31 * instead of those above.
32 */
33
34 #ifndef MS_WKS4_TEXT
35 # define MS_WKS4_TEXT
36
37 #include <vector>
38
39 #include "MWAWEntry.hxx"
40 #include "MWAWDebug.hxx"
41 #include "MWAWInputStream.hxx"
42
43 namespace MsWks4TextInternal
44 {
45 struct Font;
46 struct Paragraph;
47 struct State;
48 }
49
50 class MsWksDocument;
51 class MsWks4Zone;
52
64 class MsWks4Text
65 {
66 friend class MsWks4Zone;
67 protected:
68 struct DataFOD;
75 typedef bool (MsWks4Text::* FDPParser)(MWAWInputStreamPtr &input, long endPos,
76 int &id, std::string &mess);
77 public:
79 explicit MsWks4Text(MsWksDocument &document);
80
82 ~MsWks4Text();
83
85 void setDefault(MWAWFont &font);
86
88 int numPages() const;
89
91 void flushExtra(MWAWInputStreamPtr /*input*/) {}
92
93 protected:
97 bool readStructures(MWAWInputStreamPtr input, bool mainOle);
98
100 bool readText(MWAWInputStreamPtr input, MWAWEntry const &entry, bool mainOle);
101
103 bool readFootNote(MWAWInputStreamPtr input, int id);
104
105 //----------------------------------------
106 // PLC parsing, setting
107 //----------------------------------------
115 typedef bool (MsWks4Text::* DataParser)
116 (MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess);
117
125 bool readPLC(MWAWInputStreamPtr input, MWAWEntry const &entry,
126 std::vector<long> &textPtrs, std::vector<long> &listValues,
127 DataParser parser = &MsWks4Text::defDataParser);
135 bool readSimplePLC(MWAWInputStreamPtr &input, MWAWEntry const &entry,
136 std::vector<long> &textPtrs,
137 std::vector<long> &listValues)
138 {
139 return readPLC(input, entry, textPtrs, listValues);
140 }
141
143 bool defDataParser(MWAWInputStreamPtr input, long endPos,
144 long bot, long eot, int id, std::string &mess);
145
147 bool readFontNames(MWAWInputStreamPtr input, MWAWEntry const &entry);
148
150 bool readFont(MWAWInputStreamPtr &input, long endPos,
151 int &id, std::string &mess);
152
154 void setProperty(MsWks4TextInternal::Paragraph const &tabs);
156 bool readParagraph(MWAWInputStreamPtr &input, long endPos,
157 int &id, std::string &mess);
158
160 bool ftntDataParser(MWAWInputStreamPtr input, long endPos,
161 long bot, long eot, int id, std::string &mess);
162
164 bool eobjDataParser(MWAWInputStreamPtr input, long endPos,
165 long bot, long eot, int id, std::string &mess);
166
170 bool toknDataParser(MWAWInputStreamPtr input, long endPos,
171 long bot, long eot, int id, std::string &mess);
172
176 bool pgdDataParser(MWAWInputStreamPtr input, long endPos,
177 long, long, int id, std::string &mess);
178
180 void flushNote(int noteId);
181
182 protected:
185 std::vector<DataFOD> mergeSortedLists
186 (std::vector<DataFOD> const &lst1, std::vector<DataFOD> const &lst2) const;
187
190 bool readFDP(MWAWInputStreamPtr &input, MWAWEntry const &entry,
191 std::vector<DataFOD> &fods, FDPParser parser);
192
199 bool findFDPStructures(MWAWInputStreamPtr &input, int which);
207 bool findFDPStructuresByHand(MWAWInputStreamPtr &input, int which);
208
209 protected:
211 struct DataFOD {
218 enum Type { ATTR_TEXT, ATTR_PARAG, ATTR_PLC, ATTR_UNKN };
219
221 DataFOD()
222 : m_type(ATTR_UNKN)
223 , m_pos(-1)
224 , m_defPos(0)
225 , m_id(-1)
226 {
227 }
228
230 Type m_type;
232 long m_pos;
234 long m_defPos;
236 int m_id;
237 };
238
239 private:
240 MsWks4Text(MsWks4Text const &orig) = delete;
241 MsWks4Text &operator=(MsWks4Text const &orig) = delete;
242 protected:
244 MWAWParser *m_mainParser;
246 MWAWParserStatePtr m_parserState;
247
249 MsWksDocument &m_document;
250
252 MWAWEntry m_textPositions;
253
255 mutable std::shared_ptr<MsWks4TextInternal::State> m_state;
256
258 std::vector<DataFOD> m_FODsList;
259
261 std::vector<MWAWEntry const *> m_FDPCs;
263 std::vector<MWAWEntry const *> m_FDPPs;
264 };
265
266 #endif
267 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
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::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:1710
MsWks4Text::readText
bool readText(MWAWInputStreamPtr input, MWAWEntry const &entry, bool mainOle)
reads a text section and send it to the listener
Definition: MsWks4Text.cxx:709
MsWks4Text::DataFOD::m_type
Type m_type
the type of the attribute
Definition: MsWks4Text.hxx:230
MWAWParserStatePtr
std::shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:553
MsWks4TextInternal::Paragraph
Internal: class to store a paragraph properties.
Definition: MsWks4Text.cxx:254
MsWks4Text
The class which parses text zones in a mac MS Works document v4.
Definition: MsWks4Text.hxx:64
MWAWEntry.hxx
MsWks4Text::flushNote
void flushNote(int noteId)
sends to the listener the text which corresponds to noteId
MsWks4Text::flushExtra
void flushExtra(MWAWInputStreamPtr)
sends the data which have not been sent: actually do nothing
Definition: MsWks4Text.hxx:91
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:1873
MsWks4TextInternal
Internal: the structures of a MsWks4Text.
Definition: MsWks4Text.cxx:70
MsWks4Text::pgdDataParser
bool pgdDataParser(MWAWInputStreamPtr input, long endPos, long, long, int id, std::string &mess)
parses the pagebreak positin entries : PGD
Definition: MsWks4Text.cxx:1684
MsWks4Text::DataFOD::m_pos
long m_pos
the offset position of the text modified by this attribute
Definition: MsWks4Text.hxx:232
MsWks4Text::DataFOD::ATTR_TEXT
Definition: MsWks4Text.hxx:218
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:914
MsWks4Text::DataFOD::m_defPos
long m_defPos
the offset position of the definition of the attribute in the file
Definition: MsWks4Text.hxx:234
MsWks4Text::m_parserState
MWAWParserStatePtr m_parserState
the parser state
Definition: MsWks4Text.hxx:246
MsWks4Text::m_FODsList
std::vector< DataFOD > m_FODsList
the list of a FOD
Definition: MsWks4Text.hxx:258
MsWks4Text::operator=
MsWks4Text & operator=(MsWks4Text const &orig)=delete
MWAWFont
Class to store font.
Definition: MWAWFont.hxx:43
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:1609
MsWks4Text::m_state
std::shared_ptr< MsWks4TextInternal::State > m_state
the internal state
Definition: MsWks4Text.hxx:255
MsWks4Text::DataFOD
structure which retrieves data information which correspond to a text position
Definition: MsWks4Text.hxx:211
MsWks4Text::MsWks4Text
MsWks4Text(MsWksDocument &document)
constructor
Definition: MsWks4Text.cxx:525
MsWks4Zone
The class which parses the main zones of a mac MS Works document v4.
Definition: MsWks4Zone.hxx:73
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:1641
MsWks4Text::readFont
bool readFont(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
reads a font properties
Definition: MsWks4Text.cxx:1203
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:1102
MsWks4Text::DataFOD::ATTR_PLC
Definition: MsWks4Text.hxx:218
MsWks4Text::numPages
int numPages() const
returns the number of pages
Definition: MsWks4Text.cxx:546
MsWks4Text::m_document
MsWksDocument & m_document
the main document
Definition: MsWks4Text.hxx:249
MWAWInputStream.hxx
MWAWDebug.hxx
MWAWInputStreamPtr
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:547
MsWks4Text::readParagraph
bool readParagraph(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
reads a paragraph properties
Definition: MsWks4Text.cxx:1396
MsWks4Text::m_textPositions
MWAWEntry m_textPositions
an entry which corresponds to the complete text zone
Definition: MsWks4Text.hxx:252
MsWks4Text::DataFOD::ATTR_PARAG
Definition: MsWks4Text.hxx:218
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:1895
MsWks4Text::DataFOD::Type
Type
different type which can be associated to a text position
Definition: MsWks4Text.hxx:218
MsWks4Text::m_FDPPs
std::vector< MWAWEntry const * > m_FDPPs
the list of FDPP entries
Definition: MsWks4Text.hxx:263
MWAWParser
virtual class which defines the ancestor of all main zone parser
Definition: MWAWParser.hxx:99
MsWks4Text::m_mainParser
MWAWParser * m_mainParser
the main parser;
Definition: MsWks4Text.hxx:244
MWAWEntry
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
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::setProperty
void setProperty(MsWks4TextInternal::Paragraph const &tabs)
sends a paragraph properties to the listener
Definition: MsWks4Text.cxx:1388
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::DataFOD::ATTR_UNKN
Definition: MsWks4Text.hxx:218
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:2051
MsWks4Text::setDefault
void setDefault(MWAWFont &font)
sets the default font
Definition: MsWks4Text.cxx:1197
MsWks4Text::DataFOD::m_id
int m_id
an identificator (which must be unique by category)
Definition: MsWks4Text.hxx:236
MsWks4Text::readFontNames
bool readFontNames(MWAWInputStreamPtr input, MWAWEntry const &entry)
reads the font names entry : FONT
Definition: MsWks4Text.cxx:1126
MsWks4Text::DataFOD::DataFOD
DataFOD()
the constructor
Definition: MsWks4Text.hxx:221
MsWks4Text::readStructures
bool readStructures(MWAWInputStreamPtr input, bool mainOle)
finds and parses all structures which correspond to the text
Definition: MsWks4Text.cxx:568
MsWks4Text::m_FDPCs
std::vector< MWAWEntry const * > m_FDPCs
the list of FDPC entries
Definition: MsWks4Text.hxx:261
MsWks4Text::findFDPStructures
bool findFDPStructures(MWAWInputStreamPtr &input, int which)
Fills the vector of (FDPCs/FDPPs) paragraph/characters strutures.
Definition: MsWks4Text.cxx:1807
MsWksDocument
the main class to read/store generic data of a MsWorks document v1-v3
Definition: MsWksDocument.hxx:68
MsWks4Text::readFootNote
bool readFootNote(MWAWInputStreamPtr input, int id)
sends the text which corresponds to footnote id to the listner
Definition: MsWks4Text.cxx:674
MsWks4Text::~MsWks4Text
~MsWks4Text()
destructor
Definition: MsWks4Text.cxx:539