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
50{
51struct State;
52struct TextZoneData;
53struct TextZone;
54struct Token;
55struct Zone;
56class SubDocument;
57}
58
61
67class MacWrtProParser final : public MWAWTextParser
68{
69 friend class MacWrtProStructures;
72
73public:
75 MacWrtProParser(MWAWInputStreamPtr const &input, MWAWRSRCParserPtr const &rsrcParser, MWAWHeader *header);
77 ~MacWrtProParser() final;
78
80 bool checkHeader(MWAWHeader *header, bool strict=false) final;
81
82 // the main parse function
83 void parse(librevenge::RVNGTextInterface *documentInterface) final;
84
85protected:
87 void init();
88
90 void createDocument(librevenge::RVNGTextInterface *documentInterface);
91
93 bool createZones();
94
96 std::shared_ptr<MWAWStream> getStreamForBlock(int bId);
97
99 bool getFreeZoneList(std::vector<int> &blockLists);
100
105 bool parseDataZone(int blockId, int type);
106
108 bool parseTextZone(std::shared_ptr<MacWrtProParserInternal::Zone> zone);
109
111 bool readTextEntries(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
112 std::vector<MWAWEntry> &res, int textLength);
114 bool readTextIds(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
115 std::vector<MacWrtProParserInternal::TextZoneData> &res,
116 int textLength, int type);
118 bool readTextTokens(std::shared_ptr<MacWrtProParserInternal::Zone> zone,
119 std::vector<MacWrtProParserInternal::Token> &res,
120 int textLength);
121
124 std::vector<int> const &getGraphicIdCalledByToken() const;
125
127 float pageHeight() const;
129 int numColumns(double &sep) const;
130
132 void newPage(int number, bool softBreak=false);
134 bool hasTitlePage() const;
136 std::shared_ptr<MWAWSubDocument> getSubDocument(int blockId);
137
138 //
139 // interface with MacWrtProParserStructures
140 //
141
143 bool sendTextZone(int blockId, bool mainZone = false);
144
146 int findNumHardBreaks(int blockId);
147
149 bool sendPictureZone(int blockId, MWAWPosition const &pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
150
152 bool sendTextBoxZone(int blockId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
154 bool sendEmptyFrameZone(MWAWPosition const &pos, MWAWGraphicStyle const &style);
155
156 //
157 // low level
158 //
159
161 bool readPrintInfo();
162
164 bool readDocHeader();
165
167 bool sendPicture(std::shared_ptr<MacWrtProParserInternal::Zone> zone, MWAWPosition pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle());
168
170 bool sendText(std::shared_ptr<MacWrtProParserInternal::TextZone> zone, bool mainZone = false);
171
173 int findNumHardBreaks(std::shared_ptr<MacWrtProParserInternal::TextZone> zone);
174
176 static std::string convertDateToDebugString(unsigned date);
178 void checkUnparsed();
179
180protected:
181 //
182 // data
183 //
185 std::shared_ptr<MacWrtProParserInternal::State> m_state;
186
189};
190#endif
191// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab:
basic class to store an entry in a file This contained :
Definition: MWAWEntry.hxx:47
a structure used to define a picture style
Definition: MWAWGraphicStyle.hxx:48
a function used by MWAWDocument to store the version of document
Definition: MWAWHeader.hxx:57
Class to define the position of an object (textbox, picture, ..) in the document.
Definition: MWAWPosition.hxx:48
abstract class used to store a subdocument (with a comparison function)
Definition: MWAWSubDocument.hxx:42
virtual class which defines the ancestor of all text zone parser
Definition: MWAWParser.hxx:299
Internal: the subdocument of a MacWrtProParser.
Definition: MacWrtProParser.cxx:255
the main class to read a MacWrite II and MacWrite Pro file
Definition: MacWrtProParser.hxx:68
bool sendTextBoxZone(int blockId, MWAWPosition const &pos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
send a textbox zone
Definition: MacWrtProParser.cxx:1378
~MacWrtProParser() final
destructor
Definition: MacWrtProParser.cxx:318
bool readPrintInfo()
read the print info zone
Definition: MacWrtProParser.cxx:701
bool parseDataZone(int blockId, int type)
parse a data zone
Definition: MacWrtProParser.cxx:955
float pageHeight() const
returns the page height, ie. paper size less margin (in inches)
void parse(librevenge::RVNGTextInterface *documentInterface) final
virtual function used to parse the input
Definition: MacWrtProParser.cxx:384
bool sendEmptyFrameZone(MWAWPosition const &pos, MWAWGraphicStyle const &style)
try to send an empty zone (can exist in MacWrtPro1.5)
Definition: MacWrtProParser.cxx:1321
bool readTextIds(std::shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MacWrtProParserInternal::TextZoneData > &res, int textLength, int type)
try to read the text id entries
Definition: MacWrtProParser.cxx:1117
void init()
inits all internal variables
Definition: MacWrtProParser.cxx:322
std::shared_ptr< MWAWStream > getStreamForBlock(int bId)
returns a stream corresponding to a block
Definition: MacWrtProParser.cxx:432
std::shared_ptr< MWAWSubDocument > getSubDocument(int blockId)
returns a subdocument corresponding to a blockid
Definition: MacWrtProParser.cxx:376
std::vector< int > const & getGraphicIdCalledByToken() const
return the list of graphicid called by token.
Definition: MacWrtProParser.cxx:371
bool parseTextZone(std::shared_ptr< MacWrtProParserInternal::Zone > zone)
parse a text zone
Definition: MacWrtProParser.cxx:993
bool createZones()
finds the different objects zones
Definition: MacWrtProParser.cxx:587
bool readTextTokens(std::shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MacWrtProParserInternal::Token > &res, int textLength)
try to read the text token entries
Definition: MacWrtProParser.cxx:1182
bool readDocHeader()
try to read the doc header zone
Definition: MacWrtProParser.cxx:754
std::shared_ptr< MacWrtProParserInternal::State > m_state
the state
Definition: MacWrtProParser.hxx:185
void checkUnparsed()
a debug function which can be used to save the unparsed block
Definition: MacWrtProParser.cxx:1718
bool readTextEntries(std::shared_ptr< MacWrtProParserInternal::Zone > zone, std::vector< MWAWEntry > &res, int textLength)
try to read the text block entries
Definition: MacWrtProParser.cxx:1043
bool checkHeader(MWAWHeader *header, bool strict=false) final
checks if the document header is correct (or not)
Definition: MacWrtProParser.cxx:621
std::shared_ptr< MacWrtProStructures > m_structures
the structures parser
Definition: MacWrtProParser.hxx:188
static std::string convertDateToDebugString(unsigned date)
convert a date in a string (for debugging)
Definition: MacWrtProParser.cxx:1767
void newPage(int number, bool softBreak=false)
adds a new page
Definition: MacWrtProParser.cxx:347
void createDocument(librevenge::RVNGTextInterface *documentInterface)
creates the listener which will be associated to the document
Definition: MacWrtProParser.cxx:551
int numColumns(double &sep) const
returns the document number of columns and the column separator width in inch( filed in MWII)
Definition: MacWrtProParser.cxx:337
bool sendPictureZone(int blockId, MWAWPosition const &pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
try to send a picture
Definition: MacWrtProParser.cxx:1603
int findNumHardBreaks(int blockId)
compute the number of hard page break
Definition: MacWrtProParser.cxx:1333
bool sendPicture(std::shared_ptr< MacWrtProParserInternal::Zone > zone, MWAWPosition pictPos, MWAWGraphicStyle const &style=MWAWGraphicStyle::emptyStyle())
try to send a picture
Definition: MacWrtProParser.cxx:1615
bool sendText(std::shared_ptr< MacWrtProParserInternal::TextZone > zone, bool mainZone=false)
try to send a text
Definition: MacWrtProParser.cxx:1420
bool hasTitlePage() const
returns true if the document has a title page
Definition: MacWrtProParser.cxx:366
bool getFreeZoneList(std::vector< int > &blockLists)
return the chain list of block ( used to get free blocks): MWPro only
Definition: MacWrtProParser.cxx:511
bool sendTextZone(int blockId, bool mainZone=false)
send a text box
Definition: MacWrtProParser.cxx:1367
an interface to transmit the info of MacWrtProStructures to a listener
Definition: MacWrtProStructures.hxx:70
the main class to read the structures part of MacWrite Pro file
Definition: MacWrtProStructures.hxx:136
std::shared_ptr< MWAWRSRCParser > MWAWRSRCParserPtr
a smart pointer of MWAWRSRCParser
Definition: libmwaw_internal.hxx:561
std::shared_ptr< MWAWInputStream > MWAWInputStreamPtr
a smart pointer of MWAWInputStream
Definition: libmwaw_internal.hxx:551
Internal: the structures of a MacWrtProParser.
Definition: MacWrtProParser.cxx:62
Definition: MWAWDocument.hxx:57
small structure use to store a stream and it debug file
Definition: MWAWStream.hxx:41

Generated on Wed May 3 2023 07:18:29 for libmwaw by doxygen 1.9.6