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 
51 typedef shared_ptr<MWAWContentListener> MWAWContentListenerPtr;
53 typedef shared_ptr<MWAWParserState> MWAWParserStatePtr;
54 class MWProParser;
55 
56 namespace MWProParserInternal
57 {
58 class SubDocument;
59 }
60 
61 namespace MWProStructuresInternal
62 {
63 struct Block;
64 struct Cell;
65 struct Font;
66 struct Paragraph;
67 struct Section;
68 struct State;
69 class SubDocument;
70 }
71 
72 class MWProStructures;
73 
77 {
78 public:
80  MWProStructuresListenerState(shared_ptr<MWProStructures> structures, bool mainZone);
83 
85  bool isSent(int blockId);
87  bool send(int blockId);
88 
90  void sendSection(int numSection);
92  bool sendFont(int id);
94  bool sendParagraph(int id);
96  void sendChar(char c);
97 
99  bool resendAll();
100 
102  int numSection() const {
103  if (!m_isMainZone) {
104  MWAW_DEBUG_MSG(("MWProStructuresListenerState::numSection: not called in main zone\n"));
105  return 0;
106  }
107  return m_section;
108  }
109 
111  std::vector<int> getPageBreaksPos() const;
113  void insertSoftPageBreak();
114 
116  std::string getFontDebugString(int fontId);
117 
119  std::string getParagraphDebugString(int paraId);
120 
121 protected:
123  bool newPage(bool softBreak=false);
124 
126  void sendFont(MWProStructuresInternal::Font const &font);
129 
130  // true if this is the mainZone
132  // the actual page
134  // the actual tab
135  int m_actTab;
136  // the number of tab
137  int m_numTab;
138  // the actual section ( if mainZone )
140  // the actual number of columns
142  // a flag to know if a new page has just been open
144  // the main structure parser
145  shared_ptr<MWProStructures> m_structures;
146  // the current font
147  shared_ptr<MWProStructuresInternal::Font> m_font;
148  // the current paragraph
149  shared_ptr<MWProStructuresInternal::Paragraph> m_paragraph;
150 };
151 
158 {
159  friend class MWProParser;
163 public:
165  MWProStructures(MWProParser &mainParser);
167  virtual ~MWProStructures();
168 
172  int version() const;
173 
175  void setAsciiName(char const *name) {
176  m_asciiName = name;
177  }
178 
179 protected:
181  void init();
182 
184  bool createZones();
185 
190  bool createZonesV2();
191 
193  int numPages() const;
194 
196  bool sendMainZone();
197 
199  int getHeaderId(int page);
201  int getFooterId(int page);
202 
204  void flushExtra();
205 
207  void buildPageStructures();
208 
210  void buildTableStructures();
211 
212  //
213  // low level
214  //
215 
217  bool readStyles();
218 
220  bool readStyle(int styleId);
221 
223  bool readCharStyles();
224 
226  bool readParagraphs();
227 
230 
232  int getEndBlockSize();
233 
235  shared_ptr<MWProStructuresInternal::Block> readBlock();
236 
238  shared_ptr<MWProStructuresInternal::Block> readBlockV2(int id);
239 
241  bool readBlocksList();
242 
244  bool readFontsName();
245 
247  bool readFontsDef();
248 
251 
253  bool readSections(std::vector<MWProStructuresInternal::Section> &sections);
254 
256  bool readSelection();
257 
259  bool readStructB();
260 
262  bool readString(MWAWInputStreamPtr input, std::string &res);
263 
265  bool getColor(int colId, MWAWColor &color) const;
266 
268  bool isSent(int blockId);
269 
274  bool send(int blockId, bool mainZone=false);
275 
278 
281  return m_asciiFile;
282  }
283 
285  std::string const &asciiName() const {
286  return m_asciiName;
287  }
288 
289 protected:
290  //
291  // data
292  //
293 
296 
299 
302 
304  shared_ptr<MWProStructuresInternal::State> m_state;
305 
308 
310  std::string m_asciiName;
311 };
312 #endif
313 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:

Generated on Tue Apr 30 2013 06:31:14 for libmwaw by doxygen 1.8.3.1