MacWrtProParser.hxx Source File documentation

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MacWrtProParser.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
35 #ifndef MAC_WRT_PRO_PARSER
36 # define MAC_WRT_PRO_PARSER
37
38 #include <list>
39 #include <string>
40 #include <vector>
41
42 #include "MWAWDebug.hxx"
43 #include "MWAWEntry.hxx"
44 #include "MWAWGraphicStyle.hxx"
45 #include "MWAWInputStream.hxx"
46
47 #include "MWAWParser.hxx"
48
49 namespace MacWrtProParserInternal
50 {
51 struct State;
52 struct TextZoneData;
53 struct TextZone;
54 struct Token;
55 struct Zone;
56 class SubDocument;
57 }
58
59 class MacWrtProStructures;
60 class MacWrtProStructuresListenerState;
61
67 class MacWrtProParser : public MWAWTextParser
68 {
69 friend class MacWrtProStructures;
70 friend class MacWrtProStructuresListenerState;
71 friend class MacWrtProParserInternal::SubDocument;
72
73 public:
75 MacWrtProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header);
77 virtual ~MacWrtProParser();
78
80 bool checkHeader(MWAWHeader *header, bool strict=false);
81
82 // the main parse function
83 void parse(librevenge::RVNGTextInterface *documentInterface);
84
85 protected:
87 void init();
88
90 void createDocument(librevenge::RVNGTextInterface *documentInterface);
91
93 bool createZones();
94
96 bool getZoneData(librevenge::RVNGBinaryData &data, int blockId);
97
99 bool getFreeZoneList(int blockId, std::vector<int> &blockLists);
100
105 bool parseDataZone(int blockId, int type);
106
108 bool parseTextZone(shared_ptr<MacWrtProParserInternal::Zone> zone);
109
111 bool readTextEntries(shared_ptr<MacWrtProParserInternal::Zone> zone,
112 std::vector<MWAWEntry> &res, int textLength);
114 bool readTextIds(shared_ptr<MacWrtProParserInternal::Zone> zone,
115 std::vector<MacWrtProParserInternal::TextZoneData> &res,
116 int textLength, int type);
118 bool readTextTokens(shared_ptr<MacWrtProParserInternal::Zone> zone,
119 std::vector<MacWrtProParserInternal::Token> &res,
120 int textLength);
121
124 std::vector<int> const &getBlocksCalledByToken() const;
125
127 float pageHeight() const;
129 int numColumns() const;
130
132 void newPage(int number, bool softBreak=false);
133
134 //
135 // interface with MacWrtProParserStructures
136 //
137
139 bool sendTextZone(int blockId, bool mainZone = false);
140
142 int findNumHardBreaks(int blockId);
143
145 bool sendPictureZone(int blockId, MWAWPosition const &pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
146
148 bool sendTextBoxZone(int blockId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
150 bool sendEmptyFrameZone(MWAWPosition const &pos, MWAWGraphicStyle const &style);
151
152 //
153 // low level
154 //
155
157 bool readPrintInfo();
158
160 bool readDocHeader();
161
162 #ifdef DEBUG
163 void saveOriginal(MWAWInputStreamPtr input);
165 #endif
166
168 bool sendPicture(shared_ptr<MacWrtProParserInternal::Zone> zone, MWAWPosition pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
169
171 bool sendText(shared_ptr<MacWrtProParserInternal::TextZone> zone, bool mainZone = false);
172
174 int findNumHardBreaks(shared_ptr<MacWrtProParserInternal::TextZone> zone);
175
177 void checkUnparsed();
178
179 protected:
180 //
181 // data
182 //
184 shared_ptr<MacWrtProParserInternal::State> m_state;
185
187 shared_ptr<MacWrtProStructures> m_structures;
188 };
189 #endif
190 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
MacWrtProParser::readTextTokens
bool readTextTokens(shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MacWrtProParserInternal::Token > &res, int textLength)
try to read the text token entries
Definition: MacWrtProParser.cxx:1199
MWAWHeader
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:56
MacWrtProStructures
the main class to read the structures part of MacWrite Pro file
Definition: MacWrtProStructures.hxx:152
MacWrtProParser::sendTextBoxZone
bool sendTextBoxZone(int blockId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
send a textbox zone
Definition: MacWrtProParser.cxx:1397
MWAWParser.hxx
MacWrtProParser::checkHeader
bool checkHeader(MWAWHeader *header, bool strict=false)
checks if the document header is correct (or not)
Definition: MacWrtProParser.cxx:657
MWAWEntry.hxx
MacWrtProParser::~MacWrtProParser
virtual ~MacWrtProParser()
destructor
Definition: MacWrtProParser.cxx:314
MacWrtProParser::parseDataZone
bool parseDataZone(int blockId, int type)
parse a data zone
Definition: MacWrtProParser.cxx:967
MacWrtProParser::sendText
bool sendText(shared_ptr< MacWrtProParserInternal::TextZone > zone, bool mainZone=false)
try to send a text
Definition: MacWrtProParser.cxx:1434
MacWrtProParser::MacWrtProParser
MacWrtProParser(MWAWInputStreamPtr input, MWAWRSRCParserPtr rsrcParser, MWAWHeader *header)
constructor
Definition: MacWrtProParser.cxx:308
MWAWGraphicStyle
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:47
MacWrtProParser::readDocHeader
bool readDocHeader()
try to read the doc header zone
Definition: MacWrtProParser.cxx:791
MacWrtProParser::m_state
shared_ptr< MacWrtProParserInternal::State > m_state
the state
Definition: MacWrtProParser.hxx:184
MacWrtProParser::sendEmptyFrameZone
bool sendEmptyFrameZone(MWAWPosition const &pos, MWAWGraphicStyle const &style)
try to send an empty zone (can exist in MacWrtPro1.5)
Definition: MacWrtProParser.cxx:1337
MacWrtProParserInternal::SubDocument
Internal: the subdocument of a MacWrtProParser.
Definition: MacWrtProParser.cxx:242
MacWrtProParser::pageHeight
float pageHeight() const
returns the page height, ie. paper size less margin (in inches)
MacWrtProParser::sendTextZone
bool sendTextZone(int blockId, bool mainZone=false)
send a text box
Definition: MacWrtProParser.cxx:1385
MacWrtProParser::init
void init()
inits all internal variables
Definition: MacWrtProParser.cxx:318
MacWrtProParser::createZones
bool createZones()
finds the different objects zones
Definition: MacWrtProParser.cxx:626
MacWrtProParser::readTextIds
bool readTextIds(shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MacWrtProParserInternal::TextZoneData > &res, int textLength, int type)
try to read the text id entries
Definition: MacWrtProParser.cxx:1135
MacWrtProParser::m_structures
shared_ptr< MacWrtProStructures > m_structures
the structures parser
Definition: MacWrtProParser.hxx:187
MWAWRSRCParserPtr
shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:439
MacWrtProParser::findNumHardBreaks
int findNumHardBreaks(int blockId)
compute the number of hard page break
Definition: MacWrtProParser.cxx:1349
MacWrtProParser::parseTextZone
bool parseTextZone(shared_ptr< MacWrtProParserInternal::Zone > zone)
parse a text zone
Definition: MacWrtProParser.cxx:1010
MWAWTextParser
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:284
MacWrtProParser::parse
void parse(librevenge::RVNGTextInterface *documentInterface)
virtual function used to parse the input
Definition: MacWrtProParser.cxx:370
MacWrtProParser::sendPictureZone
bool sendPictureZone(int blockId, MWAWPosition const &pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
try to send a picture
Definition: MacWrtProParser.cxx:1628
MacWrtProParser::readTextEntries
bool readTextEntries(shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MWAWEntry > &res, int textLength)
try to read the text block entries
Definition: MacWrtProParser.cxx:1060
MWAWInputStreamPtr
shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:429
MacWrtProStructuresListenerState
an interface to transmit the info of MacWrtProStructures to a listener
Definition: MacWrtProStructures.hxx:70
MWAWInputStream.hxx
MWAWDebug.hxx
MacWrtProParser::numColumns
int numColumns() const
returns the document number of columns ( filed in MWII)
Definition: MacWrtProParser.cxx:333
MacWrtProParser::getBlocksCalledByToken
std::vector< int > const & getBlocksCalledByToken() const
return the list of blockid called by token.
Definition: MacWrtProParser.cxx:361
MacWrtProParser
the main class to read a MacWrite II and MacWrite Pro file
Definition: MacWrtProParser.hxx:67
MacWrtProParser::newPage
void newPage(int number, bool softBreak=false)
adds a new page
Definition: MacWrtProParser.cxx:342
MacWrtProParser::sendPicture
bool sendPicture(shared_ptr< MacWrtProParserInternal::Zone > zone, MWAWPosition pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
try to send a picture
Definition: MacWrtProParser.cxx:1641
MWAWPosition
Class to define the position of an object (textbox, picture, ..) in the document. ...
Definition: MWAWPosition.hxx:47
MacWrtProParser::getZoneData
bool getZoneData(librevenge::RVNGBinaryData &data, int blockId)
retrieve the data which corresponds to a zone
Definition: MacWrtProParser.cxx:422
MacWrtProParserInternal
Internal: the structures of a MacWrtProParser.
Definition: MacWrtProParser.cxx:59
MacWrtProParser::checkUnparsed
void checkUnparsed()
a debug function which can be used to save the unparsed block
Definition: MacWrtProParser.cxx:1788
MacWrtProParser::getFreeZoneList
bool getFreeZoneList(int blockId, std::vector< int > &blockLists)
return the chain list of block ( used to get free blocks)
Definition: MacWrtProParser.cxx:502
MacWrtProParser::readPrintInfo
bool readPrintInfo()
read the print info zone
Definition: MacWrtProParser.cxx:738
MacWrtProParser::createDocument
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MacWrtProParser.cxx:556
MWAWGraphicStyle.hxx
MWAWGraphicStyle::emptyStyle
static MWAWGraphicStyle emptyStyle()
returns an empty style.
Definition: MWAWGraphicStyle.hxx:204