MWProStructures.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 MW_PRO_STRUCTURES
35 # define MW_PRO_STRUCTURES
36 
37 #include <list>
38 #include <string>
39 #include <vector>
40 
41 #include "MWAWPosition.hxx"
42 
43 #include "MWAWEntry.hxx"
44 
45 #include "MWAWDebug.hxx"
46 #include "MWAWInputStream.hxx"
47 
48 class WPXBinaryData;
49 
50 class MWProParser;
51 
52 namespace MWProParserInternal
53 {
54 class SubDocument;
55 }
56 
57 namespace MWProStructuresInternal
58 {
59 struct Block;
60 struct Cell;
61 struct Font;
62 struct Paragraph;
63 struct Section;
64 struct State;
65 class SubDocument;
66 }
67 
68 class MWProStructures;
69 
73 {
74 public:
76  MWProStructuresListenerState(shared_ptr<MWProStructures> structures, bool mainZone);
79 
81  bool isSent(int blockId);
83  bool send(int blockId);
84 
86  void sendSection(int numSection);
88  bool sendFont(int id);
90  bool sendParagraph(int id);
92  void sendChar(char c);
93 
95  bool resendAll();
96 
98  int numSection() const {
99  if (!m_isMainZone) {
100  MWAW_DEBUG_MSG(("MWProStructuresListenerState::numSection: not called in main zone\n"));
101  return 0;
102  }
103  return m_section;
104  }
105 
107  std::vector<int> getPageBreaksPos() const;
109  void insertSoftPageBreak();
110 
112  std::string getFontDebugString(int fontId);
113 
115  std::string getParagraphDebugString(int paraId);
116 
117 protected:
119  bool newPage(bool softBreak=false);
120 
122  void sendFont(MWProStructuresInternal::Font const &font);
125 
126  // true if this is the mainZone
128  // the actual page
130  // the actual tab
131  int m_actTab;
132  // the number of tab
133  int m_numTab;
134  // the actual section ( if mainZone )
136  // the actual number of columns
138  // a flag to know if a new page has just been open
140  // the main structure parser
141  shared_ptr<MWProStructures> m_structures;
142  // the current font
143  shared_ptr<MWProStructuresInternal::Font> m_font;
144  // the current paragraph
145  shared_ptr<MWProStructuresInternal::Paragraph> m_paragraph;
146 };
147 
154 {
155  friend class MWProParser;
159 public:
161  MWProStructures(MWProParser &mainParser);
163  virtual ~MWProStructures();
164 
168  int version() const;
169 
171  void setAsciiName(char const *name) {
172  m_asciiName = name;
173  }
174 
175 protected:
177  void init();
178 
180  bool createZones();
181 
186  bool createZonesV2();
187 
189  int numPages() const;
190 
192  bool sendMainZone();
193 
195  int getHeaderId(int page, int &numSimillar) const;
197  int getFooterId(int page, int &numSimillar) const;
198 
200  void flushExtra();
201 
203  void buildPageStructures();
204 
206  void buildTableStructures();
207 
208  //
209  // low level
210  //
211 
213  bool readStyles();
214 
216  bool readStyle(int styleId);
217 
219  bool readCharStyles();
220 
222  bool readParagraphs();
223 
226 
228  int getEndBlockSize();
229 
231  shared_ptr<MWProStructuresInternal::Block> readBlock();
232 
234  shared_ptr<MWProStructuresInternal::Block> readBlockV2(int id);
235 
237  bool readBlocksList();
238 
240  bool readFontsName();
241 
243  bool readFontsDef();
244 
247 
249  bool readSections(std::vector<MWProStructuresInternal::Section> &sections);
250 
252  bool readSelection();
253 
255  bool readStructB();
256 
258  static bool readString(MWAWInputStreamPtr input, std::string &res);
259 
261  bool getColor(int colId, MWAWColor &color) const;
262 
264  bool isSent(int blockId);
265 
270  bool send(int blockId, bool mainZone=false);
271 
274 
277  return m_asciiFile;
278  }
279 
281  std::string const &asciiName() const {
282  return m_asciiName;
283  }
284 
285 protected:
286  //
287  // data
288  //
289 
292 
295 
298 
300  shared_ptr<MWProStructuresInternal::State> m_state;
301 
304 
306  std::string m_asciiName;
307 };
308 #endif
309 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Wed Jul 10 2013 18:15:30 for libmwaw by doxygen 1.8.4