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, int &numSimillar) const;
201  int getFooterId(int page, int &numSimillar) const;
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  static 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:
Internal: the fonts.
Definition: MWProStructures.cxx:345
Internal: class to store the paragraph properties.
Definition: MWProStructures.cxx:379
an interface to transmit the info of MWProStructures to a listener
Definition: MWProStructures.hxx:76
Internal: the subdocument of a MWProParser.
Definition: MWProParser.cxx:233
void init()
inits all internal variables
Definition: MWProStructures.cxx:594
the main class to read the structures part of MacWrite Pro file
Definition: MWProStructures.hxx:157
MWProParser & m_mainParser
the main parser
Definition: MWProStructures.hxx:301
shared_ptr< MWAWParserState > MWAWParserStatePtr
Definition: ACText.hxx:49
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
Definition: ACText.hxx:44
bool send(int blockId, bool mainZone=false)
try to send a block which corresponds to blockid
Definition: MWProStructures.cxx:2499
bool isSent(int blockId)
returns true if the block is already sent ( or does not exists)
Definition: MWProStructures.cxx:2632
bool send(int blockId)
try to send a block which corresponds to blockid
Definition: MWProStructures.cxx:2638
int getEndBlockSize()
returns the size of the block end data
Definition: MWProStructures.cxx:1824
int m_numCols
Definition: MWProStructures.hxx:141
int numSection() const
returns the actual section
Definition: MWProStructures.hxx:102
shared_ptr< MWProStructuresInternal::State > m_state
the state
Definition: MWProStructures.hxx:304
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:67
bool readParagraph(MWProStructuresInternal::Paragraph &para)
try to read a paragraph
Definition: MWProStructures.cxx:1373
std::vector< int > getPageBreaksPos() const
return a list of page break position ( as some page break are soft )
Definition: MWProStructures.cxx:2675
bool readBlocksList()
try to read the list of block entries
Definition: MWProStructures.cxx:1756
void insertSoftPageBreak()
insert a page break ( if we are not on a new page )
Definition: MWProStructures.cxx:2645
libmwaw::DebugFile & ascii()
returns the debug file
Definition: MWProStructures.hxx:280
int numPages() const
returns the number of pages
Definition: MWProStructures.cxx:612
bool sendFont(int id)
try to send a character style
Definition: MWProStructures.cxx:2771
int m_numTab
Definition: MWProStructures.hxx:137
libmwaw::DebugFile m_asciiFile
the debug file
Definition: MWProStructures.hxx:307
shared_ptr< MWProStructuresInternal::Block > readBlock()
try to read a block entry
Definition: MWProStructures.cxx:1963
int m_section
Definition: MWProStructures.hxx:139
~MWProStructuresListenerState()
the destructor
Definition: MWProStructures.cxx:2628
bool readStyle(int styleId)
try to read a style
Definition: MWProStructures.cxx:1661
bool createZones()
finds the different objects zones
Definition: MWProStructures.cxx:709
bool sendParagraph(int id)
try to send a paragraph
Definition: MWProStructures.cxx:2817
std::string getParagraphDebugString(int paraId)
debug function which returns a string corresponding to a paragrapId
Definition: MWProStructures.cxx:2840
the class to store a color
Definition: libmwaw_internal.hxx:161
bool readParagraphs()
try to read a list of paragraph
Definition: MWProStructures.cxx:1318
shared_ptr< MWAWContentListener > MWAWContentListenerPtr
Definition: MWAWContentListener.hxx:260
the main class to read a MacWrite II and MacWrite Pro file
Definition: MWProParser.hxx:70
bool readFontsName()
try to read the fonts zone
Definition: MWProStructures.cxx:1108
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:111
a class to define the parser state
Definition: MWAWParser.hxx:60
bool readFont(MWProStructuresInternal::Font &font)
try to read a font
Definition: MWProStructures.cxx:1231
bool readSelection()
try to read a 16 bytes the zone which follow the char styles zone ( the selection?)
Definition: MWProStructures.cxx:2361
shared_ptr< MWProStructuresInternal::Block > readBlockV2(int id)
try to read a block entry
Definition: MWProStructures.cxx:1836
bool readSections(std::vector< MWProStructuresInternal::Section > &sections)
try to read the section info ?
Definition: MWProStructures.cxx:2242
shared_ptr< MWProStructures > m_structures
Definition: MWProStructures.hxx:145
bool isSent(int blockId)
returns true if the block is already sent ( or does not exists)
Definition: MWProStructures.cxx:2480
bool getColor(int colId, MWAWColor &color) const
try to return the color corresponding to colId
Definition: MWProStructures.cxx:647
std::string m_asciiName
the debug file name
Definition: MWProStructures.hxx:310
bool newPage(bool softBreak=false)
create a new page
Definition: MWProStructures.cxx:2651
bool m_isMainZone
Definition: MWProStructures.hxx:131
bool readStyles()
try to read the paragraph styles zone which begins at address 0x200
Definition: MWProStructures.cxx:1620
std::string const & asciiName() const
return the ascii file name
Definition: MWProStructures.hxx:285
virtual ~MWProStructures()
destructor
Definition: MWProStructures.cxx:589
bool resendAll()
force resent data : font + paragraph
Definition: MWProStructures.cxx:2762
MWAWInputStreamPtr m_input
the main input
Definition: MWProStructures.hxx:298
void setAsciiName(char const *name)
Debugging: change the default ascii file (by default struct )
Definition: MWProStructures.hxx:175
bool createZonesV2()
finds the different objects zones in a MacWriteII file
Definition: MWProStructures.cxx:832
bool sendMainZone()
send the main zone
Definition: MWProStructures.cxx:946
void flushExtra()
flush not send zones
Definition: MWProStructures.cxx:2568
int getHeaderId(int page, int &numSimillar) const
return the header blockid ( or 0)
Definition: MWProStructures.cxx:619
int version() const
returns the file version.
Definition: MWProStructures.cxx:600
bool m_newPageDone
Definition: MWProStructures.hxx:143
MWAWParserStatePtr m_parserState
the parser state
Definition: MWProStructures.hxx:295
bool readFontsDef()
try to read the list of fonts
Definition: MWProStructures.cxx:1179
void buildPageStructures()
look for pages structures
Definition: MWProStructures.cxx:977
shared_ptr< MWProStructuresInternal::Font > m_font
Definition: MWProStructures.hxx:147
int m_actTab
Definition: MWProStructures.hxx:135
MWProStructuresListenerState(shared_ptr< MWProStructures > structures, bool mainZone)
the constructor
Definition: MWProStructures.cxx:2612
std::string getFontDebugString(int fontId)
debug function which returns a string corresponding to a fontId
Definition: MWProStructures.cxx:2794
int m_actPage
Definition: MWProStructures.hxx:133
MWAWContentListenerPtr & getListener()
returns the actual listener
Definition: MWProStructures.cxx:607
void buildTableStructures()
look for tables structures and if so, prepare data
Definition: MWProStructures.cxx:1046
void sendSection(int numSection)
try to send the i^th section
Definition: MWProStructures.cxx:2857
shared_ptr< MWProStructuresInternal::Paragraph > m_paragraph
Definition: MWProStructures.hxx:149
MWProStructures(MWProParser &mainParser)
constructor
Definition: MWProStructures.cxx:582
static bool readString(MWAWInputStreamPtr input, std::string &res)
try to read a string
Definition: MWProStructures.cxx:2401
Definition: MWAWContentListener.hxx:68
int getFooterId(int page, int &numSimillar) const
return the footer blockid ( or 0)
Definition: MWProStructures.cxx:632
bool readStructB()
try to read a zone which follow the fonts zone(checkme)
Definition: MWProStructures.cxx:2436
Internal: the cell of a WNProStructure.
Definition: MWProStructures.cxx:396
void sendChar(char c)
send a character
Definition: MWProStructures.cxx:2688
bool readCharStyles()
try to read the character styles zone
Definition: MWProStructures.cxx:1534

Generated for libmwaw by doxygen 1.8.5