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 | |||
@@ -51,7 +51,6 @@ | |||
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" |
@@ -78,8 +77,6 @@ | |||
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; |
@@ -87,7 +84,7 @@ 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; |
@@ -125,7 +122,6 @@ public: | |||
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; |
@@ -152,12 +148,12 @@ private: | |||
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 | ||
@@ -178,7 +174,8 @@ public: | |||
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(); |
@@ -195,7 +192,7 @@ public: | |||
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: |
@@ -231,17 +228,16 @@ inline QChar::Direction QTextString::direction() const | |||
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() {} |
@@ -249,13 +245,13 @@ public: | |||
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(); |
@@ -274,31 +270,29 @@ public: | |||
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(); } |
@@ -314,16 +308,13 @@ private: | |||
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 | }; |
@@ -333,7 +324,7 @@ private: | |||
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(); |
@@ -351,7 +342,7 @@ protected: | |||
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 | ||
@@ -421,25 +412,25 @@ public: | |||
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 | ||
@@ -489,7 +480,7 @@ private: | |||
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 | ||
@@ -546,7 +537,6 @@ public: | |||
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 ; |
@@ -600,8 +590,8 @@ private: | |||
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 | ||
@@ -625,12 +615,12 @@ public: | |||
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 | ||
@@ -666,7 +656,7 @@ private: | |||
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 | { |
@@ -676,10 +666,10 @@ struct Q_EXPORT QTextDocumentSelection | |||
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 | ||
@@ -690,7 +680,7 @@ class Q_EXPORT QTextDocument : public QObject | |||
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 { |
@@ -704,7 +694,7 @@ public: | |||
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; } |
@@ -722,7 +712,7 @@ public: | |||
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; |
@@ -730,10 +720,10 @@ public: | |||
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 | ||
@@ -751,8 +741,8 @@ public: | |||
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 ); |
@@ -760,17 +750,14 @@ public: | |||
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 ); |
@@ -779,7 +766,7 @@ public: | |||
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; |
@@ -791,13 +778,11 @@ public: | |||
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; } |
@@ -805,17 +790,15 @@ public: | |||
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(); |
@@ -831,8 +814,8 @@ public: | |||
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 | ||
@@ -850,21 +833,21 @@ public: | |||
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 | ||
@@ -875,7 +858,7 @@ private: | |||
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); |
@@ -883,17 +866,18 @@ private: | |||
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; |
@@ -909,16 +893,14 @@ private: | |||
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; |
@@ -926,7 +908,7 @@ private: | |||
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; |
@@ -937,7 +919,9 @@ private: | |||
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 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
@@ -947,10 +931,8 @@ 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; } |
@@ -959,11 +941,9 @@ public: | |||
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 | ||
@@ -971,11 +951,9 @@ 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 | ||
@@ -1003,70 +981,51 @@ protected: | |||
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() ) |
@@ -1102,24 +1061,24 @@ private: | |||
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; |
@@ -1128,35 +1087,35 @@ public: | |||
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 ); } |
@@ -1164,16 +1123,17 @@ public: | |||
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 | ||
@@ -1212,10 +1172,10 @@ public: | |||
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 | ||
@@ -1225,10 +1185,6 @@ public: | |||
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; |
@@ -1236,7 +1192,6 @@ public: | |||
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 | ||
@@ -1270,7 +1225,7 @@ public: | |||
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; } |
@@ -1279,59 +1234,59 @@ public: | |||
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 | ||
@@ -1343,10 +1298,10 @@ 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 ); |
@@ -1356,15 +1311,16 @@ public: | |||
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; |
@@ -1389,7 +1345,7 @@ 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 | ||
@@ -1401,7 +1357,7 @@ 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 | ||
@@ -1413,7 +1369,7 @@ 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 | ||
@@ -1429,7 +1385,7 @@ public: | |||
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 | }; |
@@ -1452,7 +1408,8 @@ public: | |||
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 | ||
@@ -1464,7 +1421,7 @@ public: | |||
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; |
@@ -1483,6 +1440,7 @@ public: | |||
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 ); |
@@ -1499,17 +1457,12 @@ public: | |||
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: |
@@ -1535,8 +1488,6 @@ private: | |||
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 | ||
@@ -1544,7 +1495,7 @@ private: | |||
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 | ||
@@ -1565,13 +1516,8 @@ public: | |||
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: |
@@ -1585,8 +1531,6 @@ private: | |||
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 | // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
@@ -1596,24 +1540,19 @@ inline int QTextString::length() const | |||
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 |
@@ -1621,35 +1560,6 @@ inline int QTextCursor::index() const | |||
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 | ||
@@ -1673,22 +1583,22 @@ inline int QTextDocument::visibleWidth() const | |||
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 | } |
@@ -1870,9 +1780,6 @@ inline QTextFormatCollection *QTextFormat::parent() const | |||
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() |
@@ -1882,9 +1789,6 @@ inline void QTextFormat::removeRef() | |||
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 | } |
@@ -1899,11 +1803,6 @@ inline bool QTextFormat::useLinkColor() const | |||
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 | ||
@@ -1914,34 +1813,34 @@ inline QTextStringChar &QTextString::at( int i ) const | |||
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 ); |
@@ -1949,170 +1848,141 @@ inline void QTextParag::append( const QString &s, bool reallyAtEnd ) | |||
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 ) |