Diffstat (limited to 'noncore/apps/opie-write/qcomplextext.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qcomplextext.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/opie-write/qcomplextext.cpp b/noncore/apps/opie-write/qcomplextext.cpp index 473f184..00a91c5 100644 --- a/noncore/apps/opie-write/qcomplextext.cpp +++ b/noncore/apps/opie-write/qcomplextext.cpp | |||
@@ -13,134 +13,134 @@ | |||
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
22 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
23 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | 37 | ||
38 | 38 | ||
39 | #include "qrichtext_p.h" | 39 | #include "qrichtext_p.h" |
40 | 40 | ||
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | 42 | ||
43 | using namespace Qt3; | 43 | using namespace Qt3; |
44 | 44 | ||
45 | // ----------------------------------------------------- | 45 | // ----------------------------------------------------- |
46 | 46 | ||
47 | /* a small helper class used internally to resolve Bidi embedding levels. | 47 | /* a small helper class used internally to resolve Bidi embedding levels. |
48 | Each line of text caches the embedding level at the start of the line for faster | 48 | Each line of text caches the embedding level at the start of the line for faster |
49 | relayouting | 49 | relayouting |
50 | */ | 50 | */ |
51 | QBidiContext::QBidiContext( uchar l, QChar::Direction e, QBidiContext *p, bool o ) | 51 | QBidiContext::QBidiContext( uchar l, QChar::Direction e, QBidiContext *p, bool o ) |
52 | : level(l) , override(o), dir(e) | 52 | : level(l) , override(o), dir(e) |
53 | { | 53 | { |
54 | if ( p ) | 54 | if ( p ) |
55 | p->ref(); | 55 | p->ref(); |
56 | parent = p; | 56 | parent = p; |
57 | count = 0; | 57 | count = 0; |
58 | } | 58 | } |
59 | 59 | ||
60 | QBidiContext::~QBidiContext() | 60 | QBidiContext::~QBidiContext() |
61 | { | 61 | { |
62 | if( parent && parent->deref() ) | 62 | if( parent && parent->deref() ) |
63 | delete parent; | 63 | delete parent; |
64 | } | 64 | } |
65 | 65 | ||
66 | /* | 66 | /* |
67 | Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on | 67 | Arabic shaping obeys a number of rules according to the joining classes (see Unicode book, section on |
68 | arabic). | 68 | arabic). |
69 | 69 | ||
70 | Each unicode char has a joining class (right, dual (left&right), center (joincausing) or transparent). | 70 | Each unicode char has a joining class (right, dual (left&right), center (joincausing) or transparent). |
71 | transparent joining is not encoded in QChar::joining(), but applies to all combining marks and format marks. | 71 | transparent joining is not encoded in QChar::joining(), but applies to all combining marks and format marks. |
72 | 72 | ||
73 | Right join-causing: dual + center | 73 | Right join-causing: dual + center |
74 | Left join-causing: dual + right + center | 74 | Left join-causing: dual + right + center |
75 | 75 | ||
76 | Rules are as follows (for a string already in visual order, as we have it here): | 76 | Rules are as follows (for a string already in visual order, as we have it here): |
77 | 77 | ||
78 | R1 Transparent characters do not affect joining behaviour. | 78 | R1 Transparent characters do not affect joining behaviour. |
79 | R2 A right joining character, that has a right join-causing char on the right will get form XRight | 79 | R2 A right joining character, that has a right join-causing char on the right will get form XRight |
80 | (R3 A left joining character, that has a left join-causing char on the left will get form XLeft) | 80 | (R3 A left joining character, that has a left join-causing char on the left will get form XLeft) |
81 | Note: the above rule is meaningless, as there are no pure left joining characters defined in Unicode | 81 | Note: the above rule is meaningless, as there are no pure left joining characters defined in Unicode |
82 | R4 A dual joining character, that has a left join-causing char on the left and a right join-causing char on | 82 | R4 A dual joining character, that has a left join-causing char on the left and a right join-causing char on |
83 | the right will get form XMedial | 83 | the right will get form XMedial |
84 | R5 A dual joining character, that has a right join causing char on the right, and no left join causing char on the left | 84 | R5 A dual joining character, that has a right join causing char on the right, and no left join causing char on the left |
85 | will get form XRight | 85 | will get form XRight |
86 | R6 A dual joining character, that has a left join causing char on the left, and no right join causing char on the right | 86 | R6 A dual joining character, that has a left join causing char on the left, and no right join causing char on the right |
87 | will get form XLeft | 87 | will get form XLeft |
88 | R7 Otherwise the character will get form XIsolated | 88 | R7 Otherwise the character will get form XIsolated |
89 | 89 | ||
90 | Additionally we have to do the minimal ligature support for lam-alef ligatures: | 90 | Additionally we have to do the minimal ligature support for lam-alef ligatures: |
91 | 91 | ||
92 | L1 Transparent characters do not affect ligature behaviour. | 92 | L1 Transparent characters do not affect ligature behaviour. |
93 | L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft) | 93 | L2 Any sequence of Alef(XRight) + Lam(XMedial) will form the ligature Alef.Lam(XLeft) |
94 | L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated) | 94 | L3 Any sequence of Alef(XRight) + Lam(XLeft) will form the ligature Alef.Lam(XIsolated) |
95 | 95 | ||
96 | The two functions defined in this class do shaping in visual and logical order. For logical order just replace right with | 96 | The two functions defined in this class do shaping in visual and logical order. For logical order just replace right with |
97 | previous and left with next in the above rules ;-) | 97 | previous and left with next in the above rules ;-) |
98 | */ | 98 | */ |
99 | 99 | ||
100 | /* | 100 | /* |
101 | Two small helper functions for arabic shaping. They get the next shape causing character on either | 101 | Two small helper functions for arabic shaping. They get the next shape causing character on either |
102 | side of the char in question. Implements rule R1. | 102 | side of the char in question. Implements rule R1. |
103 | 103 | ||
104 | leftChar() returns true if the char to the left is a left join-causing char | 104 | leftChar() returns true if the char to the left is a left join-causing char |
105 | rightChar() returns true if the char to the right is a right join-causing char | 105 | rightChar() returns true if the char to the right is a right join-causing char |
106 | */ | 106 | */ |
107 | static inline const QChar *prevChar( const QString &str, int pos ) | 107 | static inline const QChar *prevChar( const QString &str, int pos ) |
108 | { | 108 | { |
109 | //qDebug("leftChar: pos=%d", pos); | 109 | //odebug << "leftChar: pos=" << pos << "" << oendl; |
110 | pos--; | 110 | pos--; |
111 | const QChar *ch = str.unicode() + pos; | 111 | const QChar *ch = str.unicode() + pos; |
112 | while( pos > -1 ) { | 112 | while( pos > -1 ) { |
113 | if( !ch->isMark() ) | 113 | if( !ch->isMark() ) |
114 | return ch; | 114 | return ch; |
115 | pos--; | 115 | pos--; |
116 | ch--; | 116 | ch--; |
117 | } | 117 | } |
118 | return &QChar::replacement; | 118 | return &QChar::replacement; |
119 | } | 119 | } |
120 | 120 | ||
121 | static inline const QChar *nextChar( const QString &str, int pos) | 121 | static inline const QChar *nextChar( const QString &str, int pos) |
122 | { | 122 | { |
123 | pos++; | 123 | pos++; |
124 | int len = str.length(); | 124 | int len = str.length(); |
125 | const QChar *ch = str.unicode() + pos; | 125 | const QChar *ch = str.unicode() + pos; |
126 | while( pos < len ) { | 126 | while( pos < len ) { |
127 | //qDebug("rightChar: %d isLetter=%d, joining=%d", pos, ch.isLetter(), ch.joining()); | 127 | //odebug << "rightChar: " << pos << " isLetter=" << ch.isLetter() << ", joining=" << ch.joining() << "" << oendl; |
128 | if( !ch->isMark() ) | 128 | if( !ch->isMark() ) |
129 | return ch; | 129 | return ch; |
130 | // assume it's a transparent char, this might not be 100% correct | 130 | // assume it's a transparent char, this might not be 100% correct |
131 | pos++; | 131 | pos++; |
132 | ch++; | 132 | ch++; |
133 | } | 133 | } |
134 | return &QChar::replacement; | 134 | return &QChar::replacement; |
135 | } | 135 | } |
136 | 136 | ||
137 | static inline bool prevVisualCharJoins( const QString &str, int pos) | 137 | static inline bool prevVisualCharJoins( const QString &str, int pos) |
138 | { | 138 | { |
139 | return ( prevChar( str, pos )->joining() != QChar::OtherJoining ); | 139 | return ( prevChar( str, pos )->joining() != QChar::OtherJoining ); |
140 | } | 140 | } |
141 | 141 | ||
142 | static inline bool nextVisualCharJoins( const QString &str, int pos) | 142 | static inline bool nextVisualCharJoins( const QString &str, int pos) |
143 | { | 143 | { |
144 | QChar::Joining join = nextChar( str, pos )->joining(); | 144 | QChar::Joining join = nextChar( str, pos )->joining(); |
145 | return ( join == QChar::Dual || join == QChar::Center ); | 145 | return ( join == QChar::Dual || join == QChar::Center ); |
146 | } | 146 | } |