Eneboo - Documentación para desarrolladores
src/qt/src/kernel/qrichtext_p.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qrichtext_p.h   3.3.8   edited Jan 11 14:46 $
00003 **
00004 ** Definition of internal rich text classes
00005 **
00006 ** Created : 990124
00007 **
00008 ** Copyright (C) 1999-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QRICHTEXT_P_H
00039 #define QRICHTEXT_P_H
00040 
00041 //
00042 //  W A R N I N G
00043 //  -------------
00044 //
00045 // This file is not part of the Qt API.  It exists for the convenience
00046 // of a number of Qt sources files.  This header file may change from
00047 // version to version without notice, or even be removed.
00048 //
00049 // We mean it.
00050 //
00051 //
00052 
00053 #ifndef QT_H
00054 #include "qstring.h"
00055 #include "qptrlist.h"
00056 #include "qrect.h"
00057 #include "qfontmetrics.h"
00058 #include "qintdict.h"
00059 #include "qmap.h"
00060 #include "qstringlist.h"
00061 #include "qfont.h"
00062 #include "qcolor.h"
00063 #include "qsize.h"
00064 #include "qvaluelist.h"
00065 #include "qvaluestack.h"
00066 #include "qobject.h"
00067 #include "qdict.h"
00068 #include "qpixmap.h"
00069 #include "qstylesheet.h"
00070 #include "qptrvector.h"
00071 #include "qpainter.h"
00072 #include "qlayout.h"
00073 #include "qobject.h"
00074 #include "qapplication.h"
00075 #endif // QT_H
00076 
00077 #ifndef QT_NO_RICHTEXT
00078 
00079 class QTextDocument;
00080 class QTextString;
00081 class QTextPreProcessor;
00082 class QTextFormat;
00083 class QTextCursor;
00084 class QTextParagraph;
00085 class QTextFormatter;
00086 class QTextIndent;
00087 class QTextFormatCollection;
00088 class QStyleSheetItem;
00089 #ifndef QT_NO_TEXTCUSTOMITEM
00090 class QTextCustomItem;
00091 #endif
00092 class QTextFlow;
00093 struct QBidiContext;
00094 
00095 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00096 
00097 class Q_EXPORT QTextStringChar
00098 {
00099     friend class QTextString;
00100 
00101 public:
00102     // this is never called, initialize variables in QTextString::insert()!!!
00103     QTextStringChar() : nobreak(FALSE), lineStart( 0 ), type( Regular ) {d.format=0;}
00104     ~QTextStringChar();
00105 
00106     struct CustomData
00107     {
00108         QTextFormat *format;
00109 #ifndef QT_NO_TEXTCUSTOMITEM
00110         QTextCustomItem *custom;
00111 #endif
00112         QString anchorName;
00113         QString anchorHref;
00114     };
00115     enum Type { Regular=0, Custom=1, Anchor=2, CustomAnchor=3 };
00116 
00117     QChar c;
00118     // this is the same struct as in qtextengine_p.h. Don't change!
00119     uchar softBreak      :1;     // Potential linebreak point
00120     uchar whiteSpace     :1;     // A unicode whitespace character, except NBSP, ZWNBSP
00121     uchar charStop       :1;     // Valid cursor position (for left/right arrow)
00122     uchar wordStop       :1;     // Valid cursor position (for ctrl + left/right arrow)
00123     uchar nobreak        :1;
00124 
00125     uchar lineStart : 1;
00126     uchar /*Type*/ type : 2;
00127     uchar bidiLevel       :7;
00128     uchar rightToLeft : 1;
00129 
00130     int x;
00131     union {
00132         QTextFormat* format;
00133         CustomData* custom;
00134     } d;
00135 
00136 
00137     int height() const;
00138     int ascent() const;
00139     int descent() const;
00140     bool isCustom() const { return (type & Custom) != 0; }
00141     QTextFormat *format() const;
00142 #ifndef QT_NO_TEXTCUSTOMITEM
00143     QTextCustomItem *customItem() const;
00144 #endif
00145     void setFormat( QTextFormat *f );
00146 #ifndef QT_NO_TEXTCUSTOMITEM
00147     void setCustomItem( QTextCustomItem *i );
00148 #endif
00149 
00150 #ifndef QT_NO_TEXTCUSTOMITEM
00151     void loseCustomItem();
00152 #endif
00153 
00154 
00155     bool isAnchor() const { return ( type & Anchor) != 0; }
00156     bool isLink() const { return isAnchor() && !!d.custom->anchorHref; }
00157     QString anchorName() const;
00158     QString anchorHref() const;
00159     void setAnchor( const QString& name, const QString& href );
00160 
00161 private:
00162     QTextStringChar &operator=( const QTextStringChar & ) {
00163         //abort();
00164         return *this;
00165     }
00166     QTextStringChar( const QTextStringChar & ) {
00167     }
00168     friend class QTextParagraph;
00169 };
00170 
00171 #if defined(Q_TEMPLATEDLL)
00172 // MOC_SKIP_BEGIN
00173 Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<QTextStringChar>;
00174 // MOC_SKIP_END
00175 #endif
00176 
00177 class Q_EXPORT QTextString
00178 {
00179 public:
00180 
00181     QTextString();
00182     QTextString( const QTextString &s );
00183     virtual ~QTextString();
00184 
00185     static QString toString( const QMemArray<QTextStringChar> &data );
00186     QString toString() const;
00187 
00188     inline QTextStringChar &at( int i ) const { return data[ i ]; }
00189     inline int length() const { return data.size(); }
00190 
00191     int width( int idx ) const;
00192 
00193     void insert( int index, const QString &s, QTextFormat *f );
00194     void insert( int index, const QChar *unicode, int len, QTextFormat *f );
00195     void insert( int index, QTextStringChar *c, bool doAddRefFormat = FALSE );
00196     void truncate( int index );
00197     void remove( int index, int len );
00198     void clear();
00199 
00200     void setFormat( int index, QTextFormat *f, bool useCollection );
00201 
00202     void setBidi( bool b ) { bidi = b; }
00203     bool isBidi() const;
00204     bool isRightToLeft() const;
00205     QChar::Direction direction() const;
00206     void setDirection( QChar::Direction d ) { dir = d; bidiDirty = TRUE; }
00207 
00208     QMemArray<QTextStringChar> rawData() const { return data.copy(); }
00209 
00210     void operator=( const QString &s ) { clear(); insert( 0, s, 0 ); }
00211     void operator+=( const QString &s ) { insert( length(), s, 0 ); }
00212     void prepend( const QString &s ) { insert( 0, s, 0 ); }
00213     int appendParagraphs( QTextParagraph *start, QTextParagraph *end );
00214 
00215     // return next and previous valid cursor positions.
00216     bool validCursorPosition( int idx );
00217     int nextCursorPosition( int idx );
00218     int previousCursorPosition( int idx );
00219 
00220 private:
00221     void checkBidi() const;
00222 
00223     QMemArray<QTextStringChar> data;
00224     QString stringCache;
00225     uint bidiDirty : 1;
00226     uint bidi : 1; // true when the paragraph has right to left characters
00227     uint rightToLeft : 1;
00228     uint dir : 5;
00229 };
00230 
00231 inline bool QTextString::isBidi() const
00232 {
00233     if ( bidiDirty )
00234         checkBidi();
00235     return bidi;
00236 }
00237 
00238 inline bool QTextString::isRightToLeft() const
00239 {
00240     if ( bidiDirty )
00241         checkBidi();
00242     return rightToLeft;
00243 }
00244 
00245 inline QString QTextString::toString() const
00246 {
00247     if(bidiDirty)
00248         checkBidi();
00249     return stringCache;
00250 }
00251 
00252 inline QChar::Direction QTextString::direction() const
00253 {
00254     return (QChar::Direction) dir;
00255 }
00256 
00257 inline int QTextString::nextCursorPosition( int next )
00258 {
00259     if ( bidiDirty )
00260         checkBidi();
00261 
00262     const QTextStringChar *c = data.data();
00263     int len = length();
00264 
00265     if ( next < len - 1 ) {
00266         next++;
00267         while ( next < len - 1 && !c[next].charStop )
00268             next++;
00269     }
00270     return next;
00271 }
00272 
00273 inline int QTextString::previousCursorPosition( int prev )
00274 {
00275     if ( bidiDirty )
00276         checkBidi();
00277 
00278     const QTextStringChar *c = data.data();
00279 
00280     if ( prev ) {
00281         prev--;
00282         while ( prev && !c[prev].charStop )
00283             prev--;
00284     }
00285     return prev;
00286 }
00287 
00288 inline bool QTextString::validCursorPosition( int idx )
00289 {
00290     if ( bidiDirty )
00291         checkBidi();
00292 
00293     return (at( idx ).charStop);
00294 }
00295 
00296 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00297 
00298 #if defined(Q_TEMPLATEDLL)
00299 // MOC_SKIP_BEGIN
00300 Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<int>;
00301 Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<QTextParagraph*>;
00302 Q_TEMPLATE_EXTERN template class Q_EXPORT QValueStack<bool>;
00303 // MOC_SKIP_END
00304 #endif
00305 
00306 class Q_EXPORT QTextCursor
00307 {
00308 public:
00309     QTextCursor( QTextDocument *d = 0 );
00310     QTextCursor( const QTextCursor &c );
00311     QTextCursor &operator=( const QTextCursor &c );
00312     virtual ~QTextCursor() {}
00313 
00314     bool operator==( const QTextCursor &c ) const;
00315     bool operator!=( const QTextCursor &c ) const { return !(*this == c); }
00316 
00317     inline QTextParagraph *paragraph() const { return para; }
00318 
00319     QTextDocument *document() const;
00320     int index() const;
00321 
00322     void gotoPosition( QTextParagraph* p, int index = 0);
00323     void setIndex( int index ) { gotoPosition(paragraph(), index ); }
00324     void setParagraph( QTextParagraph*p ) { gotoPosition(p, 0 ); }
00325 
00326     void gotoLeft();
00327     void gotoRight();
00328     void gotoNextLetter();
00329     void gotoPreviousLetter();
00330     void gotoUp();
00331     void gotoDown();
00332     void gotoLineEnd();
00333     void gotoLineStart();
00334     void gotoHome();
00335     void gotoEnd();
00336     void gotoPageUp( int visibleHeight );
00337     void gotoPageDown( int visibleHeight );
00338     void gotoNextWord( bool onlySpace = FALSE );
00339     void gotoPreviousWord( bool onlySpace = FALSE );
00340     void gotoWordLeft();
00341     void gotoWordRight();
00342 
00343     void insert( const QString &s, bool checkNewLine, QMemArray<QTextStringChar> *formatting = 0 );
00344     void splitAndInsertEmptyParagraph( bool ind = TRUE, bool updateIds = TRUE );
00345     bool remove();
00346     bool removePreviousChar();
00347     void indent();
00348 
00349     bool atParagStart();
00350     bool atParagEnd();
00351 
00352     int x() const; // x in current paragraph
00353     int y() const; // y in current paragraph
00354 
00355     int globalX() const;
00356     int globalY() const;
00357 
00358     QTextParagraph *topParagraph() const { return paras.isEmpty() ? para : paras.first(); }
00359     int offsetX() const { return ox; } // inner document  offset
00360     int offsetY() const { return oy; } // inner document offset
00361     int totalOffsetX() const; // total document offset
00362     int totalOffsetY() const; // total document offset
00363 
00364     bool place( const QPoint &pos, QTextParagraph *s ) { return place( pos, s, FALSE ); }
00365     bool place( const QPoint &pos, QTextParagraph *s, bool link );
00366     void restoreState();
00367 
00368 
00369     int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast
00370     void oneUp() { if ( !indices.isEmpty() ) pop(); }
00371     void setValid( bool b ) { valid = b; }
00372     bool isValid() const { return valid; }
00373 
00374     void fixCursorPosition();
00375 private:
00376     enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down };
00377 
00378     void push();
00379     void pop();
00380     bool processNesting( Operation op );
00381     void invalidateNested();
00382     void gotoIntoNested( const QPoint &globalPos );
00383 
00384     QTextParagraph *para;
00385     int idx, tmpX;
00386     int ox, oy;
00387     QValueStack<int> indices;
00388     QValueStack<QTextParagraph*> paras;
00389     QValueStack<int> xOffsets;
00390     QValueStack<int> yOffsets;
00391     uint valid : 1;
00392 
00393 };
00394 
00395 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00396 
00397 class Q_EXPORT QTextCommand
00398 {
00399 public:
00400     enum Commands { Invalid, Insert, Delete, Format, Style };
00401 
00402     QTextCommand( QTextDocument *d ) : doc( d ), cursor( d ) {}
00403     virtual ~QTextCommand();
00404 
00405     virtual Commands type() const;
00406 
00407     virtual QTextCursor *execute( QTextCursor *c ) = 0;
00408     virtual QTextCursor *unexecute( QTextCursor *c ) = 0;
00409 
00410 protected:
00411     QTextDocument *doc;
00412     QTextCursor cursor;
00413 
00414 };
00415 
00416 #if defined(Q_TEMPLATEDLL)
00417 // MOC_SKIP_BEGIN
00418 Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextCommand>;
00419 // MOC_SKIP_END
00420 #endif
00421 
00422 class Q_EXPORT QTextCommandHistory
00423 {
00424 public:
00425     QTextCommandHistory( int s ) : current( -1 ), steps( s ) { history.setAutoDelete( TRUE ); }
00426     virtual ~QTextCommandHistory();
00427 
00428     void clear() { history.clear(); current = -1; }
00429 
00430     void addCommand( QTextCommand *cmd );
00431     QTextCursor *undo( QTextCursor *c );
00432     QTextCursor *redo( QTextCursor *c );
00433 
00434     bool isUndoAvailable();
00435     bool isRedoAvailable();
00436 
00437     void setUndoDepth( int d ) { steps = d; }
00438     int undoDepth() const { return steps; }
00439 
00440     int historySize() const { return history.count(); }
00441     int currentPosition() const { return current; }
00442 
00443 private:
00444     QPtrList<QTextCommand> history;
00445     int current, steps;
00446 
00447 };
00448 
00449 inline QTextCommandHistory::~QTextCommandHistory()
00450 {
00451     clear();
00452 }
00453 
00454 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00455 
00456 #ifndef QT_NO_TEXTCUSTOMITEM
00457 class Q_EXPORT QTextCustomItem
00458 {
00459 public:
00460     QTextCustomItem( QTextDocument *p )
00461         :  xpos(0), ypos(-1), width(-1), height(0), parent( p )
00462     {}
00463     virtual ~QTextCustomItem();
00464     virtual void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) = 0;
00465 
00466     virtual void adjustToPainter( QPainter* );
00467 
00468     enum Placement { PlaceInline = 0, PlaceLeft, PlaceRight };
00469     virtual Placement placement() const;
00470     bool placeInline() { return placement() == PlaceInline; }
00471 
00472     virtual bool ownLine() const;
00473     virtual void resize( int nwidth );
00474     virtual void invalidate();
00475     virtual int ascent() const { return height; }
00476 
00477     virtual bool isNested() const;
00478     virtual int minimumWidth() const;
00479 
00480     virtual QString richText() const;
00481 
00482     int xpos; // used for floating items
00483     int ypos; // used for floating items
00484     int width;
00485     int height;
00486 
00487     QRect geometry() const { return QRect( xpos, ypos, width, height ); }
00488 
00489     virtual bool enter( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, bool atEnd = FALSE );
00490     virtual bool enterAt( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, const QPoint & );
00491     virtual bool next( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
00492     virtual bool prev( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
00493     virtual bool down( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
00494     virtual bool up( QTextCursor *, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
00495 
00496     virtual void setParagraph( QTextParagraph *p ) { parag = p; }
00497     QTextParagraph *paragraph() const { return parag; }
00498 
00499     QTextDocument *parent;
00500     QTextParagraph *parag;
00501 
00502     virtual void pageBreak( int  y, QTextFlow* flow );
00503 };
00504 #endif
00505 
00506 #if defined(Q_TEMPLATEDLL)
00507 // MOC_SKIP_BEGIN
00508 //Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<QString, QString>;
00509 // MOC_SKIP_END
00510 #endif
00511 
00512 #ifndef QT_NO_TEXTCUSTOMITEM
00513 class Q_EXPORT QTextImage : public QTextCustomItem
00514 {
00515 public:
00516     QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
00517                 QMimeSourceFactory &factory );
00518     virtual ~QTextImage();
00519 
00520     Placement placement() const { return place; }
00521     void adjustToPainter( QPainter* );
00522     int minimumWidth() const { return width; }
00523 
00524     QString richText() const;
00525 
00526     void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );
00527 
00528 private:
00529     QRegion* reg;
00530     QPixmap pm;
00531     Placement place;
00532     int tmpwidth, tmpheight;
00533     QMap<QString, QString> attributes;
00534     QString imgId;
00535 
00536 };
00537 #endif
00538 
00539 #ifndef QT_NO_TEXTCUSTOMITEM
00540 class Q_EXPORT QTextHorizontalLine : public QTextCustomItem
00541 {
00542 public:
00543     QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
00544                          QMimeSourceFactory &factory );
00545     virtual ~QTextHorizontalLine();
00546 
00547     void adjustToPainter( QPainter* );
00548     void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );
00549     QString richText() const;
00550 
00551     bool ownLine() const { return TRUE; }
00552 
00553 private:
00554     int tmpheight;
00555     QColor color;
00556     bool shade;
00557 
00558 };
00559 #endif
00560 
00561 #ifndef QT_NO_TEXTCUSTOMITEM
00562 #if defined(Q_TEMPLATEDLL)
00563 // MOC_SKIP_BEGIN
00564 Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextCustomItem>;
00565 // MOC_SKIP_END
00566 #endif
00567 #endif
00568 
00569 class Q_EXPORT QTextFlow
00570 {
00571     friend class QTextDocument;
00572 #ifndef QT_NO_TEXTCUSTOMITEM
00573     friend class QTextTableCell;
00574 #endif
00575 
00576 public:
00577     QTextFlow();
00578     virtual ~QTextFlow();
00579 
00580     virtual void setWidth( int width );
00581     int width() const;
00582 
00583     virtual void setPageSize( int ps );
00584     int pageSize() const { return pagesize; }
00585 
00586     virtual int adjustLMargin( int yp, int h, int margin, int space );
00587     virtual int adjustRMargin( int yp, int h, int margin, int space );
00588 
00589 #ifndef QT_NO_TEXTCUSTOMITEM
00590     virtual void registerFloatingItem( QTextCustomItem* item );
00591     virtual void unregisterFloatingItem( QTextCustomItem* item );
00592 #endif
00593     virtual QRect boundingRect() const;
00594     virtual void drawFloatingItems(QPainter* p, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );
00595 
00596     virtual int adjustFlow( int  y, int w, int h ); // adjusts y according to the defined pagesize. Returns the shift.
00597 
00598     virtual bool isEmpty();
00599 
00600     void clear();
00601 
00602 private:
00603     int w;
00604     int pagesize;
00605 
00606 #ifndef QT_NO_TEXTCUSTOMITEM
00607     QPtrList<QTextCustomItem> leftItems;
00608     QPtrList<QTextCustomItem> rightItems;
00609 #endif
00610 };
00611 
00612 inline int QTextFlow::width() const { return w; }
00613 
00614 #ifndef QT_NO_TEXTCUSTOMITEM
00615 class QTextTable;
00616 
00617 class Q_EXPORT QTextTableCell : public QLayoutItem
00618 {
00619     friend class QTextTable;
00620 
00621 public:
00622     QTextTableCell( QTextTable* table,
00623                     int row, int column,
00624                     const QMap<QString, QString> &attr,
00625                     const QStyleSheetItem* style,
00626                     const QTextFormat& fmt, const QString& context,
00627                     QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc );
00628     virtual ~QTextTableCell();
00629 
00630     QSize sizeHint() const ;
00631     QSize minimumSize() const ;
00632     QSize maximumSize() const ;
00633     QSizePolicy::ExpandData expanding() const;
00634     bool isEmpty() const;
00635     void setGeometry( const QRect& ) ;
00636     QRect geometry() const;
00637 
00638     bool hasHeightForWidth() const;
00639     int heightForWidth( int ) const;
00640 
00641     void adjustToPainter( QPainter* );
00642 
00643     int row() const { return row_; }
00644     int column() const { return col_; }
00645     int rowspan() const { return rowspan_; }
00646     int colspan() const { return colspan_; }
00647     int stretch() const { return stretch_; }
00648 
00649     QTextDocument* richText()  const { return richtext; }
00650     QTextTable* table() const { return parent; }
00651 
00652     void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected );
00653 
00654     QBrush *backGround() const { return background; }
00655     virtual void invalidate();
00656 
00657     int verticalAlignmentOffset() const;
00658     int horizontalAlignmentOffset() const;
00659 
00660 private:
00661     QRect geom;
00662     QTextTable* parent;
00663     QTextDocument* richtext;
00664     int row_;
00665     int col_;
00666     int rowspan_;
00667     int colspan_;
00668     int stretch_;
00669     int maxw;
00670     int minw;
00671     bool hasFixedWidth;
00672     QBrush *background;
00673     int cached_width;
00674     int cached_sizehint;
00675     QMap<QString, QString> attributes;
00676     int align;
00677 };
00678 #endif
00679 
00680 #if defined(Q_TEMPLATEDLL)
00681 // MOC_SKIP_BEGIN
00682 Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextTableCell>;
00683 Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<QTextCursor*, int>;
00684 // MOC_SKIP_END
00685 #endif
00686 
00687 #ifndef QT_NO_TEXTCUSTOMITEM
00688 class Q_EXPORT QTextTable: public QTextCustomItem
00689 {
00690     friend class QTextTableCell;
00691 
00692 public:
00693     QTextTable( QTextDocument *p, const QMap<QString, QString> &attr );
00694     virtual ~QTextTable();
00695 
00696     void adjustToPainter( QPainter *p );
00697     void pageBreak( int  y, QTextFlow* flow );
00698     void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch,
00699                const QColorGroup& cg, bool selected );
00700 
00701     bool noErase() const { return TRUE; }
00702     bool ownLine() const { return TRUE; }
00703     Placement placement() const { return place; }
00704     bool isNested() const { return TRUE; }
00705     void resize( int nwidth );
00706     virtual void invalidate();
00707 
00708     virtual bool enter( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, bool atEnd = FALSE );
00709     virtual bool enterAt( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy, const QPoint &pos );
00710     virtual bool next( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
00711     virtual bool prev( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
00712     virtual bool down( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
00713     virtual bool up( QTextCursor *c, QTextDocument *&doc, QTextParagraph *&parag, int &idx, int &ox, int &oy );
00714 
00715     QString richText() const;
00716 
00717     int minimumWidth() const;
00718 
00719     QPtrList<QTextTableCell> tableCells() const { return cells; }
00720 
00721     bool isStretching() const { return stretch; }
00722     void setParagraph(QTextParagraph *p);
00723 
00724 private:
00725     void format( int w );
00726     void addCell( QTextTableCell* cell );
00727 
00728 private:
00729     QGridLayout* layout;
00730     QPtrList<QTextTableCell> cells;
00731     int cachewidth;
00732     int fixwidth;
00733     int cellpadding;
00734     int cellspacing;
00735     int border;
00736     int outerborder;
00737     int stretch;
00738     int innerborder;
00739     int us_cp, us_ib, us_b, us_ob, us_cs;
00740     int us_fixwidth;
00741     QMap<QString, QString> attributes;
00742     QMap<QTextCursor*, int> currCell;
00743     Placement place;
00744     void adjustCells( int y , int shift );
00745     int pageBreakFor;
00746 };
00747 #endif
00748 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00749 
00750 #ifndef QT_NO_TEXTCUSTOMITEM
00751 class QTextTableCell;
00752 class QTextParagraph;
00753 #endif
00754 
00755 struct Q_EXPORT QTextDocumentSelection
00756 {
00757     QTextCursor startCursor, endCursor;
00758     bool swapped;
00759     Q_DUMMY_COMPARISON_OPERATOR(QTextDocumentSelection)
00760 };
00761 
00762 #if defined(Q_TEMPLATEDLL)
00763 // MOC_SKIP_BEGIN
00764 Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QColor>;
00765 //Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, bool>;
00766 Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextDocumentSelection>;
00767 Q_TEMPLATE_EXTERN template class Q_EXPORT QPtrList<QTextDocument>;
00768 // MOC_SKIP_END
00769 #endif
00770 
00771 class Q_EXPORT QTextDocument : public QObject
00772 {
00773     Q_OBJECT
00774 
00775 #ifndef QT_NO_TEXTCUSTOMITEM
00776     friend class QTextTableCell;
00777 #endif
00778     friend class QTextCursor;
00779     friend class QTextEdit;
00780     friend class QTextParagraph;
00781     friend class QTextTable;
00782 
00783 public:
00784     enum SelectionIds {
00785         Standard = 0,
00786         IMSelectionText         = 31998,
00787         IMCompositionText       = 31999, // this must be higher!
00788         Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to
00789         // remove multiple lines with removeSelectedText()
00790     };
00791 
00792     QTextDocument( QTextDocument *p );
00793     virtual ~QTextDocument();
00794 
00795     QTextDocument *parent() const { return par; }
00796     QTextParagraph *parentParagraph() const { return parentPar; }
00797 
00798     void setText( const QString &text, const QString &context );
00799     QMap<QString, QString> attributes() const { return attribs; }
00800     void setAttributes( const QMap<QString, QString> &attr ) { attribs = attr; }
00801 
00802     QString text() const;
00803     QString text( int parag ) const;
00804     QString originalText() const;
00805 
00806     int x() const;
00807     int y() const;
00808     int width() const;
00809     int widthUsed() const;
00810     int visibleWidth() const;
00811     int height() const;
00812     void setWidth( int w );
00813     int minimumWidth() const;
00814     bool setMinimumWidth( int needed, int used = -1, QTextParagraph *parag = 0 );
00815 
00816     void setY( int y );
00817     int leftMargin() const;
00818     void setLeftMargin( int lm );
00819     int rightMargin() const;
00820     void setRightMargin( int rm );
00821 
00822     QTextParagraph *firstParagraph() const;
00823     QTextParagraph *lastParagraph() const;
00824     void setFirstParagraph( QTextParagraph *p );
00825     void setLastParagraph( QTextParagraph *p );
00826 
00827     void invalidate();
00828 
00829     void setPreProcessor( QTextPreProcessor *sh );
00830     QTextPreProcessor *preProcessor() const;
00831 
00832     void setFormatter( QTextFormatter *f );
00833     QTextFormatter *formatter() const;
00834 
00835     void setIndent( QTextIndent *i );
00836     QTextIndent *indent() const;
00837 
00838     QColor selectionColor( int id ) const;
00839     bool invertSelectionText( int id ) const;
00840     void setSelectionColor( int id, const QColor &c );
00841     void setInvertSelectionText( int id, bool b );
00842     bool hasSelection( int id, bool visible = FALSE ) const;
00843     void setSelectionStart( int id, const QTextCursor &cursor );
00844     bool setSelectionEnd( int id, const QTextCursor &cursor );
00845     void selectAll( int id );
00846     bool removeSelection( int id );
00847     void selectionStart( int id, int &paragId, int &index );
00848     QTextCursor selectionStartCursor( int id );
00849     QTextCursor selectionEndCursor( int id );
00850     void selectionEnd( int id, int &paragId, int &index );
00851     void setFormat( int id, QTextFormat *f, int flags );
00852     int numSelections() const { return nSelections; }
00853     void addSelection( int id );
00854 
00855     QString selectedText( int id, bool asRichText = FALSE ) const;
00856     void removeSelectedText( int id, QTextCursor *cursor );
00857     void indentSelection( int id );
00858 
00859     QTextParagraph *paragAt( int i ) const;
00860 
00861     void addCommand( QTextCommand *cmd );
00862     QTextCursor *undo( QTextCursor *c = 0 );
00863     QTextCursor *redo( QTextCursor *c  = 0 );
00864     QTextCommandHistory *commands() const { return commandHistory; }
00865 
00866     QTextFormatCollection *formatCollection() const;
00867 
00868     bool find( QTextCursor &cursor, const QString &expr, bool cs, bool wo, bool forward);
00869 
00870     void setTextFormat( Qt::TextFormat f );
00871     Qt::TextFormat textFormat() const;
00872 
00873     bool inSelection( int selId, const QPoint &pos ) const;
00874 
00875     QStyleSheet *styleSheet() const { return sheet_; }
00876 #ifndef QT_NO_MIME
00877     QMimeSourceFactory *mimeSourceFactory() const { return factory_; }
00878 #endif
00879     QString context() const { return contxt; }
00880 
00881     void setStyleSheet( QStyleSheet *s );
00882     void setDefaultFormat( const QFont &font, const QColor &color );
00883 #ifndef QT_NO_MIME
00884     void setMimeSourceFactory( QMimeSourceFactory *f ) { if ( f ) factory_ = f; }
00885 #endif
00886     void setContext( const QString &c ) { if ( !c.isEmpty() ) contxt = c; }
00887 
00888     void setUnderlineLinks( bool b );
00889     bool underlineLinks() const { return underlLinks; }
00890 
00891     void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; }
00892     QBrush *paper() const { return backBrush; }
00893 
00894     void doLayout( QPainter *p, int w );
00895     void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 );
00896     bool useDoubleBuffer( QTextParagraph *parag, QPainter *p );
00897 
00898     void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch,
00899                     QPixmap *&doubleBuffer, const QColorGroup &cg,
00900                     bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE );
00901     QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg,
00902                       bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0,
00903                       bool resetChanged = TRUE );
00904 
00905 #ifndef QT_NO_TEXTCUSTOMITEM
00906     void registerCustomItem( QTextCustomItem *i, QTextParagraph *p );
00907     void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p );
00908 #endif
00909 
00910     void setFlow( QTextFlow *f );
00911     void takeFlow();
00912     QTextFlow *flow() const { return flow_; }
00913     bool isPageBreakEnabled() const { return pages; }
00914     void setPageBreakEnabled( bool b ) { pages = b; }
00915 
00916     void setUseFormatCollection( bool b ) { useFC = b; }
00917     bool useFormatCollection() const { return useFC; }
00918 
00919 #ifndef QT_NO_TEXTCUSTOMITEM
00920     QTextTableCell *tableCell() const { return tc; }
00921     void setTableCell( QTextTableCell *c ) { tc = c; }
00922 #endif
00923 
00924     void setPlainText( const QString &text );
00925     void setRichText( const QString &text, const QString &context, const QTextFormat *initialFormat = 0 );
00926     QString richText() const;
00927     QString plainText() const;
00928 
00929     bool focusNextPrevChild( bool next );
00930 
00931     int alignment() const;
00932     void setAlignment( int a );
00933 
00934     int *tabArray() const;
00935     int tabStopWidth() const;
00936     void setTabArray( int *a );
00937     void setTabStops( int tw );
00938 
00939     void setUndoDepth( int d ) { commandHistory->setUndoDepth( d ); }
00940     int undoDepth() const { return commandHistory->undoDepth(); }
00941 
00942     int length() const;
00943     void clear( bool createEmptyParag = FALSE );
00944 
00945     virtual QTextParagraph *createParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE );
00946     void insertChild( QObject *o ) { QObject::insertChild( o ); }
00947     void removeChild( QObject *o ) { QObject::removeChild( o ); }
00948     void insertChild( QTextDocument *d ) { childList.append( d ); }
00949     void removeChild( QTextDocument *d ) { childList.removeRef( d ); }
00950     QPtrList<QTextDocument> children() const { return childList; }
00951 
00952     bool hasFocusParagraph() const;
00953     QString focusHref() const;
00954     QString focusName() const;
00955 
00956     void invalidateOriginalText() { oTextValid = FALSE; oText = ""; }
00957 
00958 signals:
00959     void minimumWidthChanged( int );
00960 
00961 private:
00962     void init();
00963     QPixmap *bufferPixmap( const QSize &s );
00964     // HTML parser
00965     bool hasPrefix(const QChar* doc, int length, int pos, QChar c);
00966     bool hasPrefix(const QChar* doc, int length, int pos, const QString& s);
00967 #ifndef QT_NO_TEXTCUSTOMITEM
00968     QTextCustomItem* parseTable( const QMap<QString, QString> &attr, const QTextFormat &fmt,
00969                                  const QChar* doc, int length, int& pos, QTextParagraph *curpar );
00970 #endif
00971     bool eatSpace(const QChar* doc, int length, int& pos, bool includeNbsp = FALSE );
00972     bool eat(const QChar* doc, int length, int& pos, QChar c);
00973     QString parseOpenTag(const QChar* doc, int length, int& pos, QMap<QString, QString> &attr, bool& emptyTag);
00974     QString parseCloseTag( const QChar* doc, int length, int& pos );
00975     QChar parseHTMLSpecialChar(const QChar* doc, int length, int& pos);
00976     QString parseWord(const QChar* doc, int length, int& pos, bool lower = TRUE);
00977     QChar parseChar(const QChar* doc, int length, int& pos, QStyleSheetItem::WhiteSpaceMode wsm );
00978     void setRichTextInternal( const QString &text, QTextCursor* cursor = 0, const QTextFormat *initialFormat = 0 );
00979     void setRichTextMarginsInternal( QPtrList< QPtrVector<QStyleSheetItem> >& styles, QTextParagraph* stylesPar );
00980 
00981 private:
00982     struct Q_EXPORT Focus {
00983         QTextParagraph *parag;
00984         int start, len;
00985         QString href;
00986         QString name;
00987     };
00988 
00989     int cx, cy, cw, vw;
00990     QTextParagraph *fParag, *lParag;
00991     QTextPreProcessor *pProcessor;
00992     QMap<int, QColor> selectionColors;
00993     QMap<int, QTextDocumentSelection> selections;
00994     QMap<int, bool> selectionText;
00995     QTextCommandHistory *commandHistory;
00996     QTextFormatter *pFormatter;
00997     QTextIndent *indenter;
00998     QTextFormatCollection *fCollection;
00999     Qt::TextFormat txtFormat;
01000     uint preferRichText : 1;
01001     uint pages : 1;
01002     uint useFC : 1;
01003     uint withoutDoubleBuffer : 1;
01004     uint underlLinks : 1;
01005     uint nextDoubleBuffered : 1;
01006     uint oTextValid : 1;
01007     uint mightHaveCustomItems : 1;
01008     int align;
01009     int nSelections;
01010     QTextFlow *flow_;
01011     QTextDocument *par;
01012     QTextParagraph *parentPar;
01013 #ifndef QT_NO_TEXTCUSTOMITEM
01014     QTextTableCell *tc;
01015 #endif
01016     QBrush *backBrush;
01017     QPixmap *buf_pixmap;
01018     Focus focusIndicator;
01019     int minw;
01020     int wused;
01021     int leftmargin;
01022     int rightmargin;
01023     QTextParagraph *minwParag, *curParag;
01024     QStyleSheet* sheet_;
01025 #ifndef QT_NO_MIME
01026     QMimeSourceFactory* factory_;
01027 #endif
01028     QString contxt;
01029     QMap<QString, QString> attribs;
01030     int *tArray;
01031     int tStopWidth;
01032     int uDepth;
01033     QString oText;
01034     QPtrList<QTextDocument> childList;
01035     QColor linkColor, bodyText;
01036     double scaleFontsFactor;
01037 
01038     short list_tm,list_bm, list_lm, li_tm, li_bm, par_tm, par_bm;
01039 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
01040     QTextDocument( const QTextDocument & );
01041     QTextDocument &operator=( const QTextDocument & );
01042 #endif
01043 };
01044 
01045 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01046 
01047 
01048 class Q_EXPORT QTextDeleteCommand : public QTextCommand
01049 {
01050 public:
01051     QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str,
01052                         const QByteArray& oldStyle );
01053     QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str );
01054     virtual ~QTextDeleteCommand();
01055 
01056     Commands type() const { return Delete; }
01057     QTextCursor *execute( QTextCursor *c );
01058     QTextCursor *unexecute( QTextCursor *c );
01059 
01060 protected:
01061     int id, index;
01062     QTextParagraph *parag;
01063     QMemArray<QTextStringChar> text;
01064     QByteArray styleInformation;
01065 
01066 };
01067 
01068 class Q_EXPORT QTextInsertCommand : public QTextDeleteCommand
01069 {
01070 public:
01071     QTextInsertCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str,
01072                         const QByteArray& oldStyleInfo )
01073         : QTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {}
01074     QTextInsertCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str )
01075         : QTextDeleteCommand( p, idx, str ) {}
01076     virtual ~QTextInsertCommand() {}
01077 
01078     Commands type() const { return Insert; }
01079     QTextCursor *execute( QTextCursor *c ) { return QTextDeleteCommand::unexecute( c ); }
01080     QTextCursor *unexecute( QTextCursor *c ) { return QTextDeleteCommand::execute( c ); }
01081 
01082 };
01083 
01084 class Q_EXPORT QTextFormatCommand : public QTextCommand
01085 {
01086 public:
01087     QTextFormatCommand( QTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<QTextStringChar> &old, QTextFormat *f, int fl );
01088     virtual ~QTextFormatCommand();
01089 
01090     Commands type() const { return Format; }
01091     QTextCursor *execute( QTextCursor *c );
01092     QTextCursor *unexecute( QTextCursor *c );
01093 
01094 protected:
01095     int startId, startIndex, endId, endIndex;
01096     QTextFormat *format;
01097     QMemArray<QTextStringChar> oldFormats;
01098     int flags;
01099 
01100 };
01101 
01102 class Q_EXPORT QTextStyleCommand : public QTextCommand
01103 {
01104 public:
01105     QTextStyleCommand( QTextDocument *d, int fParag, int lParag, const QByteArray& beforeChange  );
01106     virtual ~QTextStyleCommand() {}
01107 
01108     Commands type() const { return Style; }
01109     QTextCursor *execute( QTextCursor *c );
01110     QTextCursor *unexecute( QTextCursor *c );
01111 
01112     static QByteArray readStyleInformation(  QTextDocument* d, int fParag, int lParag );
01113     static void writeStyleInformation(  QTextDocument* d, int fParag, const QByteArray& style );
01114 
01115 private:
01116     int firstParag, lastParag;
01117     QByteArray before;
01118     QByteArray after;
01119 };
01120 
01121 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01122 
01123 struct Q_EXPORT QTextParagraphSelection
01124 {
01125     QTextParagraphSelection() : start(0), end(0) { }
01126     int start, end;
01127     Q_DUMMY_COMPARISON_OPERATOR(QTextParagraphSelection)
01128 };
01129 
01130 struct Q_EXPORT QTextLineStart
01131 {
01132     QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 )
01133     {  }
01134     QTextLineStart( int y_, int bl, int h_ ) : y( y_ ), baseLine( bl ), h( h_ ),
01135         w( 0 )
01136     {  }
01137 
01138 public:
01139     int y, baseLine, h;
01140     int w;
01141 };
01142 
01143 #if defined(Q_TEMPLATEDLL)
01144 // MOC_SKIP_BEGIN
01145 Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextParagraphSelection>;
01146 Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<int, QTextLineStart*>;
01147 // MOC_SKIP_END
01148 #endif
01149 
01150 class Q_EXPORT QTextParagraphData
01151 {
01152 public:
01153     QTextParagraphData() {}
01154     virtual ~QTextParagraphData();
01155     virtual void join( QTextParagraphData * );
01156 };
01157 
01158 class QTextParagraphPseudoDocument;
01159 
01160 class QSyntaxHighlighter;
01161 
01162 class Q_EXPORT QTextParagraph
01163 {
01164     friend class QTextDocument;
01165     friend class QTextCursor;
01166     friend class QSyntaxHighlighter;
01167 
01168 public:
01169     QTextParagraph( QTextDocument *d, QTextParagraph *pr = 0, QTextParagraph *nx = 0, bool updateIds = TRUE );
01170     ~QTextParagraph();
01171 
01172     QTextString *string() const;
01173     QTextStringChar *at( int i ) const; // maybe remove later
01174     int leftGap() const;
01175     int length() const; // maybe remove later
01176 
01177     void setListStyle( QStyleSheetItem::ListStyle ls ) { lstyle = ls; changed = TRUE; }
01178     QStyleSheetItem::ListStyle listStyle() const { return (QStyleSheetItem::ListStyle)lstyle; }
01179     void setListItem( bool li );
01180     bool isListItem() const { return litem; }
01181     void setListValue( int v ) { list_val = v; }
01182     int listValue() const { return list_val > 0 ? list_val : -1; }
01183 
01184     void setListDepth( int depth );
01185     int listDepth() const { return ldepth; }
01186 
01187 //     void setFormat( QTextFormat *fm );
01188 //     QTextFormat *paragFormat() const;
01189 
01190     inline QTextDocument *document() const {
01191         if (hasdoc) return (QTextDocument*) docOrPseudo;
01192         return 0;
01193     }
01194     QTextParagraphPseudoDocument *pseudoDocument() const;
01195 
01196     QRect rect() const;
01197     void setHeight( int h ) { r.setHeight( h ); }
01198     void show();
01199     void hide();
01200     bool isVisible() const { return visible; }
01201 
01202     QTextParagraph *prev() const;
01203     QTextParagraph *next() const;
01204     void setPrev( QTextParagraph *s );
01205     void setNext( QTextParagraph *s );
01206 
01207     void insert( int index, const QString &s );
01208     void insert( int index, const QChar *unicode, int len );
01209     void append( const QString &s, bool reallyAtEnd = FALSE );
01210     void truncate( int index );
01211     void remove( int index, int len );
01212     void join( QTextParagraph *s );
01213 
01214     void invalidate( int chr );
01215 
01216     void move( int &dy );
01217     void format( int start = -1, bool doMove = TRUE );
01218 
01219     bool isValid() const;
01220     bool hasChanged() const;
01221     void setChanged( bool b, bool recursive = FALSE );
01222 
01223     int lineHeightOfChar( int i, int *bl = 0, int *y = 0 ) const;
01224     QTextStringChar *lineStartOfChar( int i, int *index = 0, int *line = 0 ) const;
01225     int lines() const;
01226     QTextStringChar *lineStartOfLine( int line, int *index = 0 ) const;
01227     int lineY( int l ) const;
01228     int lineBaseLine( int l ) const;
01229     int lineHeight( int l ) const;
01230     void lineInfo( int l, int &y, int &h, int &bl ) const;
01231 
01232     void setSelection( int id, int start, int end );
01233     void removeSelection( int id );
01234     int selectionStart( int id ) const;
01235     int selectionEnd( int id ) const;
01236     bool hasSelection( int id ) const;
01237     bool hasAnySelection() const;
01238     bool fullSelected( int id ) const;
01239 
01240     void setEndState( int s );
01241     int endState() const;
01242 
01243     void setParagId( int i );
01244     int paragId() const;
01245 
01246     bool firstPreProcess() const;
01247     void setFirstPreProcess( bool b );
01248 
01249     void indent( int *oldIndent = 0, int *newIndent = 0 );
01250 
01251     void setExtraData( QTextParagraphData *data );
01252     QTextParagraphData *extraData() const;
01253 
01254     QMap<int, QTextLineStart*> &lineStartList();
01255 
01256     void setFormat( int index, int len, QTextFormat *f, bool useCollection = TRUE, int flags = -1 );
01257 
01258     void setAlignment( int a );
01259     int alignment() const;
01260 
01261     void paint( QPainter &painter, const QColorGroup &cg, QTextCursor *cursor = 0, bool drawSelections = FALSE,
01262                         int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 );
01263 
01264     int topMargin() const;
01265     int bottomMargin() const;
01266     int leftMargin() const;
01267     int firstLineMargin() const;
01268     int rightMargin() const;
01269     int lineSpacing() const;
01270 
01271 #ifndef QT_NO_TEXTCUSTOMITEM
01272     void registerFloatingItem( QTextCustomItem *i );
01273     void unregisterFloatingItem( QTextCustomItem *i );
01274 #endif
01275 
01276     void setFullWidth( bool b ) { fullWidth = b; }
01277     bool isFullWidth() const { return fullWidth; }
01278 
01279 #ifndef QT_NO_TEXTCUSTOMITEM
01280     QTextTableCell *tableCell() const;
01281 #endif
01282 
01283     QBrush *background() const;
01284 
01285     int documentWidth() const;
01286     int documentVisibleWidth() const;
01287     int documentX() const;
01288     int documentY() const;
01289     QTextFormatCollection *formatCollection() const;
01290     QTextFormatter *formatter() const;
01291 
01292     int nextTab( int i, int x );
01293     int *tabArray() const;
01294     void setTabArray( int *a );
01295     void setTabStops( int tw );
01296 
01297     void adjustToPainter( QPainter *p );
01298 
01299     void setNewLinesAllowed( bool b );
01300     bool isNewLinesAllowed() const;
01301 
01302     QString richText() const;
01303 
01304     void addCommand( QTextCommand *cmd );
01305     QTextCursor *undo( QTextCursor *c = 0 );
01306     QTextCursor *redo( QTextCursor *c  = 0 );
01307     QTextCommandHistory *commands() const;
01308     void copyParagData( QTextParagraph *parag );
01309 
01310     void setBreakable( bool b ) { breakable = b; }
01311     bool isBreakable() const { return breakable; }
01312 
01313     void setBackgroundColor( const QColor &c );
01314     QColor *backgroundColor() const { return bgcol; }
01315     void clearBackgroundColor();
01316 
01317     void setMovedDown( bool b ) { movedDown = b; }
01318     bool wasMovedDown() const { return movedDown; }
01319 
01320     void setDirection( QChar::Direction d );
01321     QChar::Direction direction() const;
01322     void setPaintDevice( QPaintDevice *pd ) { paintdevice = pd; }
01323 
01324     void readStyleInformation( QDataStream& stream );
01325     void writeStyleInformation( QDataStream& stream ) const;
01326 
01327 protected:
01328     void setColorForSelection( QColor &c, QPainter &p, const QColorGroup& cg, int selection );
01329     void drawLabel( QPainter* p, int x, int y, int w, int h, int base, const QColorGroup& cg );
01330     void drawString( QPainter &painter, const QString &str, int start, int len, int xstart,
01331                              int y, int baseLine, int w, int h, bool drawSelections, int fullSelectionWidth,
01332                              QTextStringChar *formatChar, const QColorGroup& cg,
01333                              bool rightToLeft );
01334 
01335 private:
01336     QMap<int, QTextParagraphSelection> &selections() const;
01337 #ifndef QT_NO_TEXTCUSTOMITEM
01338     QPtrList<QTextCustomItem> &floatingItems() const;
01339 #endif
01340     QBrush backgroundBrush( const QColorGroup&cg ) { if ( bgcol ) return *bgcol; return cg.brush( QColorGroup::Base ); }
01341     void invalidateStyleCache();
01342 
01343     QMap<int, QTextLineStart*> lineStarts;
01344     QRect r;
01345     QTextParagraph *p, *n;
01346     void *docOrPseudo;
01347     uint changed : 1;
01348     uint firstFormat : 1;
01349     uint firstPProcess : 1;
01350     uint needPreProcess : 1;
01351     uint fullWidth : 1;
01352     uint lastInFrame : 1;
01353     uint visible : 1;
01354     uint breakable : 1;
01355     uint movedDown : 1;
01356     uint mightHaveCustomItems : 1;
01357     uint hasdoc : 1;
01358     uint litem : 1; // whether the paragraph is a list item
01359     uint rtext : 1; // whether the paragraph needs rich text margin
01360     int align : 4;
01361     uint /*QStyleSheetItem::ListStyle*/ lstyle : 4;
01362     int invalid;
01363     int state, id;
01364     QTextString *str;
01365     QMap<int, QTextParagraphSelection> *mSelections;
01366 #ifndef QT_NO_TEXTCUSTOMITEM
01367     QPtrList<QTextCustomItem> *mFloatingItems;
01368 #endif
01369     short utm, ubm, ulm, urm, uflm, ulinespacing;
01370     short tabStopWidth;
01371     int minwidth;
01372     int *tArray;
01373     QTextParagraphData *eData;
01374     short list_val;
01375     ushort ldepth;
01376     QColor *bgcol;
01377     QPaintDevice *paintdevice;
01378 };
01379 
01380 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01381 
01382 class Q_EXPORT QTextFormatter
01383 {
01384 public:
01385     QTextFormatter();
01386     virtual ~QTextFormatter();
01387 
01388     virtual int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts ) = 0;
01389     virtual int formatVertically( QTextDocument* doc, QTextParagraph* parag );
01390 
01391     bool isWrapEnabled( QTextParagraph *p ) const { if ( !wrapEnabled ) return FALSE; if ( p && !p->isBreakable() ) return FALSE; return TRUE;}
01392     int wrapAtColumn() const { return wrapColumn;}
01393     virtual void setWrapEnabled( bool b );
01394     virtual void setWrapAtColumn( int c );
01395     virtual void setAllowBreakInWords( bool b ) { biw = b; }
01396     bool allowBreakInWords() const { return biw; }
01397 
01398     int minimumWidth() const { return thisminw; }
01399     int widthUsed() const { return thiswused; }
01400 
01401 protected:
01402     virtual QTextLineStart *formatLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start,
01403                                                QTextStringChar *last, int align = Qt::AlignAuto, int space = 0 );
01404 #ifndef QT_NO_COMPLEXTEXT
01405     virtual QTextLineStart *bidiReorderLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start,
01406                                                     QTextStringChar *last, int align, int space );
01407 #endif
01408     void insertLineStart( QTextParagraph *parag, int index, QTextLineStart *ls );
01409 
01410     int thisminw;
01411     int thiswused;
01412 
01413 private:
01414     bool wrapEnabled;
01415     int wrapColumn;
01416     bool biw;
01417 
01418 #ifdef HAVE_THAI_BREAKS
01419     static QCString *thaiCache;
01420     static QTextString *cachedString;
01421     static ThBreakIterator *thaiIt;
01422 #endif
01423 };
01424 
01425 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01426 
01427 class Q_EXPORT QTextFormatterBreakInWords : public QTextFormatter
01428 {
01429 public:
01430     QTextFormatterBreakInWords();
01431     virtual ~QTextFormatterBreakInWords() {}
01432 
01433     int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts );
01434 
01435 };
01436 
01437 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01438 
01439 class Q_EXPORT QTextFormatterBreakWords : public QTextFormatter
01440 {
01441 public:
01442     QTextFormatterBreakWords();
01443     virtual ~QTextFormatterBreakWords() {}
01444 
01445     int format( QTextDocument *doc, QTextParagraph *parag, int start, const QMap<int, QTextLineStart*> &oldLineStarts );
01446 
01447 };
01448 
01449 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01450 
01451 class Q_EXPORT QTextIndent
01452 {
01453 public:
01454     QTextIndent();
01455     virtual ~QTextIndent() {}
01456 
01457     virtual void indent( QTextDocument *doc, QTextParagraph *parag, int *oldIndent = 0, int *newIndent = 0 ) = 0;
01458 
01459 };
01460 
01461 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01462 
01463 class Q_EXPORT QTextPreProcessor
01464 {
01465 public:
01466     enum Ids {
01467         Standard = 0
01468     };
01469 
01470     QTextPreProcessor();
01471     virtual ~QTextPreProcessor() {}
01472 
01473     virtual void process( QTextDocument *doc, QTextParagraph *, int, bool = TRUE ) = 0;
01474     virtual QTextFormat *format( int id ) = 0;
01475 
01476 };
01477 
01478 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01479 
01480 class Q_EXPORT QTextFormat
01481 {
01482     friend class QTextFormatCollection;
01483     friend class QTextDocument;
01484 
01485 public:
01486     enum Flags {
01487         NoFlags,
01488         Bold = 1,
01489         Italic = 2,
01490         Underline = 4,
01491         Family = 8,
01492         Size = 16,
01493         Color = 32,
01494         Misspelled = 64,
01495         VAlign = 128,
01496         StrikeOut= 256,
01497         Font = Bold | Italic | Underline | Family | Size | StrikeOut,
01498         Format = Font | Color | Misspelled | VAlign
01499     };
01500 
01501     enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript };
01502 
01503     QTextFormat();
01504     virtual ~QTextFormat();
01505 
01506     QTextFormat( const QStyleSheetItem *s );
01507     QTextFormat( const QFont &f, const QColor &c, QTextFormatCollection *parent = 0 );
01508     QTextFormat( const QTextFormat &fm );
01509     QTextFormat makeTextFormat( const QStyleSheetItem *style, const QMap<QString,QString>& attr, double scaleFontsFactor ) const;
01510     QTextFormat& operator=( const QTextFormat &fm );
01511     QColor color() const;
01512     QFont font() const;
01513     QFontMetrics fontMetrics() const { return fm; }
01514     bool isMisspelled() const;
01515     VerticalAlignment vAlign() const;
01516     int minLeftBearing() const;
01517     int minRightBearing() const;
01518     int width( const QChar &c ) const;
01519     int width( const QString &str, int pos ) const;
01520     int height() const;
01521     int ascent() const;
01522     int descent() const;
01523     int leading() const;
01524     bool useLinkColor() const;
01525 
01526     void setBold( bool b );
01527     void setItalic( bool b );
01528     void setUnderline( bool b );
01529     void setStrikeOut( bool b );
01530     void setFamily( const QString &f );
01531     void setPointSize( int s );
01532     void setFont( const QFont &f );
01533     void setColor( const QColor &c );
01534     void setMisspelled( bool b );
01535     void setVAlign( VerticalAlignment a );
01536 
01537     bool operator==( const QTextFormat &f ) const;
01538     QTextFormatCollection *parent() const;
01539     const QString &key() const;
01540 
01541     static QString getKey( const QFont &f, const QColor &c, bool misspelled, VerticalAlignment vAlign );
01542 
01543     void addRef();
01544     void removeRef();
01545 
01546     QString makeFormatChangeTags( QTextFormat* defaultFormat, QTextFormat *f, const QString& oldAnchorHref, const QString& anchorHref ) const;
01547     QString makeFormatEndTags( QTextFormat* defaultFormat, const QString& anchorHref ) const;
01548 
01549     static void setPainter( QPainter *p );
01550     static QPainter* painter();
01551 
01552     bool fontSizesInPixels() { return usePixelSizes; }
01553 
01554 protected:
01555     virtual void generateKey();
01556 
01557 private:
01558     void update();
01559     static void applyFont( const QFont &f );
01560 
01561 private:
01562     QFont fn;
01563     QColor col;
01564     QFontMetrics fm;
01565     uint missp : 1;
01566     uint linkColor : 1;
01567     uint usePixelSizes : 1;
01568     int leftBearing, rightBearing;
01569     VerticalAlignment ha;
01570     uchar widths[ 256 ];
01571     int hei, asc, dsc;
01572     QTextFormatCollection *collection;
01573     int ref;
01574     QString k;
01575     int logicalFontSize;
01576     int stdSize;
01577     static QPainter *pntr;
01578     static QFontMetrics *pntr_fm;
01579     static int pntr_asc;
01580     static int pntr_hei;
01581     static int pntr_ldg;
01582     static int pntr_dsc;
01583 
01584 };
01585 
01586 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01587 
01588 #if defined(Q_TEMPLATEDLL)
01589 // MOC_SKIP_BEGIN
01590 Q_TEMPLATE_EXTERN template class Q_EXPORT QDict<QTextFormat>;
01591 // MOC_SKIP_END
01592 #endif
01593 
01594 class Q_EXPORT QTextFormatCollection
01595 {
01596     friend class QTextDocument;
01597     friend class QTextFormat;
01598 
01599 public:
01600     QTextFormatCollection();
01601     virtual ~QTextFormatCollection();
01602 
01603     void setDefaultFormat( QTextFormat *f );
01604     QTextFormat *defaultFormat() const;
01605     virtual QTextFormat *format( QTextFormat *f );
01606     virtual QTextFormat *format( QTextFormat *of, QTextFormat *nf, int flags );
01607     virtual QTextFormat *format( const QFont &f, const QColor &c );
01608     virtual void remove( QTextFormat *f );
01609     virtual QTextFormat *createFormat( const QTextFormat &f ) { return new QTextFormat( f ); }
01610     virtual QTextFormat *createFormat( const QFont &f, const QColor &c ) { return new QTextFormat( f, c, this ); }
01611 
01612     void updateDefaultFormat( const QFont &font, const QColor &c, QStyleSheet *sheet );
01613 
01614     QPaintDevice *paintDevice() const { return paintdevice; }
01615     void setPaintDevice( QPaintDevice * );
01616 
01617 private:
01618     void updateKeys();
01619 
01620 private:
01621     QTextFormat *defFormat, *lastFormat, *cachedFormat;
01622     QDict<QTextFormat> cKey;
01623     QTextFormat *cres;
01624     QFont cfont;
01625     QColor ccol;
01626     QString kof, knf;
01627     int cflags;
01628 
01629     QPaintDevice *paintdevice;
01630 };
01631 
01632 class Q_EXPORT QTextParagraphPseudoDocument
01633 {
01634 public:
01635     QTextParagraphPseudoDocument();
01636     ~QTextParagraphPseudoDocument();
01637     QRect docRect;
01638     QTextFormatter *pFormatter;
01639     QTextCommandHistory *commandHistory;
01640     int minw;
01641     int wused;
01642     QTextFormatCollection collection;
01643 };
01644 
01645 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01646 
01647 inline int QTextParagraph::length() const
01648 {
01649     return str->length();
01650 }
01651 
01652 inline QRect QTextParagraph::rect() const
01653 {
01654     return r;
01655 }
01656 
01657 inline int QTextCursor::index() const
01658 {
01659     return idx;
01660 }
01661 
01662 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01663 
01664 inline int QTextDocument::x() const
01665 {
01666     return cx;
01667 }
01668 
01669 inline int QTextDocument::y() const
01670 {
01671     return cy;
01672 }
01673 
01674 inline int QTextDocument::width() const
01675 {
01676     return QMAX( cw, flow_->width() );
01677 }
01678 
01679 inline int QTextDocument::visibleWidth() const
01680 {
01681     return vw;
01682 }
01683 
01684 inline QTextParagraph *QTextDocument::firstParagraph() const
01685 {
01686     return fParag;
01687 }
01688 
01689 inline QTextParagraph *QTextDocument::lastParagraph() const
01690 {
01691     return lParag;
01692 }
01693 
01694 inline void QTextDocument::setFirstParagraph( QTextParagraph *p )
01695 {
01696     fParag = p;
01697 }
01698 
01699 inline void QTextDocument::setLastParagraph( QTextParagraph *p )
01700 {
01701     lParag = p;
01702 }
01703 
01704 inline void QTextDocument::setWidth( int w )
01705 {
01706     cw = QMAX( w, minw );
01707     flow_->setWidth( cw );
01708     vw = w;
01709 }
01710 
01711 inline int QTextDocument::minimumWidth() const
01712 {
01713     return minw;
01714 }
01715 
01716 inline void QTextDocument::setY( int y )
01717 {
01718     cy = y;
01719 }
01720 
01721 inline int QTextDocument::leftMargin() const
01722 {
01723     return leftmargin;
01724 }
01725 
01726 inline void QTextDocument::setLeftMargin( int lm )
01727 {
01728     leftmargin = lm;
01729 }
01730 
01731 inline int QTextDocument::rightMargin() const
01732 {
01733     return rightmargin;
01734 }
01735 
01736 inline void QTextDocument::setRightMargin( int rm )
01737 {
01738     rightmargin = rm;
01739 }
01740 
01741 inline QTextPreProcessor *QTextDocument::preProcessor() const
01742 {
01743     return pProcessor;
01744 }
01745 
01746 inline void QTextDocument::setPreProcessor( QTextPreProcessor * sh )
01747 {
01748     pProcessor = sh;
01749 }
01750 
01751 inline void QTextDocument::setFormatter( QTextFormatter *f )
01752 {
01753     delete pFormatter;
01754     pFormatter = f;
01755 }
01756 
01757 inline QTextFormatter *QTextDocument::formatter() const
01758 {
01759     return pFormatter;
01760 }
01761 
01762 inline void QTextDocument::setIndent( QTextIndent *i )
01763 {
01764     indenter = i;
01765 }
01766 
01767 inline QTextIndent *QTextDocument::indent() const
01768 {
01769     return indenter;
01770 }
01771 
01772 inline QColor QTextDocument::selectionColor( int id ) const
01773 {
01774     return selectionColors[ id ];
01775 }
01776 
01777 inline bool QTextDocument::invertSelectionText( int id ) const
01778 {
01779     return selectionText[ id ];
01780 }
01781 
01782 inline void QTextDocument::setSelectionColor( int id, const QColor &c )
01783 {
01784     selectionColors[ id ] = c;
01785 }
01786 
01787 inline void QTextDocument::setInvertSelectionText( int id, bool b )
01788 {
01789     selectionText[ id ] = b;
01790 }
01791 
01792 inline QTextFormatCollection *QTextDocument::formatCollection() const
01793 {
01794     return fCollection;
01795 }
01796 
01797 inline int QTextDocument::alignment() const
01798 {
01799     return align;
01800 }
01801 
01802 inline void QTextDocument::setAlignment( int a )
01803 {
01804     align = a;
01805 }
01806 
01807 inline int *QTextDocument::tabArray() const
01808 {
01809     return tArray;
01810 }
01811 
01812 inline int QTextDocument::tabStopWidth() const
01813 {
01814     return tStopWidth;
01815 }
01816 
01817 inline void QTextDocument::setTabArray( int *a )
01818 {
01819     tArray = a;
01820 }
01821 
01822 inline void QTextDocument::setTabStops( int tw )
01823 {
01824     tStopWidth = tw;
01825 }
01826 
01827 inline QString QTextDocument::originalText() const
01828 {
01829     if ( oTextValid )
01830         return oText;
01831     return text();
01832 }
01833 
01834 inline void QTextDocument::setFlow( QTextFlow *f )
01835 {
01836     if ( flow_ )
01837         delete flow_;
01838     flow_ = f;
01839 }
01840 
01841 inline void QTextDocument::takeFlow()
01842 {
01843     flow_ = 0;
01844 }
01845 
01846 inline bool QTextDocument::useDoubleBuffer( QTextParagraph *parag, QPainter *p )
01847 {
01848     return ( !parag->document()->parent() || parag->document()->nextDoubleBuffered ) &&
01849         ( !p || !p->device() || p->device()->devType() != QInternal::Printer );
01850 }
01851 
01852 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01853 
01854 inline QColor QTextFormat::color() const
01855 {
01856     return col;
01857 }
01858 
01859 inline QFont QTextFormat::font() const
01860 {
01861     return fn;
01862 }
01863 
01864 inline bool QTextFormat::isMisspelled() const
01865 {
01866     return missp;
01867 }
01868 
01869 inline QTextFormat::VerticalAlignment QTextFormat::vAlign() const
01870 {
01871     return ha;
01872 }
01873 
01874 inline bool QTextFormat::operator==( const QTextFormat &f ) const
01875 {
01876     return k == f.k;
01877 }
01878 
01879 inline QTextFormatCollection *QTextFormat::parent() const
01880 {
01881     return collection;
01882 }
01883 
01884 inline void QTextFormat::addRef()
01885 {
01886     ref++;
01887 }
01888 
01889 inline void QTextFormat::removeRef()
01890 {
01891     ref--;
01892     if ( !collection )
01893         return;
01894     if ( this == collection->defFormat )
01895         return;
01896     if ( ref == 0 )
01897         collection->remove( this );
01898 }
01899 
01900 inline const QString &QTextFormat::key() const
01901 {
01902     return k;
01903 }
01904 
01905 inline bool QTextFormat::useLinkColor() const
01906 {
01907     return linkColor;
01908 }
01909 
01910 inline QTextStringChar *QTextParagraph::at( int i ) const
01911 {
01912     return &str->at( i );
01913 }
01914 
01915 inline bool QTextParagraph::isValid() const
01916 {
01917     return invalid == -1;
01918 }
01919 
01920 inline bool QTextParagraph::hasChanged() const
01921 {
01922     return changed;
01923 }
01924 
01925 inline void QTextParagraph::setBackgroundColor( const QColor & c )
01926 {
01927     delete bgcol;
01928     bgcol = new QColor( c );
01929     setChanged( TRUE );
01930 }
01931 
01932 inline void QTextParagraph::clearBackgroundColor()
01933 {
01934     delete bgcol; bgcol = 0; setChanged( TRUE );
01935 }
01936 
01937 inline void QTextParagraph::append( const QString &s, bool reallyAtEnd )
01938 {
01939     if ( reallyAtEnd )
01940         insert( str->length(), s );
01941     else
01942         insert( QMAX( str->length() - 1, 0 ), s );
01943 }
01944 
01945 inline QTextParagraph *QTextParagraph::prev() const
01946 {
01947     return p;
01948 }
01949 
01950 inline QTextParagraph *QTextParagraph::next() const
01951 {
01952     return n;
01953 }
01954 
01955 inline bool QTextParagraph::hasAnySelection() const
01956 {
01957     return mSelections ? !selections().isEmpty() : FALSE;
01958 }
01959 
01960 inline void QTextParagraph::setEndState( int s )
01961 {
01962     if ( s == state )
01963         return;
01964     state = s;
01965 }
01966 
01967 inline int QTextParagraph::endState() const
01968 {
01969     return state;
01970 }
01971 
01972 inline void QTextParagraph::setParagId( int i )
01973 {
01974     id = i;
01975 }
01976 
01977 inline int QTextParagraph::paragId() const
01978 {
01979     if ( id == -1 )
01980         qWarning( "invalid parag id!!!!!!!! (%p)", (void*)this );
01981     return id;
01982 }
01983 
01984 inline bool QTextParagraph::firstPreProcess() const
01985 {
01986     return firstPProcess;
01987 }
01988 
01989 inline void QTextParagraph::setFirstPreProcess( bool b )
01990 {
01991     firstPProcess = b;
01992 }
01993 
01994 inline QMap<int, QTextLineStart*> &QTextParagraph::lineStartList()
01995 {
01996     return lineStarts;
01997 }
01998 
01999 inline QTextString *QTextParagraph::string() const
02000 {
02001     return str;
02002 }
02003 
02004 inline QTextParagraphPseudoDocument *QTextParagraph::pseudoDocument() const
02005 {
02006     if ( hasdoc )
02007         return 0;
02008     return (QTextParagraphPseudoDocument*) docOrPseudo;
02009 }
02010 
02011 
02012 #ifndef QT_NO_TEXTCUSTOMITEM
02013 inline QTextTableCell *QTextParagraph::tableCell() const
02014 {
02015     return hasdoc ? document()->tableCell () : 0;
02016 }
02017 #endif
02018 
02019 inline QTextCommandHistory *QTextParagraph::commands() const
02020 {
02021     return hasdoc ? document()->commands() : pseudoDocument()->commandHistory;
02022 }
02023 
02024 
02025 inline int QTextParagraph::alignment() const
02026 {
02027     return align;
02028 }
02029 
02030 #ifndef QT_NO_TEXTCUSTOMITEM
02031 inline void QTextParagraph::registerFloatingItem( QTextCustomItem *i )
02032 {
02033     floatingItems().append( i );
02034 }
02035 
02036 inline void QTextParagraph::unregisterFloatingItem( QTextCustomItem *i )
02037 {
02038     floatingItems().removeRef( i );
02039 }
02040 #endif
02041 
02042 inline QBrush *QTextParagraph::background() const
02043 {
02044 #ifndef QT_NO_TEXTCUSTOMITEM
02045     return tableCell() ? tableCell()->backGround() : 0;
02046 #else
02047     return 0;
02048 #endif
02049 }
02050 
02051 inline int QTextParagraph::documentWidth() const
02052 {
02053     return hasdoc ? document()->width() : pseudoDocument()->docRect.width();
02054 }
02055 
02056 inline int QTextParagraph::documentVisibleWidth() const
02057 {
02058     return hasdoc ? document()->visibleWidth() : pseudoDocument()->docRect.width();
02059 }
02060 
02061 inline int QTextParagraph::documentX() const
02062 {
02063     return hasdoc ? document()->x() : pseudoDocument()->docRect.x();
02064 }
02065 
02066 inline int QTextParagraph::documentY() const
02067 {
02068     return hasdoc ? document()->y() : pseudoDocument()->docRect.y();
02069 }
02070 
02071 inline void QTextParagraph::setExtraData( QTextParagraphData *data )
02072 {
02073     eData = data;
02074 }
02075 
02076 inline QTextParagraphData *QTextParagraph::extraData() const
02077 {
02078     return eData;
02079 }
02080 
02081 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
02082 
02083 inline void QTextFormatCollection::setDefaultFormat( QTextFormat *f )
02084 {
02085     defFormat = f;
02086 }
02087 
02088 inline QTextFormat *QTextFormatCollection::defaultFormat() const
02089 {
02090     return defFormat;
02091 }
02092 
02093 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
02094 
02095 inline QTextFormat *QTextStringChar::format() const
02096 {
02097     return (type == Regular) ? d.format : d.custom->format;
02098 }
02099 
02100 
02101 #ifndef QT_NO_TEXTCUSTOMITEM
02102 inline QTextCustomItem *QTextStringChar::customItem() const
02103 {
02104     return isCustom() ? d.custom->custom : 0;
02105 }
02106 #endif
02107 
02108 inline int QTextStringChar::height() const
02109 {
02110 #ifndef QT_NO_TEXTCUSTOMITEM
02111     return !isCustom() ? format()->height() : ( customItem()->placement() == QTextCustomItem::PlaceInline ? customItem()->height : 0 );
02112 #else
02113     return format()->height();
02114 #endif
02115 }
02116 
02117 inline int QTextStringChar::ascent() const
02118 {
02119 #ifndef QT_NO_TEXTCUSTOMITEM
02120     return !isCustom() ? format()->ascent() : ( customItem()->placement() == QTextCustomItem::PlaceInline ? customItem()->ascent() : 0 );
02121 #else
02122     return format()->ascent();
02123 #endif
02124 }
02125 
02126 inline int QTextStringChar::descent() const
02127 {
02128 #ifndef QT_NO_TEXTCUSTOMITEM
02129     return !isCustom() ? format()->descent() : 0;
02130 #else
02131     return format()->descent();
02132 #endif
02133 }
02134 
02135 #endif //QT_NO_RICHTEXT
02136 
02137 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'