Diffstat (limited to 'noncore/apps/opie-write/qrichtext_p.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qrichtext_p.cpp | 303 |
1 files changed, 100 insertions, 203 deletions
diff --git a/noncore/apps/opie-write/qrichtext_p.cpp b/noncore/apps/opie-write/qrichtext_p.cpp index fb20730..6783e0b 100644 --- a/noncore/apps/opie-write/qrichtext_p.cpp +++ b/noncore/apps/opie-write/qrichtext_p.cpp | |||
@@ -57,28 +57,27 @@ int QTextCustomItem::minimumWidth() const { return 0; } | |||
57 | QString QTextCustomItem::richText() const { return QString::null; } | 57 | QString QTextCustomItem::richText() const { return QString::null; } |
58 | 58 | ||
59 | bool QTextCustomItem::enter( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy, bool atEnd ) | 59 | bool QTextCustomItem::enter( QTextCursor *, QTextDocument*&, QTextParagraph *&, int &, int &, int &, bool ) |
60 | { | 60 | { |
61 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; Q_UNUSED( atEnd ) return TRUE; | 61 | return TRUE; |
62 | |||
63 | } | 62 | } |
64 | bool QTextCustomItem::enterAt( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy, const QPoint & ) | 63 | bool QTextCustomItem::enterAt( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int &, const QPoint & ) |
65 | { | 64 | { |
66 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 65 | return TRUE; |
67 | } | 66 | } |
68 | bool QTextCustomItem::next( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ) | 67 | bool QTextCustomItem::next( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) |
69 | { | 68 | { |
70 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 69 | return TRUE; |
71 | } | 70 | } |
72 | bool QTextCustomItem::prev( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ) | 71 | bool QTextCustomItem::prev( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) |
73 | { | 72 | { |
74 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 73 | return TRUE; |
75 | } | 74 | } |
76 | bool QTextCustomItem::down( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ) | 75 | bool QTextCustomItem::down( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) |
77 | { | 76 | { |
78 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 77 | return TRUE; |
79 | } | 78 | } |
80 | bool QTextCustomItem::up( QTextCursor *, QTextDocument *&doc, QTextParag *¶g, int &idx, int &ox, int &oy ) | 79 | bool QTextCustomItem::up( QTextCursor *, QTextDocument *&, QTextParagraph *&, int &, int &, int & ) |
81 | { | 80 | { |
82 | doc = doc; parag = parag; idx = idx; ox = ox; oy = oy; return TRUE; | 81 | return TRUE; |
83 | } | 82 | } |
84 | 83 | ||
@@ -90,6 +89,6 @@ void QTextTableCell::invalidate() { cached_width = -1; cached_sizehint = -1; } | |||
90 | void QTextTable::invalidate() { cachewidth = -1; } | 89 | void QTextTable::invalidate() { cachewidth = -1; } |
91 | 90 | ||
92 | QTextParagData::~QTextParagData() {} | 91 | QTextParagraphData::~QTextParagraphData() {} |
93 | void QTextParagData::join( QTextParagData * ) {} | 92 | void QTextParagraphData::join( QTextParagraphData * ) {} |
94 | 93 | ||
95 | QTextFormatter::~QTextFormatter() {} | 94 | QTextFormatter::~QTextFormatter() {} |
@@ -101,13 +100,14 @@ void QTextFormatter::setWrapAtColumn( int c ) { wrapColumn = c; } | |||
101 | int QTextCursor::x() const | 100 | int QTextCursor::x() const |
102 | { | 101 | { |
103 | QTextStringChar *c = string->at( idx ); | 102 | QTextStringChar *c = para->at( idx ); |
104 | int curx = c->x; | 103 | int curx = c->x; |
105 | if ( !c->rightToLeft && | 104 | if ( !c->rightToLeft && |
106 | c->c.isSpace() && | 105 | c->c.isSpace() && |
107 | idx > 0 && | 106 | idx > 0 && |
108 | ( string->alignment() & Qt3::AlignJustify ) == Qt3::AlignJustify ) | 107 | !c->lineStart && |
109 | curx = string->at( idx - 1 )->x + string->string()->width( idx - 1 ); | 108 | ( para->alignment() & Qt3::AlignJustify ) == Qt3::AlignJustify ) |
109 | curx = para->at( idx - 1 )->x + para->string()->width( idx - 1 ); | ||
110 | if ( c->rightToLeft ) | 110 | if ( c->rightToLeft ) |
111 | curx += string->string()->width( idx ); | 111 | curx += para->string()->width( idx ); |
112 | return curx; | 112 | return curx; |
113 | } | 113 | } |
@@ -116,6 +116,33 @@ int QTextCursor::y() const | |||
116 | { | 116 | { |
117 | int dummy, line; | 117 | int dummy, line; |
118 | string->lineStartOfChar( idx, &dummy, &line ); | 118 | para->lineStartOfChar( idx, &dummy, &line ); |
119 | return string->lineY( line ); | 119 | return para->lineY( line ); |
120 | } | ||
121 | |||
122 | int QTextCursor::globalX() const { return totalOffsetX() + para->rect().x() + x(); } | ||
123 | int QTextCursor::globalY() const { return totalOffsetY() + para->rect().y() + y(); } | ||
124 | |||
125 | QTextDocument *QTextCursor::document() const | ||
126 | { | ||
127 | return para ? para->document() : 0; | ||
128 | } | ||
129 | |||
130 | void QTextCursor::gotoPosition( QTextParagraph* p, int index ) | ||
131 | { | ||
132 | if ( para && p != para ) { | ||
133 | while ( para->document() != p->document() && !indices.isEmpty() ) | ||
134 | pop(); | ||
135 | Q_ASSERT( indices.isEmpty() || para->document() == p->document() ); | ||
136 | } | ||
137 | para = p; | ||
138 | if ( index < 0 || index >= para->length() ) { | ||
139 | #if defined(QT_CHECK_RANGE) | ||
140 | qWarning( "QTextCursor::gotoParagraph Index: %d out of range", index ); | ||
141 | #endif | ||
142 | index = index < 0 ? 0 : para->length() - 1; | ||
143 | } | ||
144 | |||
145 | tmpIndex = -1; | ||
146 | idx = index; | ||
120 | } | 147 | } |
121 | 148 | ||
@@ -128,16 +155,16 @@ bool QTextDocument::hasSelection( int id, bool visible ) const | |||
128 | } | 155 | } |
129 | 156 | ||
130 | void QTextDocument::setSelectionStart( int id, QTextCursor *cursor ) | 157 | void QTextDocument::setSelectionStart( int id, const QTextCursor &cursor ) |
131 | { | 158 | { |
132 | QTextDocumentSelection sel; | 159 | QTextDocumentSelection sel; |
133 | sel.startCursor = *cursor; | 160 | sel.startCursor = cursor; |
134 | sel.endCursor = *cursor; | 161 | sel.endCursor = cursor; |
135 | sel.swapped = FALSE; | 162 | sel.swapped = FALSE; |
136 | selections[ id ] = sel; | 163 | selections[ id ] = sel; |
137 | } | 164 | } |
138 | 165 | ||
139 | QTextParag *QTextDocument::paragAt( int i ) const | 166 | QTextParagraph *QTextDocument::paragAt( int i ) const |
140 | { | 167 | { |
141 | QTextParag* p = curParag; | 168 | QTextParagraph* p = curParag; |
142 | if ( !p || p->paragId() > i ) | 169 | if ( !p || p->paragId() > i ) |
143 | p = fParag; | 170 | p = fParag; |
@@ -154,6 +181,5 @@ QTextFormat::~QTextFormat() | |||
154 | 181 | ||
155 | QTextFormat::QTextFormat() | 182 | QTextFormat::QTextFormat() |
156 | : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ), | 183 | : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ) |
157 | different( NoFlags ) | ||
158 | { | 184 | { |
159 | ref = 0; | 185 | ref = 0; |
@@ -164,5 +190,5 @@ QTextFormat::QTextFormat() | |||
164 | usePixelSizes = TRUE; | 190 | usePixelSizes = TRUE; |
165 | } | 191 | } |
166 | 192 | ||
167 | missp = FALSE; | 193 | missp = FALSE; |
168 | ha = AlignNormal; | 194 | ha = AlignNormal; |
@@ -171,6 +197,5 @@ QTextFormat::QTextFormat() | |||
171 | 197 | ||
172 | QTextFormat::QTextFormat( const QStyleSheetItem *style ) | 198 | QTextFormat::QTextFormat( const QStyleSheetItem *style ) |
173 | : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ), | 199 | : fm( QFontMetrics( fn ) ), linkColor( TRUE ), logicalFontSize( 3 ), stdSize( qApp->font().pointSize() ) |
174 | different( NoFlags ) | ||
175 | { | 200 | { |
176 | ref = 0; | 201 | ref = 0; |
@@ -182,5 +207,4 @@ QTextFormat::QTextFormat( const QStyleSheetItem *style ) | |||
182 | } | 207 | } |
183 | 208 | ||
184 | this->style = style->name(); | ||
185 | missp = FALSE; | 209 | missp = FALSE; |
186 | ha = AlignNormal; | 210 | ha = AlignNormal; |
@@ -191,4 +215,5 @@ QTextFormat::QTextFormat( const QStyleSheetItem *style ) | |||
191 | style->fontItalic() ); | 215 | style->fontItalic() ); |
192 | fn.setUnderline( style->fontUnderline() ); | 216 | fn.setUnderline( style->fontUnderline() ); |
217 | fn.setStrikeOut( style->fontStrikeOut() ); | ||
193 | col = style->color(); | 218 | col = style->color(); |
194 | fm = QFontMetrics( fn ); | 219 | fm = QFontMetrics( fn ); |
@@ -203,10 +228,9 @@ QTextFormat::QTextFormat( const QStyleSheetItem *style ) | |||
203 | generateKey(); | 228 | generateKey(); |
204 | addRef(); | 229 | addRef(); |
205 | updateStyleFlags(); | ||
206 | } | 230 | } |
207 | 231 | ||
208 | QTextFormat::QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection *parent ) | 232 | QTextFormat::QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection *parent ) |
209 | : fn( f ), col( c ), fm( QFontMetrics( f ) ), linkColor( TRUE ), | 233 | : fn( f ), col( c ), fm( QFontMetrics( f ) ), linkColor( TRUE ), |
210 | logicalFontSize( 3 ), stdSize( f.pointSize() ), different( NoFlags ) | 234 | logicalFontSize( 3 ), stdSize( f.pointSize() ) |
211 | { | 235 | { |
212 | ref = 0; | 236 | ref = 0; |
@@ -227,5 +251,4 @@ QTextFormat::QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection | |||
227 | generateKey(); | 251 | generateKey(); |
228 | addRef(); | 252 | addRef(); |
229 | updateStyleFlags(); | ||
230 | } | 253 | } |
231 | 254 | ||
@@ -250,6 +273,4 @@ QTextFormat::QTextFormat( const QTextFormat &f ) | |||
250 | k = f.k; | 273 | k = f.k; |
251 | linkColor = f.linkColor; | 274 | linkColor = f.linkColor; |
252 | style = f.style; | ||
253 | different = f.different; | ||
254 | addRef(); | 275 | addRef(); |
255 | } | 276 | } |
@@ -275,6 +296,4 @@ QTextFormat& QTextFormat::operator=( const QTextFormat &f ) | |||
275 | k = f.k; | 296 | k = f.k; |
276 | linkColor = f.linkColor; | 297 | linkColor = f.linkColor; |
277 | style = f.style; | ||
278 | different = f.different; | ||
279 | addRef(); | 298 | addRef(); |
280 | return *this; | 299 | return *this; |
@@ -291,5 +310,4 @@ void QTextFormat::update() | |||
291 | memset( widths, 0, 256 ); | 310 | memset( widths, 0, 256 ); |
292 | generateKey(); | 311 | generateKey(); |
293 | updateStyleFlags(); | ||
294 | } | 312 | } |
295 | 313 | ||
@@ -373,50 +391,4 @@ QString QTextFormat::getKey( const QFont &fn, const QColor &col, bool misspelled | |||
373 | } | 391 | } |
374 | 392 | ||
375 | void QTextFormat::updateStyle() | ||
376 | { | ||
377 | if ( !collection || !collection->styleSheet() ) | ||
378 | return; | ||
379 | QStyleSheetItem *item = collection->styleSheet()->item( style ); | ||
380 | if ( !item ) | ||
381 | return; | ||
382 | if ( !( different & Color ) && item->color().isValid() ) | ||
383 | col = item->color(); | ||
384 | if ( !( different & Size ) && item->fontSize() != -1 ) | ||
385 | fn.setPointSize( item->fontSize() ); | ||
386 | if ( !( different & Family ) && !item->fontFamily().isEmpty() ) | ||
387 | fn.setFamily( item->fontFamily() ); | ||
388 | if ( !( different & Bold ) && item->fontWeight() != -1 ) | ||
389 | fn.setWeight( item->fontWeight() ); | ||
390 | if ( !( different & Italic ) && item->definesFontItalic() ) | ||
391 | fn.setItalic( item->fontItalic() ); | ||
392 | if ( !( different & Underline ) && item->definesFontUnderline() ) | ||
393 | fn.setUnderline( item->fontUnderline() ); | ||
394 | generateKey(); | ||
395 | update(); | ||
396 | |||
397 | } | ||
398 | |||
399 | void QTextFormat::updateStyleFlags() | ||
400 | { | ||
401 | different = NoFlags; | ||
402 | if ( !collection || !collection->styleSheet() ) | ||
403 | return; | ||
404 | QStyleSheetItem *item = collection->styleSheet()->item( style ); | ||
405 | if ( !item ) | ||
406 | return; | ||
407 | if ( item->color() != col ) | ||
408 | different |= Color; | ||
409 | if ( item->fontSize() != fn.pointSize() ) | ||
410 | different |= Size; | ||
411 | if ( item->fontFamily() != fn.family() ) | ||
412 | different |= Family; | ||
413 | if ( item->fontItalic() != fn.italic() ) | ||
414 | different |= Italic; | ||
415 | if ( item->fontUnderline() != fn.underline() ) | ||
416 | different |= Underline; | ||
417 | if ( item->fontWeight() != fn.weight() ) | ||
418 | different |= Bold; | ||
419 | } | ||
420 | |||
421 | QString QTextString::toString( const QMemArray<QTextStringChar> &data ) | 393 | QString QTextString::toString( const QMemArray<QTextStringChar> &data ) |
422 | { | 394 | { |
@@ -444,7 +416,7 @@ QString QTextString::toString() const | |||
444 | } | 416 | } |
445 | 417 | ||
446 | void QTextParag::setSelection( int id, int start, int end ) | 418 | void QTextParagraph::setSelection( int id, int start, int end ) |
447 | { | 419 | { |
448 | QMap<int, QTextParagSelection>::ConstIterator it = selections().find( id ); | 420 | QMap<int, QTextParagraphSelection>::ConstIterator it = selections().find( id ); |
449 | if ( it != mSelections->end() ) { | 421 | if ( it != mSelections->end() ) { |
450 | if ( start == ( *it ).start && end == ( *it ).end ) | 422 | if ( start == ( *it ).start && end == ( *it ).end ) |
@@ -452,5 +424,5 @@ void QTextParag::setSelection( int id, int start, int end ) | |||
452 | } | 424 | } |
453 | 425 | ||
454 | QTextParagSelection sel; | 426 | QTextParagraphSelection sel; |
455 | sel.start = start; | 427 | sel.start = start; |
456 | sel.end = end; | 428 | sel.end = end; |
@@ -459,5 +431,5 @@ void QTextParag::setSelection( int id, int start, int end ) | |||
459 | } | 431 | } |
460 | 432 | ||
461 | void QTextParag::removeSelection( int id ) | 433 | void QTextParagraph::removeSelection( int id ) |
462 | { | 434 | { |
463 | if ( !hasSelection( id ) ) | 435 | if ( !hasSelection( id ) ) |
@@ -468,9 +440,9 @@ void QTextParag::removeSelection( int id ) | |||
468 | } | 440 | } |
469 | 441 | ||
470 | int QTextParag::selectionStart( int id ) const | 442 | int QTextParagraph::selectionStart( int id ) const |
471 | { | 443 | { |
472 | if ( !mSelections ) | 444 | if ( !mSelections ) |
473 | return -1; | 445 | return -1; |
474 | QMap<int, QTextParagSelection>::ConstIterator it = mSelections->find( id ); | 446 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); |
475 | if ( it == mSelections->end() ) | 447 | if ( it == mSelections->end() ) |
476 | return -1; | 448 | return -1; |
@@ -478,9 +450,9 @@ int QTextParag::selectionStart( int id ) const | |||
478 | } | 450 | } |
479 | 451 | ||
480 | int QTextParag::selectionEnd( int id ) const | 452 | int QTextParagraph::selectionEnd( int id ) const |
481 | { | 453 | { |
482 | if ( !mSelections ) | 454 | if ( !mSelections ) |
483 | return -1; | 455 | return -1; |
484 | QMap<int, QTextParagSelection>::ConstIterator it = mSelections->find( id ); | 456 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); |
485 | if ( it == mSelections->end() ) | 457 | if ( it == mSelections->end() ) |
486 | return -1; | 458 | return -1; |
@@ -488,19 +460,14 @@ int QTextParag::selectionEnd( int id ) const | |||
488 | } | 460 | } |
489 | 461 | ||
490 | bool QTextParag::hasSelection( int id ) const | 462 | bool QTextParagraph::hasSelection( int id ) const |
491 | { | 463 | { |
492 | if ( !mSelections ) | 464 | return mSelections ? mSelections->contains( id ) : FALSE; |
493 | return FALSE; | ||
494 | QMap<int, QTextParagSelection>::ConstIterator it = mSelections->find( id ); | ||
495 | if ( it == mSelections->end() ) | ||
496 | return FALSE; | ||
497 | return ( *it ).start != ( *it ).end || length() == 1; | ||
498 | } | 465 | } |
499 | 466 | ||
500 | bool QTextParag::fullSelected( int id ) const | 467 | bool QTextParagraph::fullSelected( int id ) const |
501 | { | 468 | { |
502 | if ( !mSelections ) | 469 | if ( !mSelections ) |
503 | return FALSE; | 470 | return FALSE; |
504 | QMap<int, QTextParagSelection>::ConstIterator it = mSelections->find( id ); | 471 | QMap<int, QTextParagraphSelection>::ConstIterator it = mSelections->find( id ); |
505 | if ( it == mSelections->end() ) | 472 | if ( it == mSelections->end() ) |
506 | return FALSE; | 473 | return FALSE; |
@@ -508,15 +475,15 @@ bool QTextParag::fullSelected( int id ) const | |||
508 | } | 475 | } |
509 | 476 | ||
510 | int QTextParag::lineY( int l ) const | 477 | int QTextParagraph::lineY( int l ) const |
511 | { | 478 | { |
512 | if ( l > (int)lineStarts.count() - 1 ) { | 479 | if ( l > (int)lineStarts.count() - 1 ) { |
513 | qWarning( "QTextParag::lineY: line %d out of range!", l ); | 480 | qWarning( "QTextParagraph::lineY: line %d out of range!", l ); |
514 | return 0; | 481 | return 0; |
515 | } | 482 | } |
516 | 483 | ||
517 | if ( !isValid() ) | 484 | if ( !isValid() ) |
518 | ( (QTextParag*)this )->format(); | 485 | ( (QTextParagraph*)this )->format(); |
519 | 486 | ||
520 | QMap<int, QTextParagLineStart*>::ConstIterator it = lineStarts.begin(); | 487 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
521 | while ( l-- > 0 ) | 488 | while ( l-- > 0 ) |
522 | ++it; | 489 | ++it; |
@@ -524,15 +491,15 @@ int QTextParag::lineY( int l ) const | |||
524 | } | 491 | } |
525 | 492 | ||
526 | int QTextParag::lineBaseLine( int l ) const | 493 | int QTextParagraph::lineBaseLine( int l ) const |
527 | { | 494 | { |
528 | if ( l > (int)lineStarts.count() - 1 ) { | 495 | if ( l > (int)lineStarts.count() - 1 ) { |
529 | qWarning( "QTextParag::lineBaseLine: line %d out of range!", l ); | 496 | qWarning( "QTextParagraph::lineBaseLine: line %d out of range!", l ); |
530 | return 10; | 497 | return 10; |
531 | } | 498 | } |
532 | 499 | ||
533 | if ( !isValid() ) | 500 | if ( !isValid() ) |
534 | ( (QTextParag*)this )->format(); | 501 | ( (QTextParagraph*)this )->format(); |
535 | 502 | ||
536 | QMap<int, QTextParagLineStart*>::ConstIterator it = lineStarts.begin(); | 503 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
537 | while ( l-- > 0 ) | 504 | while ( l-- > 0 ) |
538 | ++it; | 505 | ++it; |
@@ -540,15 +507,15 @@ int QTextParag::lineBaseLine( int l ) const | |||
540 | } | 507 | } |
541 | 508 | ||
542 | int QTextParag::lineHeight( int l ) const | 509 | int QTextParagraph::lineHeight( int l ) const |
543 | { | 510 | { |
544 | if ( l > (int)lineStarts.count() - 1 ) { | 511 | if ( l > (int)lineStarts.count() - 1 ) { |
545 | qWarning( "QTextParag::lineHeight: line %d out of range!", l ); | 512 | qWarning( "QTextParagraph::lineHeight: line %d out of range!", l ); |
546 | return 15; | 513 | return 15; |
547 | } | 514 | } |
548 | 515 | ||
549 | if ( !isValid() ) | 516 | if ( !isValid() ) |
550 | ( (QTextParag*)this )->format(); | 517 | ( (QTextParagraph*)this )->format(); |
551 | 518 | ||
552 | QMap<int, QTextParagLineStart*>::ConstIterator it = lineStarts.begin(); | 519 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
553 | while ( l-- > 0 ) | 520 | while ( l-- > 0 ) |
554 | ++it; | 521 | ++it; |
@@ -556,8 +523,8 @@ int QTextParag::lineHeight( int l ) const | |||
556 | } | 523 | } |
557 | 524 | ||
558 | void QTextParag::lineInfo( int l, int &y, int &h, int &bl ) const | 525 | void QTextParagraph::lineInfo( int l, int &y, int &h, int &bl ) const |
559 | { | 526 | { |
560 | if ( l > (int)lineStarts.count() - 1 ) { | 527 | if ( l > (int)lineStarts.count() - 1 ) { |
561 | qWarning( "QTextParag::lineInfo: line %d out of range!", l ); | 528 | qWarning( "QTextParagraph::lineInfo: line %d out of range!", l ); |
562 | qDebug( "%d %d", (int)lineStarts.count() - 1, l ); | 529 | qDebug( "%d %d", (int)lineStarts.count() - 1, l ); |
563 | y = 0; | 530 | y = 0; |
@@ -568,7 +535,7 @@ void QTextParag::lineInfo( int l, int &y, int &h, int &bl ) const | |||
568 | 535 | ||
569 | if ( !isValid() ) | 536 | if ( !isValid() ) |
570 | ( (QTextParag*)this )->format(); | 537 | ( (QTextParagraph*)this )->format(); |
571 | 538 | ||
572 | QMap<int, QTextParagLineStart*>::ConstIterator it = lineStarts.begin(); | 539 | QMap<int, QTextLineStart*>::ConstIterator it = lineStarts.begin(); |
573 | while ( l-- > 0 ) | 540 | while ( l-- > 0 ) |
574 | ++it; | 541 | ++it; |
@@ -578,78 +545,14 @@ void QTextParag::lineInfo( int l, int &y, int &h, int &bl ) const | |||
578 | } | 545 | } |
579 | 546 | ||
580 | int QTextParag::alignment() const | ||
581 | { | ||
582 | if ( align != -1 ) | ||
583 | return align; | ||
584 | QStyleSheetItem *item = style(); | ||
585 | if ( !item ) | ||
586 | return Qt3::AlignAuto; | ||
587 | if ( mStyleSheetItemsVec ) { | ||
588 | for ( int i = 0; i < (int)mStyleSheetItemsVec->size(); ++i ) { | ||
589 | item = (*mStyleSheetItemsVec)[ i ]; | ||
590 | if ( item->alignment() != QStyleSheetItem::Undefined ) | ||
591 | return item->alignment(); | ||
592 | } | ||
593 | } | ||
594 | return Qt3::AlignAuto; | ||
595 | } | ||
596 | 547 | ||
597 | QPtrVector<QStyleSheetItem> QTextParag::styleSheetItems() const | 548 | void QTextParagraph::setAlignment( int a ) |
598 | { | 549 | { |
599 | QPtrVector<QStyleSheetItem> vec; | 550 | if ( a == (int)align ) |
600 | if ( mStyleSheetItemsVec ) { | ||
601 | vec.resize( mStyleSheetItemsVec->size() ); | ||
602 | for ( int i = 0; i < (int)vec.size(); ++i ) | ||
603 | vec.insert( i, (*mStyleSheetItemsVec)[ i ] ); | ||
604 | } | ||
605 | return vec; | ||
606 | } | ||
607 | |||
608 | QStyleSheetItem *QTextParag::style() const | ||
609 | { | ||
610 | if ( !mStyleSheetItemsVec || mStyleSheetItemsVec->size() == 0 ) | ||
611 | return 0; | ||
612 | return (*mStyleSheetItemsVec)[ mStyleSheetItemsVec->size() - 1 ]; | ||
613 | } | ||
614 | |||
615 | int QTextParag::numberOfSubParagraph() const | ||
616 | { | ||
617 | if ( list_val != -1 ) | ||
618 | return list_val; | ||
619 | if ( numSubParag != -1 ) | ||
620 | return numSubParag; | ||
621 | int n = 0; | ||
622 | QTextParag *p = (QTextParag*)this; | ||
623 | while ( p && ( styleSheetItemsVec().size() >= p->styleSheetItemsVec().size() && | ||
624 | styleSheetItemsVec()[ (int)p->styleSheetItemsVec().size() - 1 ] == p->style() || | ||
625 | p->styleSheetItemsVec().size() >= styleSheetItemsVec().size() && | ||
626 | p->styleSheetItemsVec()[ (int)styleSheetItemsVec().size() - 1 ] == style() ) ) { | ||
627 | if ( p->style() == style() && listStyle() != p->listStyle() | ||
628 | && p->styleSheetItemsVec().size() == styleSheetItemsVec().size() ) | ||
629 | break; | ||
630 | if ( p->style()->displayMode() == QStyleSheetItem::DisplayListItem | ||
631 | && p->style() != style() || styleSheetItemsVec().size() == p->styleSheetItemsVec().size() ) | ||
632 | ++n; | ||
633 | p = p->prev(); | ||
634 | } | ||
635 | ( (QTextParag*)this )->numSubParag = n; | ||
636 | return n; | ||
637 | } | ||
638 | |||
639 | void QTextParag::setFormat( QTextFormat *fm ) | ||
640 | { | ||
641 | bool doUpdate = FALSE; | ||
642 | if (defFormat && (defFormat != formatCollection()->defaultFormat())) | ||
643 | doUpdate = TRUE; | ||
644 | defFormat = formatCollection()->format( fm ); | ||
645 | if ( !doUpdate ) | ||
646 | return; | 551 | return; |
647 | for ( int i = 0; i < length(); ++i ) { | 552 | align = a; |
648 | if ( at( i )->format()->styleName() == defFormat->styleName() ) | 553 | invalidate( 0 ); |
649 | at( i )->format()->updateStyle(); | ||
650 | } | ||
651 | } | 554 | } |
652 | 555 | ||
653 | QTextFormatter *QTextParag::formatter() const | 556 | QTextFormatter *QTextParagraph::formatter() const |
654 | { | 557 | { |
655 | if ( hasdoc ) | 558 | if ( hasdoc ) |
@@ -657,8 +560,8 @@ QTextFormatter *QTextParag::formatter() const | |||
657 | if ( pseudoDocument()->pFormatter ) | 560 | if ( pseudoDocument()->pFormatter ) |
658 | return pseudoDocument()->pFormatter; | 561 | return pseudoDocument()->pFormatter; |
659 | return ( ( (QTextParag*)this )->pseudoDocument()->pFormatter = new QTextFormatterBreakWords ); | 562 | return ( ( (QTextParagraph*)this )->pseudoDocument()->pFormatter = new QTextFormatterBreakWords ); |
660 | } | 563 | } |
661 | 564 | ||
662 | void QTextParag::setTabArray( int *a ) | 565 | void QTextParagraph::setTabArray( int *a ) |
663 | { | 566 | { |
664 | delete [] tArray; | 567 | delete [] tArray; |
@@ -666,5 +569,5 @@ void QTextParag::setTabArray( int *a ) | |||
666 | } | 569 | } |
667 | 570 | ||
668 | void QTextParag::setTabStops( int tw ) | 571 | void QTextParagraph::setTabStops( int tw ) |
669 | { | 572 | { |
670 | if ( hasdoc ) | 573 | if ( hasdoc ) |
@@ -674,22 +577,16 @@ void QTextParag::setTabStops( int tw ) | |||
674 | } | 577 | } |
675 | 578 | ||
676 | QMap<int, QTextParagSelection> &QTextParag::selections() const | 579 | QMap<int, QTextParagraphSelection> &QTextParagraph::selections() const |
677 | { | 580 | { |
678 | if ( !mSelections ) | 581 | if ( !mSelections ) |
679 | ((QTextParag *)this)->mSelections = new QMap<int, QTextParagSelection>; | 582 | ((QTextParagraph *)this)->mSelections = new QMap<int, QTextParagraphSelection>; |
680 | return *mSelections; | 583 | return *mSelections; |
681 | } | 584 | } |
682 | 585 | ||
683 | QPtrVector<QStyleSheetItem> &QTextParag::styleSheetItemsVec() const | ||
684 | { | ||
685 | if ( !mStyleSheetItemsVec ) | ||
686 | ((QTextParag *)this)->mStyleSheetItemsVec = new QPtrVector<QStyleSheetItem>; | ||
687 | return *mStyleSheetItemsVec; | ||
688 | } | ||
689 | 586 | ||
690 | QPtrList<QTextCustomItem> &QTextParag::floatingItems() const | 587 | QPtrList<QTextCustomItem> &QTextParagraph::floatingItems() const |
691 | { | 588 | { |
692 | if ( !mFloatingItems ) | 589 | if ( !mFloatingItems ) |
693 | ((QTextParag *)this)->mFloatingItems = new QPtrList<QTextCustomItem>; | 590 | ((QTextParagraph *)this)->mFloatingItems = new QPtrList<QTextCustomItem>; |
694 | return *mFloatingItems; | 591 | return *mFloatingItems; |
695 | } | 592 | } |
@@ -703,4 +600,4 @@ QTextStringChar::~QTextStringChar() | |||
703 | } | 600 | } |
704 | 601 | ||
705 | QTextParagPseudoDocument::QTextParagPseudoDocument():pFormatter(0),commandHistory(0), minw(0),wused(0){} | 602 | QTextParagraphPseudoDocument::QTextParagraphPseudoDocument():pFormatter(0),commandHistory(0), minw(0),wused(0){} |
706 | QTextParagPseudoDocument::~QTextParagPseudoDocument(){ delete pFormatter; delete commandHistory; } | 603 | QTextParagraphPseudoDocument::~QTextParagraphPseudoDocument(){ delete pFormatter; delete commandHistory; } |