filters

transform.h

00001 /*
00002  * Copyright (c) 2003 Nicolas HADACEK (hadacek@kde.org)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #ifndef TRANSFORM_H
00021 #define TRANSFORM_H
00022 
00023 #include <qpair.h>
00024 #include "CharTypes.h"
00025 
00026 namespace PDFImport
00027 {
00028     // check for special char (numerical values should be < 256)
00029     enum CharType {
00030         Unknown = 0,
00031         Punctuation = 1,
00032         SymbolChar = 2,
00033         Digit = 3,
00034         Letter = 4,
00035 
00036         Hyphen = 5,        // symbol that can be an hyphen or a bullet
00037         Bullet = 6,        // symbol that can be a bullet
00038         SuperScript = 7,
00039         SpecialSymbol = 8, // symbol that appears in Times font (0x22??)
00040         Ligature = 13,
00041 
00042         // latex
00043         Punctuation_Accent = 9, // punctuation that can be an accent
00044         Accent = 10,            // other accent
00045         Letter_CanHaveAccent = 11, // letter that can have an accent
00046 
00047         LatexSpecial = 12 // special case of needed Symbol->Times mapping
00048                           // only '\' (0x005C)
00049     };
00050 
00051     inline bool isPunctuation(CharType type) {
00052         return ( type==Punctuation || type==Hyphen
00053                  || type==Punctuation_Accent );
00054     }
00055     inline bool isSymbol(CharType type) {
00056         return ( type==SymbolChar || type==Hyphen || type==Bullet
00057                  || type==SpecialSymbol || type==Accent
00058                  || type==LatexSpecial );
00059     }
00060     inline bool isLetter(CharType type) {
00061         return ( type==Letter || type==Letter_CanHaveAccent );
00062     }
00063     inline bool isAlphaNumeric(CharType type) {
00064         return ( type==Digit || isLetter(type) );
00065     }
00066     inline bool isAccent(CharType type) {
00067         return ( type==Punctuation_Accent || type==Accent );
00068     }
00069 
00070     CharType type(Unicode);
00071 
00072     enum { MaxLigatureLength = 3 };
00073     uint checkLigature(Unicode, Unicode res[MaxLigatureLength]);
00074 
00075     CharType checkSpecial(Unicode, Unicode &res);
00076 
00077     // detect some letter/accent combinations
00078     // (latex layouts them separately)
00079     Unicode checkCombi(Unicode letter, Unicode accent);
00080 }
00081 
00082 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys