Diffstat (limited to 'noncore/apps/opie-write/qrichtext_p.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qrichtext_p.h | 576 |
1 files changed, 223 insertions, 353 deletions
diff --git a/noncore/apps/opie-write/qrichtext_p.h b/noncore/apps/opie-write/qrichtext_p.h index 94ce913..e368edb 100644 --- a/noncore/apps/opie-write/qrichtext_p.h +++ b/noncore/apps/opie-write/qrichtext_p.h | |||
@@ -30,349 +30,340 @@ | |||
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 | #ifndef QRICHTEXT_P_H | 38 | #ifndef QRICHTEXT_P_H |
39 | #define QRICHTEXT_P_H | 39 | #define QRICHTEXT_P_H |
40 | 40 | ||
41 | // | 41 | // |
42 | // W A R N I N G | 42 | // W A R N I N G |
43 | // ------------- | 43 | // ------------- |
44 | // | 44 | // |
45 | // This file is not part of the Qt API. It exists for the convenience | 45 | // This file is not part of the Qt API. It exists for the convenience |
46 | // of a number of Qt sources files. This header file may change from | 46 | // of a number of Qt sources files. This header file may change from |
47 | // version to version without notice, or even be removed. | 47 | // version to version without notice, or even be removed. |
48 | // | 48 | // |
49 | // We mean it. | 49 | // We mean it. |
50 | // | 50 | // |
51 | // | 51 | // |
52 | 52 | ||
53 | #ifndef QT_H | 53 | #ifndef QT_H |
54 | #include "qt3namespace.h" | ||
55 | #include "qstring.h" | 54 | #include "qstring.h" |
56 | #include "qlist.h" | 55 | #include "qlist.h" |
57 | #include "qrect.h" | 56 | #include "qrect.h" |
58 | #include "qfontmetrics.h" | 57 | #include "qfontmetrics.h" |
59 | #include "qintdict.h" | 58 | #include "qintdict.h" |
60 | #include "qmap.h" | 59 | #include "qmap.h" |
61 | #include "qstringlist.h" | 60 | #include "qstringlist.h" |
62 | #include "qfont.h" | 61 | #include "qfont.h" |
63 | #include "qcolor.h" | 62 | #include "qcolor.h" |
64 | #include "qsize.h" | 63 | #include "qsize.h" |
65 | #include "qvaluelist.h" | 64 | #include "qvaluelist.h" |
66 | #include "qvaluestack.h" | 65 | #include "qvaluestack.h" |
67 | #include "qobject.h" | 66 | #include "qobject.h" |
68 | #include "qdict.h" | 67 | #include "qdict.h" |
69 | #include "qtextstream.h" | 68 | #include "qtextstream.h" |
70 | #include "qpixmap.h" | 69 | #include "qpixmap.h" |
71 | #include "qstylesheet.h" | 70 | #include "qstylesheet.h" |
72 | #include "qvector.h" | 71 | #include "qvector.h" |
73 | #include "qpainter.h" | 72 | #include "qpainter.h" |
74 | #include "qlayout.h" | 73 | #include "qlayout.h" |
75 | #include "qobject.h" | 74 | #include "qobject.h" |
76 | #include "qcomplextext_p.h" | 75 | #include "qcomplextext_p.h" |
77 | #include "qapplication.h" | 76 | #include "qapplication.h" |
78 | #include <limits.h> | 77 | #include <limits.h> |
79 | #endif // QT_H | 78 | #endif // QT_H |
80 | 79 | ||
81 | //#define DEBUG_COLLECTION | ||
82 | |||
83 | namespace Qt3 { | 80 | namespace Qt3 { |
84 | 81 | ||
85 | class QTextDocument; | 82 | class QTextDocument; |
86 | class QTextString; | 83 | class QTextString; |
87 | class QTextPreProcessor; | 84 | class QTextPreProcessor; |
88 | class QTextFormat; | 85 | class QTextFormat; |
89 | class QTextCursor; | 86 | class QTextCursor; |
90 | class QTextParag; | 87 | class QTextParagraph; |
91 | class QTextFormatter; | 88 | class QTextFormatter; |
92 | class QTextIndent; | 89 | class QTextIndent; |
93 | class QTextFormatCollection; | 90 | class QTextFormatCollection; |
94 | class QStyleSheetItem; | 91 | class QStyleSheetItem; |
95 | class QTextCustomItem; | 92 | class QTextCustomItem; |
96 | class QTextFlow; | 93 | class QTextFlow; |
97 | struct QBidiContext; | 94 | struct QBidiContext; |
98 | 95 | ||
99 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 96 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
100 | 97 | ||
101 | class Q_EXPORT QTextStringChar | 98 | class Q_EXPORT QTextStringChar |
102 | { | 99 | { |
103 | friend class QTextString; | 100 | friend class QTextString; |
104 | 101 | ||
105 | public: | 102 | public: |
106 | // this is never called, initialize variables in QTextString::insert()!!! | 103 | // this is never called, initialize variables in QTextString::insert()!!! |
107 | QTextStringChar() : lineStart( 0 ), type( Regular ), startOfRun( 0 ) {d.format=0;} | 104 | QTextStringChar() : lineStart( 0 ), type( Regular ), startOfRun( 0 ) {d.format=0;} |
108 | ~QTextStringChar(); | 105 | ~QTextStringChar(); |
109 | 106 | ||
110 | QChar c; | 107 | QChar c; |
111 | enum Type { Regular=0, Custom=1, Anchor=2, CustomAnchor=3 }; | 108 | enum Type { Regular=0, Custom=1, Anchor=2, CustomAnchor=3 }; |
112 | uint lineStart : 1; | 109 | uint lineStart : 1; |
113 | uint rightToLeft : 1; | 110 | uint rightToLeft : 1; |
114 | uint hasCursor : 1; | 111 | uint hasCursor : 1; |
115 | uint canBreak : 1; | 112 | uint canBreak : 1; |
116 | Type type : 2; | 113 | Type type : 2; |
117 | uint startOfRun : 1; | 114 | uint startOfRun : 1; |
118 | 115 | ||
119 | int x; | 116 | int x; |
120 | int height() const; | 117 | int height() const; |
121 | int ascent() const; | 118 | int ascent() const; |
122 | int descent() const; | 119 | int descent() const; |
123 | bool isCustom() const { return (type & Custom) != 0; } | 120 | bool isCustom() const { return (type & Custom) != 0; } |
124 | QTextFormat *format() const; | 121 | QTextFormat *format() const; |
125 | QTextCustomItem *customItem() const; | 122 | QTextCustomItem *customItem() const; |
126 | void setFormat( QTextFormat *f ); | 123 | void setFormat( QTextFormat *f ); |
127 | void setCustomItem( QTextCustomItem *i ); | 124 | void setCustomItem( QTextCustomItem *i ); |
128 | QTextStringChar *clone() const; | ||
129 | struct CustomData | 125 | struct CustomData |
130 | { | 126 | { |
131 | QTextFormat *format; | 127 | QTextFormat *format; |
132 | QTextCustomItem *custom; | 128 | QTextCustomItem *custom; |
133 | QString anchorName; | 129 | QString anchorName; |
134 | QString anchorHref; | 130 | QString anchorHref; |
135 | }; | 131 | }; |
136 | 132 | ||
137 | void loseCustomItem(); | 133 | void loseCustomItem(); |
138 | 134 | ||
139 | union { | 135 | union { |
140 | QTextFormat* format; | 136 | QTextFormat* format; |
141 | CustomData* custom; | 137 | CustomData* custom; |
142 | } d; | 138 | } d; |
143 | 139 | ||
144 | bool isAnchor() const { return ( type & Anchor) != 0; } | 140 | bool isAnchor() const { return ( type & Anchor) != 0; } |
145 | QString anchorName() const; | 141 | QString anchorName() const; |
146 | QString anchorHref() const; | 142 | QString anchorHref() const; |
147 | void setAnchor( const QString& name, const QString& href ); | 143 | void setAnchor( const QString& name, const QString& href ); |
148 | 144 | ||
149 | private: | 145 | private: |
150 | QTextStringChar &operator=( const QTextStringChar & ) { | 146 | QTextStringChar &operator=( const QTextStringChar & ) { |
151 | //abort(); | 147 | //abort(); |
152 | return *this; | 148 | return *this; |
153 | } | 149 | } |
154 | friend class QComplexText; | 150 | friend class QComplexText; |
155 | friend class QTextParag; | 151 | friend class QTextParagraph; |
156 | }; | 152 | }; |
157 | 153 | ||
158 | #if defined(Q_TEMPLATEDLL) | 154 | #if defined(Q_TEMPLATEDLL) |
159 | // MOC_SKIP_BEGIN | 155 | // MOC_SKIP_BEGIN |
160 | template class Q_EXPORT QMemArray<QTextStringChar>; | 156 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<QTextStringChar>; |
161 | // MOC_SKIP_END | 157 | // MOC_SKIP_END |
162 | #endif | 158 | #endif |
163 | 159 | ||
164 | class Q_EXPORT QTextString | 160 | class Q_EXPORT QTextString |
165 | { | 161 | { |
166 | public: | 162 | public: |
167 | 163 | ||
168 | QTextString(); | 164 | QTextString(); |
169 | QTextString( const QTextString &s ); | 165 | QTextString( const QTextString &s ); |
170 | virtual ~QTextString(); | 166 | virtual ~QTextString(); |
171 | 167 | ||
172 | static QString toString( const QMemArray<QTextStringChar> &data ); | 168 | static QString toString( const QMemArray<QTextStringChar> &data ); |
173 | QString toString() const; | 169 | QString toString() const; |
174 | 170 | ||
175 | QTextStringChar &at( int i ) const; | 171 | QTextStringChar &at( int i ) const; |
176 | int length() const; | 172 | int length() const; |
177 | 173 | ||
178 | int width( int idx ) const; | 174 | int width( int idx ) const; |
179 | 175 | ||
180 | void insert( int index, const QString &s, QTextFormat *f ); | 176 | void insert( int index, const QString &s, QTextFormat *f ); |
181 | void insert( int index, QTextStringChar *c ); | 177 | void insert( int index, const QChar *unicode, int len, QTextFormat *f ); |
178 | void insert( int index, QTextStringChar *c, bool doAddRefFormat = FALSE ); | ||
182 | void truncate( int index ); | 179 | void truncate( int index ); |
183 | void remove( int index, int len ); | 180 | void remove( int index, int len ); |
184 | void clear(); | 181 | void clear(); |
185 | 182 | ||
186 | void setFormat( int index, QTextFormat *f, bool useCollection ); | 183 | void setFormat( int index, QTextFormat *f, bool useCollection ); |
187 | 184 | ||
188 | void setBidi( bool b ) { bidi = b; } | 185 | void setBidi( bool b ) { bidi = b; } |
189 | bool isBidi() const; | 186 | bool isBidi() const; |
190 | bool isRightToLeft() const; | 187 | bool isRightToLeft() const; |
191 | QChar::Direction direction() const; | 188 | QChar::Direction direction() const; |
192 | void setDirection( QChar::Direction d ) { dir = d; bidiDirty = TRUE; } | 189 | void setDirection( QChar::Direction d ) { dir = d; bidiDirty = TRUE; } |
193 | 190 | ||
194 | QMemArray<QTextStringChar> subString( int start = 0, int len = 0xFFFFFF ) const; | 191 | QMemArray<QTextStringChar> subString( int start = 0, int len = 0xFFFFFF ) const; |
195 | QMemArray<QTextStringChar> rawData() const { return data; } | 192 | QMemArray<QTextStringChar> rawData() const { return data; } |
196 | 193 | ||
197 | void operator=( const QString &s ) { clear(); insert( 0, s, 0 ); } | 194 | void operator=( const QString &s ) { clear(); insert( 0, s, 0 ); } |
198 | void operator+=( const QString &s ); | 195 | void operator+=( const QString &s ) {insert( length(), s, 0 ); } |
199 | void prepend( const QString &s ) { insert( 0, s, 0 ); } | 196 | void prepend( const QString &s ) { insert( 0, s, 0 ); } |
200 | 197 | ||
201 | private: | 198 | private: |
202 | void checkBidi() const; | 199 | void checkBidi() const; |
203 | 200 | ||
204 | QMemArray<QTextStringChar> data; | 201 | QMemArray<QTextStringChar> data; |
205 | uint bidiDirty : 1; | 202 | uint bidiDirty : 1; |
206 | uint bidi : 1; // true when the paragraph has right to left characters | 203 | uint bidi : 1; // true when the paragraph has right to left characters |
207 | uint rightToLeft : 1; | 204 | uint rightToLeft : 1; |
208 | uint dir : 5; | 205 | uint dir : 5; |
209 | }; | 206 | }; |
210 | 207 | ||
211 | inline bool QTextString::isBidi() const | 208 | inline bool QTextString::isBidi() const |
212 | { | 209 | { |
213 | if ( bidiDirty ) | 210 | if ( bidiDirty ) |
214 | checkBidi(); | 211 | checkBidi(); |
215 | return bidi; | 212 | return bidi; |
216 | } | 213 | } |
217 | 214 | ||
218 | inline bool QTextString::isRightToLeft() const | 215 | inline bool QTextString::isRightToLeft() const |
219 | { | 216 | { |
220 | if ( bidiDirty ) | 217 | if ( bidiDirty ) |
221 | checkBidi(); | 218 | checkBidi(); |
222 | return rightToLeft; | 219 | return rightToLeft; |
223 | } | 220 | } |
224 | 221 | ||
225 | inline QChar::Direction QTextString::direction() const | 222 | inline QChar::Direction QTextString::direction() const |
226 | { | 223 | { |
227 | return (QChar::Direction) dir; | 224 | return (QChar::Direction) dir; |
228 | } | 225 | } |
229 | 226 | ||
230 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 227 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
231 | 228 | ||
232 | #if defined(Q_TEMPLATEDLL) | 229 | #if defined(Q_TEMPLATEDLL) |
233 | // MOC_SKIP_BEGIN | 230 | // MOC_SKIP_BEGIN |
234 | template class Q_EXPORT QValueStack<int>; | 231 | Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<int>; |
235 | template class Q_EXPORT QValueStack<QTextParag*>; | 232 | Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<QTextParagraph*>; |
236 | template class Q_EXPORT QValueStack<bool>; | 233 | Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<bool>; |
237 | // MOC_SKIP_END | 234 | // MOC_SKIP_END |
238 | #endif | 235 | #endif |
239 | 236 | ||
240 | class Q_EXPORT QTextCursor | 237 | class Q_EXPORT QTextCursor |
241 | { | 238 | { |
242 | public: | 239 | public: |
243 | QTextCursor( QTextDocument *d ); | 240 | QTextCursor( QTextDocument *d = 0 ); |
244 | QTextCursor(); | ||
245 | QTextCursor( const QTextCursor &c ); | 241 | QTextCursor( const QTextCursor &c ); |
246 | QTextCursor &operator=( const QTextCursor &c ); | 242 | QTextCursor &operator=( const QTextCursor &c ); |
247 | virtual ~QTextCursor() {} | 243 | virtual ~QTextCursor() {} |
248 | 244 | ||
249 | bool operator==( const QTextCursor &c ) const; | 245 | bool operator==( const QTextCursor &c ) const; |
250 | bool operator!=( const QTextCursor &c ) const { return !(*this == c); } | 246 | bool operator!=( const QTextCursor &c ) const { return !(*this == c); } |
251 | 247 | ||
252 | QTextDocument *document() const { return doc; } | 248 | QTextParagraph *paragraph() const; |
253 | void setDocument( QTextDocument *d ); | 249 | void setParagraph( QTextParagraph*p ) { gotoPosition(p, 0 ); } |
254 | 250 | QTextDocument *document() const; | |
255 | QTextParag *parag() const; | ||
256 | int index() const; | 251 | int index() const; |
257 | void setParag( QTextParag *s, bool restore = TRUE ); | 252 | void setIndex( int index ) { gotoPosition(paragraph(), index ); } |
258 | 253 | ||
254 | void gotoPosition( QTextParagraph* p, int index = 0); | ||
259 | void gotoLeft(); | 255 | void gotoLeft(); |
260 | void gotoRight(); | 256 | void gotoRight(); |
261 | void gotoNextLetter(); | 257 | void gotoNextLetter(); |
262 | void gotoPreviousLetter(); | 258 | void gotoPreviousLetter(); |
263 | void gotoUp(); | 259 | void gotoUp(); |
264 | void gotoDown(); | 260 | void gotoDown(); |
265 | void gotoLineEnd(); | 261 | void gotoLineEnd(); |
266 | void gotoLineStart(); | 262 | void gotoLineStart(); |
267 | void gotoHome(); | 263 | void gotoHome(); |
268 | void gotoEnd(); | 264 | void gotoEnd(); |
269 | void gotoPageUp( int visibleHeight ); | 265 | void gotoPageUp( int visibleHeight ); |
270 | void gotoPageDown( int visibleHeight ); | 266 | void gotoPageDown( int visibleHeight ); |
271 | void gotoNextWord(); | 267 | void gotoNextWord(); |
272 | void gotoPreviousWord(); | 268 | void gotoPreviousWord(); |
273 | void gotoWordLeft(); | 269 | void gotoWordLeft(); |
274 | void gotoWordRight(); | 270 | void gotoWordRight(); |
275 | 271 | ||
276 | void insert( const QString &s, bool checkNewLine, QMemArray<QTextStringChar> *formatting = 0 ); | 272 | void insert( const QString &s, bool checkNewLine, QMemArray<QTextStringChar> *formatting = 0 ); |
277 | void splitAndInsertEmptyParag( bool ind = TRUE, bool updateIds = TRUE ); | 273 | void splitAndInsertEmptyParagraph( bool ind = TRUE, bool updateIds = TRUE ); |
278 | bool remove(); | 274 | bool remove(); |
279 | void killLine(); | ||
280 | void indent(); | 275 | void indent(); |
281 | 276 | ||
282 | bool atParagStart(); | 277 | bool atParagStart(); |
283 | bool atParagEnd(); | 278 | bool atParagEnd(); |
284 | 279 | ||
285 | void setIndex( int i, bool restore = TRUE ); | 280 | int x() const; // x in current paragraph |
286 | 281 | int y() const; // y in current paragraph | |
287 | void checkIndex(); | ||
288 | 282 | ||
289 | int offsetX() const { return ox; } | 283 | int globalX() const; |
290 | int offsetY() const { return oy; } | 284 | int globalY() const; |
291 | 285 | ||
292 | QTextParag *topParag() const { return parags.isEmpty() ? string : parags.first(); } | 286 | QTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); } |
293 | int totalOffsetX() const; | 287 | int offsetX() const { return ox; } // inner document offset |
294 | int totalOffsetY() const; | 288 | int offsetY() const { return oy; } // inner document offset |
289 | int totalOffsetX() const; // total document offset | ||
290 | int totalOffsetY() const; // total document offset | ||
295 | 291 | ||
296 | bool place( const QPoint &pos, QTextParag *s ) { return place( pos, s, FALSE ); } | 292 | bool place( const QPoint &pos, QTextParagraph *s ) { return place( pos, s, FALSE ); } |
297 | bool place( const QPoint &pos, QTextParag *s, bool link ); | 293 | bool place( const QPoint &pos, QTextParagraph *s, bool link ); |
298 | void restoreState(); | 294 | void restoreState(); |
299 | 295 | ||
300 | int x() const; | ||
301 | int y() const; | ||
302 | 296 | ||
303 | int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast | 297 | int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast |
304 | void oneUp() { if ( !indices.isEmpty() ) pop(); } | 298 | void oneUp() { if ( !indices.isEmpty() ) pop(); } |
305 | void setValid( bool b ) { valid = b; } | 299 | void setValid( bool b ) { valid = b; } |
306 | bool isValid() const { return valid; } | 300 | bool isValid() const { return valid; } |
307 | 301 | ||
308 | private: | 302 | private: |
309 | enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down }; | 303 | enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down }; |
310 | 304 | ||
311 | void push(); | 305 | void push(); |
312 | void pop(); | 306 | void pop(); |
313 | void processNesting( Operation op ); | 307 | void processNesting( Operation op ); |
314 | void invalidateNested(); | 308 | void invalidateNested(); |
315 | void gotoIntoNested( const QPoint &globalPos ); | 309 | void gotoIntoNested( const QPoint &globalPos ); |
316 | 310 | ||
317 | QTextParag *string; | 311 | QTextParagraph *para; |
318 | QTextDocument *doc; | ||
319 | int idx, tmpIndex; | 312 | int idx, tmpIndex; |
320 | int ox, oy; | 313 | int ox, oy; |
321 | QValueStack<int> indices; | 314 | QValueStack<int> indices; |
322 | QValueStack<QTextParag*> parags; | 315 | QValueStack<QTextParagraph*> paras; |
323 | QValueStack<int> xOffsets; | 316 | QValueStack<int> xOffsets; |
324 | QValueStack<int> yOffsets; | 317 | QValueStack<int> yOffsets; |
325 | QValueStack<bool> nestedStack; | ||
326 | uint nested : 1; | ||
327 | uint valid : 1; | 318 | uint valid : 1; |
328 | 319 | ||
329 | }; | 320 | }; |
330 | 321 | ||
331 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 322 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
332 | 323 | ||
333 | class Q_EXPORT QTextCommand | 324 | class Q_EXPORT QTextCommand |
334 | { | 325 | { |
335 | public: | 326 | public: |
336 | enum Commands { Invalid, Insert, Delete, Format, Alignment, ParagType }; | 327 | enum Commands { Invalid, Insert, Delete, Format, Style }; |
337 | 328 | ||
338 | QTextCommand( QTextDocument *d ) : doc( d ), cursor( d ) {} | 329 | QTextCommand( QTextDocument *d ) : doc( d ), cursor( d ) {} |
339 | virtual ~QTextCommand(); | 330 | virtual ~QTextCommand(); |
340 | 331 | ||
341 | virtual Commands type() const; | 332 | virtual Commands type() const; |
342 | 333 | ||
343 | virtual QTextCursor *execute( QTextCursor *c ) = 0; | 334 | virtual QTextCursor *execute( QTextCursor *c ) = 0; |
344 | virtual QTextCursor *unexecute( QTextCursor *c ) = 0; | 335 | virtual QTextCursor *unexecute( QTextCursor *c ) = 0; |
345 | 336 | ||
346 | protected: | 337 | protected: |
347 | QTextDocument *doc; | 338 | QTextDocument *doc; |
348 | QTextCursor cursor; | 339 | QTextCursor cursor; |
349 | 340 | ||
350 | }; | 341 | }; |
351 | 342 | ||
352 | #if defined(Q_TEMPLATEDLL) | 343 | #if defined(Q_TEMPLATEDLL) |
353 | // MOC_SKIP_BEGIN | 344 | // MOC_SKIP_BEGIN |
354 | template class Q_EXPORT QPtrList<QTextCommand>; | 345 | Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextCommand>; |
355 | // MOC_SKIP_END | 346 | // MOC_SKIP_END |
356 | #endif | 347 | #endif |
357 | 348 | ||
358 | class Q_EXPORT QTextCommandHistory | 349 | class Q_EXPORT QTextCommandHistory |
359 | { | 350 | { |
360 | public: | 351 | public: |
361 | QTextCommandHistory( int s ) : current( -1 ), steps( s ) { history.setAutoDelete( TRUE ); } | 352 | QTextCommandHistory( int s ) : current( -1 ), steps( s ) { history.setAutoDelete( TRUE ); } |
362 | virtual ~QTextCommandHistory(); | 353 | virtual ~QTextCommandHistory(); |
363 | 354 | ||
364 | void clear() { history.clear(); current = -1; } | 355 | void clear() { history.clear(); current = -1; } |
365 | 356 | ||
366 | void addCommand( QTextCommand *cmd ); | 357 | void addCommand( QTextCommand *cmd ); |
367 | QTextCursor *undo( QTextCursor *c ); | 358 | QTextCursor *undo( QTextCursor *c ); |
368 | QTextCursor *redo( QTextCursor *c ); | 359 | QTextCursor *redo( QTextCursor *c ); |
369 | 360 | ||
370 | bool isUndoAvailable(); | 361 | bool isUndoAvailable(); |
371 | bool isRedoAvailable(); | 362 | bool isRedoAvailable(); |
372 | 363 | ||
373 | void setUndoDepth( int d ) { steps = d; } | 364 | void setUndoDepth( int d ) { steps = d; } |
374 | int undoDepth() const { return steps; } | 365 | int undoDepth() const { return steps; } |
375 | 366 | ||
376 | int historySize() const { return history.count(); } | 367 | int historySize() const { return history.count(); } |
377 | int currentPosition() const { return current; } | 368 | int currentPosition() const { return current; } |
378 | 369 | ||
@@ -400,67 +391,67 @@ public: | |||
400 | 391 | ||
401 | virtual void adjustToPainter( QPainter* ); | 392 | virtual void adjustToPainter( QPainter* ); |
402 | 393 | ||
403 | enum Placement { PlaceInline = 0, PlaceLeft, PlaceRight }; | 394 | enum Placement { PlaceInline = 0, PlaceLeft, PlaceRight }; |
404 | virtual Placement placement() const; | 395 | virtual Placement placement() const; |
405 | bool placeInline() { return placement() == PlaceInline; } | 396 | bool placeInline() { return placement() == PlaceInline; } |
406 | 397 | ||
407 | virtual bool ownLine() const; | 398 | virtual bool ownLine() const; |
408 | virtual void resize( int nwidth ); | 399 | virtual void resize( int nwidth ); |
409 | virtual void invalidate(); | 400 | virtual void invalidate(); |
410 | virtual int ascent() const { return height; } | 401 | virtual int ascent() const { return height; } |
411 | 402 | ||
412 | virtual bool isNested() const; | 403 | virtual bool isNested() const; |
413 | virtual int minimumWidth() const; | 404 | virtual int minimumWidth() const; |
414 | 405 | ||
415 | virtual QString richText() const; | 406 | virtual QString richText() const; |
416 | 407 | ||
417 | int xpos; // used for floating items | 408 | int xpos; // used for floating items |
418 | int ypos; // used for floating items | 409 | int ypos; // used for floating items |
419 | int width; | 410 | int width; |
420 | int height; | 411 | int height; |
421 | 412 | ||
422 | QRect geometry() const { return QRect( xpos, ypos, width, height ); } | 413 | QRect geometry() const { return QRect( xpos, ypos, width, height ); } |
423 | 414 | ||
424 | virtual bool enter( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy, bool atEnd = FALSE ); | 415 | virtual bool enter( QTextCursor *, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy, bool atEnd = FALSE ); |
425 | virtual bool enterAt( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy, const QPoint & ); | 416 | virtual bool enterAt( QTextCursor *, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy, const QPoint & ); |
426 | virtual bool next( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ); | 417 | virtual bool next( QTextCursor *, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy ); |
427 | virtual bool prev( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ); | 418 | virtual bool prev( QTextCursor *, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy ); |
428 | virtual bool down( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ); | 419 | virtual bool down( QTextCursor *, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy ); |
429 | virtual bool up( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ); | 420 | virtual bool up( QTextCursor *, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy ); |
430 | 421 | ||
431 | void setParagraph( QTextParag *p ) { parag = p; } | 422 | void setParagraph( QTextParagraph *p ) { parag = p; } |
432 | QTextParag *paragrapth() const { return parag; } | 423 | QTextParagraph *paragraph() const { return parag; } |
433 | 424 | ||
434 | QTextDocument *parent; | 425 | QTextDocument *parent; |
435 | QTextParag *parag; | 426 | QTextParagraph *parag; |
436 | 427 | ||
437 | virtual void pageBreak( int y, QTextFlow* flow ); | 428 | virtual void pageBreak( int y, QTextFlow* flow ); |
438 | }; | 429 | }; |
439 | 430 | ||
440 | #if defined(Q_TEMPLATEDLL) | 431 | #if defined(Q_TEMPLATEDLL) |
441 | // MOC_SKIP_BEGIN | 432 | // MOC_SKIP_BEGIN |
442 | template class Q_EXPORT QMap<QString, QString>; | 433 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<QString, QString>; |
443 | // MOC_SKIP_END | 434 | // MOC_SKIP_END |
444 | #endif | 435 | #endif |
445 | 436 | ||
446 | class Q_EXPORT QTextImage : public QTextCustomItem | 437 | class Q_EXPORT QTextImage : public QTextCustomItem |
447 | { | 438 | { |
448 | public: | 439 | public: |
449 | QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, | 440 | QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, |
450 | QMimeSourceFactory &factory ); | 441 | QMimeSourceFactory &factory ); |
451 | virtual ~QTextImage(); | 442 | virtual ~QTextImage(); |
452 | 443 | ||
453 | Placement placement() const { return place; } | 444 | Placement placement() const { return place; } |
454 | void adjustToPainter( QPainter* ); | 445 | void adjustToPainter( QPainter* ); |
455 | int minimumWidth() const { return width; } | 446 | int minimumWidth() const { return width; } |
456 | 447 | ||
457 | QString richText() const; | 448 | QString richText() const; |
458 | 449 | ||
459 | void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); | 450 | void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); |
460 | 451 | ||
461 | private: | 452 | private: |
462 | QRegion* reg; | 453 | QRegion* reg; |
463 | QPixmap pm; | 454 | QPixmap pm; |
464 | Placement place; | 455 | Placement place; |
465 | int tmpwidth, tmpheight; | 456 | int tmpwidth, tmpheight; |
466 | QMap<QString, QString> attributes; | 457 | QMap<QString, QString> attributes; |
@@ -468,49 +459,49 @@ private: | |||
468 | 459 | ||
469 | }; | 460 | }; |
470 | 461 | ||
471 | class Q_EXPORT QTextHorizontalLine : public QTextCustomItem | 462 | class Q_EXPORT QTextHorizontalLine : public QTextCustomItem |
472 | { | 463 | { |
473 | public: | 464 | public: |
474 | QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, | 465 | QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, |
475 | QMimeSourceFactory &factory ); | 466 | QMimeSourceFactory &factory ); |
476 | virtual ~QTextHorizontalLine(); | 467 | virtual ~QTextHorizontalLine(); |
477 | 468 | ||
478 | void adjustToPainter( QPainter* ); | 469 | void adjustToPainter( QPainter* ); |
479 | void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); | 470 | void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); |
480 | QString richText() const; | 471 | QString richText() const; |
481 | 472 | ||
482 | bool ownLine() const { return TRUE; } | 473 | bool ownLine() const { return TRUE; } |
483 | 474 | ||
484 | private: | 475 | private: |
485 | int tmpheight; | 476 | int tmpheight; |
486 | QColor color; | 477 | QColor color; |
487 | 478 | ||
488 | }; | 479 | }; |
489 | 480 | ||
490 | #if defined(Q_TEMPLATEDLL) | 481 | #if defined(Q_TEMPLATEDLL) |
491 | // MOC_SKIP_BEGIN | 482 | // MOC_SKIP_BEGIN |
492 | template class Q_EXPORT QPtrList<QTextCustomItem>; | 483 | Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextCustomItem>; |
493 | // MOC_SKIP_END | 484 | // MOC_SKIP_END |
494 | #endif | 485 | #endif |
495 | 486 | ||
496 | class Q_EXPORT QTextFlow | 487 | class Q_EXPORT QTextFlow |
497 | { | 488 | { |
498 | friend class QTextDocument; | 489 | friend class QTextDocument; |
499 | friend class QTextTableCell; | 490 | friend class QTextTableCell; |
500 | 491 | ||
501 | public: | 492 | public: |
502 | QTextFlow(); | 493 | QTextFlow(); |
503 | virtual ~QTextFlow(); | 494 | virtual ~QTextFlow(); |
504 | 495 | ||
505 | virtual void setWidth( int width ); | 496 | virtual void setWidth( int width ); |
506 | int width() const; | 497 | int width() const; |
507 | 498 | ||
508 | virtual void setPageSize( int ps ); | 499 | virtual void setPageSize( int ps ); |
509 | int pageSize() const { return pagesize; } | 500 | int pageSize() const { return pagesize; } |
510 | 501 | ||
511 | virtual int adjustLMargin( int yp, int h, int margin, int space ); | 502 | virtual int adjustLMargin( int yp, int h, int margin, int space ); |
512 | virtual int adjustRMargin( int yp, int h, int margin, int space ); | 503 | virtual int adjustRMargin( int yp, int h, int margin, int space ); |
513 | 504 | ||
514 | virtual void registerFloatingItem( QTextCustomItem* item ); | 505 | virtual void registerFloatingItem( QTextCustomItem* item ); |
515 | virtual void unregisterFloatingItem( QTextCustomItem* item ); | 506 | virtual void unregisterFloatingItem( QTextCustomItem* item ); |
516 | virtual QRect boundingRect() const; | 507 | virtual QRect boundingRect() const; |
@@ -525,49 +516,48 @@ public: | |||
525 | private: | 516 | private: |
526 | int w; | 517 | int w; |
527 | int pagesize; | 518 | int pagesize; |
528 | 519 | ||
529 | QPtrList<QTextCustomItem> leftItems; | 520 | QPtrList<QTextCustomItem> leftItems; |
530 | QPtrList<QTextCustomItem> rightItems; | 521 | QPtrList<QTextCustomItem> rightItems; |
531 | 522 | ||
532 | }; | 523 | }; |
533 | 524 | ||
534 | inline int QTextFlow::width() const { return w; } | 525 | inline int QTextFlow::width() const { return w; } |
535 | 526 | ||
536 | class QTextTable; | 527 | class QTextTable; |
537 | 528 | ||
538 | class Q_EXPORT QTextTableCell : public QLayoutItem | 529 | class Q_EXPORT QTextTableCell : public QLayoutItem |
539 | { | 530 | { |
540 | friend class QTextTable; | 531 | friend class QTextTable; |
541 | 532 | ||
542 | public: | 533 | public: |
543 | QTextTableCell( QTextTable* table, | 534 | QTextTableCell( QTextTable* table, |
544 | int row, int column, | 535 | int row, int column, |
545 | const QMap<QString, QString> &attr, | 536 | const QMap<QString, QString> &attr, |
546 | const QStyleSheetItem* style, | 537 | const QStyleSheetItem* style, |
547 | const QTextFormat& fmt, const QString& context, | 538 | const QTextFormat& fmt, const QString& context, |
548 | QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc ); | 539 | QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc ); |
549 | QTextTableCell( QTextTable* table, int row, int column ); | ||
550 | virtual ~QTextTableCell(); | 540 | virtual ~QTextTableCell(); |
551 | 541 | ||
552 | QSize sizeHint() const ; | 542 | QSize sizeHint() const ; |
553 | QSize minimumSize() const ; | 543 | QSize minimumSize() const ; |
554 | QSize maximumSize() const ; | 544 | QSize maximumSize() const ; |
555 | QSizePolicy::ExpandData expanding() const; | 545 | QSizePolicy::ExpandData expanding() const; |
556 | bool isEmpty() const; | 546 | bool isEmpty() const; |
557 | void setGeometry( const QRect& ) ; | 547 | void setGeometry( const QRect& ) ; |
558 | QRect geometry() const; | 548 | QRect geometry() const; |
559 | 549 | ||
560 | bool hasHeightForWidth() const; | 550 | bool hasHeightForWidth() const; |
561 | int heightForWidth( int ) const; | 551 | int heightForWidth( int ) const; |
562 | 552 | ||
563 | void adjustToPainter( QPainter* ); | 553 | void adjustToPainter( QPainter* ); |
564 | 554 | ||
565 | int row() const { return row_; } | 555 | int row() const { return row_; } |
566 | int column() const { return col_; } | 556 | int column() const { return col_; } |
567 | int rowspan() const { return rowspan_; } | 557 | int rowspan() const { return rowspan_; } |
568 | int colspan() const { return colspan_; } | 558 | int colspan() const { return colspan_; } |
569 | int stretch() const { return stretch_; } | 559 | int stretch() const { return stretch_; } |
570 | 560 | ||
571 | QTextDocument* richText() const { return richtext; } | 561 | QTextDocument* richText() const { return richtext; } |
572 | QTextTable* table() const { return parent; } | 562 | QTextTable* table() const { return parent; } |
573 | 563 | ||
@@ -579,1137 +569,1057 @@ public: | |||
579 | int verticalAlignmentOffset() const; | 569 | int verticalAlignmentOffset() const; |
580 | int horizontalAlignmentOffset() const; | 570 | int horizontalAlignmentOffset() const; |
581 | 571 | ||
582 | private: | 572 | private: |
583 | QRect geom; | 573 | QRect geom; |
584 | QTextTable* parent; | 574 | QTextTable* parent; |
585 | QTextDocument* richtext; | 575 | QTextDocument* richtext; |
586 | int row_; | 576 | int row_; |
587 | int col_; | 577 | int col_; |
588 | int rowspan_; | 578 | int rowspan_; |
589 | int colspan_; | 579 | int colspan_; |
590 | int stretch_; | 580 | int stretch_; |
591 | int maxw; | 581 | int maxw; |
592 | int minw; | 582 | int minw; |
593 | bool hasFixedWidth; | 583 | bool hasFixedWidth; |
594 | QBrush *background; | 584 | QBrush *background; |
595 | int cached_width; | 585 | int cached_width; |
596 | int cached_sizehint; | 586 | int cached_sizehint; |
597 | QMap<QString, QString> attributes; | 587 | QMap<QString, QString> attributes; |
598 | int align; | 588 | int align; |
599 | }; | 589 | }; |
600 | 590 | ||
601 | #if defined(Q_TEMPLATEDLL) | 591 | #if defined(Q_TEMPLATEDLL) |
602 | // MOC_SKIP_BEGIN | 592 | // MOC_SKIP_BEGIN |
603 | template class Q_EXPORT QPtrList<QTextTableCell>; | 593 | Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextTableCell>; |
604 | template class Q_EXPORT QMap<QTextCursor*, int>; | 594 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<QTextCursor*, int>; |
605 | // MOC_SKIP_END | 595 | // MOC_SKIP_END |
606 | #endif | 596 | #endif |
607 | 597 | ||
608 | class Q_EXPORT QTextTable: public QTextCustomItem | 598 | class Q_EXPORT QTextTable: public QTextCustomItem |
609 | { | 599 | { |
610 | friend class QTextTableCell; | 600 | friend class QTextTableCell; |
611 | 601 | ||
612 | public: | 602 | public: |
613 | QTextTable( QTextDocument *p, const QMap<QString, QString> &attr ); | 603 | QTextTable( QTextDocument *p, const QMap<QString, QString> &attr ); |
614 | virtual ~QTextTable(); | 604 | virtual ~QTextTable(); |
615 | 605 | ||
616 | void adjustToPainter( QPainter *p ); | 606 | void adjustToPainter( QPainter *p ); |
617 | void pageBreak( int y, QTextFlow* flow ); | 607 | void pageBreak( int y, QTextFlow* flow ); |
618 | void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, | 608 | void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, |
619 | const QColorGroup& cg, bool selected ); | 609 | const QColorGroup& cg, bool selected ); |
620 | 610 | ||
621 | bool noErase() const { return TRUE; } | 611 | bool noErase() const { return TRUE; } |
622 | bool ownLine() const { return TRUE; } | 612 | bool ownLine() const { return TRUE; } |
623 | Placement placement() const { return place; } | 613 | Placement placement() const { return place; } |
624 | bool isNested() const { return TRUE; } | 614 | bool isNested() const { return TRUE; } |
625 | void resize( int nwidth ); | 615 | void resize( int nwidth ); |
626 | virtual void invalidate(); | 616 | virtual void invalidate(); |
627 | 617 | ||
628 | virtual bool enter( QTextCursor *c, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy, bool atEnd = FALSE ); | 618 | virtual bool enter( QTextCursor *c, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy, bool atEnd = FALSE ); |
629 | virtual bool enterAt( QTextCursor *c, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy, const QPoint &pos ); | 619 | virtual bool enterAt( QTextCursor *c, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy, const QPoint &pos ); |
630 | virtual bool next( QTextCursor *c, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ); | 620 | virtual bool next( QTextCursor *c, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy ); |
631 | virtual bool prev( QTextCursor *c, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ); | 621 | virtual bool prev( QTextCursor *c, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy ); |
632 | virtual bool down( QTextCursor *c, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ); | 622 | virtual bool down( QTextCursor *c, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy ); |
633 | virtual bool up( QTextCursor *c, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ); | 623 | virtual bool up( QTextCursor *c, QTextDocument *&doc, QTextParagraph *¶g, int &idx, int &ox, int &oy ); |
634 | 624 | ||
635 | QString richText() const; | 625 | QString richText() const; |
636 | 626 | ||
637 | int minimumWidth() const; | 627 | int minimumWidth() const; |
638 | 628 | ||
639 | QPtrList<QTextTableCell> tableCells() const { return cells; } | 629 | QPtrList<QTextTableCell> tableCells() const { return cells; } |
640 | 630 | ||
641 | bool isStretching() const { return stretch; } | 631 | bool isStretching() const { return stretch; } |
642 | 632 | ||
643 | private: | 633 | private: |
644 | void format( int w ); | 634 | void format( int w ); |
645 | void addCell( QTextTableCell* cell ); | 635 | void addCell( QTextTableCell* cell ); |
646 | 636 | ||
647 | private: | 637 | private: |
648 | QGridLayout* layout; | 638 | QGridLayout* layout; |
649 | QPtrList<QTextTableCell> cells; | 639 | QPtrList<QTextTableCell> cells; |
650 | int cachewidth; | 640 | int cachewidth; |
651 | int fixwidth; | 641 | int fixwidth; |
652 | int cellpadding; | 642 | int cellpadding; |
653 | int cellspacing; | 643 | int cellspacing; |
654 | int border; | 644 | int border; |
655 | int outerborder; | 645 | int outerborder; |
656 | int stretch; | 646 | int stretch; |
657 | int innerborder; | 647 | int innerborder; |
658 | int us_cp, us_ib, us_b, us_ob, us_cs; | 648 | int us_cp, us_ib, us_b, us_ob, us_cs; |
659 | QMap<QString, QString> attributes; | 649 | QMap<QString, QString> attributes; |
660 | QMap<QTextCursor*, int> currCell; | 650 | QMap<QTextCursor*, int> currCell; |
661 | Placement place; | 651 | Placement place; |
662 | void adjustCells( int y , int shift ); | 652 | void adjustCells( int y , int shift ); |
663 | int pageBreakFor; | 653 | int pageBreakFor; |
664 | }; | 654 | }; |
665 | 655 | ||
666 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 656 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
667 | 657 | ||
668 | class QTextTableCell; | 658 | class QTextTableCell; |
669 | class QTextParag; | 659 | class QTextParagraph; |
670 | 660 | ||
671 | struct Q_EXPORT QTextDocumentSelection | 661 | struct Q_EXPORT QTextDocumentSelection |
672 | { | 662 | { |
673 | QTextCursor startCursor, endCursor; | 663 | QTextCursor startCursor, endCursor; |
674 | bool swapped; | 664 | bool swapped; |
675 | }; | 665 | }; |
676 | 666 | ||
677 | #if defined(Q_TEMPLATEDLL) | 667 | #if defined(Q_TEMPLATEDLL) |
678 | // MOC_SKIP_BEGIN | 668 | // MOC_SKIP_BEGIN |
679 | template class Q_EXPORT QMap<int, QColor>; | 669 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QColor>; |
680 | template class Q_EXPORT QMap<int, bool>; | 670 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, bool>; |
681 | template class Q_EXPORT QMap<int, QTextDocumentSelection>; | 671 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextDocumentSelection>; |
682 | template class Q_EXPORT QPtrList<QTextDocument>; | 672 | Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextDocument>; |
683 | // MOC_SKIP_END | 673 | // MOC_SKIP_END |
684 | #endif | 674 | #endif |
685 | 675 | ||
686 | class Q_EXPORT QTextDocument : public QObject | 676 | class Q_EXPORT QTextDocument : public QObject |
687 | { | 677 | { |
688 | Q_OBJECT | 678 | Q_OBJECT |
689 | 679 | ||
690 | friend class QTextTableCell; | 680 | friend class QTextTableCell; |
691 | friend class QTextCursor; | 681 | friend class QTextCursor; |
692 | friend class QTextEdit; | 682 | friend class QTextEdit; |
693 | friend class QTextParag; | 683 | friend class QTextParagraph; |
694 | 684 | ||
695 | public: | 685 | public: |
696 | enum SelectionIds { | 686 | enum SelectionIds { |
697 | Standard = 0, | 687 | Standard = 0, |
698 | Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to | 688 | Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to |
699 | // remove multiple lines with removeSelectedText() | 689 | // remove multiple lines with removeSelectedText() |
700 | }; | 690 | }; |
701 | 691 | ||
702 | QTextDocument( QTextDocument *p ); | 692 | QTextDocument( QTextDocument *p ); |
703 | QTextDocument( QTextDocument *d, QTextFormatCollection *f ); | 693 | QTextDocument( QTextDocument *d, QTextFormatCollection *f ); |
704 | virtual ~QTextDocument(); | 694 | virtual ~QTextDocument(); |
705 | 695 | ||
706 | QTextDocument *parent() const { return par; } | 696 | QTextDocument *parent() const { return par; } |
707 | QTextParag *parentParag() const { return parParag; } | 697 | QTextParagraph *parentParagraph() const { return parentPar; } |
708 | 698 | ||
709 | void setText( const QString &text, const QString &context ); | 699 | void setText( const QString &text, const QString &context ); |
710 | QMap<QString, QString> attributes() const { return attribs; } | 700 | QMap<QString, QString> attributes() const { return attribs; } |
711 | void setAttributes( const QMap<QString, QString> &attr ) { attribs = attr; } | 701 | void setAttributes( const QMap<QString, QString> &attr ) { attribs = attr; } |
712 | 702 | ||
713 | QString text() const; | 703 | QString text() const; |
714 | QString text( int parag ) const; | 704 | QString text( int parag ) const; |
715 | QString originalText() const; | 705 | QString originalText() const; |
716 | 706 | ||
717 | int x() const; | 707 | int x() const; |
718 | int y() const; | 708 | int y() const; |
719 | int width() const; | 709 | int width() const; |
720 | int widthUsed() const; | 710 | int widthUsed() const; |
721 | int visibleWidth() const; | 711 | int visibleWidth() const; |
722 | int height() const; | 712 | int height() const; |
723 | void setWidth( int w ); | 713 | void setWidth( int w ); |
724 | int minimumWidth() const; | 714 | int minimumWidth() const; |
725 | bool setMinimumWidth( int needed, int used = -1, QTextParag *parag = 0 ); | 715 | bool setMinimumWidth( int needed, int used = -1, QTextParagraph *parag = 0 ); |
726 | 716 | ||
727 | void setY( int y ); | 717 | void setY( int y ); |
728 | int leftMargin() const; | 718 | int leftMargin() const; |
729 | void setLeftMargin( int lm ); | 719 | void setLeftMargin( int lm ); |
730 | int rightMargin() const; | 720 | int rightMargin() const; |
731 | void setRightMargin( int rm ); | 721 | void setRightMargin( int rm ); |
732 | 722 | ||
733 | QTextParag *firstParag() const; | 723 | QTextParagraph *firstParagraph() const; |
734 | QTextParag *lastParag() const; | 724 | QTextParagraph *lastParagraph() const; |
735 | void setFirstParag( QTextParag *p ); | 725 | void setFirstParagraph( QTextParagraph *p ); |
736 | void setLastParag( QTextParag *p ); | 726 | void setLastParagraph( QTextParagraph *p ); |
737 | 727 | ||
738 | void invalidate(); | 728 | void invalidate(); |
739 | 729 | ||
740 | void setPreProcessor( QTextPreProcessor *sh ); | 730 | void setPreProcessor( QTextPreProcessor *sh ); |
741 | QTextPreProcessor *preProcessor() const; | 731 | QTextPreProcessor *preProcessor() const; |
742 | 732 | ||
743 | void setFormatter( QTextFormatter *f ); | 733 | void setFormatter( QTextFormatter *f ); |
744 | QTextFormatter *formatter() const; | 734 | QTextFormatter *formatter() const; |
745 | 735 | ||
746 | void setIndent( QTextIndent *i ); | 736 | void setIndent( QTextIndent *i ); |
747 | QTextIndent *indent() const; | 737 | QTextIndent *indent() const; |
748 | 738 | ||
749 | QColor selectionColor( int id ) const; | 739 | QColor selectionColor( int id ) const; |
750 | bool invertSelectionText( int id ) const; | 740 | bool invertSelectionText( int id ) const; |
751 | void setSelectionColor( int id, const QColor &c ); | 741 | void setSelectionColor( int id, const QColor &c ); |
752 | void setInvertSelectionText( int id, bool b ); | 742 | void setInvertSelectionText( int id, bool b ); |
753 | bool hasSelection( int id, bool visible = FALSE ) const; | 743 | bool hasSelection( int id, bool visible = FALSE ) const; |
754 | void setSelectionStart( int id, QTextCursor *cursor ); | 744 | void setSelectionStart( int id, const QTextCursor &cursor ); |
755 | bool setSelectionEnd( int id, QTextCursor *cursor ); | 745 | bool setSelectionEnd( int id, const QTextCursor &cursor ); |
756 | void selectAll( int id ); | 746 | void selectAll( int id ); |
757 | bool removeSelection( int id ); | 747 | bool removeSelection( int id ); |
758 | void selectionStart( int id, int ¶gId, int &index ); | 748 | void selectionStart( int id, int ¶gId, int &index ); |
759 | QTextCursor selectionStartCursor( int id ); | 749 | QTextCursor selectionStartCursor( int id ); |
760 | QTextCursor selectionEndCursor( int id ); | 750 | QTextCursor selectionEndCursor( int id ); |
761 | void selectionEnd( int id, int ¶gId, int &index ); | 751 | void selectionEnd( int id, int ¶gId, int &index ); |
762 | void setFormat( int id, QTextFormat *f, int flags ); | 752 | void setFormat( int id, QTextFormat *f, int flags ); |
763 | QTextParag *selectionStart( int id ); | ||
764 | QTextParag *selectionEnd( int id ); | ||
765 | int numSelections() const { return nSelections; } | 753 | int numSelections() const { return nSelections; } |
766 | void addSelection( int id ); | 754 | void addSelection( int id ); |
767 | 755 | ||
768 | QString selectedText( int id, bool withCustom = TRUE ) const; | 756 | QString selectedText( int id, bool asRichText = FALSE ) const; |
769 | void copySelectedText( int id ); | ||
770 | void removeSelectedText( int id, QTextCursor *cursor ); | 757 | void removeSelectedText( int id, QTextCursor *cursor ); |
771 | void indentSelection( int id ); | 758 | void indentSelection( int id ); |
772 | 759 | ||
773 | QTextParag *paragAt( int i ) const; | 760 | QTextParagraph *paragAt( int i ) const; |
774 | 761 | ||
775 | void addCommand( QTextCommand *cmd ); | 762 | void addCommand( QTextCommand *cmd ); |
776 | QTextCursor *undo( QTextCursor *c = 0 ); | 763 | QTextCursor *undo( QTextCursor *c = 0 ); |
777 | QTextCursor *redo( QTextCursor *c = 0 ); | 764 | QTextCursor *redo( QTextCursor *c = 0 ); |
778 | QTextCommandHistory *commands() const { return commandHistory; } | 765 | QTextCommandHistory *commands() const { return commandHistory; } |
779 | 766 | ||
780 | QTextFormatCollection *formatCollection() const; | 767 | QTextFormatCollection *formatCollection() const; |
781 | 768 | ||
782 | bool find( const QString &expr, bool cs, bool wo, bool forward, int *parag, int *index, QTextCursor *cursor ); | 769 | bool find( QTextCursor &cursor, const QString &expr, bool cs, bool wo, bool forward); |
783 | 770 | ||
784 | void setTextFormat( Qt::TextFormat f ); | 771 | void setTextFormat( Qt::TextFormat f ); |
785 | Qt::TextFormat textFormat() const; | 772 | Qt::TextFormat textFormat() const; |
786 | 773 | ||
787 | bool inSelection( int selId, const QPoint &pos ) const; | 774 | bool inSelection( int selId, const QPoint &pos ) const; |
788 | 775 | ||
789 | QStyleSheet *styleSheet() const { return sheet_; } | 776 | QStyleSheet *styleSheet() const { return sheet_; } |
790 | QMimeSourceFactory *mimeSourceFactory() const { return factory_; } | 777 | QMimeSourceFactory *mimeSourceFactory() const { return factory_; } |
791 | QString context() const { return contxt; } | 778 | QString context() const { return contxt; } |
792 | 779 | ||
793 | void setStyleSheet( QStyleSheet *s ); | 780 | void setStyleSheet( QStyleSheet *s ); |
794 | void updateStyles(); | 781 | void setDefaultFormat( const QFont &font, const QColor &color ); |
795 | void updateFontSizes( int base, bool usePixels ); | ||
796 | void updateFontAttributes( const QFont &f, const QFont &old ); | ||
797 | void setMimeSourceFactory( QMimeSourceFactory *f ) { if ( f ) factory_ = f; } | 782 | void setMimeSourceFactory( QMimeSourceFactory *f ) { if ( f ) factory_ = f; } |
798 | void setContext( const QString &c ) { if ( !c.isEmpty() ) contxt = c; } | 783 | void setContext( const QString &c ) { if ( !c.isEmpty() ) contxt = c; } |
799 | 784 | ||
800 | void setUnderlineLinks( bool b ) { underlLinks = b; } | 785 | void setUnderlineLinks( bool b ); |
801 | bool underlineLinks() const { return underlLinks; } | 786 | bool underlineLinks() const { return underlLinks; } |
802 | 787 | ||
803 | void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; } | 788 | void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; } |
804 | QBrush *paper() const { return backBrush; } | 789 | QBrush *paper() const { return backBrush; } |
805 | 790 | ||
806 | void doLayout( QPainter *p, int w ); | 791 | void doLayout( QPainter *p, int w ); |
807 | void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 ); | 792 | void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 ); |
808 | void drawParag( QPainter *p, QTextParag *parag, int cx, int cy, int cw, int ch, | 793 | void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch, |
809 | QPixmap *&doubleBuffer, const QColorGroup &cg, | 794 | QPixmap *&doubleBuffer, const QColorGroup &cg, |
810 | bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE ); | 795 | bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE ); |
811 | QTextParag *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg, | 796 | QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg, |
812 | bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0, | 797 | bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0, |
813 | bool resetChanged = TRUE ); | 798 | bool resetChanged = TRUE ); |
814 | 799 | ||
815 | void setDefaultFont( const QFont &f ); | 800 | void registerCustomItem( QTextCustomItem *i, QTextParagraph *p ); |
816 | 801 | void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p ); | |
817 | void registerCustomItem( QTextCustomItem *i, QTextParag *p ); | ||
818 | void unregisterCustomItem( QTextCustomItem *i, QTextParag *p ); | ||
819 | 802 | ||
820 | void setFlow( QTextFlow *f ); | 803 | void setFlow( QTextFlow *f ); |
821 | void takeFlow(); | 804 | void takeFlow(); |
822 | QTextFlow *flow() const { return flow_; } | 805 | QTextFlow *flow() const { return flow_; } |
823 | bool isPageBreakEnabled() const { return pages; } | 806 | bool isPageBreakEnabled() const { return pages; } |
824 | void setPageBreakEnabled( bool b ) { pages = b; } | 807 | void setPageBreakEnabled( bool b ) { pages = b; } |
825 | 808 | ||
826 | void setUseFormatCollection( bool b ) { useFC = b; } | 809 | void setUseFormatCollection( bool b ) { useFC = b; } |
827 | bool useFormatCollection() const { return useFC; } | 810 | bool useFormatCollection() const { return useFC; } |
828 | 811 | ||
829 | QTextTableCell *tableCell() const { return tc; } | 812 | QTextTableCell *tableCell() const { return tc; } |
830 | void setTableCell( QTextTableCell *c ) { tc = c; } | 813 | void setTableCell( QTextTableCell *c ) { tc = c; } |
831 | 814 | ||
832 | void setPlainText( const QString &text ); | 815 | void setPlainText( const QString &text ); |
833 | void setRichText( const QString &text, const QString &context ); | 816 | void setRichText( const QString &text, const QString &context ); |
834 | QString richText( QTextParag *p = 0 ) const; | 817 | QString richText() const; |
835 | QString plainText( QTextParag *p = 0 ) const; | 818 | QString plainText() const; |
836 | 819 | ||
837 | bool focusNextPrevChild( bool next ); | 820 | bool focusNextPrevChild( bool next ); |
838 | 821 | ||
839 | int alignment() const; | 822 | int alignment() const; |
840 | void setAlignment( int a ); | 823 | void setAlignment( int a ); |
841 | 824 | ||
842 | int *tabArray() const; | 825 | int *tabArray() const; |
843 | int tabStopWidth() const; | 826 | int tabStopWidth() const; |
844 | void setTabArray( int *a ); | 827 | void setTabArray( int *a ); |
845 | void setTabStops( int tw ); | 828 | void setTabStops( int tw ); |
846 | 829 | ||
847 | void setUndoDepth( int d ) { commandHistory->setUndoDepth( d ); } | 830 | void setUndoDepth( int d ) { commandHistory->setUndoDepth( d ); } |
848 | int undoDepth() const { return commandHistory->undoDepth(); } | 831 | int undoDepth() const { return commandHistory->undoDepth(); } |
849 | 832 | ||
850 | int length() const; | 833 | int length() const; |
851 | void clear( bool createEmptyParag = FALSE ); | 834 | void clear( bool createEmptyParag = FALSE ); |
852 | 835 | ||
853 | virtual QTextParag *createParag( QTextDocument *d, QTextParag *pr = 0, QTextParag *nx = 0, bool updateIds = TRUE ); | 836 | virtual QTextParagraph *createParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE ); |
854 | void insertChild( QObject *o ) { QObject::insertChild( o ); } | 837 | void insertChild( QObject *o ) { QObject::insertChild( o ); } |
855 | void removeChild( QObject *o ) { QObject::removeChild( o ); } | 838 | void removeChild( QObject *o ) { QObject::removeChild( o ); } |
856 | void insertChild( QTextDocument *d ) { childList.append( d ); } | 839 | void insertChild( QTextDocument *d ) { childList.append( d ); } |
857 | void removeChild( QTextDocument *d ) { childList.removeRef( d ); } | 840 | void removeChild( QTextDocument *d ) { childList.removeRef( d ); } |
858 | QPtrList<QTextDocument> children() const { return childList; } | 841 | QPtrList<QTextDocument> children() const { return childList; } |
859 | 842 | ||
860 | void setAddMargins( bool b ) { addMargs = b; } | ||
861 | int addMargins() const { return addMargs; } | ||
862 | |||
863 | bool hasFocusParagraph() const; | 843 | bool hasFocusParagraph() const; |
864 | QString focusHref() const; | 844 | QString focusHref() const; |
865 | 845 | ||
866 | void invalidateOriginalText() { oTextValid = FALSE; oText = ""; } | 846 | void invalidateOriginalText() { oTextValid = FALSE; oText = ""; } |
867 | 847 | ||
848 | static QString section( QString str, const QString &sep, int start, int end = 0xffffffff ); | ||
849 | static bool endsWith( QString str, const QString &s); | ||
850 | |||
868 | signals: | 851 | signals: |
869 | void minimumWidthChanged( int ); | 852 | void minimumWidthChanged( int ); |
870 | 853 | ||
871 | private: | 854 | private: |
872 | void init(); | 855 | void init(); |
873 | QPixmap *bufferPixmap( const QSize &s ); | 856 | QPixmap *bufferPixmap( const QSize &s ); |
874 | // HTML parser | 857 | // HTML parser |
875 | bool hasPrefix(const QChar* doc, int length, int pos, QChar c); | 858 | bool hasPrefix(const QChar* doc, int length, int pos, QChar c); |
876 | bool hasPrefix(const QChar* doc, int length, int pos, const QString& s); | 859 | bool hasPrefix(const QChar* doc, int length, int pos, const QString& s); |
877 | QTextCustomItem* parseTable( const QMap<QString, QString> &attr, const QTextFormat &fmt, | 860 | QTextCustomItem* parseTable( const QMap<QString, QString> &attr, const QTextFormat &fmt, |
878 | const QChar* doc, int length, int& pos, QTextParag *curpar ); | 861 | const QChar* doc, int length, int& pos, QTextParagraph *curpar ); |
879 | bool eatSpace(const QChar* doc, int length, int& pos, bool includeNbsp = FALSE ); | 862 | bool eatSpace(const QChar* doc, int length, int& pos, bool includeNbsp = FALSE ); |
880 | bool eat(const QChar* doc, int length, int& pos, QChar c); | 863 | bool eat(const QChar* doc, int length, int& pos, QChar c); |
881 | QString parseOpenTag(const QChar* doc, int length, int& pos, QMap<QString, QString> &attr, bool& emptyTag); | 864 | QString parseOpenTag(const QChar* doc, int length, int& pos, QMap<QString, QString> &attr, bool& emptyTag); |
882 | QString parseCloseTag( const QChar* doc, int length, int& pos ); | 865 | QString parseCloseTag( const QChar* doc, int length, int& pos ); |
883 | QChar parseHTMLSpecialChar(const QChar* doc, int length, int& pos); | 866 | QChar parseHTMLSpecialChar(const QChar* doc, int length, int& pos); |
884 | QString parseWord(const QChar* doc, int length, int& pos, bool lower = TRUE); | 867 | QString parseWord(const QChar* doc, int length, int& pos, bool lower = TRUE); |
885 | QChar parseChar(const QChar* doc, int length, int& pos, QStyleSheetItem::WhiteSpaceMode wsm ); | 868 | QChar parseChar(const QChar* doc, int length, int& pos, QStyleSheetItem::WhiteSpaceMode wsm ); |
886 | void setRichTextInternal( const QString &text ); | 869 | void setRichTextInternal( const QString &text, QTextCursor* cursor = 0 ); |
870 | void setRichTextMarginsInternal( QPtrList< QPtrVector<QStyleSheetItem> >& styles, QTextParagraph* stylesPar ); | ||
887 | 871 | ||
888 | private: | 872 | private: |
889 | struct Q_EXPORT Focus { | 873 | struct Q_EXPORT Focus { |
890 | QTextParag *parag; | 874 | QTextParagraph *parag; |
891 | int start, len; | 875 | int start, len; |
892 | QString href; | 876 | QString href; |
893 | }; | 877 | }; |
894 | 878 | ||
895 | int cx, cy, cw, vw; | 879 | int cx, cy, cw, vw; |
896 | QTextParag *fParag, *lParag; | 880 | QTextParagraph *fParag, *lParag; |
897 | QTextPreProcessor *pProcessor; | 881 | QTextPreProcessor *pProcessor; |
898 | QMap<int, QColor> selectionColors; | 882 | QMap<int, QColor> selectionColors; |
899 | QMap<int, QTextDocumentSelection> selections; | 883 | QMap<int, QTextDocumentSelection> selections; |
900 | QMap<int, bool> selectionText; | 884 | QMap<int, bool> selectionText; |
901 | QTextCommandHistory *commandHistory; | 885 | QTextCommandHistory *commandHistory; |
902 | QTextFormatter *pFormatter; | 886 | QTextFormatter *pFormatter; |
903 | QTextIndent *indenter; | 887 | QTextIndent *indenter; |
904 | QTextFormatCollection *fCollection; | 888 | QTextFormatCollection *fCollection; |
905 | Qt::TextFormat txtFormat; | 889 | Qt::TextFormat txtFormat; |
906 | uint preferRichText : 1; | 890 | uint preferRichText : 1; |
907 | uint pages : 1; | 891 | uint pages : 1; |
908 | uint useFC : 1; | 892 | uint useFC : 1; |
909 | uint withoutDoubleBuffer : 1; | 893 | uint withoutDoubleBuffer : 1; |
910 | uint underlLinks : 1; | 894 | uint underlLinks : 1; |
911 | uint nextDoubleBuffered : 1; | 895 | uint nextDoubleBuffered : 1; |
912 | uint addMargs : 1; | ||
913 | uint oTextValid : 1; | 896 | uint oTextValid : 1; |
914 | uint mightHaveCustomItems : 1; | 897 | uint mightHaveCustomItems : 1; |
915 | int align; | 898 | int align; |
916 | int nSelections; | 899 | int nSelections; |
917 | QTextFlow *flow_; | 900 | QTextFlow *flow_; |
918 | QTextDocument *par; | 901 | QTextDocument *par; |
919 | QTextParag *parParag; | 902 | QTextParagraph *parentPar; |
920 | QTextTableCell *tc; | 903 | QTextTableCell *tc; |
921 | QTextCursor *tmpCursor; | ||
922 | QBrush *backBrush; | 904 | QBrush *backBrush; |
923 | QPixmap *buf_pixmap; | 905 | QPixmap *buf_pixmap; |
924 | Focus focusIndicator; | 906 | Focus focusIndicator; |
925 | int minw; | 907 | int minw; |
926 | int wused; | 908 | int wused; |
927 | int leftmargin; | 909 | int leftmargin; |
928 | int rightmargin; | 910 | int rightmargin; |
929 | QTextParag *minwParag, *curParag; | 911 | QTextParagraph *minwParag, *curParag; |
930 | QStyleSheet* sheet_; | 912 | QStyleSheet* sheet_; |
931 | QMimeSourceFactory* factory_; | 913 | QMimeSourceFactory* factory_; |
932 | QString contxt; | 914 | QString contxt; |
933 | QMap<QString, QString> attribs; | 915 | QMap<QString, QString> attribs; |
934 | int *tArray; | 916 | int *tArray; |
935 | int tStopWidth; | 917 | int tStopWidth; |
936 | int uDepth; | 918 | int uDepth; |
937 | QString oText; | 919 | QString oText; |
938 | QPtrList<QTextDocument> childList; | 920 | QPtrList<QTextDocument> childList; |
939 | QColor linkColor; | 921 | QColor linkColor; |
922 | double scaleFontsFactor; | ||
940 | 923 | ||
924 | short list_tm,list_bm, list_lm, li_tm, li_bm, par_tm, par_bm; | ||
941 | }; | 925 | }; |
942 | 926 | ||
943 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 927 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
944 | 928 | ||
945 | 929 | ||
946 | class Q_EXPORT QTextDeleteCommand : public QTextCommand | 930 | class Q_EXPORT QTextDeleteCommand : public QTextCommand |
947 | { | 931 | { |
948 | public: | 932 | public: |
949 | QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, | 933 | QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, |
950 | const QValueList< QPtrVector<QStyleSheetItem> > &os, | 934 | const QByteArray& oldStyle ); |
951 | const QValueList<QStyleSheetItem::ListStyle> &ols, | 935 | QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ); |
952 | const QMemArray<int> &oas ); | ||
953 | QTextDeleteCommand( QTextParag *p, int idx, const QMemArray<QTextStringChar> &str ); | ||
954 | virtual ~QTextDeleteCommand(); | 936 | virtual ~QTextDeleteCommand(); |
955 | 937 | ||
956 | Commands type() const { return Delete; } | 938 | Commands type() const { return Delete; } |
957 | QTextCursor *execute( QTextCursor *c ); | 939 | QTextCursor *execute( QTextCursor *c ); |
958 | QTextCursor *unexecute( QTextCursor *c ); | 940 | QTextCursor *unexecute( QTextCursor *c ); |
959 | 941 | ||
960 | protected: | 942 | protected: |
961 | int id, index; | 943 | int id, index; |
962 | QTextParag *parag; | 944 | QTextParagraph *parag; |
963 | QMemArray<QTextStringChar> text; | 945 | QMemArray<QTextStringChar> text; |
964 | QValueList< QPtrVector<QStyleSheetItem> > oldStyles; | 946 | QByteArray styleInformation; |
965 | QValueList<QStyleSheetItem::ListStyle> oldListStyles; | ||
966 | QMemArray<int> oldAligns; | ||
967 | 947 | ||
968 | }; | 948 | }; |
969 | 949 | ||
970 | class Q_EXPORT QTextInsertCommand : public QTextDeleteCommand | 950 | class Q_EXPORT QTextInsertCommand : public QTextDeleteCommand |
971 | { | 951 | { |
972 | public: | 952 | public: |
973 | QTextInsertCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, | 953 | QTextInsertCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, |
974 | const QValueList< QPtrVector<QStyleSheetItem> > &os, | 954 | const QByteArray& oldStyleInfo ) |
975 | const QValueList<QStyleSheetItem::ListStyle> &ols, | 955 | : QTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {} |
976 | const QMemArray<int> &oas ) | 956 | QTextInsertCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ) |
977 | : QTextDeleteCommand( d, i, idx, str, os, ols, oas ) {} | ||
978 | QTextInsertCommand( QTextParag *p, int idx, const QMemArray<QTextStringChar> &str ) | ||
979 | : QTextDeleteCommand( p, idx, str ) {} | 957 | : QTextDeleteCommand( p, idx, str ) {} |
980 | virtual ~QTextInsertCommand() {} | 958 | virtual ~QTextInsertCommand() {} |
981 | 959 | ||
982 | Commands type() const { return Insert; } | 960 | Commands type() const { return Insert; } |
983 | QTextCursor *execute( QTextCursor *c ) { return QTextDeleteCommand::unexecute( c ); } | 961 | QTextCursor *execute( QTextCursor *c ) { return QTextDeleteCommand::unexecute( c ); } |
984 | QTextCursor *unexecute( QTextCursor *c ) { return QTextDeleteCommand::execute( c ); } | 962 | QTextCursor *unexecute( QTextCursor *c ) { return QTextDeleteCommand::execute( c ); } |
985 | 963 | ||
986 | }; | 964 | }; |
987 | 965 | ||
988 | class Q_EXPORT QTextFormatCommand : public QTextCommand | 966 | class Q_EXPORT QTextFormatCommand : public QTextCommand |
989 | { | 967 | { |
990 | public: | 968 | public: |
991 | QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl ); | 969 | QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl ); |
992 | virtual ~QTextFormatCommand(); | 970 | virtual ~QTextFormatCommand(); |
993 | 971 | ||
994 | Commands type() const { return Format; } | 972 | Commands type() const { return Format; } |
995 | QTextCursor *execute( QTextCursor *c ); | 973 | QTextCursor *execute( QTextCursor *c ); |
996 | QTextCursor *unexecute( QTextCursor *c ); | 974 | QTextCursor *unexecute( QTextCursor *c ); |
997 | 975 | ||
998 | protected: | 976 | protected: |
999 | int startId, startIndex, endId, endIndex; | 977 | int startId, startIndex, endId, endIndex; |
1000 | QTextFormat *format; | 978 | QTextFormat *format; |
1001 | QMemArray<QTextStringChar> oldFormats; | 979 | QMemArray<QTextStringChar> oldFormats; |
1002 | int flags; | 980 | int flags; |
1003 | 981 | ||
1004 | }; | 982 | }; |
1005 | 983 | ||
1006 | class Q_EXPORT QTextAlignmentCommand : public QTextCommand | 984 | class Q_EXPORT QTextStyleCommand : public QTextCommand |
1007 | { | 985 | { |
1008 | public: | 986 | public: |
1009 | QTextAlignmentCommand( QTextDocument *d, int fParag, int lParag, int na, const QMemArray<int> &oa ); | 987 | QTextStyleCommand( QTextDocument *d, int fParag, int lParag, const QByteArray& beforeChange ); |
1010 | virtual ~QTextAlignmentCommand() {} | 988 | virtual ~QTextStyleCommand() {} |
1011 | 989 | ||
1012 | Commands type() const { return Alignment; } | 990 | Commands type() const { return Style; } |
1013 | QTextCursor *execute( QTextCursor *c ); | 991 | QTextCursor *execute( QTextCursor *c ); |
1014 | QTextCursor *unexecute( QTextCursor *c ); | 992 | QTextCursor *unexecute( QTextCursor *c ); |
1015 | 993 | ||
1016 | private: | 994 | static QByteArray readStyleInformation( QTextDocument* d, int fParag, int lParag ); |
1017 | int firstParag, lastParag; | 995 | static void writeStyleInformation( QTextDocument* d, int fParag, const QByteArray& style ); |
1018 | int newAlign; | ||
1019 | QMemArray<int> oldAligns; | ||
1020 | |||
1021 | }; | ||
1022 | |||
1023 | class Q_EXPORT QTextParagTypeCommand : public QTextCommand | ||
1024 | { | ||
1025 | public: | ||
1026 | QTextParagTypeCommand( QTextDocument *d, int fParag, int lParag, bool l, | ||
1027 | QStyleSheetItem::ListStyle s, const QValueList< QPtrVector<QStyleSheetItem> > &os, | ||
1028 | const QValueList<QStyleSheetItem::ListStyle> &ols ); | ||
1029 | virtual ~QTextParagTypeCommand() {} | ||
1030 | |||
1031 | Commands type() const { return ParagType; } | ||
1032 | QTextCursor *execute( QTextCursor *c ); | ||
1033 | QTextCursor *unexecute( QTextCursor *c ); | ||
1034 | 996 | ||
1035 | private: | 997 | private: |
1036 | int firstParag, lastParag; | 998 | int firstParag, lastParag; |
1037 | bool list; | 999 | QByteArray before; |
1038 | QStyleSheetItem::ListStyle listStyle; | 1000 | QByteArray after; |
1039 | QValueList< QPtrVector<QStyleSheetItem> > oldStyles; | ||
1040 | QValueList<QStyleSheetItem::ListStyle> oldListStyles; | ||
1041 | |||
1042 | }; | 1001 | }; |
1043 | 1002 | ||
1044 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1003 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1045 | 1004 | ||
1046 | struct Q_EXPORT QTextParagSelection | 1005 | struct Q_EXPORT QTextParagraphSelection |
1047 | { | 1006 | { |
1048 | int start, end; | 1007 | int start, end; |
1049 | }; | 1008 | }; |
1050 | 1009 | ||
1051 | struct Q_EXPORT QTextParagLineStart | 1010 | struct Q_EXPORT QTextLineStart |
1052 | { | 1011 | { |
1053 | QTextParagLineStart() : y( 0 ), baseLine( 0 ), h( 0 ) | 1012 | QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 ) |
1054 | #ifndef QT_NO_COMPLEXTEXT | 1013 | #ifndef QT_NO_COMPLEXTEXT |
1055 | , bidicontext( 0 ) | 1014 | , bidicontext( 0 ) |
1056 | #endif | 1015 | #endif |
1057 | { } | 1016 | { } |
1058 | QTextParagLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ), | 1017 | QTextLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ), |
1059 | w( 0 ) | 1018 | w( 0 ) |
1060 | #ifndef QT_NO_COMPLEXTEXT | 1019 | #ifndef QT_NO_COMPLEXTEXT |
1061 | , bidicontext( 0 ) | 1020 | , bidicontext( 0 ) |
1062 | #endif | 1021 | #endif |
1063 | { } | 1022 | { } |
1064 | #ifndef QT_NO_COMPLEXTEXT | 1023 | #ifndef QT_NO_COMPLEXTEXT |
1065 | QTextParagLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0), | 1024 | QTextLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0), |
1066 | status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); } | 1025 | status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); } |
1067 | #endif | 1026 | #endif |
1068 | 1027 | ||
1069 | virtual ~QTextParagLineStart() | 1028 | virtual ~QTextLineStart() |
1070 | { | 1029 | { |
1071 | #ifndef QT_NO_COMPLEXTEXT | 1030 | #ifndef QT_NO_COMPLEXTEXT |
1072 | if ( bidicontext && bidicontext->deref() ) | 1031 | if ( bidicontext && bidicontext->deref() ) |
1073 | delete bidicontext; | 1032 | delete bidicontext; |
1074 | #endif | 1033 | #endif |
1075 | } | 1034 | } |
1076 | 1035 | ||
1077 | #ifndef QT_NO_COMPLEXTEXT | 1036 | #ifndef QT_NO_COMPLEXTEXT |
1078 | void setContext( QBidiContext *c ) { | 1037 | void setContext( QBidiContext *c ) { |
1079 | if ( c == bidicontext ) | 1038 | if ( c == bidicontext ) |
1080 | return; | 1039 | return; |
1081 | if ( bidicontext && bidicontext->deref() ) | 1040 | if ( bidicontext && bidicontext->deref() ) |
1082 | delete bidicontext; | 1041 | delete bidicontext; |
1083 | bidicontext = c; | 1042 | bidicontext = c; |
1084 | if ( bidicontext ) | 1043 | if ( bidicontext ) |
1085 | bidicontext->ref(); | 1044 | bidicontext->ref(); |
1086 | } | 1045 | } |
1087 | QBidiContext *context() const { return bidicontext; } | 1046 | QBidiContext *context() const { return bidicontext; } |
1088 | #endif | 1047 | #endif |
1089 | 1048 | ||
1090 | public: | 1049 | public: |
1091 | ushort y, baseLine, h; | 1050 | ushort y, baseLine, h; |
1092 | #ifndef QT_NO_COMPLEXTEXT | 1051 | #ifndef QT_NO_COMPLEXTEXT |
1093 | QBidiStatus status; | 1052 | QBidiStatus status; |
1094 | #endif | 1053 | #endif |
1095 | int w; | 1054 | int w; |
1096 | 1055 | ||
1097 | private: | 1056 | private: |
1098 | #ifndef QT_NO_COMPLEXTEXT | 1057 | #ifndef QT_NO_COMPLEXTEXT |
1099 | QBidiContext *bidicontext; | 1058 | QBidiContext *bidicontext; |
1100 | #endif | 1059 | #endif |
1101 | }; | 1060 | }; |
1102 | 1061 | ||
1103 | #if defined(Q_TEMPLATEDLL) | 1062 | #if defined(Q_TEMPLATEDLL) |
1104 | // MOC_SKIP_BEGIN | 1063 | // MOC_SKIP_BEGIN |
1105 | template class Q_EXPORT QMap<int, QTextParagSelection>; | 1064 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextParagraphSelection>; |
1106 | template class Q_EXPORT QMap<int, QTextParagLineStart*>; | 1065 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextLineStart*>; |
1107 | // MOC_SKIP_END | 1066 | // MOC_SKIP_END |
1108 | #endif | 1067 | #endif |
1109 | 1068 | ||
1110 | class Q_EXPORT QTextParagData | 1069 | class Q_EXPORT QTextParagraphData |
1111 | { | 1070 | { |
1112 | public: | 1071 | public: |
1113 | QTextParagData() {} | 1072 | QTextParagraphData() {} |
1114 | virtual ~QTextParagData(); | 1073 | virtual ~QTextParagraphData(); |
1115 | virtual void join( QTextParagData * ); | 1074 | virtual void join( QTextParagraphData * ); |
1116 | }; | 1075 | }; |
1117 | 1076 | ||
1118 | class Q_EXPORT QTextParagPseudoDocument | 1077 | class Q_EXPORT QTextParagraphPseudoDocument |
1119 | { | 1078 | { |
1120 | public: | 1079 | public: |
1121 | QTextParagPseudoDocument(); | 1080 | QTextParagraphPseudoDocument(); |
1122 | ~QTextParagPseudoDocument(); | 1081 | ~QTextParagraphPseudoDocument(); |
1123 | QRect docRect; | 1082 | QRect docRect; |
1124 | QTextFormatter *pFormatter; | 1083 | QTextFormatter *pFormatter; |
1125 | QTextCommandHistory *commandHistory; | 1084 | QTextCommandHistory *commandHistory; |
1126 | int minw; | 1085 | int minw; |
1127 | int wused; | 1086 | int wused; |
1128 | }; | 1087 | }; |
1129 | 1088 | ||
1130 | //nase | 1089 | //nase |
1131 | class Q_EXPORT QTextParag | 1090 | class Q_EXPORT QTextParagraph |
1132 | { | 1091 | { |
1133 | friend class QTextDocument; | 1092 | friend class QTextDocument; |
1134 | friend class QTextCursor; | 1093 | friend class QTextCursor; |
1135 | 1094 | ||
1136 | public: | 1095 | public: |
1137 | QTextParag( QTextDocument *d, QTextParag *pr = 0, QTextParag *nx = 0, bool updateIds = TRUE ); | 1096 | QTextParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE ); |
1138 | virtual ~QTextParag(); | 1097 | virtual ~QTextParagraph(); |
1139 | 1098 | ||
1140 | QTextString *string() const; | 1099 | QTextString *string() const; |
1141 | QTextStringChar *at( int i ) const; // maybe remove later | 1100 | QTextStringChar *at( int i ) const; // maybe remove later |
1142 | int leftGap() const; | 1101 | int leftGap() const; |
1143 | int length() const; // maybe remove later | 1102 | int length() const; // maybe remove later |
1144 | 1103 | ||
1145 | void setListStyle( QStyleSheetItem::ListStyle ls ); | 1104 | void setListStyle( QStyleSheetItem::ListStyle ls ) { lstyle = ls; changed = TRUE; } |
1146 | QStyleSheetItem::ListStyle listStyle() const; | 1105 | QStyleSheetItem::ListStyle listStyle() const { return lstyle; } |
1106 | void setListItem( bool li ) { litem = li; changed = TRUE; } | ||
1107 | bool isListItem() const { return litem; } | ||
1147 | void setListValue( int v ) { list_val = v; } | 1108 | void setListValue( int v ) { list_val = v; } |
1148 | int listValue() const { return list_val; } | 1109 | int listValue() const { return list_val > 0 ? list_val : -1; } |
1149 | 1110 | ||
1150 | void setList( bool b, int listStyle ); | 1111 | void setListDepth( int depth ); |
1151 | void incDepth(); | 1112 | int listDepth() const { return ldepth; } |
1152 | void decDepth(); | ||
1153 | int listDepth() const; | ||
1154 | 1113 | ||
1155 | void setFormat( QTextFormat *fm ); | 1114 | // void setFormat( QTextFormat *fm ); |
1156 | QTextFormat *paragFormat() const; | 1115 | // QTextFormat *paragFormat() const; |
1157 | 1116 | ||
1158 | QTextDocument *document() const; | 1117 | QTextDocument *document() const; |
1159 | QTextParagPseudoDocument *pseudoDocument() const; | 1118 | QTextParagraphPseudoDocument *pseudoDocument() const; |
1160 | 1119 | ||
1161 | QRect rect() const; | 1120 | QRect rect() const; |
1162 | void setHeight( int h ) { r.setHeight( h ); } | 1121 | void setHeight( int h ) { r.setHeight( h ); } |
1163 | void show(); | 1122 | void show(); |
1164 | void hide(); | 1123 | void hide(); |
1165 | bool isVisible() const { return visible; } | 1124 | bool isVisible() const { return visible; } |
1166 | 1125 | ||
1167 | QTextParag *prev() const; | 1126 | QTextParagraph *prev() const; |
1168 | QTextParag *next() const; | 1127 | QTextParagraph *next() const; |
1169 | void setPrev( QTextParag *s ); | 1128 | void setPrev( QTextParagraph *s ); |
1170 | void setNext( QTextParag *s ); | 1129 | void setNext( QTextParagraph *s ); |
1171 | 1130 | ||
1172 | void insert( int index, const QString &s ); | 1131 | void insert( int index, const QString &s ); |
1132 | void insert( int index, const QChar *unicode, int len ); | ||
1173 | void append( const QString &s, bool reallyAtEnd = FALSE ); | 1133 | void append( const QString &s, bool reallyAtEnd = FALSE ); |
1174 | void truncate( int index ); | 1134 | void truncate( int index ); |
1175 | void remove( int index, int len ); | 1135 | void remove( int index, int len ); |
1176 | void join( QTextParag *s ); | 1136 | void join( QTextParagraph *s ); |
1177 | 1137 | ||
1178 | void invalidate( int chr ); | 1138 | void invalidate( int chr ); |
1179 | 1139 | ||
1180 | void move( int &dy ); | 1140 | void move( int &dy ); |
1181 | void format( int start = -1, bool doMove = TRUE ); | 1141 | void format( int start = -1, bool doMove = TRUE ); |
1182 | 1142 | ||
1183 | bool isValid() const; | 1143 | bool isValid() const; |
1184 | bool hasChanged() const; | 1144 | bool hasChanged() const; |
1185 | void setChanged( bool b, bool recursive = FALSE ); | 1145 | void setChanged( bool b, bool recursive = FALSE ); |
1186 | 1146 | ||
1187 | int lineHeightOfChar( int i, int *bl = 0, int *y = 0 ) const; | 1147 | int lineHeightOfChar( int i, int *bl = 0, int *y = 0 ) const; |
1188 | QTextStringChar *lineStartOfChar( int i, int *index = 0, int *line = 0 ) const; | 1148 | QTextStringChar *lineStartOfChar( int i, int *index = 0, int *line = 0 ) const; |
1189 | int lines() const; | 1149 | int lines() const; |
1190 | QTextStringChar *lineStartOfLine( int line, int *index = 0 ) const; | 1150 | QTextStringChar *lineStartOfLine( int line, int *index = 0 ) const; |
1191 | int lineY( int l ) const; | 1151 | int lineY( int l ) const; |
1192 | int lineBaseLine( int l ) const; | 1152 | int lineBaseLine( int l ) const; |
1193 | int lineHeight( int l ) const; | 1153 | int lineHeight( int l ) const; |
1194 | void lineInfo( int l, int &y, int &h, int &bl ) const; | 1154 | void lineInfo( int l, int &y, int &h, int &bl ) const; |
1195 | 1155 | ||
1196 | void setSelection( int id, int start, int end ); | 1156 | void setSelection( int id, int start, int end ); |
1197 | void removeSelection( int id ); | 1157 | void removeSelection( int id ); |
1198 | int selectionStart( int id ) const; | 1158 | int selectionStart( int id ) const; |
1199 | int selectionEnd( int id ) const; | 1159 | int selectionEnd( int id ) const; |
1200 | bool hasSelection( int id ) const; | 1160 | bool hasSelection( int id ) const; |
1201 | bool hasAnySelection() const; | 1161 | bool hasAnySelection() const; |
1202 | bool fullSelected( int id ) const; | 1162 | bool fullSelected( int id ) const; |
1203 | 1163 | ||
1204 | void setEndState( int s ); | 1164 | void setEndState( int s ); |
1205 | int endState() const; | 1165 | int endState() const; |
1206 | 1166 | ||
1207 | void setParagId( int i ); | 1167 | void setParagId( int i ); |
1208 | int paragId() const; | 1168 | int paragId() const; |
1209 | 1169 | ||
1210 | bool firstPreProcess() const; | 1170 | bool firstPreProcess() const; |
1211 | void setFirstPreProcess( bool b ); | 1171 | void setFirstPreProcess( bool b ); |
1212 | 1172 | ||
1213 | void indent( int *oldIndent = 0, int *newIndent = 0 ); | 1173 | void indent( int *oldIndent = 0, int *newIndent = 0 ); |
1214 | 1174 | ||
1215 | void setExtraData( QTextParagData *data ); | 1175 | void setExtraData( QTextParagraphData *data ); |
1216 | QTextParagData *extraData() const; | 1176 | QTextParagraphData *extraData() const; |
1217 | 1177 | ||
1218 | QMap<int, QTextParagLineStart*> &lineStartList(); | 1178 | QMap<int, QTextLineStart*> &lineStartList(); |
1219 | 1179 | ||
1220 | void setFormat( int index, int len, QTextFormat *f, bool useCollection = TRUE, int flags = -1 ); | 1180 | void setFormat( int index, int len, QTextFormat *f, bool useCollection = TRUE, int flags = -1 ); |
1221 | 1181 | ||
1222 | void setAlignment( int a ); | 1182 | void setAlignment( int a ); |
1223 | int alignment() const; | 1183 | int alignment() const; |
1224 | 1184 | ||
1225 | virtual void paint( QPainter &painter, const QColorGroup &cg, QTextCursor *cursor = 0, bool drawSelections = FALSE, | 1185 | virtual void paint( QPainter &painter, const QColorGroup &cg, QTextCursor *cursor = 0, bool drawSelections = FALSE, |
1226 | int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 ); | 1186 | int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 ); |
1227 | 1187 | ||
1228 | void setStyleSheetItems( const QPtrVector<QStyleSheetItem> &vec ); | ||
1229 | QPtrVector<QStyleSheetItem> styleSheetItems() const; | ||
1230 | QStyleSheetItem *style() const; | ||
1231 | |||
1232 | virtual int topMargin() const; | 1188 | virtual int topMargin() const; |
1233 | virtual int bottomMargin() const; | 1189 | virtual int bottomMargin() const; |
1234 | virtual int leftMargin() const; | 1190 | virtual int leftMargin() const; |
1235 | virtual int firstLineMargin() const; | 1191 | virtual int firstLineMargin() const; |
1236 | virtual int rightMargin() const; | 1192 | virtual int rightMargin() const; |
1237 | virtual int lineSpacing() const; | 1193 | virtual int lineSpacing() const; |
1238 | 1194 | ||
1239 | int numberOfSubParagraph() const; | ||
1240 | void registerFloatingItem( QTextCustomItem *i ); | 1195 | void registerFloatingItem( QTextCustomItem *i ); |
1241 | void unregisterFloatingItem( QTextCustomItem *i ); | 1196 | void unregisterFloatingItem( QTextCustomItem *i ); |
1242 | 1197 | ||
1243 | void setFullWidth( bool b ) { fullWidth = b; } | 1198 | void setFullWidth( bool b ) { fullWidth = b; } |
1244 | bool isFullWidth() const { return fullWidth; } | 1199 | bool isFullWidth() const { return fullWidth; } |
1245 | 1200 | ||
1246 | QTextTableCell *tableCell() const; | 1201 | QTextTableCell *tableCell() const; |
1247 | 1202 | ||
1248 | QBrush *background() const; | 1203 | QBrush *background() const; |
1249 | 1204 | ||
1250 | int documentWidth() const; | 1205 | int documentWidth() const; |
1251 | int documentVisibleWidth() const; | 1206 | int documentVisibleWidth() const; |
1252 | int documentX() const; | 1207 | int documentX() const; |
1253 | int documentY() const; | 1208 | int documentY() const; |
1254 | QTextFormatCollection *formatCollection() const; | 1209 | QTextFormatCollection *formatCollection() const; |
1255 | QTextFormatter *formatter() const; | 1210 | QTextFormatter *formatter() const; |
1256 | 1211 | ||
1257 | virtual int nextTab( int i, int x ); | 1212 | virtual int nextTab( int i, int x ); |
1258 | int *tabArray() const; | 1213 | int *tabArray() const; |
1259 | void setTabArray( int *a ); | 1214 | void setTabArray( int *a ); |
1260 | void setTabStops( int tw ); | 1215 | void setTabStops( int tw ); |
1261 | 1216 | ||
1262 | void adjustToPainter( QPainter *p ); | 1217 | void adjustToPainter( QPainter *p ); |
1263 | 1218 | ||
1264 | void setNewLinesAllowed( bool b ); | 1219 | void setNewLinesAllowed( bool b ); |
1265 | bool isNewLinesAllowed() const; | 1220 | bool isNewLinesAllowed() const; |
1266 | 1221 | ||
1267 | QString richText() const; | 1222 | QString richText() const; |
1268 | 1223 | ||
1269 | void addCommand( QTextCommand *cmd ); | 1224 | void addCommand( QTextCommand *cmd ); |
1270 | QTextCursor *undo( QTextCursor *c = 0 ); | 1225 | QTextCursor *undo( QTextCursor *c = 0 ); |
1271 | QTextCursor *redo( QTextCursor *c = 0 ); | 1226 | QTextCursor *redo( QTextCursor *c = 0 ); |
1272 | QTextCommandHistory *commands() const; | 1227 | QTextCommandHistory *commands() const; |
1273 | virtual void copyParagData( QTextParag *parag ); | 1228 | virtual void copyParagData( QTextParagraph *parag ); |
1274 | 1229 | ||
1275 | void setBreakable( bool b ) { breakable = b; } | 1230 | void setBreakable( bool b ) { breakable = b; } |
1276 | bool isBreakable() const { return breakable; } | 1231 | bool isBreakable() const { return breakable; } |
1277 | 1232 | ||
1278 | void setBackgroundColor( const QColor &c ); | 1233 | void setBackgroundColor( const QColor &c ); |
1279 | QColor *backgroundColor() const { return bgcol; } | 1234 | QColor *backgroundColor() const { return bgcol; } |
1280 | void clearBackgroundColor(); | 1235 | void clearBackgroundColor(); |
1281 | 1236 | ||
1282 | bool isLineBreak() const { return isBr; } | ||
1283 | |||
1284 | void setMovedDown( bool b ) { movedDown = b; } | 1237 | void setMovedDown( bool b ) { movedDown = b; } |
1285 | bool wasMovedDown() const { return movedDown; } | 1238 | bool wasMovedDown() const { return movedDown; } |
1286 | 1239 | ||
1287 | void setDirection( QChar::Direction d ); | 1240 | void setDirection( QChar::Direction d ); |
1288 | QChar::Direction direction() const; | 1241 | QChar::Direction direction() const; |
1289 | 1242 | ||
1243 | void readStyleInformation( QDataStream& stream ); | ||
1244 | void writeStyleInformation( QDataStream& stream ) const; | ||
1245 | |||
1290 | protected: | 1246 | protected: |
1291 | virtual void drawLabel( QPainter* p, int x, int y, int w, int h, int base, const QColorGroup& cg ); | 1247 | virtual void drawLabel( QPainter* p, int x, int y, int w, int h, int base, const QColorGroup& cg ); |
1292 | virtual void drawParagString( QPainter &painter, const QString &str, int start, int len, int startX, | 1248 | virtual void drawString( QPainter &painter, const QString &str, int start, int len, int xstart, |
1293 | int lastY, int baseLine, int bw, int h, bool drawSelections, | 1249 | int y, int baseLine, int w, int h, int selection, |
1294 | QTextStringChar *formatChar, int i, const QMemArray<int> &selectionStarts, | 1250 | QTextStringChar *formatChar, const QColorGroup& cg, |
1295 | const QMemArray<int> &selectionEnds, const QColorGroup &cg, bool rightToLeft ); | 1251 | bool rightToLeft ); |
1296 | 1252 | ||
1297 | private: | 1253 | private: |
1298 | QMap<int, QTextParagSelection> &selections() const; | 1254 | QMap<int, QTextParagraphSelection> &selections() const; |
1299 | QPtrVector<QStyleSheetItem> &styleSheetItemsVec() const; | ||
1300 | QPtrList<QTextCustomItem> &floatingItems() const; | 1255 | QPtrList<QTextCustomItem> &floatingItems() const; |
1256 | QBrush backgroundBrush( const QColorGroup&cg ) { if ( bgcol ) return *bgcol; return cg.brush( QColorGroup::Base ); } | ||
1257 | void invalidateStyleCache(); | ||
1301 | 1258 | ||
1302 | QMap<int, QTextParagLineStart*> lineStarts; | 1259 | QMap<int, QTextLineStart*> lineStarts; |
1303 | int invalid; | 1260 | int invalid; |
1304 | QRect r; | 1261 | QRect r; |
1305 | QTextParag *p, *n; | 1262 | QTextParagraph *p, *n; |
1306 | void *docOrPseudo; | 1263 | void *docOrPseudo; |
1307 | uint changed : 1; | 1264 | uint changed : 1; |
1308 | uint firstFormat : 1; | 1265 | uint firstFormat : 1; |
1309 | uint firstPProcess : 1; | 1266 | uint firstPProcess : 1; |
1310 | uint needPreProcess : 1; | 1267 | uint needPreProcess : 1; |
1311 | uint fullWidth : 1; | 1268 | uint fullWidth : 1; |
1312 | uint newLinesAllowed : 1; | ||
1313 | uint lastInFrame : 1; | 1269 | uint lastInFrame : 1; |
1314 | uint visible : 1; | 1270 | uint visible : 1; |
1315 | uint breakable : 1; | 1271 | uint breakable : 1; |
1316 | uint isBr : 1; | ||
1317 | uint movedDown : 1; | 1272 | uint movedDown : 1; |
1318 | uint mightHaveCustomItems : 1; | 1273 | uint mightHaveCustomItems : 1; |
1319 | uint hasdoc : 1; | 1274 | uint hasdoc : 1; |
1275 | uint litem : 1; // whether the paragraph is a list item | ||
1276 | uint rtext : 1; // whether the paragraph needs rich text margin | ||
1320 | int align : 4; | 1277 | int align : 4; |
1321 | int state, id; | 1278 | int state, id; |
1322 | QTextString *str; | 1279 | QTextString *str; |
1323 | QMap<int, QTextParagSelection> *mSelections; | 1280 | QMap<int, QTextParagraphSelection> *mSelections; |
1324 | QPtrVector<QStyleSheetItem> *mStyleSheetItemsVec; | ||
1325 | QPtrList<QTextCustomItem> *mFloatingItems; | 1281 | QPtrList<QTextCustomItem> *mFloatingItems; |
1326 | QStyleSheetItem::ListStyle listS; | 1282 | QStyleSheetItem::ListStyle lstyle; |
1327 | int numSubParag; | 1283 | short utm, ubm, ulm, urm, uflm, ulinespacing; |
1328 | int tm, bm, lm, rm, flm; | ||
1329 | QTextFormat *defFormat; | ||
1330 | int *tArray; | 1284 | int *tArray; |
1331 | int tabStopWidth; | 1285 | short tabStopWidth; |
1332 | QTextParagData *eData; | 1286 | QTextParagraphData *eData; |
1333 | int list_val; | 1287 | short list_val; |
1334 | QColor *bgcol; | 1288 | QColor *bgcol; |
1289 | ushort ldepth; | ||
1335 | 1290 | ||
1336 | }; | 1291 | }; |
1337 | 1292 | ||
1338 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1293 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1339 | 1294 | ||
1340 | class Q_EXPORT QTextFormatter | 1295 | class Q_EXPORT QTextFormatter |
1341 | { | 1296 | { |
1342 | public: | 1297 | public: |
1343 | QTextFormatter(); | 1298 | QTextFormatter(); |
1344 | virtual ~QTextFormatter(); | 1299 | virtual ~QTextFormatter(); |
1345 | 1300 | ||
1346 | virtual int format( QTextDocument *doc, QTextParag *parag, int start, const QMap<int, QTextParagLineStart*> &oldLineStarts ) = 0; | 1301 | virtual int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts ) = 0; |
1347 | virtual int formatVertically( QTextDocument* doc, QTextParag* parag ); | 1302 | virtual int formatVertically( QTextDocument* doc, QTextParagraph* parag ); |
1348 | 1303 | ||
1349 | bool isWrapEnabled( QTextParag *p ) const { if ( !wrapEnabled ) return FALSE; if ( p && !p->isBreakable() ) return FALSE; return TRUE;} | 1304 | bool isWrapEnabled( QTextParagraph *p ) const { if ( !wrapEnabled ) return FALSE; if ( p && !p->isBreakable() ) return FALSE; return TRUE;} |
1350 | int wrapAtColumn() const { return wrapColumn;} | 1305 | int wrapAtColumn() const { return wrapColumn;} |
1351 | virtual void setWrapEnabled( bool b ); | 1306 | virtual void setWrapEnabled( bool b ); |
1352 | virtual void setWrapAtColumn( int c ); | 1307 | virtual void setWrapAtColumn( int c ); |
1353 | virtual void setAllowBreakInWords( bool b ) { biw = b; } | 1308 | virtual void setAllowBreakInWords( bool b ) { biw = b; } |
1354 | bool allowBreakInWords() const { return biw; } | 1309 | bool allowBreakInWords() const { return biw; } |
1355 | 1310 | ||
1356 | int minimumWidth() const { return thisminw; } | 1311 | int minimumWidth() const { return thisminw; } |
1357 | int widthUsed() const { return thiswused; } | 1312 | int widthUsed() const { return thiswused; } |
1358 | 1313 | ||
1314 | static bool isBreakable( QTextString *string, int pos ); | ||
1315 | |||
1359 | protected: | 1316 | protected: |
1360 | virtual QTextParagLineStart *formatLine( QTextParag *parag, QTextString *string, QTextParagLineStart *line, QTextStringChar *start, | 1317 | virtual QTextLineStart *formatLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start, |
1361 | QTextStringChar *last, int align = Qt3::AlignAuto, int space = 0 ); | 1318 | QTextStringChar *last, int align = Qt3::AlignAuto, int space = 0 ); |
1362 | #ifndef QT_NO_COMPLEXTEXT | 1319 | #ifndef QT_NO_COMPLEXTEXT |
1363 | virtual QTextParagLineStart *bidiReorderLine( QTextParag *parag, QTextString *string, QTextParagLineStart *line, QTextStringChar *start, | 1320 | virtual QTextLineStart *bidiReorderLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start, |
1364 | QTextStringChar *last, int align, int space ); | 1321 | QTextStringChar *last, int align, int space ); |
1365 | #endif | 1322 | #endif |
1366 | virtual bool isBreakable( QTextString *string, int pos ) const; | 1323 | void insertLineStart( QTextParagraph *parag, int index, QTextLineStart *ls ); |
1367 | void insertLineStart( QTextParag *parag, int index, QTextParagLineStart *ls ); | ||
1368 | 1324 | ||
1369 | int thisminw; | 1325 | int thisminw; |
1370 | int thiswused; | 1326 | int thiswused; |
1371 | 1327 | ||
1372 | private: | 1328 | private: |
1373 | bool wrapEnabled; | 1329 | bool wrapEnabled; |
1374 | int wrapColumn; | 1330 | int wrapColumn; |
1375 | bool biw; | 1331 | bool biw; |
1376 | 1332 | ||
1377 | #ifdef HAVE_THAI_BREAKS | 1333 | #ifdef HAVE_THAI_BREAKS |
1378 | static QCString *thaiCache; | 1334 | static QCString *thaiCache; |
1379 | static QTextString *cachedString; | 1335 | static QTextString *cachedString; |
1380 | static ThBreakIterator *thaiIt; | 1336 | static ThBreakIterator *thaiIt; |
1381 | #endif | 1337 | #endif |
1382 | }; | 1338 | }; |
1383 | 1339 | ||
1384 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1340 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1385 | 1341 | ||
1386 | class Q_EXPORT QTextFormatterBreakInWords : public QTextFormatter | 1342 | class Q_EXPORT QTextFormatterBreakInWords : public QTextFormatter |
1387 | { | 1343 | { |
1388 | public: | 1344 | public: |
1389 | QTextFormatterBreakInWords(); | 1345 | QTextFormatterBreakInWords(); |
1390 | virtual ~QTextFormatterBreakInWords() {} | 1346 | virtual ~QTextFormatterBreakInWords() {} |
1391 | 1347 | ||
1392 | int format( QTextDocument *doc, QTextParag *parag, int start, const QMap<int, QTextParagLineStart*> &oldLineStarts ); | 1348 | int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts ); |
1393 | 1349 | ||
1394 | }; | 1350 | }; |
1395 | 1351 | ||
1396 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1352 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1397 | 1353 | ||
1398 | class Q_EXPORT QTextFormatterBreakWords : public QTextFormatter | 1354 | class Q_EXPORT QTextFormatterBreakWords : public QTextFormatter |
1399 | { | 1355 | { |
1400 | public: | 1356 | public: |
1401 | QTextFormatterBreakWords(); | 1357 | QTextFormatterBreakWords(); |
1402 | virtual ~QTextFormatterBreakWords() {} | 1358 | virtual ~QTextFormatterBreakWords() {} |
1403 | 1359 | ||
1404 | int format( QTextDocument *doc, QTextParag *parag, int start, const QMap<int, QTextParagLineStart*> &oldLineStarts ); | 1360 | int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts ); |
1405 | 1361 | ||
1406 | }; | 1362 | }; |
1407 | 1363 | ||
1408 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1364 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1409 | 1365 | ||
1410 | class Q_EXPORT QTextIndent | 1366 | class Q_EXPORT QTextIndent |
1411 | { | 1367 | { |
1412 | public: | 1368 | public: |
1413 | QTextIndent(); | 1369 | QTextIndent(); |
1414 | virtual ~QTextIndent() {} | 1370 | virtual ~QTextIndent() {} |
1415 | 1371 | ||
1416 | virtual void indent( QTextDocument *doc, QTextParag *parag, int *oldIndent = 0, int *newIndent = 0 ) = 0; | 1372 | virtual void indent( QTextDocument *doc, QTextParagraph *parag, int *oldIndent = 0, int *newIndent = 0 ) = 0; |
1417 | 1373 | ||
1418 | }; | 1374 | }; |
1419 | 1375 | ||
1420 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1376 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1421 | 1377 | ||
1422 | class Q_EXPORT QTextPreProcessor | 1378 | class Q_EXPORT QTextPreProcessor |
1423 | { | 1379 | { |
1424 | public: | 1380 | public: |
1425 | enum Ids { | 1381 | enum Ids { |
1426 | Standard = 0 | 1382 | Standard = 0 |
1427 | }; | 1383 | }; |
1428 | 1384 | ||
1429 | QTextPreProcessor(); | 1385 | QTextPreProcessor(); |
1430 | virtual ~QTextPreProcessor() {} | 1386 | virtual ~QTextPreProcessor() {} |
1431 | 1387 | ||
1432 | virtual void process( QTextDocument *doc, QTextParag *, int, bool = TRUE ) = 0; | 1388 | virtual void process( QTextDocument *doc, QTextParagraph *, int, bool = TRUE ) = 0; |
1433 | virtual QTextFormat *format( int id ) = 0; | 1389 | virtual QTextFormat *format( int id ) = 0; |
1434 | 1390 | ||
1435 | }; | 1391 | }; |
1436 | 1392 | ||
1437 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1393 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1438 | 1394 | ||
1439 | class Q_EXPORT QTextFormat | 1395 | class Q_EXPORT QTextFormat |
1440 | { | 1396 | { |
1441 | friend class QTextFormatCollection; | 1397 | friend class QTextFormatCollection; |
1442 | friend class QTextDocument; | 1398 | friend class QTextDocument; |
1443 | 1399 | ||
1444 | public: | 1400 | public: |
1445 | enum Flags { | 1401 | enum Flags { |
1446 | NoFlags, | 1402 | NoFlags, |
1447 | Bold = 1, | 1403 | Bold = 1, |
1448 | Italic = 2, | 1404 | Italic = 2, |
1449 | Underline = 4, | 1405 | Underline = 4, |
1450 | Family = 8, | 1406 | Family = 8, |
1451 | Size = 16, | 1407 | Size = 16, |
1452 | Color = 32, | 1408 | Color = 32, |
1453 | Misspelled = 64, | 1409 | Misspelled = 64, |
1454 | VAlign = 128, | 1410 | VAlign = 128, |
1455 | Font = Bold | Italic | Underline | Family | Size, | 1411 | StrikeOut= 256, |
1412 | Font = Bold | Italic | Underline | Family | Size | StrikeOut, | ||
1456 | Format = Font | Color | Misspelled | VAlign | 1413 | Format = Font | Color | Misspelled | VAlign |
1457 | }; | 1414 | }; |
1458 | 1415 | ||
1459 | enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript }; | 1416 | enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript }; |
1460 | 1417 | ||
1461 | QTextFormat(); | 1418 | QTextFormat(); |
1462 | virtual ~QTextFormat(); | 1419 | virtual ~QTextFormat(); |
1463 | 1420 | ||
1464 | QTextFormat( const QStyleSheetItem *s ); | 1421 | QTextFormat( const QStyleSheetItem *s ); |
1465 | QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection *parent = 0 ); | 1422 | QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection *parent = 0 ); |
1466 | QTextFormat( const QTextFormat &fm ); | 1423 | QTextFormat( const QTextFormat &fm ); |
1467 | QTextFormat makeTextFormat( const QStyleSheetItem *style, const QMap<QString,QString>& attr ) const; | 1424 | QTextFormat makeTextFormat( const QStyleSheetItem *style, const QMap<QString,QString>& attr, double scaleFontsFactor ) const; |
1468 | QTextFormat& operator=( const QTextFormat &fm ); | 1425 | QTextFormat& operator=( const QTextFormat &fm ); |
1469 | QColor color() const; | 1426 | QColor color() const; |
1470 | QFont font() const; | 1427 | QFont font() const; |
1471 | bool isMisspelled() const; | 1428 | bool isMisspelled() const; |
1472 | VerticalAlignment vAlign() const; | 1429 | VerticalAlignment vAlign() const; |
1473 | int minLeftBearing() const; | 1430 | int minLeftBearing() const; |
1474 | int minRightBearing() const; | 1431 | int minRightBearing() const; |
1475 | int width( const QChar &c ) const; | 1432 | int width( const QChar &c ) const; |
1476 | int width( const QString &str, int pos ) const; | 1433 | int width( const QString &str, int pos ) const; |
1477 | int height() const; | 1434 | int height() const; |
1478 | int ascent() const; | 1435 | int ascent() const; |
1479 | int descent() const; | 1436 | int descent() const; |
1480 | int leading() const; | 1437 | int leading() const; |
1481 | bool useLinkColor() const; | 1438 | bool useLinkColor() const; |
1482 | 1439 | ||
1483 | void setBold( bool b ); | 1440 | void setBold( bool b ); |
1484 | void setItalic( bool b ); | 1441 | void setItalic( bool b ); |
1485 | void setUnderline( bool b ); | 1442 | void setUnderline( bool b ); |
1443 | void setStrikeOut( bool b ); | ||
1486 | void setFamily( const QString &f ); | 1444 | void setFamily( const QString &f ); |
1487 | void setPointSize( int s ); | 1445 | void setPointSize( int s ); |
1488 | void setFont( const QFont &f ); | 1446 | void setFont( const QFont &f ); |
1489 | void setColor( const QColor &c ); | 1447 | void setColor( const QColor &c ); |
1490 | void setMisspelled( bool b ); | 1448 | void setMisspelled( bool b ); |
1491 | void setVAlign( VerticalAlignment a ); | 1449 | void setVAlign( VerticalAlignment a ); |
1492 | 1450 | ||
1493 | bool operator==( const QTextFormat &f ) const; | 1451 | bool operator==( const QTextFormat &f ) const; |
1494 | QTextFormatCollection *parent() const; | 1452 | QTextFormatCollection *parent() const; |
1495 | QString key() const; | 1453 | QString key() const; |
1496 | 1454 | ||
1497 | static QString getKey( const QFont &f, const QColor &c, bool misspelled, VerticalAlignment vAlign ); | 1455 | static QString getKey( const QFont &f, const QColor &c, bool misspelled, VerticalAlignment vAlign ); |
1498 | 1456 | ||
1499 | void addRef(); | 1457 | void addRef(); |
1500 | void removeRef(); | 1458 | void removeRef(); |
1501 | 1459 | ||
1502 | QString makeFormatChangeTags( QTextFormat *f, const QString& oldAnchorHref, const QString& anchorHref ) const; | 1460 | QString makeFormatChangeTags( QTextFormat* defaultFormat, QTextFormat *f, const QString& oldAnchorHref, const QString& anchorHref ) const; |
1503 | QString makeFormatEndTags( const QString& anchorHref ) const; | 1461 | QString makeFormatEndTags( QTextFormat* defaultFormat, const QString& anchorHref ) const; |
1504 | 1462 | ||
1505 | static void setPainter( QPainter *p ); | 1463 | static void setPainter( QPainter *p ); |
1506 | static QPainter* painter(); | 1464 | static QPainter* painter(); |
1507 | void updateStyle(); | ||
1508 | void updateStyleFlags(); | ||
1509 | void setStyle( const QString &s ); | ||
1510 | QString styleName() const { return style; } | ||
1511 | 1465 | ||
1512 | int changed() const { return different; } | ||
1513 | bool fontSizesInPixels() { return usePixelSizes; } | 1466 | bool fontSizesInPixels() { return usePixelSizes; } |
1514 | 1467 | ||
1515 | protected: | 1468 | protected: |
1516 | virtual void generateKey(); | 1469 | virtual void generateKey(); |
1517 | 1470 | ||
1518 | private: | 1471 | private: |
1519 | void update(); | 1472 | void update(); |
1520 | 1473 | ||
1521 | private: | 1474 | private: |
1522 | QFont fn; | 1475 | QFont fn; |
1523 | QColor col; | 1476 | QColor col; |
1524 | QFontMetrics fm; | 1477 | QFontMetrics fm; |
1525 | uint missp : 1; | 1478 | uint missp : 1; |
1526 | uint linkColor : 1; | 1479 | uint linkColor : 1; |
1527 | uint usePixelSizes : 1; | 1480 | uint usePixelSizes : 1; |
1528 | int leftBearing, rightBearing; | 1481 | int leftBearing, rightBearing; |
1529 | VerticalAlignment ha; | 1482 | VerticalAlignment ha; |
1530 | uchar widths[ 256 ]; | 1483 | uchar widths[ 256 ]; |
1531 | int hei, asc, dsc; | 1484 | int hei, asc, dsc; |
1532 | QTextFormatCollection *collection; | 1485 | QTextFormatCollection *collection; |
1533 | int ref; | 1486 | int ref; |
1534 | QString k; | 1487 | QString k; |
1535 | int logicalFontSize; | 1488 | int logicalFontSize; |
1536 | int stdSize; | 1489 | int stdSize; |
1537 | static QPainter *pntr; | 1490 | static QPainter *pntr; |
1538 | QString style; | ||
1539 | int different; | ||
1540 | 1491 | ||
1541 | }; | 1492 | }; |
1542 | 1493 | ||
1543 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1494 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1544 | 1495 | ||
1545 | #if defined(Q_TEMPLATEDLL) | 1496 | #if defined(Q_TEMPLATEDLL) |
1546 | // MOC_SKIP_BEGIN | 1497 | // MOC_SKIP_BEGIN |
1547 | template class Q_EXPORT QDict<QTextFormat>; | 1498 | Q_TEMPLATE_EXTERN template class Q_EXPORT QDict<QTextFormat>; |
1548 | // MOC_SKIP_END | 1499 | // MOC_SKIP_END |
1549 | #endif | 1500 | #endif |
1550 | 1501 | ||
1551 | class Q_EXPORT QTextFormatCollection | 1502 | class Q_EXPORT QTextFormatCollection |
1552 | { | 1503 | { |
1553 | friend class QTextDocument; | 1504 | friend class QTextDocument; |
1554 | friend class QTextFormat; | 1505 | friend class QTextFormat; |
1555 | 1506 | ||
1556 | public: | 1507 | public: |
1557 | QTextFormatCollection(); | 1508 | QTextFormatCollection(); |
1558 | virtual ~QTextFormatCollection(); | 1509 | virtual ~QTextFormatCollection(); |
1559 | 1510 | ||
1560 | void setDefaultFormat( QTextFormat *f ); | 1511 | void setDefaultFormat( QTextFormat *f ); |
1561 | QTextFormat *defaultFormat() const; | 1512 | QTextFormat *defaultFormat() const; |
1562 | virtual QTextFormat *format( QTextFormat *f ); | 1513 | virtual QTextFormat *format( QTextFormat *f ); |
1563 | virtual QTextFormat *format( QTextFormat *of, QTextFormat *nf, int flags ); | 1514 | virtual QTextFormat *format( QTextFormat *of, QTextFormat *nf, int flags ); |
1564 | virtual QTextFormat *format( const QFont &f, const QColor &c ); | 1515 | virtual QTextFormat *format( const QFont &f, const QColor &c ); |
1565 | virtual void remove( QTextFormat *f ); | 1516 | virtual void remove( QTextFormat *f ); |
1566 | virtual QTextFormat *createFormat( const QTextFormat &f ) { return new QTextFormat( f ); } | 1517 | virtual QTextFormat *createFormat( const QTextFormat &f ) { return new QTextFormat( f ); } |
1567 | virtual QTextFormat *createFormat( const QFont &f, const QColor &c ) { return new QTextFormat( f, c, this ); } | 1518 | virtual QTextFormat *createFormat( const QFont &f, const QColor &c ) { return new QTextFormat( f, c, this ); } |
1568 | void debug(); | ||
1569 | 1519 | ||
1570 | QStyleSheet *styleSheet() const { return sheet; } | 1520 | void updateDefaultFormat( const QFont &font, const QColor &c, QStyleSheet *sheet ); |
1571 | void setStyleSheet( QStyleSheet *s ) { sheet = s; } | ||
1572 | void updateStyles(); | ||
1573 | void updateFontSizes( int base, bool usePixels ); | ||
1574 | void updateFontAttributes( const QFont &f, const QFont &old ); | ||
1575 | QDict<QTextFormat> dict() const { return cKey; } | 1521 | QDict<QTextFormat> dict() const { return cKey; } |
1576 | 1522 | ||
1577 | private: | 1523 | private: |
1578 | void updateKeys(); | 1524 | void updateKeys(); |
1579 | 1525 | ||
1580 | private: | 1526 | private: |
1581 | QTextFormat *defFormat, *lastFormat, *cachedFormat; | 1527 | QTextFormat *defFormat, *lastFormat, *cachedFormat; |
1582 | QDict<QTextFormat> cKey; | 1528 | QDict<QTextFormat> cKey; |
1583 | QTextFormat *cres; | 1529 | QTextFormat *cres; |
1584 | QFont cfont; | 1530 | QFont cfont; |
1585 | QColor ccol; | 1531 | QColor ccol; |
1586 | QString kof, knf; | 1532 | QString kof, knf; |
1587 | int cflags; | 1533 | int cflags; |
1588 | QStyleSheet *sheet; | ||
1589 | |||
1590 | }; | 1534 | }; |
1591 | 1535 | ||
1592 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1536 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1593 | 1537 | ||
1594 | inline int QTextString::length() const | 1538 | inline int QTextString::length() const |
1595 | { | 1539 | { |
1596 | return data.size(); | 1540 | return data.size(); |
1597 | } | 1541 | } |
1598 | 1542 | ||
1599 | inline void QTextString::operator+=( const QString &s ) | 1543 | inline int QTextParagraph::length() const |
1600 | { | ||
1601 | insert( length(), s, 0 ); | ||
1602 | } | ||
1603 | |||
1604 | inline int QTextParag::length() const | ||
1605 | { | 1544 | { |
1606 | return str->length(); | 1545 | return str->length(); |
1607 | } | 1546 | } |
1608 | 1547 | ||
1609 | inline QRect QTextParag::rect() const | 1548 | inline QRect QTextParagraph::rect() const |
1610 | { | 1549 | { |
1611 | return r; | 1550 | return r; |
1612 | } | 1551 | } |
1613 | 1552 | ||
1614 | inline QTextParag *QTextCursor::parag() const | 1553 | inline QTextParagraph *QTextCursor::paragraph() const |
1615 | { | 1554 | { |
1616 | return string; | 1555 | return para; |
1617 | } | 1556 | } |
1618 | 1557 | ||
1619 | inline int QTextCursor::index() const | 1558 | inline int QTextCursor::index() const |
1620 | { | 1559 | { |
1621 | return idx; | 1560 | return idx; |
1622 | } | 1561 | } |
1623 | 1562 | ||
1624 | inline void QTextCursor::setIndex( int i, bool restore ) | ||
1625 | { | ||
1626 | if ( restore ) | ||
1627 | restoreState(); | ||
1628 | if ( i < 0 || i >= string->length() ) { | ||
1629 | #if defined(QT_CHECK_RANGE) | ||
1630 | qWarning( "QTextCursor::setIndex: %d out of range", i ); | ||
1631 | #endif | ||
1632 | i = i < 0 ? 0 : string->length() - 1; | ||
1633 | } | ||
1634 | |||
1635 | tmpIndex = -1; | ||
1636 | idx = i; | ||
1637 | } | ||
1638 | |||
1639 | inline void QTextCursor::setParag( QTextParag *s, bool restore ) | ||
1640 | { | ||
1641 | if ( restore ) | ||
1642 | restoreState(); | ||
1643 | idx = 0; | ||
1644 | string = s; | ||
1645 | tmpIndex = -1; | ||
1646 | } | ||
1647 | |||
1648 | inline void QTextCursor::checkIndex() | ||
1649 | { | ||
1650 | if ( idx >= string->length() ) | ||
1651 | idx = string->length() - 1; | ||
1652 | } | ||
1653 | 1563 | ||
1654 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1564 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1655 | 1565 | ||
1656 | inline int QTextDocument::x() const | 1566 | inline int QTextDocument::x() const |
1657 | { | 1567 | { |
1658 | return cx; | 1568 | return cx; |
1659 | } | 1569 | } |
1660 | 1570 | ||
1661 | inline int QTextDocument::y() const | 1571 | inline int QTextDocument::y() const |
1662 | { | 1572 | { |
1663 | return cy; | 1573 | return cy; |
1664 | } | 1574 | } |
1665 | 1575 | ||
1666 | inline int QTextDocument::width() const | 1576 | inline int QTextDocument::width() const |
1667 | { | 1577 | { |
1668 | return QMAX( cw, flow_->width() ); | 1578 | return QMAX( cw, flow_->width() ); |
1669 | } | 1579 | } |
1670 | 1580 | ||
1671 | inline int QTextDocument::visibleWidth() const | 1581 | inline int QTextDocument::visibleWidth() const |
1672 | { | 1582 | { |
1673 | return vw; | 1583 | return vw; |
1674 | } | 1584 | } |
1675 | 1585 | ||
1676 | inline QTextParag *QTextDocument::firstParag() const | 1586 | inline QTextParagraph *QTextDocument::firstParagraph() const |
1677 | { | 1587 | { |
1678 | return fParag; | 1588 | return fParag; |
1679 | } | 1589 | } |
1680 | 1590 | ||
1681 | inline QTextParag *QTextDocument::lastParag() const | 1591 | inline QTextParagraph *QTextDocument::lastParagraph() const |
1682 | { | 1592 | { |
1683 | return lParag; | 1593 | return lParag; |
1684 | } | 1594 | } |
1685 | 1595 | ||
1686 | inline void QTextDocument::setFirstParag( QTextParag *p ) | 1596 | inline void QTextDocument::setFirstParagraph( QTextParagraph *p ) |
1687 | { | 1597 | { |
1688 | fParag = p; | 1598 | fParag = p; |
1689 | } | 1599 | } |
1690 | 1600 | ||
1691 | inline void QTextDocument::setLastParag( QTextParag *p ) | 1601 | inline void QTextDocument::setLastParagraph( QTextParagraph *p ) |
1692 | { | 1602 | { |
1693 | lParag = p; | 1603 | lParag = p; |
1694 | } | 1604 | } |
1695 | 1605 | ||
1696 | inline void QTextDocument::setWidth( int w ) | 1606 | inline void QTextDocument::setWidth( int w ) |
1697 | { | 1607 | { |
1698 | cw = QMAX( w, minw ); | 1608 | cw = QMAX( w, minw ); |
1699 | flow_->setWidth( cw ); | 1609 | flow_->setWidth( cw ); |
1700 | vw = w; | 1610 | vw = w; |
1701 | } | 1611 | } |
1702 | 1612 | ||
1703 | inline int QTextDocument::minimumWidth() const | 1613 | inline int QTextDocument::minimumWidth() const |
1704 | { | 1614 | { |
1705 | return minw; | 1615 | return minw; |
1706 | } | 1616 | } |
1707 | 1617 | ||
1708 | inline void QTextDocument::setY( int y ) | 1618 | inline void QTextDocument::setY( int y ) |
1709 | { | 1619 | { |
1710 | cy = y; | 1620 | cy = y; |
1711 | } | 1621 | } |
1712 | 1622 | ||
1713 | inline int QTextDocument::leftMargin() const | 1623 | inline int QTextDocument::leftMargin() const |
1714 | { | 1624 | { |
1715 | return leftmargin; | 1625 | return leftmargin; |
@@ -1849,291 +1759,251 @@ inline QFont QTextFormat::font() const | |||
1849 | 1759 | ||
1850 | inline bool QTextFormat::isMisspelled() const | 1760 | inline bool QTextFormat::isMisspelled() const |
1851 | { | 1761 | { |
1852 | return missp; | 1762 | return missp; |
1853 | } | 1763 | } |
1854 | 1764 | ||
1855 | inline QTextFormat::VerticalAlignment QTextFormat::vAlign() const | 1765 | inline QTextFormat::VerticalAlignment QTextFormat::vAlign() const |
1856 | { | 1766 | { |
1857 | return ha; | 1767 | return ha; |
1858 | } | 1768 | } |
1859 | 1769 | ||
1860 | inline bool QTextFormat::operator==( const QTextFormat &f ) const | 1770 | inline bool QTextFormat::operator==( const QTextFormat &f ) const |
1861 | { | 1771 | { |
1862 | return k == f.k; | 1772 | return k == f.k; |
1863 | } | 1773 | } |
1864 | 1774 | ||
1865 | inline QTextFormatCollection *QTextFormat::parent() const | 1775 | inline QTextFormatCollection *QTextFormat::parent() const |
1866 | { | 1776 | { |
1867 | return collection; | 1777 | return collection; |
1868 | } | 1778 | } |
1869 | 1779 | ||
1870 | inline void QTextFormat::addRef() | 1780 | inline void QTextFormat::addRef() |
1871 | { | 1781 | { |
1872 | ref++; | 1782 | ref++; |
1873 | #ifdef DEBUG_COLLECTION | ||
1874 | qDebug( "add ref of '%s' to %d (%p)", k.latin1(), ref, this ); | ||
1875 | #endif | ||
1876 | } | 1783 | } |
1877 | 1784 | ||
1878 | inline void QTextFormat::removeRef() | 1785 | inline void QTextFormat::removeRef() |
1879 | { | 1786 | { |
1880 | ref--; | 1787 | ref--; |
1881 | if ( !collection ) | 1788 | if ( !collection ) |
1882 | return; | 1789 | return; |
1883 | if ( this == collection->defFormat ) | 1790 | if ( this == collection->defFormat ) |
1884 | return; | 1791 | return; |
1885 | #ifdef DEBUG_COLLECTION | ||
1886 | qDebug( "remove ref of '%s' to %d (%p)", k.latin1(), ref, this ); | ||
1887 | #endif | ||
1888 | if ( ref == 0 ) | 1792 | if ( ref == 0 ) |
1889 | collection->remove( this ); | 1793 | collection->remove( this ); |
1890 | } | 1794 | } |
1891 | 1795 | ||
1892 | inline QString QTextFormat::key() const | 1796 | inline QString QTextFormat::key() const |
1893 | { | 1797 | { |
1894 | return k; | 1798 | return k; |
1895 | } | 1799 | } |
1896 | 1800 | ||
1897 | inline bool QTextFormat::useLinkColor() const | 1801 | inline bool QTextFormat::useLinkColor() const |
1898 | { | 1802 | { |
1899 | return linkColor; | 1803 | return linkColor; |
1900 | } | 1804 | } |
1901 | 1805 | ||
1902 | inline void QTextFormat::setStyle( const QString &s ) | ||
1903 | { | ||
1904 | style = s; | ||
1905 | updateStyleFlags(); | ||
1906 | } | ||
1907 | 1806 | ||
1908 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1807 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1909 | 1808 | ||
1910 | inline QTextStringChar &QTextString::at( int i ) const | 1809 | inline QTextStringChar &QTextString::at( int i ) const |
1911 | { | 1810 | { |
1912 | return data[ i ]; | 1811 | return data[ i ]; |
1913 | } | 1812 | } |
1914 | 1813 | ||
1915 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1814 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1916 | 1815 | ||
1917 | inline QTextStringChar *QTextParag::at( int i ) const | 1816 | inline QTextStringChar *QTextParagraph::at( int i ) const |
1918 | { | 1817 | { |
1919 | return &str->at( i ); | 1818 | return &str->at( i ); |
1920 | } | 1819 | } |
1921 | 1820 | ||
1922 | inline bool QTextParag::isValid() const | 1821 | inline bool QTextParagraph::isValid() const |
1923 | { | 1822 | { |
1924 | return invalid == -1; | 1823 | return invalid == -1; |
1925 | } | 1824 | } |
1926 | 1825 | ||
1927 | inline bool QTextParag::hasChanged() const | 1826 | inline bool QTextParagraph::hasChanged() const |
1928 | { | 1827 | { |
1929 | return changed; | 1828 | return changed; |
1930 | } | 1829 | } |
1931 | 1830 | ||
1932 | inline void QTextParag::setBackgroundColor( const QColor & c ) | 1831 | inline void QTextParagraph::setBackgroundColor( const QColor & c ) |
1933 | { | 1832 | { |
1934 | delete bgcol; | 1833 | delete bgcol; |
1935 | bgcol = new QColor( c ); | 1834 | bgcol = new QColor( c ); |
1936 | setChanged( TRUE ); | 1835 | setChanged( TRUE ); |
1937 | } | 1836 | } |
1938 | 1837 | ||
1939 | inline void QTextParag::clearBackgroundColor() | 1838 | inline void QTextParagraph::clearBackgroundColor() |
1940 | { | 1839 | { |
1941 | delete bgcol; bgcol = 0; setChanged( TRUE ); | 1840 | delete bgcol; bgcol = 0; setChanged( TRUE ); |
1942 | } | 1841 | } |
1943 | 1842 | ||
1944 | inline void QTextParag::append( const QString &s, bool reallyAtEnd ) | 1843 | inline void QTextParagraph::append( const QString &s, bool reallyAtEnd ) |
1945 | { | 1844 | { |
1946 | if ( reallyAtEnd ) | 1845 | if ( reallyAtEnd ) |
1947 | insert( str->length(), s ); | 1846 | insert( str->length(), s ); |
1948 | else | 1847 | else |
1949 | insert( QMAX( str->length() - 1, 0 ), s ); | 1848 | insert( QMAX( str->length() - 1, 0 ), s ); |
1950 | } | 1849 | } |
1951 | 1850 | ||
1952 | inline QTextParag *QTextParag::prev() const | 1851 | inline QTextParagraph *QTextParagraph::prev() const |
1953 | { | 1852 | { |
1954 | return p; | 1853 | return p; |
1955 | } | 1854 | } |
1956 | 1855 | ||
1957 | inline QTextParag *QTextParag::next() const | 1856 | inline QTextParagraph *QTextParagraph::next() const |
1958 | { | 1857 | { |
1959 | return n; | 1858 | return n; |
1960 | } | 1859 | } |
1961 | 1860 | ||
1962 | inline bool QTextParag::hasAnySelection() const | 1861 | inline bool QTextParagraph::hasAnySelection() const |
1963 | { | 1862 | { |
1964 | return mSelections ? !selections().isEmpty() : FALSE; | 1863 | return mSelections ? !selections().isEmpty() : FALSE; |
1965 | } | 1864 | } |
1966 | 1865 | ||
1967 | inline void QTextParag::setEndState( int s ) | 1866 | inline void QTextParagraph::setEndState( int s ) |
1968 | { | 1867 | { |
1969 | if ( s == state ) | 1868 | if ( s == state ) |
1970 | return; | 1869 | return; |
1971 | state = s; | 1870 | state = s; |
1972 | } | 1871 | } |
1973 | 1872 | ||
1974 | inline int QTextParag::endState() const | 1873 | inline int QTextParagraph::endState() const |
1975 | { | 1874 | { |
1976 | return state; | 1875 | return state; |
1977 | } | 1876 | } |
1978 | 1877 | ||
1979 | inline void QTextParag::setParagId( int i ) | 1878 | inline void QTextParagraph::setParagId( int i ) |
1980 | { | 1879 | { |
1981 | id = i; | 1880 | id = i; |
1982 | } | 1881 | } |
1983 | 1882 | ||
1984 | inline int QTextParag::paragId() const | 1883 | inline int QTextParagraph::paragId() const |
1985 | { | 1884 | { |
1986 | if ( id == -1 ) | 1885 | if ( id == -1 ) |
1987 | qWarning( "invalid parag id!!!!!!!! (%p)", (void*)this ); | 1886 | qWarning( "invalid parag id!!!!!!!! (%p)", (void*)this ); |
1988 | return id; | 1887 | return id; |
1989 | } | 1888 | } |
1990 | 1889 | ||
1991 | inline bool QTextParag::firstPreProcess() const | 1890 | inline bool QTextParagraph::firstPreProcess() const |
1992 | { | 1891 | { |
1993 | return firstPProcess; | 1892 | return firstPProcess; |
1994 | } | 1893 | } |
1995 | 1894 | ||
1996 | inline void QTextParag::setFirstPreProcess( bool b ) | 1895 | inline void QTextParagraph::setFirstPreProcess( bool b ) |
1997 | { | 1896 | { |
1998 | firstPProcess = b; | 1897 | firstPProcess = b; |
1999 | } | 1898 | } |
2000 | 1899 | ||
2001 | inline QMap<int, QTextParagLineStart*> &QTextParag::lineStartList() | 1900 | inline QMap<int, QTextLineStart*> &QTextParagraph::lineStartList() |
2002 | { | 1901 | { |
2003 | return lineStarts; | 1902 | return lineStarts; |
2004 | } | 1903 | } |
2005 | 1904 | ||
2006 | inline QTextString *QTextParag::string() const | 1905 | inline QTextString *QTextParagraph::string() const |
2007 | { | 1906 | { |
2008 | return str; | 1907 | return str; |
2009 | } | 1908 | } |
2010 | 1909 | ||
2011 | inline QTextDocument *QTextParag::document() const | 1910 | inline QTextDocument *QTextParagraph::document() const |
2012 | { | 1911 | { |
2013 | if ( hasdoc ) | 1912 | if ( hasdoc ) |
2014 | return (QTextDocument*) docOrPseudo; | 1913 | return (QTextDocument*) docOrPseudo; |
2015 | return 0; | 1914 | return 0; |
2016 | } | 1915 | } |
2017 | 1916 | ||
2018 | inline QTextParagPseudoDocument *QTextParag::pseudoDocument() const | 1917 | inline QTextParagraphPseudoDocument *QTextParagraph::pseudoDocument() const |
2019 | { | 1918 | { |
2020 | if ( hasdoc ) | 1919 | if ( hasdoc ) |
2021 | return 0; | 1920 | return 0; |
2022 | return (QTextParagPseudoDocument*) docOrPseudo; | 1921 | return (QTextParagraphPseudoDocument*) docOrPseudo; |
2023 | } | 1922 | } |
2024 | 1923 | ||
2025 | 1924 | ||
2026 | inline QTextTableCell *QTextParag::tableCell() const | 1925 | inline QTextTableCell *QTextParagraph::tableCell() const |
2027 | { | 1926 | { |
2028 | return hasdoc ? document()->tableCell () : 0; | 1927 | return hasdoc ? document()->tableCell () : 0; |
2029 | } | 1928 | } |
2030 | 1929 | ||
2031 | inline QTextCommandHistory *QTextParag::commands() const | 1930 | inline QTextCommandHistory *QTextParagraph::commands() const |
2032 | { | 1931 | { |
2033 | return hasdoc ? document()->commands() : pseudoDocument()->commandHistory; | 1932 | return hasdoc ? document()->commands() : pseudoDocument()->commandHistory; |
2034 | } | 1933 | } |
2035 | 1934 | ||
2036 | 1935 | ||
2037 | inline void QTextParag::setAlignment( int a ) | 1936 | inline int QTextParagraph::alignment() const |
2038 | { | ||
2039 | if ( a == (int)align ) | ||
2040 | return; | ||
2041 | align = a; | ||
2042 | invalidate( 0 ); | ||
2043 | } | ||
2044 | |||
2045 | inline void QTextParag::setListStyle( QStyleSheetItem::ListStyle ls ) | ||
2046 | { | ||
2047 | listS = ls; | ||
2048 | invalidate( 0 ); | ||
2049 | } | ||
2050 | |||
2051 | inline QStyleSheetItem::ListStyle QTextParag::listStyle() const | ||
2052 | { | ||
2053 | return listS; | ||
2054 | } | ||
2055 | |||
2056 | inline QTextFormat *QTextParag::paragFormat() const | ||
2057 | { | 1937 | { |
2058 | return defFormat; | 1938 | return align; |
2059 | } | 1939 | } |
2060 | 1940 | ||
2061 | inline void QTextParag::registerFloatingItem( QTextCustomItem *i ) | 1941 | inline void QTextParagraph::registerFloatingItem( QTextCustomItem *i ) |
2062 | { | 1942 | { |
2063 | floatingItems().append( i ); | 1943 | floatingItems().append( i ); |
2064 | } | 1944 | } |
2065 | 1945 | ||
2066 | inline void QTextParag::unregisterFloatingItem( QTextCustomItem *i ) | 1946 | inline void QTextParagraph::unregisterFloatingItem( QTextCustomItem *i ) |
2067 | { | 1947 | { |
2068 | floatingItems().removeRef( i ); | 1948 | floatingItems().removeRef( i ); |
2069 | } | 1949 | } |
2070 | 1950 | ||
2071 | inline QBrush *QTextParag::background() const | 1951 | inline QBrush *QTextParagraph::background() const |
2072 | { | 1952 | { |
2073 | return tableCell() ? tableCell()->backGround() : 0; | 1953 | return tableCell() ? tableCell()->backGround() : 0; |
2074 | } | 1954 | } |
2075 | 1955 | ||
2076 | inline int QTextParag::documentWidth() const | 1956 | inline int QTextParagraph::documentWidth() const |
2077 | { | 1957 | { |
2078 | return hasdoc ? document()->width() : pseudoDocument()->docRect.width(); | 1958 | return hasdoc ? document()->width() : pseudoDocument()->docRect.width(); |
2079 | } | 1959 | } |
2080 | 1960 | ||
2081 | inline int QTextParag::documentVisibleWidth() const | 1961 | inline int QTextParagraph::documentVisibleWidth() const |
2082 | { | 1962 | { |
2083 | return hasdoc ? document()->visibleWidth() : pseudoDocument()->docRect.width(); | 1963 | return hasdoc ? document()->visibleWidth() : pseudoDocument()->docRect.width(); |
2084 | } | 1964 | } |
2085 | 1965 | ||
2086 | inline int QTextParag::documentX() const | 1966 | inline int QTextParagraph::documentX() const |
2087 | { | 1967 | { |
2088 | return hasdoc ? document()->x() : pseudoDocument()->docRect.x(); | 1968 | return hasdoc ? document()->x() : pseudoDocument()->docRect.x(); |
2089 | } | 1969 | } |
2090 | 1970 | ||
2091 | inline int QTextParag::documentY() const | 1971 | inline int QTextParagraph::documentY() const |
2092 | { | 1972 | { |
2093 | return hasdoc ? document()->y() : pseudoDocument()->docRect.y(); | 1973 | return hasdoc ? document()->y() : pseudoDocument()->docRect.y(); |
2094 | } | 1974 | } |
2095 | 1975 | ||
2096 | inline void QTextParag::setExtraData( QTextParagData *data ) | 1976 | inline void QTextParagraph::setExtraData( QTextParagraphData *data ) |
2097 | { | 1977 | { |
2098 | eData = data; | 1978 | eData = data; |
2099 | } | 1979 | } |
2100 | 1980 | ||
2101 | inline QTextParagData *QTextParag::extraData() const | 1981 | inline QTextParagraphData *QTextParagraph::extraData() const |
2102 | { | 1982 | { |
2103 | return eData; | 1983 | return eData; |
2104 | } | 1984 | } |
2105 | 1985 | ||
2106 | inline void QTextParag::setNewLinesAllowed( bool b ) | ||
2107 | { | ||
2108 | newLinesAllowed = b; | ||
2109 | } | ||
2110 | |||
2111 | inline bool QTextParag::isNewLinesAllowed() const | ||
2112 | { | ||
2113 | return newLinesAllowed; | ||
2114 | } | ||
2115 | |||
2116 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1986 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2117 | 1987 | ||
2118 | inline void QTextFormatCollection::setDefaultFormat( QTextFormat *f ) | 1988 | inline void QTextFormatCollection::setDefaultFormat( QTextFormat *f ) |
2119 | { | 1989 | { |
2120 | defFormat = f; | 1990 | defFormat = f; |
2121 | } | 1991 | } |
2122 | 1992 | ||
2123 | inline QTextFormat *QTextFormatCollection::defaultFormat() const | 1993 | inline QTextFormat *QTextFormatCollection::defaultFormat() const |
2124 | { | 1994 | { |
2125 | return defFormat; | 1995 | return defFormat; |
2126 | } | 1996 | } |
2127 | 1997 | ||
2128 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 1998 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2129 | 1999 | ||
2130 | inline QTextFormat *QTextStringChar::format() const | 2000 | inline QTextFormat *QTextStringChar::format() const |
2131 | { | 2001 | { |
2132 | return (type == Regular) ? d.format : d.custom->format; | 2002 | return (type == Regular) ? d.format : d.custom->format; |
2133 | } | 2003 | } |
2134 | 2004 | ||
2135 | 2005 | ||
2136 | inline QTextCustomItem *QTextStringChar::customItem() const | 2006 | inline QTextCustomItem *QTextStringChar::customItem() const |
2137 | { | 2007 | { |
2138 | return isCustom() ? d.custom->custom : 0; | 2008 | return isCustom() ? d.custom->custom : 0; |
2139 | } | 2009 | } |