You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
4.0 KiB
153 lines
4.0 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
|
||
|
Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
|
||
|
Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
14 years ago
|
#include <tqfile.h>
|
||
|
#include <tqregexp.h>
|
||
|
#include <tqstring.h>
|
||
|
#include <tqstringlist.h>
|
||
13 years ago
|
#include <tqtextstream.h>
|
||
14 years ago
|
#include <tqfontmetrics.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
15 years ago
|
#include <kdebug.h>
|
||
12 years ago
|
#include <tdeglobal.h>
|
||
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kstandarddirs.h>
|
||
|
|
||
|
#include "symboltable.h"
|
||
|
#include "contextstyle.h"
|
||
4 years ago
|
#include "unicodetable.cpp"
|
||
15 years ago
|
|
||
|
|
||
|
KFORMULA_NAMESPACE_BEGIN
|
||
|
|
||
4 years ago
|
#include "symbolfontmapping.cpp"
|
||
15 years ago
|
|
||
|
SymbolFontHelper::SymbolFontHelper()
|
||
14 years ago
|
: greek("abgdezhqiklmnxpvrstufjcywGDTQLXPSUFYVW")
|
||
15 years ago
|
{
|
||
13 years ago
|
for ( uint i = 0; symbolMap[ i ].unicode != 0; i++ ) {
|
||
|
compatibility[ symbolMap[ i ].pos ] = symbolMap[ i ].unicode;
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
TQChar SymbolFontHelper::unicodeFromSymbolFont( TQChar pos ) const
|
||
15 years ago
|
{
|
||
13 years ago
|
if ( compatibility.contains( pos ) ) {
|
||
15 years ago
|
return compatibility[ pos.latin1() ];
|
||
|
}
|
||
14 years ago
|
return TQChar::null;
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
SymbolTable::SymbolTable()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void SymbolTable::init( const TQFont& font )
|
||
15 years ago
|
{
|
||
|
backupFont = font;
|
||
13 years ago
|
for ( int i=0; operatorTable[i].unicode != 0; ++i ) {
|
||
|
names[TQChar( operatorTable[i].unicode )] = get_name( operatorTable[i] );
|
||
|
entries[get_name( operatorTable[i] )] = TQChar( operatorTable[i].unicode );
|
||
15 years ago
|
}
|
||
13 years ago
|
for ( int i=0; arrowTable[i].unicode != 0; ++i ) {
|
||
|
names[TQChar( arrowTable[i].unicode )] = get_name( arrowTable[i] );
|
||
|
entries[get_name( arrowTable[i] )] = TQChar( arrowTable[i].unicode );
|
||
15 years ago
|
}
|
||
13 years ago
|
for ( int i=0; greekTable[i].unicode != 0; ++i ) {
|
||
|
names[TQChar( greekTable[i].unicode )] = get_name( greekTable[i] );
|
||
|
entries[get_name( greekTable[i] )] = TQChar( greekTable[i].unicode );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
bool SymbolTable::contains(TQString name) const
|
||
15 years ago
|
{
|
||
13 years ago
|
return entries.find( name ) != entries.end();
|
||
15 years ago
|
}
|
||
|
|
||
13 years ago
|
TQChar SymbolTable::unicode(TQString name) const
|
||
15 years ago
|
{
|
||
|
return entries[ name ];
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
TQString SymbolTable::name( TQChar symbol ) const
|
||
15 years ago
|
{
|
||
|
return names[symbol];
|
||
|
}
|
||
|
|
||
14 years ago
|
TQFont SymbolTable::font( TQChar symbol, const TQFont& f ) const {
|
||
|
TQFontMetrics fm( f );
|
||
15 years ago
|
if ( fm.inFont( symbol ) ) {
|
||
|
return f;
|
||
|
}
|
||
14 years ago
|
return TQFont("Arev Sans");
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
CharClass SymbolTable::charClass( TQChar symbol ) const
|
||
15 years ago
|
{
|
||
|
return ORDINARY;
|
||
|
// FIXME
|
||
|
// return entry( symbol, style ).charClass();
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
TQChar SymbolTable::unicodeFromSymbolFont( TQChar pos ) const
|
||
15 years ago
|
{
|
||
13 years ago
|
return symbolFontHelper.unicodeFromSymbolFont( pos );
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
14 years ago
|
TQString SymbolTable::greekLetters() const
|
||
15 years ago
|
{
|
||
|
return symbolFontHelper.greekLetters();
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
TQStringList SymbolTable::allNames() const
|
||
15 years ago
|
{
|
||
14 years ago
|
TQStringList list;
|
||
15 years ago
|
|
||
13 years ago
|
for ( int i=0; operatorTable[i].unicode != 0; ++i ) {
|
||
15 years ago
|
list.append( get_name( operatorTable[i] ));
|
||
|
}
|
||
13 years ago
|
for ( int i=0; arrowTable[i].unicode != 0; ++i ) {
|
||
15 years ago
|
list.append( get_name( arrowTable[i] ));
|
||
|
}
|
||
13 years ago
|
for ( int i=0; greekTable[i].unicode != 0; ++i ) {
|
||
15 years ago
|
list.append( get_name( greekTable[i] ) );
|
||
|
}
|
||
|
return list;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
TQString SymbolTable::get_name( struct UnicodeNameTable entry ) const
|
||
15 years ago
|
{
|
||
|
if ( !*entry.name ) {
|
||
13 years ago
|
return "U" + TQString( "%1" ).arg( entry.unicode, 4, 16 ).upper();
|
||
15 years ago
|
}
|
||
|
return entry.name;
|
||
|
}
|
||
|
|
||
|
KFORMULA_NAMESPACE_END
|