MacWrtProStructures.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 MAC_WRT_PRO_STRUCTURES
35# define MAC_WRT_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
48class MacWrtProParser;
49
51{
52class SubDocument;
53}
54
56{
57struct Block;
58struct Cell;
59struct Font;
60struct Paragraph;
61struct Section;
62struct State;
63class SubDocument;
64}
65
67
71{
72public:
74 MacWrtProStructuresListenerState(shared_ptr<MacWrtProStructures> structures, bool mainZone);
77
79 bool isSent(int blockId);
81 bool send(int blockId);
82
84 void sendSection(int numSection);
86 bool sendFont(int id);
88 bool sendParagraph(int id);
90 void sendChar(char c);
91
93 bool resendAll();
94
96 int numSection() const
97 {
98 if (!m_isMainZone) {
99 MWAW_DEBUG_MSG(("MacWrtProStructuresListenerState::numSection: not called in main zone\n"));
100 return 0;
101 }
102 return m_section;
103 }
104
106 std::vector<int> getPageBreaksPos() const;
108 void insertSoftPageBreak();
109
111 std::string getFontDebugString(int fontId);
112
114 std::string getParagraphDebugString(int paraId);
115
116protected:
118 bool newPage(bool softBreak=false);
119
124
125 // true if this is the mainZone
127 // the actual page
129 // the actual tab
131 // the number of tab
133 // the actual section ( if mainZone )
135 // the actual number of columns
137 // a flag to know if a new page has just been open
139 // the main structure parser
140 shared_ptr<MacWrtProStructures> m_structures;
141 // the current font
142 shared_ptr<MacWrtProStructuresInternal::Font> m_font;
143 // the current paragraph
144 shared_ptr<MacWrtProStructuresInternal::Paragraph> m_paragraph;
145};
146
153{
154 friend class MacWrtProParser;
158public:
160 explicit MacWrtProStructures(MacWrtProParser &mainParser);
162 virtual ~MacWrtProStructures();
163
167 int version() const;
168
170 void setAsciiName(char const *name)
171 {
172 m_asciiName = name;
173 }
174
175protected:
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
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<MacWrtProStructuresInternal::Block> readBlock();
232
234 shared_ptr<MacWrtProStructuresInternal::Block> readBlockV2(int id);
235
237 bool readBlocksList();
238
240 bool readFontsName();
241
243 bool readFontsDef();
244
247
249 bool readSections(std::vector<MacWrtProStructuresInternal::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 {
284 return m_asciiFile;
285 }
286
288 std::string const &asciiName() const
289 {
290 return m_asciiName;
291 }
292
293protected:
294 //
295 // data
296 //
297
300
303
306
308 shared_ptr<MacWrtProStructuresInternal::State> m_state;
309
312
314 std::string m_asciiName;
315};
316#endif
317// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
Internal: the subdocument of a MacWrtProParser.
Definition: MacWrtProParser.cxx:243
the main class to read a MacWrite II and MacWrite Pro file
Definition: MacWrtProParser.hxx:68
an interface to transmit the info of MacWrtProStructures to a listener
Definition: MacWrtProStructures.hxx:71
int m_numTab
Definition: MacWrtProStructures.hxx:132
void sendChar(char c)
send a character
Definition: MacWrtProStructures.cxx:2743
bool newPage(bool softBreak=false)
create a new page
Definition: MacWrtProStructures.cxx:2706
shared_ptr< MacWrtProStructuresInternal::Font > m_font
Definition: MacWrtProStructures.hxx:142
bool isSent(int blockId)
returns true if the block is already sent ( or does not exists)
Definition: MacWrtProStructures.cxx:2687
bool sendFont(int id)
try to send a character style
Definition: MacWrtProStructures.cxx:2827
std::string getParagraphDebugString(int paraId)
debug function which returns a string corresponding to a paragrapId
Definition: MacWrtProStructures.cxx:2896
void insertSoftPageBreak()
insert a page break ( if we are not on a new page )
Definition: MacWrtProStructures.cxx:2700
MacWrtProStructuresListenerState(shared_ptr< MacWrtProStructures > structures, bool mainZone)
the constructor
Definition: MacWrtProStructures.cxx:2667
bool sendParagraph(int id)
try to send a paragraph
Definition: MacWrtProStructures.cxx:2873
int m_actPage
Definition: MacWrtProStructures.hxx:128
std::string getFontDebugString(int fontId)
debug function which returns a string corresponding to a fontId
Definition: MacWrtProStructures.cxx:2850
bool resendAll()
force resent data : font + paragraph
Definition: MacWrtProStructures.cxx:2818
int m_section
Definition: MacWrtProStructures.hxx:134
int m_numCols
Definition: MacWrtProStructures.hxx:136
void sendSection(int numSection)
try to send the i^th section
Definition: MacWrtProStructures.cxx:2913
int numSection() const
returns the actual section
Definition: MacWrtProStructures.hxx:96
std::vector< int > getPageBreaksPos() const
return a list of page break position ( as some page break are soft )
Definition: MacWrtProStructures.cxx:2730
bool m_newPageDone
Definition: MacWrtProStructures.hxx:138
~MacWrtProStructuresListenerState()
the destructor
Definition: MacWrtProStructures.cxx:2683
bool send(int blockId)
try to send a block which corresponds to blockid
Definition: MacWrtProStructures.cxx:2693
bool m_isMainZone
Definition: MacWrtProStructures.hxx:126
int m_actTab
Definition: MacWrtProStructures.hxx:130
shared_ptr< MacWrtProStructures > m_structures
Definition: MacWrtProStructures.hxx:140
shared_ptr< MacWrtProStructuresInternal::Paragraph > m_paragraph
Definition: MacWrtProStructures.hxx:144
the main class to read the structures part of MacWrite Pro file
Definition: MacWrtProStructures.hxx:153
bool createZones()
finds the different objects zones
Definition: MacWrtProStructures.cxx:760
bool readStructB()
try to read a zone which follow the fonts zone(checkme)
Definition: MacWrtProStructures.cxx:2475
bool readCharStyles()
try to read the character styles zone
Definition: MacWrtProStructures.cxx:1571
bool readFontsDef()
try to read the list of fonts
Definition: MacWrtProStructures.cxx:1213
bool readStyles()
try to read the paragraph styles zone which begins at address 0x200
Definition: MacWrtProStructures.cxx:1659
bool createZonesV2()
finds the different objects zones in a MacWriteII file
Definition: MacWrtProStructures.cxx:878
shared_ptr< MacWrtProStructuresInternal::State > m_state
the state
Definition: MacWrtProStructures.hxx:308
bool getColor(int colId, MWAWColor &color) const
try to return the color corresponding to colId
Definition: MacWrtProStructures.cxx:661
static bool readString(MWAWInputStreamPtr input, std::string &res)
try to read a string
Definition: MacWrtProStructures.cxx:2442
void init()
inits all internal variables
Definition: MacWrtProStructures.cxx:594
std::string const & asciiName() const
return the ascii file name
Definition: MacWrtProStructures.hxx:288
bool readSections(std::vector< MacWrtProStructuresInternal::Section > &sections)
try to read the section info ?
Definition: MacWrtProStructures.cxx:2280
int numPages() const
returns the number of pages
Definition: MacWrtProStructures.cxx:612
bool readSelection()
try to read a 16 bytes the zone which follow the char styles zone ( the selection?...
Definition: MacWrtProStructures.cxx:2402
int version() const
returns the file version.
Definition: MacWrtProStructures.cxx:600
bool isSent(int blockId)
returns true if the block is already sent ( or does not exists)
Definition: MacWrtProStructures.cxx:2517
int getEndBlockSize()
returns the size of the block end data
Definition: MacWrtProStructures.cxx:1865
libmwaw::DebugFile & ascii()
returns the debug file
Definition: MacWrtProStructures.hxx:282
void setAsciiName(char const *name)
Debugging: change the default ascii file (by default struct )
Definition: MacWrtProStructures.hxx:170
void buildPageStructures()
look for pages structures
Definition: MacWrtProStructures.cxx:1020
int getHeaderId(int page, int &numSimillar) const
return the header blockid ( or 0)
Definition: MacWrtProStructures.cxx:619
MWAWInputStreamPtr m_input
the main input
Definition: MacWrtProStructures.hxx:302
MacWrtProStructures(MacWrtProParser &mainParser)
constructor
Definition: MacWrtProStructures.cxx:582
MacWrtProParser & m_mainParser
the main parser
Definition: MacWrtProStructures.hxx:305
bool readParagraphs()
try to read a list of paragraph
Definition: MacWrtProStructures.cxx:1352
shared_ptr< MacWrtProStructuresInternal::Block > readBlockV2(int id)
try to read a block entry
Definition: MacWrtProStructures.cxx:1877
bool readFontsName()
try to read the fonts zone
Definition: MacWrtProStructures.cxx:1147
void flushExtra()
flush not send zones
Definition: MacWrtProStructures.cxx:2622
shared_ptr< MacWrtProStructuresInternal::Block > readBlock()
try to read a block entry
Definition: MacWrtProStructures.cxx:2008
bool readStyle(int styleId)
try to read a style
Definition: MacWrtProStructures.cxx:1700
void buildTableStructures()
look for tables structures and if so, prepare data
Definition: MacWrtProStructures.cxx:1089
bool getPattern(int patId, float &patternPercent) const
try to return the pattern corresponding to patId
Definition: MacWrtProStructures.cxx:719
virtual ~MacWrtProStructures()
destructor
Definition: MacWrtProStructures.cxx:589
int getFooterId(int page, int &numSimillar) const
return the footer blockid ( or 0)
Definition: MacWrtProStructures.cxx:639
bool readBlocksList()
try to read the list of block entries
Definition: MacWrtProStructures.cxx:1796
MWAWTextListenerPtr & getTextListener()
returns the actual listener
Definition: MacWrtProStructures.cxx:607
bool readFont(MacWrtProStructuresInternal::Font &font)
try to read a font
Definition: MacWrtProStructures.cxx:1265
bool send(int blockId, bool mainZone=false)
try to send a block which corresponds to blockid
Definition: MacWrtProStructures.cxx:2536
MWAWParserStatePtr m_parserState
the parser state
Definition: MacWrtProStructures.hxx:299
std::string m_asciiName
the debug file name
Definition: MacWrtProStructures.hxx:314
bool sendMainZone()
send the main zone
Definition: MacWrtProStructures.cxx:989
bool readParagraph(MacWrtProStructuresInternal::Paragraph &para)
try to read a paragraph
Definition: MacWrtProStructures.cxx:1407
libmwaw::DebugFile m_asciiFile
the debug file
Definition: MacWrtProStructures.hxx:311
an interface used to insert comment in a binary file, written in ascii form (if debug_with_files is n...
Definition: MWAWDebug.hxx:66
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:503
shared_ptr< MWAWParserState > MWAWParserStatePtr
a smart pointer of MWAWParserState
Definition: libmwaw_internal.hxx:509
shared_ptr< MWAWTextListener > MWAWTextListenerPtr
a smart pointer of MWAWTextListener
Definition: libmwaw_internal.hxx:519
#define MWAW_DEBUG_MSG(M)
Definition: libmwaw_internal.hxx:127
Internal: the structures of a MacWrtProParser.
Definition: MacWrtProParser.cxx:60
Internal: the structures of a MacWrtProStructures.
Definition: MacWrtProStructures.cxx:59
the class to store a color
Definition: libmwaw_internal.hxx:182
Internal: the cell of a MacWrtProStructure.
Definition: MacWrtProStructures.cxx:363
Internal: the fonts.
Definition: MacWrtProStructures.cxx:303
Internal: class to store the paragraph properties.
Definition: MacWrtProStructures.cxx:339

Generated on Wed Jan 19 2022 22:23:14 for libmwaw by doxygen 1.9.3