00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef QCOMPLEXTEXT_H
00039 #define QCOMPLEXTEXT_H
00040
00041 #include <koffice_export.h>
00042
00043 #include <QString>
00044 #include <q3pointarray.h>
00045 #include <QFont>
00046 #include <QPainter>
00047 #include <q3ptrlist.h>
00048 #include <q3shared.h>
00049 #include <QPainter>
00050
00051
00052 struct KOTEXT_EXPORT KoBidiStatus {
00053 KoBidiStatus() {
00054 eor = QChar::DirON;
00055 lastStrong = QChar::DirON;
00056 last = QChar:: DirON;
00057 }
00058 QChar::Direction eor;
00059 QChar::Direction lastStrong;
00060 QChar::Direction last;
00061 };
00062
00063 struct KOTEXT_EXPORT KoBidiContext : public Q3Shared {
00064
00065 KoBidiContext( uchar level, QChar::Direction embedding, KoBidiContext *parent = 0, bool override = false );
00066 ~KoBidiContext();
00067
00068 unsigned char level;
00069 bool override : 1;
00070 QChar::Direction dir : 5;
00071
00072 KoBidiContext *parent;
00073 };
00074
00075 struct KOTEXT_EXPORT KoBidiControl {
00076 KoBidiControl() { context = 0; }
00077 KoBidiControl( KoBidiContext *c, KoBidiStatus s)
00078 { context = c; if( context ) context->ref(); status = s; }
00079 ~KoBidiControl() { if ( context && context->deref() ) delete context; }
00080 void setContext( KoBidiContext *c ) { if ( context == c ) return; if ( context && context->deref() ) delete context; context = c; context->ref(); }
00081 KoBidiContext *context;
00082 KoBidiStatus status;
00083 };
00084
00085 struct KOTEXT_EXPORT KoTextRun {
00086 KoTextRun(int _start, int _stop, KoBidiContext *context, QChar::Direction dir);
00087
00088 int start;
00089 int stop;
00090
00091 uchar level;
00092 };
00093
00094 class KOTEXT_EXPORT KoComplexText {
00095 public:
00096 enum Shape {
00097 XIsolated,
00098 XFinal,
00099 XInitial,
00100 XMedial
00101 };
00102 static Shape glyphVariant( const QString &str, int pos);
00103 static Shape glyphVariantLogical( const QString &str, int pos);
00104
00105 static QString shapedString( const QString &str, int from = 0, int len = -1, QPainter::LayoutDirection dir = QPainter::Auto, const QFontMetrics *fm = 0);
00106 static QChar shapedCharacter(const QString &str, int pos, const QFontMetrics *fm = 0);
00107
00108
00109
00110
00111 static Q3PtrList<KoTextRun> *bidiReorderLine( KoBidiControl *control, const QString &str, int start, int len,
00112 QChar::Direction basicDir = QChar::DirON );
00113 static QString bidiReorderString( const QString &str, QChar::Direction basicDir = QChar::DirON );
00114 };
00115
00116 #endif