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 namespace MSK4TextInternal
44 {
45 struct Font;
46 struct Paragraph;
47 struct State;
48 }
49 
50 class MSK4Zone;
51 
63 class MSK4Text
64 {
65  friend class MSK4Zone;
66 protected:
67  struct DataFOD;
73  typedef bool (MSK4Text::* FDPParser) (MWAWInputStreamPtr &input, long endPos,
74  int &id, std::string &mess);
75 public:
77  MSK4Text(MSK4Zone &parser);
78 
80  ~MSK4Text();
81 
83  void setDefault(MWAWFont &font);
84 
86  int numPages() const;
87 
89  void flushExtra(MWAWInputStreamPtr /*input*/) {}
90 
91 protected:
95  bool readStructures(MWAWInputStreamPtr input, bool mainOle);
96 
98  bool readText(MWAWInputStreamPtr input, MWAWEntry const &entry, bool mainOle);
99 
101  bool readFootNote(MWAWInputStreamPtr input, int id);
102 
103  //----------------------------------------
104  // PLC parsing, setting
105  //----------------------------------------
112  typedef bool (MSK4Text::* DataParser)
113  (MWAWInputStreamPtr input, long endPos, long bot, long eot, int id, std::string &mess);
114 
122  bool readPLC(MWAWInputStreamPtr input, MWAWEntry const &entry,
123  std::vector<long> &textPtrs, std::vector<long> &listValues,
132  bool readSimplePLC(MWAWInputStreamPtr &input, MWAWEntry const &entry,
133  std::vector<long> &textPtrs,
134  std::vector<long> &listValues) {
135  return readPLC(input, entry, textPtrs, listValues);
136  }
137 
139  bool defDataParser(MWAWInputStreamPtr input, long endPos,
140  long bot, long eot, int id, std::string &mess);
141 
143  bool readFontNames(MWAWInputStreamPtr input, MWAWEntry const &entry);
144 
146  bool readFont (MWAWInputStreamPtr &input, long endPos,
147  int &id, std::string &mess);
148 
150  void setProperty(MSK4TextInternal::Paragraph const &tabs);
152  bool readParagraph (MWAWInputStreamPtr &input, long endPos,
153  int &id, std::string &mess);
154 
156  bool ftntDataParser(MWAWInputStreamPtr input, long endPos,
157  long bot, long eot, int id, std::string &mess);
158 
160  bool eobjDataParser(MWAWInputStreamPtr input, long endPos,
161  long bot, long eot, int id, std::string &mess);
162 
166  bool toknDataParser(MWAWInputStreamPtr input, long endPos,
167  long bot, long eot, int id, std::string &mess);
168 
172  bool pgdDataParser(MWAWInputStreamPtr input, long endPos,
173  long , long, int id, std::string &mess);
174 
176  void flushNote(int noteId);
177 
178 protected:
180  MSK4Zone const *mainParser() const {
181  return m_mainParser;
182  }
185  return m_mainParser;
186  }
187 
190  std::vector<DataFOD> mergeSortedLists
191  (std::vector<DataFOD> const &lst1, std::vector<DataFOD> const &lst2) const;
192 
195  bool readFDP(MWAWInputStreamPtr &input, MWAWEntry const &entry,
196  std::vector<DataFOD> &fods, FDPParser parser);
197 
205  bool findFDPStructures(MWAWInputStreamPtr &input, int which);
214  bool findFDPStructuresByHand(MWAWInputStreamPtr &input, int which);
215 
216 protected:
218  struct DataFOD {
226 
228  DataFOD() : m_type(ATTR_UNKN), m_pos(-1), m_defPos(0), m_id(-1) {}
229 
233  long m_pos;
235  long m_defPos;
237  int m_id;
238  };
239 
240 private:
241  MSK4Text(MSK4Text const &orig);
242  MSK4Text &operator=(MSK4Text const &orig);
243 protected:
246 
249 
252 
254  mutable shared_ptr<MSK4TextInternal::State> m_state;
255 
257  std::vector<DataFOD> m_FODsList;
258 
260  std::vector<MWAWEntry const *> m_FDPCs;
262  std::vector<MWAWEntry const *> m_FDPPs;
263 };
264 
265 #endif
266 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Wed Jul 10 2013 18:19:40 for libmwaw by doxygen 1.8.4