MSK4Text.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 MSK4_TEXT
35 # define MSK4_TEXT
36 
37 #include <vector>
38 
39 #include "MWAWEntry.hxx"
40 #include "MWAWDebug.hxx"
41 #include "MWAWInputStream.hxx"
42 
43 class MWAWFont;
45 typedef shared_ptr<MWAWParserState> MWAWParserStatePtr;
46 
47 namespace MSK4TextInternal
48 {
49 struct Font;
50 struct Paragraph;
51 struct State;
52 }
53 
54 class MSK4Zone;
55 
67 class MSK4Text
68 {
69  friend class MSK4Zone;
70 protected:
71  struct DataFOD;
77  typedef bool (MSK4Text::* FDPParser) (MWAWInputStreamPtr &input, long endPos,
78  int &id, std::string &mess);
79 public:
81  MSK4Text(MSK4Zone &parser);
82 
84  ~MSK4Text();
85 
87  void setDefault(MWAWFont &font);
88 
90  int numPages() const;
91 
93  void flushExtra(MWAWInputStreamPtr /*input*/) {}
94 
95 protected:
99  bool readStructures(MWAWInputStreamPtr input, bool mainOle);
100 
102  bool readText(MWAWInputStreamPtr input, MWAWEntry const &entry, bool mainOle);
103 
105  bool readFootNote(MWAWInputStreamPtr input, int id);
106 
107  //----------------------------------------
108  // PLC parsing, setting
109  //----------------------------------------
116  typedef bool (MSK4Text::* DataParser)
117  (MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess);
118 
126  bool readPLC(MWAWInputStreamPtr input, MWAWEntry const &entry,
127  std::vector<long> &textPtrs, std::vector<long> &listValues,
136  bool readSimplePLC(MWAWInputStreamPtr &input, MWAWEntry const &entry,
137  std::vector<long> &textPtrs,
138  std::vector<long> &listValues) {
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(MSK4TextInternal::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:
184  MSK4Zone const *mainParser() const {
185  return m_mainParser;
186  }
189  return m_mainParser;
190  }
191 
194  std::vector<DataFOD> mergeSortedLists
195  (std::vector<DataFOD> const &lst1, std::vector<DataFOD> const &lst2) const;
196 
199  bool readFDP(MWAWInputStreamPtr &input, MWAWEntry const &entry,
200  std::vector<DataFOD> &fods, FDPParser parser);
201 
209  bool findFDPStructures(MWAWInputStreamPtr &input, int which);
218  bool findFDPStructuresByHand(MWAWInputStreamPtr &input, int which);
219 
220 protected:
222  struct DataFOD {
230 
232  DataFOD() : m_type(ATTR_UNKN), m_pos(-1), m_defPos(0), m_id(-1) {}
233 
237  long m_pos;
239  long m_defPos;
241  int m_id;
242  };
243 
244 private:
245  MSK4Text(MSK4Text const &orig);
246  MSK4Text &operator=(MSK4Text const &orig);
247 protected:
250 
253 
256 
258  mutable shared_ptr<MSK4TextInternal::State> m_state;
259 
261  std::vector<DataFOD> m_FODsList;
262 
264  std::vector<MWAWEntry const *> m_FDPCs;
266  std::vector<MWAWEntry const *> m_FDPPs;
267 };
268 
269 #endif
270 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
DataFOD()
the constructor
Definition: MSK4Text.hxx:232
void flushExtra(MWAWInputStreamPtr)
sends the data which have not been sent: actually do nothing
Definition: MSK4Text.hxx:93
shared_ptr< MWAWParserState > MWAWParserStatePtr
Definition: ACText.hxx:49
int m_id
an identificator (which must be unique by category)
Definition: MSK4Text.hxx:241
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
Definition: ACText.hxx:44
MSK4Text & operator=(MSK4Text const &orig)
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:77
void setDefault(MWAWFont &font)
sets the default font
Definition: MSK4Text.cxx:1078
long m_pos
the offset position of the text modified by this attribute
Definition: MSK4Text.hxx:237
int numPages() const
returns the number of pages
Definition: MSK4Text.cxx:458
void flushNote(int noteId)
sends to the listener the text which corresponds to noteId
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:809
Definition: MSK4Text.hxx:229
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:117
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:1760
std::vector< DataFOD > m_FODsList
the list of a FOD
Definition: MSK4Text.hxx:261
bool readText(MWAWInputStreamPtr input, MWAWEntry const &entry, bool mainOle)
reads a text section and send it to the listener
Definition: MSK4Text.cxx:625
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:136
bool ftntDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the footnote position : FTNT
Definition: MSK4Text.cxx:1522
bool readParagraph(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
reads a paragraph properties
Definition: MSK4Text.cxx:1277
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:1782
MWAWEntry m_textPositions
an entry which corresponds to the complete text zone
Definition: MSK4Text.hxx:255
MSK4Zone * m_mainParser
the main parser
Definition: MSK4Text.hxx:252
MWAWParserStatePtr m_parserState
the parser state
Definition: MSK4Text.hxx:249
MSK4Zone * mainParser()
returns the main parser
Definition: MSK4Text.hxx:188
bool eobjDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the object position : EOBJ
Definition: MSK4Text.cxx:1490
Class to store font.
Definition: MWAWFont.hxx:47
a class to define the parser state
Definition: MWAWParser.hxx:60
~MSK4Text()
destructor
Definition: MSK4Text.cxx:452
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:1938
bool defDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
the default parser (does nothing)
Definition: MSK4Text.cxx:989
MSK4Zone const * mainParser() const
returns the main parser
Definition: MSK4Text.hxx:184
MSK4Text(MSK4Zone &parser)
constructor
Definition: MSK4Text.cxx:445
shared_ptr< MSK4TextInternal::State > m_state
the internal state
Definition: MSK4Text.hxx:258
The class which parses the main zones of a mac MS Works document v4.
Definition: MSK4Zone.hxx:80
bool readFontNames(MWAWInputStreamPtr input, MWAWEntry const &entry)
reads the font names entry : FONT
Definition: MSK4Text.cxx:1013
Definition: MSK4Text.hxx:229
Type
different type which can be associated to a text position
Definition: MSK4Text.hxx:229
structure which retrieves data information which correspond to a text position
Definition: MSK4Text.hxx:222
Definition: MSK4Text.hxx:229
bool readFont(MWAWInputStreamPtr &input, long endPos, int &id, std::string &mess)
reads a font properties
Definition: MSK4Text.cxx:1084
long m_defPos
the offset position of the definition of the attribute in the file
Definition: MSK4Text.hxx:239
bool readStructures(MWAWInputStreamPtr input, bool mainOle)
finds and parses all structures which correspond to the text
Definition: MSK4Text.cxx:481
bool pgdDataParser(MWAWInputStreamPtr input, long endPos, long, long, int id, std::string &mess)
parses the pagebreak positin entries : PGD
Definition: MSK4Text.cxx:1565
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:46
std::vector< MWAWEntry const * > m_FDPPs
the list of FDPP entries
Definition: MSK4Text.hxx:266
void setProperty(MSK4TextInternal::Paragraph const &tabs)
sends a paragraph properties to the listener
Definition: MSK4Text.cxx:1269
bool toknDataParser(MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess)
parses the field properties entries : TOKN.
Definition: MSK4Text.cxx:1591
The class which parses text zones in a mac MS Works document v4.
Definition: MSK4Text.hxx:67
std::vector< MWAWEntry const * > m_FDPCs
the list of FDPC entries
Definition: MSK4Text.hxx:264
Type m_type
the type of the attribute
Definition: MSK4Text.hxx:235
bool readFootNote(MWAWInputStreamPtr input, int id)
sends the text which corresponds to footnote id to the listner
Definition: MSK4Text.cxx:590
Internal: class to store a paragraph properties.
Definition: MSK4Text.cxx:221
Definition: MSK4Text.hxx:229
bool findFDPStructures(MWAWInputStreamPtr &input, int which)
Fills the vector of (FDPCs/FDPPs) paragraph/characters strutures.
Definition: MSK4Text.cxx:1687

Generated for libmwaw by doxygen 1.8.5