1
/* This file is part of the KDE project
2
Copyright (C) 2001 Ariya Hidayat <ariyahidayat@yahoo.de>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
25
#include <qmemarray.h>
32
* This class is an abstract encapsulation of a token to be use in the parser.
43
Unknown, Function, Text, Lang,
44
SoftSpace, HardSpace, HardHyphen, ExtChar,
45
SoftReturn, HardReturn, DormantHardReturn,
46
AttrOn, AttrOff, UnderlineMode,
47
MarkTocStart, MarkTocEnd,
48
LeftMargin, RightMargin, TopMargin, BottomMargin,
49
Linespace, Justification, ParagraphIndent, LeftMarginAdjust,
51
TabSet, TabLeft, TabHardFlushRight,
52
FontColor, FontSize, FontFace, HighlightOn, HighlightOff,
53
TableOn, TableColumn, TableEnd, TableCell, TableRow, TableOff
58
None, ExtraLarge, VeryLarge, Large, Small, Fine,
59
Bold, Italic, Underline, DoubleUnderline, Subscript, Superscript,
60
StrikedOut, Redline, Shadow, Outline, SmallCaps, Blink
64
{ Left, Right, Center, Full, All };
67
{ LeftTab, CenterTab, RightTab, DecimalTab, VerticalTab };
74
Tab (TabType t, int p)
81
Token () { m_type = Unknown; }
83
Token (Type type) { m_type = type; }
85
Token (const QString & text) { m_type = Text; m_text = text; }
87
Token (Type type, Attr attr) { m_type = type; m_attr = attr; }
89
Token (Type type, int value) { m_type = type; m_value = value; }
91
Token (Type type, Align align){ m_type = type; m_align = align; }
93
Token (Type type, int charset, int charcode)
97
m_charcode = charcode;
100
Token (Type type, int red, int green, int blue)
108
Token (Type type, QString fontface){ m_type = FontFace; m_fontface = fontface; }
110
Token (const QPtrList < Tab > &tabs)
116
Type type (){ return m_type; }
118
int value (){ return m_value; }
120
QString text (){ return m_text; }
122
Attr attr (){ return m_attr; }
124
Align align (){ return m_align; }
126
int red (){ return m_red; }
127
int green (){ return m_green; }
128
int blue (){ return m_blue; }
130
QString fontface (){ return m_fontface; }
131
int charset (){ return m_charset; }
132
int charcode (){ return m_charcode; }
133
QPtrList < Tab > tabs (){ return m_tabs; }
143
int m_red, m_green, m_blue;
145
int m_charset, m_charcode;
146
QPtrList < Tab > m_tabs;
155
unsigned type, size, pos;
156
QMemArray<Q_UINT8> data;
160
* This class implements a functional parser for WordPerfect documents.
161
* @author Ariya Hidayat
172
* Parses given filename.
173
* @returns TRUE if parsing was successful, otherwise FALSE.
176
bool parse (const QString & filename);
178
// high byte is major version, 0=WP 5.x, 2=WP 6/7/8
181
QString docTitle, docAuthor, docAbstract;
183
QPtrList<Token> tokens;
184
QPtrList<Packet> packets;
187
* Maps WordPerfect extended character to its Unicode equivalent. Supported character
188
* sets at the moment are Multinational (charset 1), Phonetic Symbol (charset 2),
189
* Typographic Symbol (charset 4), Iconic Symbol (charset 5),
190
* Math/Scientific (charset 6 and 7), Greek (charset 8), Hebrew (harset 9), and
191
* Cyrillic (charset 10)
193
static unsigned int ExtCharToUnicode (int charset, int charcode);
199
void handleTab ( QMemArray <Q_UINT8> data );
201
void parsePacketWP5( const QString & filename );
202
void parseDocWP5( const QString & filename, int start );
204
void parsePacketWP6( const QString & filename );
205
void parseDocWP6( const QString & filename, int start );