F:/KPlato/koffice/libs/kformula/symboltable.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
00003                       Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef SYMBOLTABLE_H
00022 #define SYMBOLTABLE_H
00023 
00024 #include <QFont>
00025 #include <QMap>
00026 #include <QString>
00027 #include <QStringList>
00028 #include <QVector>
00029 #include "kformuladefs.h"
00030 #include "contextstyle.h"
00031 class KConfig;
00032 
00033 namespace KFormula
00034 {
00035 
00036         
00042 class CharTableEntry {
00043 public:
00044 
00048     CharTableEntry( CharClass cl=ORDINARY, char font=0, QChar ch=0 )
00049         : m_charClass( static_cast<char>( cl ) ), m_font( font ), m_character( ch ) {}
00050 
00051     char font() const { return m_font; }
00052     QChar character() const { return m_character; }
00053     CharClass charClass() const { return static_cast<CharClass>( m_charClass ); }
00054 
00055 private:
00056 
00057     char m_charClass;
00058     char m_font;
00059     QChar m_character;
00060 };
00061 
00062 
00066 class SymbolFontHelper {
00067 public:
00068 
00069     SymbolFontHelper();
00070 
00074     QString greekLetters() const { return greek; }
00075 
00079     QChar unicodeFromSymbolFont( QChar pos ) const;
00080 
00081 private:
00082 
00086     QMap<QChar, QChar> compatibility;
00087 
00091     QString greek;
00092 };
00093 
00094 
00100 class KOFORMULA_EXPORT SymbolTable
00101 {
00102   public:
00103          SymbolTable();
00104 
00108     void init( ContextStyle* context );
00109 
00110     bool contains( const QString & name ) const;
00111 
00116     QChar unicode( const QString & name ) const;
00117     QString name( QChar symbol ) const;
00118 
00119     const CharTableEntry& entry( QChar symbol, CharStyle style=normalChar ) const;
00120     QFont font( QChar symbol, CharStyle style=normalChar ) const;
00121     QChar character( QChar symbol, CharStyle style=normalChar ) const;
00122     CharClass charClass( QChar symbol, CharStyle style=normalChar ) const;
00123 
00127     QChar unicodeFromSymbolFont( QChar pos ) const;
00128 
00132     QString greekLetters() const;
00133 
00137     QStringList allNames() const;
00138 
00139     typedef QMap<QChar, CharTableEntry> UnicodeTable;
00140     typedef QMap<QChar, QString> NameTable;
00141     typedef QMap<QString, QChar> EntryTable;
00142     typedef QVector<QFont> FontTable;
00143 
00144     bool inTable( QChar ch, CharStyle style=anyChar ) const;
00145 
00146     void initFont( const InternFontTable* table,
00147                    const char* fontname,
00148                    const NameTable& tempNames );
00149 
00150 private:
00151 
00152     UnicodeTable& unicodeTable( CharStyle style );
00153     const UnicodeTable& unicodeTable( CharStyle style ) const;
00154 
00158     UnicodeTable normalChars;
00159     UnicodeTable boldChars;
00160     UnicodeTable italicChars;
00161     UnicodeTable boldItalicChars;
00162 
00166     NameTable names;
00167 
00171     EntryTable entries;
00172 
00177     FontTable fontTable;
00178 
00182     SymbolFontHelper symbolFontHelper;
00183 
00184     // An empty entry that's used if nothing was found.
00185     CharTableEntry dummyEntry;
00186 };
00187 
00188 }
00189 
00190 #endif // SYMBOLTABLE_H

Généré le Wed Nov 22 23:41:01 2006 pour KPlato par  doxygen 1.5.1-p1