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 getPattern(int patId, float &patternPercent) const;
265 
267  bool getColor(int colId, int patId, MWAWColor &color) const;
268 
270  bool isSent(int blockId);
271 
276  bool send(int blockId, bool mainZone=false);
277 
280 
283  return m_asciiFile;
284  }
285 
287  std::string const &asciiName() const {
288  return m_asciiName;
289  }
290 
291 protected:
292  //
293  // data
294  //
295 
298 
301 
304 
306  shared_ptr<MWProStructuresInternal::State> m_state;
307 
310 
312  std::string m_asciiName;
313 };
314 #endif
315 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Internal: the fonts.
Definition: MWProStructures.cxx:288
Internal: class to store the paragraph properties.
Definition: MWProStructures.cxx:322
an interface to transmit the info of MWProStructures to a listener
Definition: MWProStructures.hxx:72
Internal: the subdocument of a MWProParser.
Definition: MWProParser.cxx:233
void init()
inits all internal variables
Definition: MWProStructures.cxx:545
the main class to read the structures part of MacWrite Pro file
Definition: MWProStructures.hxx:153
MWProParser & m_mainParser
the main parser
Definition: MWProStructures.hxx:303
bool send(int blockId, bool mainZone=false)
try to send a block which corresponds to blockid
Definition: MWProStructures.cxx:2476
bool isSent(int blockId)
returns true if the block is already sent ( or does not exists)
Definition: MWProStructures.cxx:2609
bool send(int blockId)
try to send a block which corresponds to blockid
Definition: MWProStructures.cxx:2615
int getEndBlockSize()
returns the size of the block end data
Definition: MWProStructures.cxx:1811
int m_numCols
Definition: MWProStructures.hxx:137
int numSection() const
returns the actual section
Definition: MWProStructures.hxx:98
shared_ptr< MWProStructuresInternal::State > m_state
the state
Definition: MWProStructures.hxx:306
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
bool readParagraph(MWProStructuresInternal::Paragraph &para)
try to read a paragraph
Definition: MWProStructures.cxx:1360
std::vector< int > getPageBreaksPos() const
return a list of page break position ( as some page break are soft )
Definition: MWProStructures.cxx:2652
bool readBlocksList()
try to read the list of block entries
Definition: MWProStructures.cxx:1743
void insertSoftPageBreak()
insert a page break ( if we are not on a new page )
Definition: MWProStructures.cxx:2622
libmwaw::DebugFile & ascii()
returns the debug file
Definition: MWProStructures.hxx:282
int numPages() const
returns the number of pages
Definition: MWProStructures.cxx:563
bool sendFont(int id)
try to send a character style
Definition: MWProStructures.cxx:2748
int m_numTab
Definition: MWProStructures.hxx:133
libmwaw::DebugFile m_asciiFile
the debug file
Definition: MWProStructures.hxx:309
shared_ptr< MWProStructuresInternal::Block > readBlock()
try to read a block entry
Definition: MWProStructures.cxx:1950
int m_section
Definition: MWProStructures.hxx:135
~MWProStructuresListenerState()
the destructor
Definition: MWProStructures.cxx:2605
bool readStyle(int styleId)
try to read a style
Definition: MWProStructures.cxx:1648
bool createZones()
finds the different objects zones
Definition: MWProStructures.cxx:710
bool getPattern(int patId, float &patternPercent) const
try to return the pattern corresponding to patId
Definition: MWProStructures.cxx:669
bool sendParagraph(int id)
try to send a paragraph
Definition: MWProStructures.cxx:2794
std::string getParagraphDebugString(int paraId)
debug function which returns a string corresponding to a paragrapId
Definition: MWProStructures.cxx:2817
the class to store a color
Definition: libmwaw_internal.hxx:166
bool readParagraphs()
try to read a list of paragraph
Definition: MWProStructures.cxx:1306
the main class to read a MacWrite II and MacWrite Pro file
Definition: MWProParser.hxx:68
bool readFontsName()
try to read the fonts zone
Definition: MWProStructures.cxx:1096
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:116
bool readFont(MWProStructuresInternal::Font &font)
try to read a font
Definition: MWProStructures.cxx:1219
bool readSelection()
try to read a 16 bytes the zone which follow the char styles zone ( the selection?)
Definition: MWProStructures.cxx:2338
shared_ptr< MWProStructuresInternal::Block > readBlockV2(int id)
try to read a block entry
Definition: MWProStructures.cxx:1823
bool readSections(std::vector< MWProStructuresInternal::Section > &sections)
try to read the section info ?
Definition: MWProStructures.cxx:2220
shared_ptr< MWProStructures > m_structures
Definition: MWProStructures.hxx:141
bool isSent(int blockId)
returns true if the block is already sent ( or does not exists)
Definition: MWProStructures.cxx:2457
bool getColor(int colId, MWAWColor &color) const
try to return the color corresponding to colId
Definition: MWProStructures.cxx:612
std::string m_asciiName
the debug file name
Definition: MWProStructures.hxx:312
bool newPage(bool softBreak=false)
create a new page
Definition: MWProStructures.cxx:2628
bool m_isMainZone
Definition: MWProStructures.hxx:127
bool readStyles()
try to read the paragraph styles zone which begins at address 0x200
Definition: MWProStructures.cxx:1607
std::string const & asciiName() const
return the ascii file name
Definition: MWProStructures.hxx:287
virtual ~MWProStructures()
destructor
Definition: MWProStructures.cxx:540
bool resendAll()
force resent data : font + paragraph
Definition: MWProStructures.cxx:2739
MWAWInputStreamPtr m_input
the main input
Definition: MWProStructures.hxx:300
void setAsciiName(char const *name)
Debugging: change the default ascii file (by default struct )
Definition: MWProStructures.hxx:171
bool createZonesV2()
finds the different objects zones in a MacWriteII file
Definition: MWProStructures.cxx:828
bool sendMainZone()
send the main zone
Definition: MWProStructures.cxx:938
void flushExtra()
flush not send zones
Definition: MWProStructures.cxx:2545
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:348
int getHeaderId(int page, int &numSimillar) const
return the header blockid ( or 0)
Definition: MWProStructures.cxx:570
int version() const
returns the file version.
Definition: MWProStructures.cxx:551
bool m_newPageDone
Definition: MWProStructures.hxx:139
MWAWParserStatePtr m_parserState
the parser state
Definition: MWProStructures.hxx:297
bool readFontsDef()
try to read the list of fonts
Definition: MWProStructures.cxx:1167
void buildPageStructures()
look for pages structures
Definition: MWProStructures.cxx:969
shared_ptr< MWProStructuresInternal::Font > m_font
Definition: MWProStructures.hxx:143
int m_actTab
Definition: MWProStructures.hxx:131
MWProStructuresListenerState(shared_ptr< MWProStructures > structures, bool mainZone)
the constructor
Definition: MWProStructures.cxx:2589
std::string getFontDebugString(int fontId)
debug function which returns a string corresponding to a fontId
Definition: MWProStructures.cxx:2771
int m_actPage
Definition: MWProStructures.hxx:129
shared_ptr< MWAWContentListener > MWAWContentListenerPtr
a smart pointer of MWAWContentListener
Definition: libmwaw_internal.hxx:340
MWAWContentListenerPtr & getListener()
returns the actual listener
Definition: MWProStructures.cxx:558
void buildTableStructures()
look for tables structures and if so, prepare data
Definition: MWProStructures.cxx:1038
void sendSection(int numSection)
try to send the i^th section
Definition: MWProStructures.cxx:2834
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:356
shared_ptr< MWProStructuresInternal::Paragraph > m_paragraph
Definition: MWProStructures.hxx:145
MWProStructures(MWProParser &mainParser)
constructor
Definition: MWProStructures.cxx:533
static bool readString(MWAWInputStreamPtr input, std::string &res)
try to read a string
Definition: MWProStructures.cxx:2378
int getFooterId(int page, int &numSimillar) const
return the footer blockid ( or 0)
Definition: MWProStructures.cxx:590
bool readStructB()
try to read a zone which follow the fonts zone(checkme)
Definition: MWProStructures.cxx:2413
Internal: the cell of a WNProStructure.
Definition: MWProStructures.cxx:338
void sendChar(char c)
send a character
Definition: MWProStructures.cxx:2665
bool readCharStyles()
try to read the character styles zone
Definition: MWProStructures.cxx:1521

Generated on Tue Mar 10 2015 17:32:09 for libmwaw by doxygen 1.8.5