lib Library API Documentation

korichtext.h

00001 00008 /**************************************************************************** 00009 ** 00010 ** Definition of internal rich text classes 00011 ** 00012 ** Created : 990124 00013 ** 00014 ** Copyright (C) 1999-2000 Trolltech AS. All rights reserved. 00015 ** 00016 ** This file is part of the kernel module of the Qt GUI Toolkit. 00017 ** 00018 ** This file may be distributed under the terms of the Q Public License 00019 ** as defined by Trolltech AS of Norway and appearing in the file 00020 ** LICENSE.QPL included in the packaging of this file. 00021 ** 00022 ** This file may be distributed and/or modified under the terms of the 00023 ** GNU General Public License version 2 as publish by the Free Software 00024 ** Foundation and appearing in the file LICENSE.GPL included in the 00025 ** packaging of this file. 00026 ** 00027 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00028 ** licenses may use this file in accordance with the Qt Commercial License 00029 ** Agreement provided with the Software. 00030 ** 00031 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00032 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00033 ** 00034 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00035 ** information about Qt Commercial License Agreements. 00036 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00037 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00038 ** 00039 ** Contact info@trolltech.com if any conditions of this licensing are 00040 ** not clear to you. 00041 ** 00042 **********************************************************************/ 00043 00044 #ifndef QRICHTEXT_P_H 00045 #define QRICHTEXT_P_H 00046 00047 // 00048 // W A R N I N G 00049 // ------------- 00050 // 00051 // This file is not part of the Qt API. It exists for the convenience 00052 // of a number of Qt sources files. This header file may change from 00053 // version to version without notice, or even be removed. 00054 // 00055 // We mean it. 00056 // 00057 // 00058 00059 #ifndef QT_H 00060 #include "qstring.h" 00061 #include "qptrlist.h" 00062 #include "qrect.h" 00063 #include "qfontmetrics.h" 00064 #include "qintdict.h" 00065 #include "qmap.h" 00066 #include "qstringlist.h" 00067 #include "qfont.h" 00068 #include "qcolor.h" 00069 #include "qsize.h" 00070 #include "qvaluelist.h" 00071 #include "qvaluestack.h" 00072 #include "qobject.h" 00073 #include "qdict.h" 00074 #include "qtextstream.h" 00075 #include "qpixmap.h" 00076 #include "qstylesheet.h" 00077 #include "qptrvector.h" 00078 #include "qpainter.h" 00079 #include "qlayout.h" 00080 #include "qobject.h" 00081 #include <limits.h> 00082 #include "qcomplextext_p.h" 00083 #include "qapplication.h" 00084 #endif // QT_H 00085 00086 class KoTextParag; 00087 class KoTextString; 00088 class KoTextCursor; 00089 class KoTextCustomItem; 00090 class KoTextFlow; 00091 class KoTextDocument; 00092 //class KoTextPreProcessor; 00093 class KoTextFormatterBase; 00094 class KoTextIndent; 00095 class KoTextFormat; 00096 class KoTextFormatCollection; 00097 struct KoBidiContext; 00098 00100 class KCommand; 00101 class QDomElement; 00102 class KoZoomHandler; 00103 class KoTextFormatter; 00104 class KoParagVisitor; 00105 class KoTextDocCommand; 00106 #include <qmemarray.h> 00107 #include "koparaglayout.h" 00108 #include "korichtext.h" 00110 00111 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00112 00113 class KoTextStringChar 00114 { 00115 friend class KoTextString; 00116 00117 public: 00118 // this is never called, initialize variables in KoTextString::insert()!!! 00119 KoTextStringChar() : lineStart( 0 ), type( Regular ), startOfRun( 0 ) {d.format=0; } 00120 ~KoTextStringChar(); 00121 00122 QChar c; 00123 00124 // this is the same struct as in qtextengine_p.h. Don't change! 00125 uchar softBreak :1; // Potential linebreak point 00126 uchar whiteSpace :1; // A unicode whitespace character, except NBSP, ZWNBSP 00127 uchar charStop :1; // Valid cursor position (for left/right arrow) 00128 uchar wordStop :1; // Valid cursor position (for ctrl + left/right arrow) (TODO: use) 00129 //uchar nobreak :1; 00130 00131 enum Type { Regular, Custom }; 00132 uint lineStart : 1; 00133 Type type : 1; 00134 uint startOfRun : 1; 00135 uint rightToLeft : 1; 00136 00137 // --- added for WYSIWYG --- 00138 Q_INT8 pixelxadj; // adjustment to apply to lu2pixel(x) 00139 short int pixelwidth; // width in pixels 00140 short int width; // width in LU 00141 00142 int x; 00143 int height() const; 00144 int ascent() const; 00145 int descent() const; 00146 bool isCustom() const { return type == Custom; } 00147 KoTextFormat *format() const; 00148 KoTextCustomItem *customItem() const; 00149 void setFormat( KoTextFormat *f ); 00150 void setCustomItem( KoTextCustomItem *i ); 00151 void loseCustomItem(); 00152 struct CustomData 00153 { 00154 KoTextFormat *format; 00155 KoTextCustomItem *custom; 00156 }; 00157 00158 union { 00159 KoTextFormat* format; 00160 CustomData* custom; 00161 } d; 00162 00163 private: 00164 KoTextStringChar &operator=( const KoTextStringChar & ) { 00165 //abort(); 00166 return *this; 00167 } 00168 KoTextStringChar( const KoTextStringChar & ); // copy-constructor, forbidden 00169 friend class KoComplexText; 00170 friend class KoTextParag; 00171 }; 00172 00173 #if defined(Q_TEMPLATEDLL) 00174 // MOC_SKIP_BEGIN 00175 template class QMemArray<KoTextStringChar>; 00176 // MOC_SKIP_END 00177 #endif 00178 00179 class KoTextString 00180 { 00181 public: 00182 00183 KoTextString(); 00184 KoTextString( const KoTextString &s ); 00185 virtual ~KoTextString(); 00186 00187 QString toString() const; 00188 static QString toString( const QMemArray<KoTextStringChar> &data ); 00189 QString toReverseString() const; 00190 00191 KoTextStringChar &at( int i ) const; 00192 int length() const; 00193 00194 //int width( int idx ) const; // moved to KoTextFormat 00195 00196 void insert( int index, const QString &s, KoTextFormat *f ); 00197 void insert( int index, KoTextStringChar *c ); 00198 void truncate( int index ); 00199 void remove( int index, int len ); 00200 void clear(); 00201 00202 void setFormat( int index, KoTextFormat *f, bool useCollection ); 00203 00204 void setBidi( bool b ) { bidi = b; } 00205 bool isBidi() const; 00206 bool isRightToLeft() const; 00207 QChar::Direction direction() const; 00208 void setDirection( QChar::Direction d ) { dir = d; bidiDirty = TRUE; } 00209 00211 void setNeedsSpellCheck( bool b ) { bNeedsSpellCheck = b; } 00212 bool needsSpellCheck() const { return bNeedsSpellCheck; } 00213 00214 QMemArray<KoTextStringChar> subString( int start = 0, int len = 0xFFFFFF ) const; 00215 QString mid( int start = 0, int len = 0xFFFFFF ) const; // kotext addition 00216 QMemArray<KoTextStringChar> rawData() const { return data.copy(); } 00217 00218 void operator=( const QString &s ) { clear(); insert( 0, s, 0 ); } 00219 void operator+=( const QString &s ); 00220 void prepend( const QString &s ) { insert( 0, s, 0 ); } 00221 00222 // return next and previous valid cursor positions. 00223 bool validCursorPosition( int idx ); 00224 int nextCursorPosition( int idx ); 00225 int previousCursorPosition( int idx ); 00226 00227 private: 00228 void checkBidi() const; 00229 00230 QMemArray<KoTextStringChar> data; 00231 uint bidiDirty : 1; 00232 uint bidi : 1; // true when the paragraph has right to left characters 00233 uint rightToLeft : 1; 00234 uint dir : 5; 00235 uint bNeedsSpellCheck : 1; 00236 }; 00237 00238 inline bool KoTextString::isBidi() const 00239 { 00240 if ( bidiDirty ) 00241 checkBidi(); 00242 return bidi; 00243 } 00244 00245 inline bool KoTextString::isRightToLeft() const 00246 { 00247 if ( bidiDirty ) 00248 checkBidi(); 00249 return rightToLeft; 00250 } 00251 00252 inline QChar::Direction KoTextString::direction() const 00253 { 00254 return (QChar::Direction) dir; 00255 } 00256 00257 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00258 00259 #if defined(Q_TEMPLATEDLL) 00260 // MOC_SKIP_BEGIN 00261 template class QValueStack<int>; 00262 template class QValueStack<KoTextParag*>; 00263 template class QValueStack<bool>; 00264 // MOC_SKIP_END 00265 #endif 00266 00267 class KoTextCursor 00268 { 00269 public: 00270 KoTextCursor( KoTextDocument *d ); 00271 KoTextCursor(); 00272 KoTextCursor( const KoTextCursor &c ); 00273 KoTextCursor &operator=( const KoTextCursor &c ); 00274 virtual ~KoTextCursor() {} 00275 00276 bool operator==( const KoTextCursor &c ) const; 00277 bool operator!=( const KoTextCursor &c ) const { return !(*this == c); } 00278 00279 KoTextDocument *document() const { return doc; } 00280 void setDocument( KoTextDocument *d ); 00281 00282 KoTextParag *parag() const; 00283 int index() const; 00284 void setParag( KoTextParag *s, bool restore = TRUE ); 00285 00286 void gotoLeft(); 00287 void gotoRight(); 00288 void gotoNextLetter(); 00289 void gotoPreviousLetter(); 00290 void gotoUp(); 00291 void gotoDown(); 00292 void gotoLineEnd(); 00293 void gotoLineStart(); 00294 void gotoHome(); 00295 void gotoEnd(); 00296 void gotoPageUp( int visibleHeight ); 00297 void gotoPageDown( int visibleHeight ); 00298 void gotoNextWord(); 00299 void gotoPreviousWord(); 00300 void gotoWordLeft(); 00301 void gotoWordRight(); 00302 00303 void insert( const QString &s, bool checkNewLine, QMemArray<KoTextStringChar> *formatting = 0 ); 00304 void splitAndInsertEmptyParag( bool ind = TRUE, bool updateIds = TRUE ); 00305 bool remove(); 00306 bool removePreviousChar(); 00307 void killLine(); 00308 void indent(); 00309 00310 bool atParagStart() const; 00311 bool atParagEnd() const; 00312 00313 void setIndex( int i, bool restore = TRUE ); 00314 00315 void checkIndex(); 00316 00317 int offsetX() const { return ox; } 00318 int offsetY() const { return oy; } 00319 00320 KoTextParag *topParag() const { return parags.isEmpty() ? string : parags.first(); } 00321 int totalOffsetX() const; 00322 int totalOffsetY() const; 00323 00324 bool place( const QPoint &pos, KoTextParag *s, bool link = false, int *customItemIndex = 0 ); 00325 void restoreState(); 00326 00327 int x() const; 00328 int y() const; 00329 void fixCursorPosition(); 00330 int nestedDepth() const { return (int)indices.count(); } //### size_t/int cast 00331 00332 private: 00333 enum Operation { EnterBegin, EnterEnd, Next, Prev, Up, Down }; 00334 00335 void push(); 00336 void pop(); 00337 void processNesting( Operation op ); 00338 void invalidateNested(); 00339 void gotoIntoNested( const QPoint &globalPos ); 00340 00341 KoTextParag *string; 00342 KoTextDocument *doc; 00343 int idx, tmpIndex; 00344 int ox, oy; 00345 QValueStack<int> indices; 00346 QValueStack<KoTextParag*> parags; 00347 QValueStack<int> xOffsets; 00348 QValueStack<int> yOffsets; 00349 QValueStack<bool> nestedStack; 00350 bool nested; 00351 00352 }; 00353 00354 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00355 00356 class KoTextDocCommand 00357 { 00358 public: 00359 enum Commands { Invalid, Insert, Delete, Format, Alignment, ParagType }; 00360 00361 KoTextDocCommand( KoTextDocument *d ) : doc( d ), cursor( d ) {} 00362 virtual ~KoTextDocCommand() {} 00363 virtual Commands type() const { return Invalid; }; 00364 00365 virtual KoTextCursor *execute( KoTextCursor *c ) = 0; 00366 virtual KoTextCursor *unexecute( KoTextCursor *c ) = 0; 00367 00368 protected: 00369 KoTextDocument *doc; 00370 KoTextCursor cursor; 00371 00372 }; 00373 00374 #if defined(Q_TEMPLATEDLL) 00375 // MOC_SKIP_BEGIN 00376 template class QPtrList<KoTextDocCommand>; 00377 // MOC_SKIP_END 00378 #endif 00379 00380 class KoTextDocCommandHistory 00381 { 00382 public: 00383 KoTextDocCommandHistory( int s ) : current( -1 ), steps( s ) { history.setAutoDelete( TRUE ); } 00384 virtual ~KoTextDocCommandHistory() { clear(); } 00385 00386 void clear() { history.clear(); current = -1; } 00387 00388 void addCommand( KoTextDocCommand *cmd ); 00389 KoTextCursor *undo( KoTextCursor *c ); 00390 KoTextCursor *redo( KoTextCursor *c ); 00391 00392 bool isUndoAvailable(); 00393 bool isRedoAvailable(); 00394 00395 void setUndoDepth( int d ) { steps = d; } 00396 int undoDepth() const { return steps; } 00397 00398 int historySize() const { return history.count(); } 00399 int currentPosition() const { return current; } 00400 00401 private: 00402 QPtrList<KoTextDocCommand> history; 00403 int current, steps; 00404 00405 }; 00406 00407 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00408 00409 class KoTextCustomItem 00410 { 00411 public: 00412 KoTextCustomItem( KoTextDocument *p ); 00413 virtual ~KoTextCustomItem(); 00414 virtual void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) /* = 0*/; 00415 00416 // Called after the item's paragraph has been formatted 00417 virtual void finalize() {} 00418 00419 void move( int x, int y ) { xpos = x; ypos = y; } 00420 int x() const { return xpos; } 00421 int y() const { return ypos; } 00422 00423 // Called when the format of the character is being changed, see KoTextStringChar::setFormat 00424 virtual void setFormat( KoTextFormat * ) { } 00425 00426 //virtual void setPainter( QPainter*, bool adjust ); 00427 00428 enum Placement { PlaceInline = 0, PlaceLeft, PlaceRight }; 00429 virtual Placement placement() const { return PlaceInline; } 00430 bool placeInline() { return placement() == PlaceInline; } 00431 00432 virtual bool ownLine() const { return FALSE; } 00433 // Called for "ownline" items 00434 virtual void resize( int nwidth ) { width = nwidth; } 00435 virtual void invalidate() {}; 00436 00437 virtual bool isNested() const { return FALSE; } 00438 virtual int minimumWidth() const { return 0; } 00439 virtual int widthHint() const { return 0; } 00440 virtual int ascent() const { return height; } 00441 00442 virtual QString richText() const { return QString::null; } 00443 00444 int width; 00445 int height; 00446 00447 QRect geometry() const { return QRect( xpos, ypos, width, height ); } 00448 00449 virtual bool enter( KoTextCursor *, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy, bool atEnd = FALSE ); 00450 virtual bool enterAt( KoTextCursor *, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy, const QPoint & ); 00451 virtual bool next( KoTextCursor *, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy ); 00452 virtual bool prev( KoTextCursor *, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy ); 00453 virtual bool down( KoTextCursor *, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy ); 00454 virtual bool up( KoTextCursor *, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy ); 00455 00456 void setParagraph( KoTextParag * p ) { parag = p; } 00457 KoTextParag *paragraph() const { return parag; } 00458 00459 virtual void pageBreak( int /*y*/, KoTextFlow* /*flow*/ ) {} 00460 00461 KoTextDocument *parent; 00462 00463 #include "kotextcustomitem.h" 00464 00465 protected: 00466 int xpos; 00467 int ypos; 00468 private: 00469 KoTextParag *parag; 00470 }; 00471 00472 #if defined(Q_TEMPLATEDLL) 00473 // MOC_SKIP_BEGIN 00474 template class QMap<QString, QString>; 00475 // MOC_SKIP_END 00476 #endif 00477 00478 #if 0 00479 class KoTextImage : public KoTextCustomItem 00480 { 00481 public: 00482 KoTextImage( KoTextDocument *p, const QMap<QString, QString> &attr, const QString& context, 00483 QMimeSourceFactory &factory ); 00484 virtual ~KoTextImage(); 00485 00486 Placement placement() const { return place; } 00487 //void setPainter( QPainter*, bool ); 00488 int widthHint() const { return width; } 00489 int minimumWidth() const { return width; } 00490 00491 QString richText() const; 00492 00493 void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); 00494 00495 private: 00496 QRegion* reg; 00497 QPixmap pm; 00498 Placement place; 00499 int tmpwidth, tmpheight; 00500 QMap<QString, QString> attributes; 00501 QString imgId; 00502 00503 }; 00504 #endif 00505 00506 class KoTextHorizontalLine : public KoTextCustomItem 00507 { 00508 public: 00509 KoTextHorizontalLine( KoTextDocument *p, const QMap<QString, QString> &attr, const QString& context, 00510 QMimeSourceFactory &factory ); 00511 virtual ~KoTextHorizontalLine(); 00512 00513 //void setPainter( QPainter*, bool ); 00514 void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); 00515 QString richText() const; 00516 00517 bool ownLine() const { return TRUE; } 00518 00519 private: 00520 int tmpheight; 00521 QColor color; 00522 00523 }; 00524 00525 #if defined(Q_TEMPLATEDLL) 00526 // MOC_SKIP_BEGIN 00527 template class QPtrList<KoTextCustomItem>; 00528 // MOC_SKIP_END 00529 #endif 00530 00531 class KoTextFlow 00532 { 00533 friend class KoTextDocument; 00534 friend class KoTextTableCell; 00535 00536 public: 00537 KoTextFlow(); 00538 virtual ~KoTextFlow(); 00539 00540 virtual void setWidth( int width ); 00541 int width() const { return w; } 00542 00543 //virtual void setPageSize( int ps ); 00544 //int pageSize() const { return pagesize; } 00545 00553 virtual void adjustMargins( int yp, int h, int reqMinWidth, int& leftMargin, int& rightMargin, int& pageWidth, KoTextParag* parag ); 00554 00555 virtual void registerFloatingItem( KoTextCustomItem* item ); 00556 virtual void unregisterFloatingItem( KoTextCustomItem* item ); 00557 //virtual QRect boundingRect() const; 00558 00560 virtual int availableHeight() const; 00561 virtual void drawFloatingItems(QPainter* p, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); 00562 00563 virtual int adjustFlow( int y, int w, int h ); // adjusts y according to the defined pagesize. Returns the shift. 00564 00565 virtual bool isEmpty(); 00566 00567 void clear(); 00568 00569 private: 00570 int w; 00571 //int pagesize; 00572 00573 QPtrList<KoTextCustomItem> leftItems; 00574 QPtrList<KoTextCustomItem> rightItems; 00575 00576 }; 00577 00578 #ifdef QTEXTTABLE_AVAILABLE 00579 class KoTextTable; 00580 00581 class KoTextTableCell : public QLayoutItem 00582 { 00583 friend class KoTextTable; 00584 00585 public: 00586 KoTextTableCell( KoTextTable* table, 00587 int row, int column, 00588 const QMap<QString, QString> &attr, 00589 const QStyleSheetItem* style, 00590 const KoTextFormat& fmt, const QString& context, 00591 QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc ); 00592 KoTextTableCell( KoTextTable* table, int row, int column ); 00593 virtual ~KoTextTableCell(); 00594 00595 QSize sizeHint() const ; 00596 QSize minimumSize() const ; 00597 QSize maximumSize() const ; 00598 QSizePolicy::ExpandData expanding() const; 00599 bool isEmpty() const; 00600 void setGeometry( const QRect& ) ; 00601 QRect geometry() const; 00602 00603 bool hasHeightForWidth() const; 00604 int heightForWidth( int ) const; 00605 00606 void setPainter( QPainter*, bool ); 00607 00608 int row() const { return row_; } 00609 int column() const { return col_; } 00610 int rowspan() const { return rowspan_; } 00611 int colspan() const { return colspan_; } 00612 int stretch() const { return stretch_; } 00613 00614 KoTextDocument* richText() const { return richtext; } 00615 KoTextTable* table() const { return parent; } 00616 00617 void draw( int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); 00618 00619 QBrush *backGround() const { return background; } 00620 virtual void invalidate(); 00621 00622 int verticalAlignmentOffset() const; 00623 int horizontalAlignmentOffset() const; 00624 00625 private: 00626 QPainter* painter() const; 00627 QRect geom; 00628 KoTextTable* parent; 00629 KoTextDocument* richtext; 00630 int row_; 00631 int col_; 00632 int rowspan_; 00633 int colspan_; 00634 int stretch_; 00635 int maxw; 00636 int minw; 00637 bool hasFixedWidth; 00638 QBrush *background; 00639 int cached_width; 00640 int cached_sizehint; 00641 QMap<QString, QString> attributes; 00642 int align; 00643 }; 00644 00645 #if defined(Q_TEMPLATEDLL) 00646 // MOC_SKIP_BEGIN 00647 template class QPtrList<KoTextTableCell>; 00648 template class QMap<KoTextCursor*, int>; 00649 // MOC_SKIP_END 00650 #endif 00651 00652 class KoTextTable: public KoTextCustomItem 00653 { 00654 friend class KoTextTableCell; 00655 00656 public: 00657 KoTextTable( KoTextDocument *p, const QMap<QString, QString> &attr ); 00658 virtual ~KoTextTable(); 00659 00660 void setPainter( QPainter *p, bool adjust ); 00661 void pageBreak( int y, KoTextFlow* flow ); 00662 void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, 00663 const QColorGroup& cg, bool selected ); 00664 00665 bool noErase() const { return TRUE; } 00666 bool ownLine() const { return TRUE; } 00667 Placement placement() const { return place; } 00668 bool isNested() const { return TRUE; } 00669 void resize( int nwidth ); 00670 virtual void invalidate(); 00672 00673 virtual bool enter( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy, bool atEnd = FALSE ); 00674 virtual bool enterAt( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy, const QPoint &pos ); 00675 virtual bool next( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy ); 00676 virtual bool prev( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy ); 00677 virtual bool down( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy ); 00678 virtual bool up( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy ); 00679 00680 QString richText() const; 00681 00682 int minimumWidth() const { return layout ? layout->minimumSize().width() : 0; } 00683 int widthHint() const { return ( layout ? layout->sizeHint().width() : 0 ) + 2 * outerborder; } 00684 00685 QPtrList<KoTextTableCell> tableCells() const { return cells; } 00686 00687 QRect geometry() const { return layout ? layout->geometry() : QRect(); } 00688 bool isStretching() const { return stretch; } 00689 00690 private: 00691 void format( int &w ); 00692 void addCell( KoTextTableCell* cell ); 00693 00694 private: 00695 QGridLayout* layout; 00696 QPtrList<KoTextTableCell> cells; 00697 QPainter* painter; 00698 int cachewidth; 00699 int fixwidth; 00700 int cellpadding; 00701 int cellspacing; 00702 int border; 00703 int outerborder; 00704 int stretch; 00705 int innerborder; 00706 int us_cp, us_ib, us_b, us_ob, us_cs; 00707 QMap<QString, QString> attributes; 00708 QMap<KoTextCursor*, int> currCell; 00709 Placement place; 00710 void adjustCells( int y , int shift ); 00711 int pageBreakFor; 00712 }; 00713 #endif // QTEXTTABLE_AVAILABLE 00714 00715 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00716 00717 class KoTextTableCell; 00718 00719 struct KoTextDocumentSelection 00720 { 00721 KoTextCursor startCursor, endCursor; 00722 bool swapped; 00723 }; 00724 00725 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00726 00727 00728 class KoTextDocDeleteCommand : public KoTextDocCommand 00729 { 00730 public: 00731 KoTextDocDeleteCommand( KoTextDocument *d, int i, int idx, const QMemArray<KoTextStringChar> &str ); 00732 //KoTextDocDeleteCommand( KoTextParag *p, int idx, const QMemArray<KoTextStringChar> &str ); 00733 virtual ~KoTextDocDeleteCommand(); 00734 00735 Commands type() const { return Delete; } 00736 KoTextCursor *execute( KoTextCursor *c ); 00737 KoTextCursor *unexecute( KoTextCursor *c ); 00738 00739 protected: 00740 int id, index; 00741 KoTextParag *parag; 00742 QMemArray<KoTextStringChar> text; 00743 00744 }; 00745 00746 #if 0 00747 class KoTextDocInsertCommand : public KoTextDocDeleteCommand 00748 { 00749 public: 00750 KoTextDocInsertCommand( KoTextDocument *d, int i, int idx, const QMemArray<KoTextStringChar> &str ) 00751 : KoTextDocDeleteCommand( d, i, idx, str ) {} 00752 KoTextDocInsertCommand( KoTextParag *p, int idx, const QMemArray<KoTextStringChar> &str ) 00753 : KoTextDocDeleteCommand( p, idx, str ) {} 00754 virtual ~KoTextDocInsertCommand() {} 00755 00756 Commands type() const { return Insert; } 00757 KoTextCursor *execute( KoTextCursor *c ) { return KoTextDocDeleteCommand::unexecute( c ); } 00758 KoTextCursor *unexecute( KoTextCursor *c ) { return KoTextDocDeleteCommand::execute( c ); } 00759 00760 }; 00761 #endif 00762 00763 class KoTextDocFormatCommand : public KoTextDocCommand 00764 { 00765 public: 00766 KoTextDocFormatCommand( KoTextDocument *d, int sid, int sidx, int eid, int eidx, const QMemArray<KoTextStringChar> &old, const KoTextFormat *f, int fl ); 00767 virtual ~KoTextDocFormatCommand(); 00768 00769 Commands type() const { return Format; } 00770 KoTextCursor *execute( KoTextCursor *c ); 00771 KoTextCursor *unexecute( KoTextCursor *c ); 00772 00773 protected: 00774 int startId, startIndex, endId, endIndex; 00775 KoTextFormat *format; 00776 QMemArray<KoTextStringChar> oldFormats; 00777 int flags; 00778 00779 }; 00780 00781 class KoTextAlignmentCommand : public KoTextDocCommand 00782 { 00783 public: 00784 KoTextAlignmentCommand( KoTextDocument *d, int fParag, int lParag, int na, const QMemArray<int> &oa ); 00785 virtual ~KoTextAlignmentCommand() {} 00786 00787 Commands type() const { return Alignment; } 00788 KoTextCursor *execute( KoTextCursor *c ); 00789 KoTextCursor *unexecute( KoTextCursor *c ); 00790 00791 private: 00792 int firstParag, lastParag; 00793 int newAlign; 00794 QMemArray<int> oldAligns; 00795 00796 }; 00797 00798 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00799 00800 struct KoTextParagSelection 00801 { 00802 int start, end; 00803 }; 00804 00805 struct KoTextParagLineStart 00806 { 00807 KoTextParagLineStart() : y( 0 ), baseLine( 0 ), h( 0 ), lineSpacing( 0 ), hyphenated( false ) 00808 #ifndef QT_NO_COMPLEXTEXT 00809 , bidicontext( 0 ) 00810 #endif 00811 { } 00812 KoTextParagLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ), 00813 lineSpacing( 0 ), hyphenated( false ), 00814 w( 0 ) 00815 #ifndef QT_NO_COMPLEXTEXT 00816 , bidicontext( 0 ) 00817 #endif 00818 { } 00819 #ifndef QT_NO_COMPLEXTEXT 00820 KoTextParagLineStart( KoBidiContext *c, KoBidiStatus s ) : y(0), baseLine(0), h(0), 00821 lineSpacing( 0 ), hyphenated( false ), 00822 status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); } 00823 #endif 00824 00825 virtual ~KoTextParagLineStart() 00826 { 00827 #ifndef QT_NO_COMPLEXTEXT 00828 if ( bidicontext && bidicontext->deref() ) 00829 delete bidicontext; 00830 #endif 00831 } 00832 00833 #ifndef QT_NO_COMPLEXTEXT 00834 void setContext( KoBidiContext *c ) { 00835 if ( c == bidicontext ) 00836 return; 00837 if ( bidicontext && bidicontext->deref() ) 00838 delete bidicontext; 00839 bidicontext = c; 00840 if ( bidicontext ) 00841 bidicontext->ref(); 00842 } 00843 KoBidiContext *context() const { return bidicontext; } 00844 #endif 00845 00846 public: 00847 ushort y, baseLine, h; 00848 short lineSpacing; 00849 bool hyphenated; 00850 #ifndef QT_NO_COMPLEXTEXT 00851 KoBidiStatus status; 00852 #endif 00853 int w; 00854 00855 private: 00856 #ifndef QT_NO_COMPLEXTEXT 00857 KoBidiContext *bidicontext; 00858 #endif 00859 }; 00860 00861 #if defined(Q_TEMPLATEDLL) 00862 // MOC_SKIP_BEGIN 00863 template class QMap<int, KoTextParagSelection>; 00864 template class QMap<int, KoTextParagLineStart*>; 00865 // MOC_SKIP_END 00866 #endif 00867 00868 /*class KoTextParagData 00869 { 00870 public: 00871 KoTextParagData() {} 00872 virtual ~KoTextParagData() {} 00873 virtual void join( KoTextParagData * ) {} 00874 };*/ 00875 00876 class KoTextParag 00877 { 00878 friend class KoTextDocument; 00879 friend class KoTextCursor; 00880 00881 public: 00882 KoTextParag( KoTextDocument *d, KoTextParag *pr = 0, KoTextParag *nx = 0, bool updateIds = TRUE ); 00883 virtual ~KoTextParag(); 00884 00885 KoTextString *string() const; 00886 KoTextStringChar *at( int i ) const; // maybe remove later 00887 int leftGap() const; 00888 int length() const; // maybe remove later 00889 00890 void setFormat( KoTextFormat *fm ); 00891 KoTextFormat *paragFormat() const; 00892 00893 KoTextDocument *document() const; 00894 00895 QRect rect() const; 00896 void setRect( const QRect& rect ) { r = rect; } 00897 void setHeight( int h ) { r.setHeight( h ); } 00898 void setWidth( int w ) { r.setWidth( w ); } 00899 void show(); 00900 void hide(); 00901 bool isVisible() const { return visible; } 00902 00903 //bool isLastInFrame() const { return lastInFrame; } 00904 //void setLastInFrame( bool b ) { lastInFrame = b; } 00905 00906 KoTextParag *prev() const; 00907 KoTextParag *next() const; 00908 void setPrev( KoTextParag *s ); 00909 void setNext( KoTextParag *s ); 00910 00911 void insert( int index, const QString &s ); 00912 void append( const QString &s, bool reallyAtEnd = FALSE ); 00913 void truncate( int index ); 00914 void remove( int index, int len ); 00915 00916 void invalidate( int chr ); 00917 00918 void move( int &dy ); 00919 void format( int start = -1, bool doMove = TRUE ); 00920 00921 bool isValid() const; 00922 bool hasChanged() const; 00923 void setChanged( bool b, bool recursive = FALSE ); 00924 short int lineChanged(); // first line that has been changed. 00925 void setLineChanged( short int line ); 00926 00927 int lineHeightOfChar( int i, int *bl = 0, int *y = 0 ) const; 00928 KoTextStringChar *lineStartOfChar( int i, int *index = 0, int *line = 0 ) const; 00929 int lines() const; 00930 KoTextStringChar *lineStartOfLine( int line, int *index = 0 ) const; 00931 int lineY( int l ) const; 00932 int lineBaseLine( int l ) const; 00933 int lineHeight( int l ) const; 00934 void lineInfo( int l, int &y, int &h, int &bl ) const; 00935 00936 void setSelection( int id, int start, int end ); 00937 void removeSelection( int id ); 00938 int selectionStart( int id ) const; 00939 int selectionEnd( int id ) const; 00940 bool hasSelection( int id ) const; 00941 bool hasAnySelection() const; 00942 bool fullSelected( int id ) const; 00943 00944 //void setEndState( int s ); 00945 //int endState() const; 00946 00947 void setParagId( int i ); 00948 int paragId() const; 00949 00950 //bool firstPreProcess() const; 00951 //void setFirstPreProcess( bool b ); 00952 00953 void indent( int *oldIndent = 0, int *newIndent = 0 ); 00954 00955 //void setExtraData( KoTextParagData *data ); 00956 //KoTextParagData *extraData() const; 00957 00958 QMap<int, KoTextParagLineStart*> &lineStartList(); 00959 00960 void setFormat( int index, int len, const KoTextFormat *f, bool useCollection = TRUE, int flags = -1 ); 00961 00962 void setAlignment( uint a ); 00963 void setAlignmentDirect( uint a ) { align = a; } 00964 uint alignment() const; 00965 00966 virtual void paint( QPainter &painter, const QColorGroup &cg, KoTextCursor *cursor, bool drawSelections, 00967 int clipx, int clipy, int clipw, int cliph ); // kotextparag.cc 00968 00969 00970 int topMargin() const; 00971 int bottomMargin() const; 00972 int leftMargin() const; 00973 int firstLineMargin() const; 00974 int rightMargin() const; 00975 int lineSpacing( int line ) const; 00976 00977 int numberOfSubParagraph() const; 00978 void registerFloatingItem( KoTextCustomItem *i ); 00979 void unregisterFloatingItem( KoTextCustomItem *i ); 00980 00981 void setFullWidth( bool b ) { fullWidth = b; } 00982 bool isFullWidth() const { return fullWidth; } 00983 00984 #ifdef QTEXTTABLE_AVAILABLE 00985 KoTextTableCell *tableCell() const { return tc; } 00986 void setTableCell( KoTextTableCell *c ) { tc = c; } 00987 #endif 00988 00989 //void addCustomItem(); 00990 //void removeCustomItem(); 00991 int customItems() const; 00992 00993 QBrush *background() const; 00994 00995 void setDocumentRect( const QRect &r ); 00996 int documentWidth() const; 00997 //int documentVisibleWidth() const; 00998 int documentX() const; 00999 int documentY() const; 01000 KoTextFormatCollection *formatCollection() const; 01001 //void setFormatter( KoTextFormatterBase *f ); 01002 KoTextFormatterBase *formatter() const; 01003 //int minimumWidth() const; 01004 int widthUsed() const; 01005 01006 int nextTabDefault( int i, int x ); 01007 int nextTab( int i, int x ); // kotextparag.cc 01008 int *tabArray() const; 01009 void setTabArray( int *a ); 01010 void setTabStops( int tw ); 01011 01012 //void setPainter( QPainter *p, bool adjust ); 01013 //QPainter *painter() const { return pntr; } 01014 01015 void setNewLinesAllowed( bool b ); 01016 bool isNewLinesAllowed() const; 01017 01018 QString richText() const; 01019 01020 //void addCommand( KoTextDocCommand *cmd ); 01021 //KoTextCursor *undo( KoTextCursor *c = 0 ); 01022 //KoTextCursor *redo( KoTextCursor *c = 0 ); 01023 //KoTextDocCommandHistory *commands() const { return commandHistory; } 01024 01025 virtual void join( KoTextParag *s ); 01026 virtual void copyParagData( KoTextParag *parag ); 01027 01028 void setBreakable( bool b ) { breakable = b; } 01029 bool isBreakable() const { return breakable; } 01030 01031 //void setBackgroundColor( const QColor &c ); 01032 //QColor *backgroundColor() const { return bgcol; } 01033 //void clearBackgroundColor(); 01034 01035 //bool isLineBreak() const { return isBr; } 01036 01037 void setMovedDown( bool b ) { movedDown = b; } 01038 bool wasMovedDown() const { return movedDown; } 01039 01040 void setDirection( QChar::Direction d ); 01041 QChar::Direction direction() const; 01042 01043 // For KoTextFormatter only 01044 void insertLineStart( int index, KoTextParagLineStart *ls ); 01045 01046 protected: 01047 void drawLabel( QPainter* p, int x, int y, int w, int h, int base, const QColorGroup& cg ); 01048 void drawCursorDefault( QPainter &painter, KoTextCursor *cursor, int curx, int cury, int curh, const QColorGroup &cg ); 01049 void drawCursor( QPainter &painter, KoTextCursor *cursor, int curx, int cury, int curh, const QColorGroup &cg ); 01050 01051 #include "kotextparag.h" 01052 01053 private: 01054 QMap<int, KoTextParagSelection> &selections() const; 01055 QPtrVector<QStyleSheetItem> &styleSheetItemsVec() const; 01056 QPtrList<KoTextCustomItem> &floatingItems() const; 01057 01058 QMap<int, KoTextParagLineStart*> lineStarts; 01059 int invalid; 01060 QRect r; 01061 KoTextParag *p, *n; 01062 KoTextDocument *doc; 01063 uint changed : 1; 01064 //uint firstFormat : 1; /// unused 01065 //uint firstPProcess : 1; 01066 //uint needPreProcess : 1; 01067 uint fullWidth : 1; 01068 uint newLinesAllowed : 1; 01069 //uint lastInFrame : 1; 01070 uint visible : 1; 01071 uint breakable : 1; 01072 //uint isBr : 1; 01073 uint movedDown : 1; 01074 uint align : 4; 01075 short int m_lineChanged; 01076 int id; 01077 int m_wused; 01078 KoTextString *str; 01079 QMap<int, KoTextParagSelection> *mSelections; 01080 QPtrList<KoTextCustomItem> *mFloatingItems; 01081 //int tm, bm, lm, rm, flm; // margins 01082 KoTextFormat *defFormat; // is this really used? 01083 //int numCustomItems; 01084 int *tArray; 01085 //KoTextParagData *eData; 01086 //QColor *bgcol; 01087 //QPainter *pntr; 01088 01089 // Those things are used by QRT for the case of a paragraph without document 01090 // We don't use this currently, and it's not worth making EVERY parag bigger 01091 // just for a special case that's rarely used. Better have lightweight KoTextDocument 01092 // replacement (with common base class), if we ever want efficient single-parag docs... 01093 //int tabStopWidth; 01094 //QRect docRect; 01095 //KoTextFormatterBase *pFormatter; 01096 //KoTextDocCommandHistory *commandHistory; 01097 }; 01098 01099 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 01100 01101 class KoTextFormatterBase 01102 { 01103 public: 01104 KoTextFormatterBase(); 01105 virtual ~KoTextFormatterBase() {} 01106 virtual bool format( KoTextDocument *doc, KoTextParag *parag, int start, const QMap<int, KoTextParagLineStart*> &oldLineStarts, int& y, int& widthUsed ) = 0; 01107 virtual int formatVertically( KoTextDocument* doc, KoTextParag* parag ); 01108 01109 // Called after formatting a paragraph 01110 virtual void postFormat( KoTextParag* parag ) = 0; 01111 01112 bool isWrapEnabled( KoTextParag *p ) const { if ( !wrapEnabled ) return FALSE; if ( p && !p->isBreakable() ) return FALSE; return TRUE;} 01113 int wrapAtColumn() const { return wrapColumn;} 01114 virtual void setWrapEnabled( bool b ) { wrapEnabled = b; } 01115 virtual void setWrapAtColumn( int c ) { wrapColumn = c; } 01116 virtual void setAllowBreakInWords( bool b ) { biw = b; } 01117 bool allowBreakInWords() const { return biw; } 01118 01119 // This setting is passed to KoTextParag::fixParagWidth by postFormat() 01120 void setViewFormattingChars( bool b ) { m_bViewFormattingChars = b; } 01121 bool viewFormattingChars() const { return m_bViewFormattingChars; } 01122 01123 /*virtual*/ bool isBreakable( KoTextString *string, int pos ) const; 01124 /*virtual*/ bool isStretchable( KoTextString *string, int pos ) const; 01125 01126 protected: 01127 //virtual KoTextParagLineStart *formatLine( KoTextParag *parag, KoTextString *string, KoTextParagLineStart *line, KoTextStringChar *start, 01128 // KoTextStringChar *last, int align = AlignAuto, int space = 0 ); 01129 //KoTextStringChar 01130 01131 #ifndef QT_NO_COMPLEXTEXT 01132 virtual KoTextParagLineStart *bidiReorderLine( KoTextParag *parag, KoTextString *string, KoTextParagLineStart *line, KoTextStringChar *start, 01133 KoTextStringChar *last, int align, int space ); 01134 #endif 01135 01136 private: 01137 int wrapColumn; 01138 bool wrapEnabled; 01139 bool m_bViewFormattingChars; 01140 bool biw; 01141 bool unused; // for future extensions 01142 01143 #ifdef HAVE_THAI_BREAKS 01144 static QCString *thaiCache; 01145 static KoTextString *cachedString; 01146 static ThBreakIterator *thaiIt; 01147 #endif 01148 }; 01149 01150 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 01151 01152 // Not used 01153 class KoTextIndent 01154 { 01155 public: 01156 KoTextIndent(); 01157 virtual ~KoTextIndent() {} 01158 01159 virtual void indent( KoTextDocument *doc, KoTextParag *parag, int *oldIndent = 0, int *newIndent = 0 ) = 0; 01160 01161 }; 01162 01163 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 01164 01165 #if 0 01166 class KoTextPreProcessor 01167 { 01168 public: 01169 enum Ids { 01170 Standard = 0 01171 }; 01172 01173 KoTextPreProcessor() {} 01174 virtual ~KoTextPreProcessor() {} 01175 01176 virtual void process( KoTextDocument *doc, KoTextParag *, int, bool = TRUE ) = 0; 01177 virtual KoTextFormat *format( int id ) = 0; 01178 01179 }; 01180 #endif 01181 01182 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 01183 01184 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 01185 01186 inline int KoTextString::length() const 01187 { 01188 return data.size(); 01189 } 01190 01191 inline void KoTextString::operator+=( const QString &s ) 01192 { 01193 insert( length(), s, 0 ); 01194 } 01195 01196 inline int KoTextParag::length() const 01197 { 01198 return str->length(); 01199 } 01200 01201 inline QRect KoTextParag::rect() const 01202 { 01203 return r; 01204 } 01205 01206 inline KoTextParag *KoTextCursor::parag() const 01207 { 01208 return string; 01209 } 01210 01211 inline int KoTextCursor::index() const 01212 { 01213 return idx; 01214 } 01215 01216 inline void KoTextCursor::setParag( KoTextParag *s, bool restore ) 01217 { 01218 if ( restore ) 01219 restoreState(); 01220 idx = 0; 01221 string = s; 01222 tmpIndex = -1; 01223 } 01224 01225 inline void KoTextCursor::checkIndex() 01226 { 01227 if ( idx >= string->length() ) 01228 idx = string->length() - 1; 01229 } 01230 01231 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 01232 01233 inline KoTextStringChar &KoTextString::at( int i ) const 01234 { 01235 return data[ i ]; 01236 } 01237 01238 inline QString KoTextString::toString() const 01239 { 01240 return toString( data ); 01241 } 01242 01243 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 01244 01245 inline KoTextStringChar *KoTextParag::at( int i ) const 01246 { 01247 return &str->at( i ); 01248 } 01249 01250 inline bool KoTextParag::isValid() const 01251 { 01252 return invalid == -1; 01253 } 01254 01255 inline bool KoTextParag::hasChanged() const 01256 { 01257 return changed; 01258 } 01259 01260 inline short int KoTextParag::lineChanged() 01261 { 01262 return m_lineChanged; 01263 } 01264 01265 /*inline void KoTextParag::setBackgroundColor( const QColor & c ) 01266 { 01267 delete bgcol; 01268 bgcol = new QColor( c ); 01269 setChanged( TRUE ); 01270 } 01271 01272 inline void KoTextParag::clearBackgroundColor() 01273 { 01274 delete bgcol; bgcol = 0; setChanged( TRUE ); 01275 } 01276 */ 01277 01278 inline void KoTextParag::append( const QString &s, bool reallyAtEnd ) 01279 { 01280 if ( reallyAtEnd ) 01281 insert( str->length(), s ); 01282 else 01283 insert( QMAX( str->length() - 1, 0 ), s ); 01284 } 01285 01286 inline KoTextParag *KoTextParag::prev() const 01287 { 01288 return p; 01289 } 01290 01291 inline KoTextParag *KoTextParag::next() const 01292 { 01293 return n; 01294 } 01295 01296 inline bool KoTextParag::hasAnySelection() const 01297 { 01298 return mSelections ? !selections().isEmpty() : FALSE; 01299 } 01300 01301 /*inline void KoTextParag::setEndState( int s ) 01302 { 01303 if ( s == state ) 01304 return; 01305 state = s; 01306 } 01307 01308 inline int KoTextParag::endState() const 01309 { 01310 return state; 01311 }*/ 01312 01313 inline void KoTextParag::setParagId( int i ) 01314 { 01315 id = i; 01316 } 01317 01318 inline int KoTextParag::paragId() const 01319 { 01320 //if ( id == -1 ) 01321 // kdWarning() << "invalid parag id!!!!!!!! (" << (void*)this << ")" << endl; 01322 return id; 01323 } 01324 01325 /*inline bool KoTextParag::firstPreProcess() const 01326 { 01327 return firstPProcess; 01328 } 01329 01330 inline void KoTextParag::setFirstPreProcess( bool b ) 01331 { 01332 firstPProcess = b; 01333 }*/ 01334 01335 inline QMap<int, KoTextParagLineStart*> &KoTextParag::lineStartList() 01336 { 01337 return lineStarts; 01338 } 01339 01340 inline KoTextString *KoTextParag::string() const 01341 { 01342 return str; 01343 } 01344 01345 inline KoTextDocument *KoTextParag::document() const 01346 { 01347 return doc; 01348 } 01349 01350 inline void KoTextParag::setAlignment( uint a ) 01351 { 01352 if ( a == align ) 01353 return; 01354 align = a; 01355 invalidate( 0 ); 01356 } 01357 01358 /*inline void KoTextParag::setListStyle( QStyleSheetItem::ListStyle ls ) 01359 { 01360 lstyle = ls; 01361 invalidate( 0 ); 01362 } 01363 01364 inline QStyleSheetItem::ListStyle KoTextParag::listStyle() const 01365 { 01366 return lstyle; 01367 }*/ 01368 01369 inline KoTextFormat *KoTextParag::paragFormat() const 01370 { 01371 return defFormat; 01372 } 01373 01374 inline void KoTextParag::registerFloatingItem( KoTextCustomItem *i ) 01375 { 01376 floatingItems().append( i ); 01377 } 01378 01379 inline void KoTextParag::unregisterFloatingItem( KoTextCustomItem *i ) 01380 { 01381 floatingItems().removeRef( i ); 01382 } 01383 01384 /*inline void KoTextParag::addCustomItem() 01385 { 01386 numCustomItems++; 01387 } 01388 01389 inline void KoTextParag::removeCustomItem() 01390 { 01391 numCustomItems--; 01392 }*/ 01393 01394 inline int KoTextParag::customItems() const 01395 { 01396 return mFloatingItems ? mFloatingItems->count() : 0; 01397 // was numCustomItems, but no need for a separate count 01398 } 01399 01400 inline QBrush *KoTextParag::background() const 01401 { 01402 #ifdef QTEXTTABLE_AVAILABLE 01403 return tc ? tc->backGround() : 0; 01404 #endif 01405 return 0; 01406 } 01407 01408 01409 //inline void KoTextParag::setDocumentRect( const QRect &r ) 01410 //{ 01411 // docRect = r; 01412 //} 01413 01414 /*inline void KoTextParag::setExtraData( KoTextParagData *data ) 01415 { 01416 eData = data; 01417 } 01418 01419 inline KoTextParagData *KoTextParag::extraData() const 01420 { 01421 return eData; 01422 }*/ 01423 01424 inline void KoTextParag::setNewLinesAllowed( bool b ) 01425 { 01426 newLinesAllowed = b; 01427 } 01428 01429 inline bool KoTextParag::isNewLinesAllowed() const 01430 { 01431 return newLinesAllowed; 01432 } 01433 01434 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 01435 01436 inline KoTextFormat *KoTextStringChar::format() const 01437 { 01438 return (type == Regular) ? d.format : d.custom->format; 01439 } 01440 01441 inline KoTextCustomItem *KoTextStringChar::customItem() const 01442 { 01443 return isCustom() ? d.custom->custom : 0; 01444 } 01445 01446 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Sep 24 18:22:26 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003