00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef SYMBOLTABLE_H
00022
#define SYMBOLTABLE_H
00023
00024
#include <qfont.h>
00025
#include <qmap.h>
00026
#include <qstring.h>
00027
#include <qstringlist.h>
00028
#include <qvaluevector.h>
00029
00030
#include "kformuladefs.h"
00031
00032
class KConfig;
00033
00034 KFORMULA_NAMESPACE_BEGIN
00035
00036
class ContextStyle;
00037
00043 class CharTableEntry {
00044
public:
00045
00049 CharTableEntry( CharClass cl=ORDINARY,
char font=0, uchar ch=0 )
00050 : m_charClass( static_cast<char>( cl ) ), m_font( font ), m_character( ch ) {}
00051
00052
char font()
const {
return m_font; }
00053 uchar character()
const {
return m_character; }
00054 CharClass charClass()
const {
return static_cast<CharClass>( m_charClass ); }
00055
00056
private:
00057
00058
char m_charClass;
00059
char m_font;
00060 uchar m_character;
00061 };
00062
00063
00067 class SymbolFontHelper {
00068
public:
00069
00070
SymbolFontHelper();
00071
00075 QString greekLetters()
const {
return greek; }
00076
00080
QChar unicodeFromSymbolFont(
QChar pos )
const;
00081
00082
private:
00083
00087
QMap<uchar, QChar> compatibility;
00088
00092
QString greek;
00093 };
00094
00095
00101 class SymbolTable {
00102
public:
00103
00104
SymbolTable();
00105
00109
void init(
ContextStyle* context );
00110
00111
bool contains(
QString name )
const;
00112
00117
QChar unicode(
QString name )
const;
00118
QString name(
QChar symbol )
const;
00119
00120
const CharTableEntry& entry(
QChar symbol, CharStyle style=normalChar )
const;
00121
QFont font(
QChar symbol, CharStyle style=normalChar )
const;
00122 uchar character(
QChar symbol, CharStyle style=normalChar )
const;
00123 CharClass charClass(
QChar symbol, CharStyle style=normalChar )
const;
00124
00128
QChar unicodeFromSymbolFont(
QChar pos )
const;
00129
00133
QString greekLetters()
const;
00134
00138
QStringList allNames()
const;
00139
00140
typedef QMap<QChar, CharTableEntry> UnicodeTable;
00141
typedef QMap<QChar, QString> NameTable;
00142
typedef QMap<QString, QChar> EntryTable;
00143
typedef QValueVector<QFont> FontTable;
00144
00145
bool inTable(
QChar ch, CharStyle style=anyChar )
const;
00146
00147
void initFont(
const InternFontTable* table,
00148
const char* fontname,
00149
const NameTable& tempNames );
00150
00151
private:
00152
00153
UnicodeTable& unicodeTable( CharStyle style );
00154
const UnicodeTable& unicodeTable( CharStyle style )
const;
00155
00159
UnicodeTable normalChars;
00160
UnicodeTable boldChars;
00161
UnicodeTable italicChars;
00162
UnicodeTable boldItalicChars;
00163
00167
NameTable names;
00168
00172
EntryTable entries;
00173
00178
FontTable fontTable;
00179
00183
SymbolFontHelper symbolFontHelper;
00184
00185
00186
CharTableEntry dummyEntry;
00187 };
00188
00189 KFORMULA_NAMESPACE_END
00190
00191
#endif // SYMBOLTABLE_H