Diffstat (limited to 'noncore/apps/opie-write/qrichtext_p.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-write/qrichtext_p.h | 157 |
1 files changed, 80 insertions, 77 deletions
diff --git a/noncore/apps/opie-write/qrichtext_p.h b/noncore/apps/opie-write/qrichtext_p.h index e368edb..3778feb 100644 --- a/noncore/apps/opie-write/qrichtext_p.h +++ b/noncore/apps/opie-write/qrichtext_p.h @@ -47,12 +47,15 @@ // version to version without notice, or even be removed. // // We mean it. // // +#include <opie2/odebug.h> +using namespace Opie::Core; + #ifndef QT_H #include "qstring.h" #include "qlist.h" #include "qrect.h" #include "qfontmetrics.h" #include "qintdict.h" @@ -121,34 +124,34 @@ public: QTextFormat *format() const; QTextCustomItem *customItem() const; void setFormat( QTextFormat *f ); void setCustomItem( QTextCustomItem *i ); struct CustomData { - QTextFormat *format; - QTextCustomItem *custom; - QString anchorName; - QString anchorHref; + QTextFormat *format; + QTextCustomItem *custom; + QString anchorName; + QString anchorHref; }; void loseCustomItem(); union { - QTextFormat* format; - CustomData* custom; + QTextFormat* format; + CustomData* custom; } d; bool isAnchor() const { return ( type & Anchor) != 0; } QString anchorName() const; QString anchorHref() const; void setAnchor( const QString& name, const QString& href ); private: QTextStringChar &operator=( const QTextStringChar & ) { - //abort(); - return *this; + //abort(); + return *this; } friend class QComplexText; friend class QTextParagraph; }; #if defined(Q_TEMPLATEDLL) @@ -205,20 +208,20 @@ private: uint dir : 5; }; inline bool QTextString::isBidi() const { if ( bidiDirty ) - checkBidi(); + checkBidi(); return bidi; } inline bool QTextString::isRightToLeft() const { if ( bidiDirty ) - checkBidi(); + checkBidi(); return rightToLeft; } inline QChar::Direction QTextString::direction() const { return (QChar::Direction) dir; @@ -381,13 +384,13 @@ inline QTextCommandHistory::~QTextCommandHistory() // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ class Q_EXPORT QTextCustomItem { public: QTextCustomItem( QTextDocument *p ) - : xpos(0), ypos(-1), width(-1), height(0), parent( p ) + : xpos(0), ypos(-1), width(-1), height(0), parent( p ) {} virtual ~QTextCustomItem(); virtual void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) = 0; virtual void adjustToPainter( QPainter* ); @@ -435,13 +438,13 @@ Q_TEMPLATE_EXTERN template class Q_EXPORT QMap<QString, QString>; #endif class Q_EXPORT QTextImage : public QTextCustomItem { public: QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, - QMimeSourceFactory &factory ); + QMimeSourceFactory &factory ); virtual ~QTextImage(); Placement placement() const { return place; } void adjustToPainter( QPainter* ); int minimumWidth() const { return width; } @@ -460,13 +463,13 @@ private: }; class Q_EXPORT QTextHorizontalLine : public QTextCustomItem { public: QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, - QMimeSourceFactory &factory ); + QMimeSourceFactory &factory ); virtual ~QTextHorizontalLine(); void adjustToPainter( QPainter* ); void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ); QString richText() const; @@ -529,17 +532,17 @@ class QTextTable; class Q_EXPORT QTextTableCell : public QLayoutItem { friend class QTextTable; public: QTextTableCell( QTextTable* table, - int row, int column, - const QMap<QString, QString> &attr, - const QStyleSheetItem* style, - const QTextFormat& fmt, const QString& context, - QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc ); + int row, int column, + const QMap<QString, QString> &attr, + const QStyleSheetItem* style, + const QTextFormat& fmt, const QString& context, + QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc ); virtual ~QTextTableCell(); QSize sizeHint() const ; QSize minimumSize() const ; QSize maximumSize() const ; QSizePolicy::ExpandData expanding() const; @@ -603,13 +606,13 @@ public: QTextTable( QTextDocument *p, const QMap<QString, QString> &attr ); virtual ~QTextTable(); void adjustToPainter( QPainter *p ); void pageBreak( int y, QTextFlow* flow ); void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, - const QColorGroup& cg, bool selected ); + const QColorGroup& cg, bool selected ); bool noErase() const { return TRUE; } bool ownLine() const { return TRUE; } Placement placement() const { return place; } bool isNested() const { return TRUE; } void resize( int nwidth ); @@ -681,15 +684,15 @@ class Q_EXPORT QTextDocument : public QObject friend class QTextCursor; friend class QTextEdit; friend class QTextParagraph; public: enum SelectionIds { - Standard = 0, - Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to - // remove multiple lines with removeSelectedText() + Standard = 0, + Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to + // remove multiple lines with removeSelectedText() }; QTextDocument( QTextDocument *p ); QTextDocument( QTextDocument *d, QTextFormatCollection *f ); virtual ~QTextDocument(); @@ -788,17 +791,17 @@ public: void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; } QBrush *paper() const { return backBrush; } void doLayout( QPainter *p, int w ); void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 ); void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch, - QPixmap *&doubleBuffer, const QColorGroup &cg, - bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE ); + QPixmap *&doubleBuffer, const QColorGroup &cg, + bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE ); QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg, - bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0, - bool resetChanged = TRUE ); + bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0, + bool resetChanged = TRUE ); void registerCustomItem( QTextCustomItem *i, QTextParagraph *p ); void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p ); void setFlow( QTextFlow *f ); void takeFlow(); @@ -855,28 +858,28 @@ private: void init(); QPixmap *bufferPixmap( const QSize &s ); // HTML parser bool hasPrefix(const QChar* doc, int length, int pos, QChar c); bool hasPrefix(const QChar* doc, int length, int pos, const QString& s); QTextCustomItem* parseTable( const QMap<QString, QString> &attr, const QTextFormat &fmt, - const QChar* doc, int length, int& pos, QTextParagraph *curpar ); + const QChar* doc, int length, int& pos, QTextParagraph *curpar ); bool eatSpace(const QChar* doc, int length, int& pos, bool includeNbsp = FALSE ); bool eat(const QChar* doc, int length, int& pos, QChar c); QString parseOpenTag(const QChar* doc, int length, int& pos, QMap<QString, QString> &attr, bool& emptyTag); QString parseCloseTag( const QChar* doc, int length, int& pos ); QChar parseHTMLSpecialChar(const QChar* doc, int length, int& pos); QString parseWord(const QChar* doc, int length, int& pos, bool lower = TRUE); QChar parseChar(const QChar* doc, int length, int& pos, QStyleSheetItem::WhiteSpaceMode wsm ); void setRichTextInternal( const QString &text, QTextCursor* cursor = 0 ); void setRichTextMarginsInternal( QPtrList< QPtrVector<QStyleSheetItem> >& styles, QTextParagraph* stylesPar ); private: struct Q_EXPORT Focus { - QTextParagraph *parag; - int start, len; - QString href; + QTextParagraph *parag; + int start, len; + QString href; }; int cx, cy, cw, vw; QTextParagraph *fParag, *lParag; QTextPreProcessor *pProcessor; QMap<int, QColor> selectionColors; @@ -928,13 +931,13 @@ private: class Q_EXPORT QTextDeleteCommand : public QTextCommand { public: QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, - const QByteArray& oldStyle ); + const QByteArray& oldStyle ); QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ); virtual ~QTextDeleteCommand(); Commands type() const { return Delete; } QTextCursor *execute( QTextCursor *c ); QTextCursor *unexecute( QTextCursor *c ); @@ -948,16 +951,16 @@ protected: }; class Q_EXPORT QTextInsertCommand : public QTextDeleteCommand { public: QTextInsertCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, - const QByteArray& oldStyleInfo ) - : QTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {} + const QByteArray& oldStyleInfo ) + : QTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {} QTextInsertCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ) - : QTextDeleteCommand( p, idx, str ) {} + : QTextDeleteCommand( p, idx, str ) {} virtual ~QTextInsertCommand() {} Commands type() const { return Insert; } QTextCursor *execute( QTextCursor *c ) { return QTextDeleteCommand::unexecute( c ); } QTextCursor *unexecute( QTextCursor *c ) { return QTextDeleteCommand::execute( c ); } @@ -1008,43 +1011,43 @@ struct Q_EXPORT QTextParagraphSelection }; struct Q_EXPORT QTextLineStart { QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 ) #ifndef QT_NO_COMPLEXTEXT - , bidicontext( 0 ) + , bidicontext( 0 ) #endif { } QTextLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ), - w( 0 ) + w( 0 ) #ifndef QT_NO_COMPLEXTEXT - , bidicontext( 0 ) + , bidicontext( 0 ) #endif { } #ifndef QT_NO_COMPLEXTEXT QTextLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0), - status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); } + status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); } #endif virtual ~QTextLineStart() { #ifndef QT_NO_COMPLEXTEXT - if ( bidicontext && bidicontext->deref() ) - delete bidicontext; + if ( bidicontext && bidicontext->deref() ) + delete bidicontext; #endif } #ifndef QT_NO_COMPLEXTEXT void setContext( QBidiContext *c ) { - if ( c == bidicontext ) - return; - if ( bidicontext && bidicontext->deref() ) - delete bidicontext; - bidicontext = c; - if ( bidicontext ) - bidicontext->ref(); + if ( c == bidicontext ) + return; + if ( bidicontext && bidicontext->deref() ) + delete bidicontext; + bidicontext = c; + if ( bidicontext ) + bidicontext->ref(); } QBidiContext *context() const { return bidicontext; } #endif public: ushort y, baseLine, h; @@ -1180,13 +1183,13 @@ public: void setFormat( int index, int len, QTextFormat *f, bool useCollection = TRUE, int flags = -1 ); void setAlignment( int a ); int alignment() const; virtual void paint( QPainter &painter, const QColorGroup &cg, QTextCursor *cursor = 0, bool drawSelections = FALSE, - int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 ); + int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 ); virtual int topMargin() const; virtual int bottomMargin() const; virtual int leftMargin() const; virtual int firstLineMargin() const; virtual int rightMargin() const; @@ -1243,15 +1246,15 @@ public: void readStyleInformation( QDataStream& stream ); void writeStyleInformation( QDataStream& stream ) const; protected: virtual void drawLabel( QPainter* p, int x, int y, int w, int h, int base, const QColorGroup& cg ); virtual void drawString( QPainter &painter, const QString &str, int start, int len, int xstart, - int y, int baseLine, int w, int h, int selection, - QTextStringChar *formatChar, const QColorGroup& cg, - bool rightToLeft ); + int y, int baseLine, int w, int h, int selection, + QTextStringChar *formatChar, const QColorGroup& cg, + bool rightToLeft ); private: QMap<int, QTextParagraphSelection> &selections() const; QPtrList<QTextCustomItem> &floatingItems() const; QBrush backgroundBrush( const QColorGroup&cg ) { if ( bgcol ) return *bgcol; return cg.brush( QColorGroup::Base ); } void invalidateStyleCache(); @@ -1312,16 +1315,16 @@ public: int widthUsed() const { return thiswused; } static bool isBreakable( QTextString *string, int pos ); protected: virtual QTextLineStart *formatLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start, - QTextStringChar *last, int align = Qt3::AlignAuto, int space = 0 ); + QTextStringChar *last, int align = Qt3::AlignAuto, int space = 0 ); #ifndef QT_NO_COMPLEXTEXT virtual QTextLineStart *bidiReorderLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start, - QTextStringChar *last, int align, int space ); + QTextStringChar *last, int align, int space ); #endif void insertLineStart( QTextParagraph *parag, int index, QTextLineStart *ls ); int thisminw; int thiswused; @@ -1376,13 +1379,13 @@ public: // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ class Q_EXPORT QTextPreProcessor { public: enum Ids { - Standard = 0 + Standard = 0 }; QTextPreProcessor(); virtual ~QTextPreProcessor() {} virtual void process( QTextDocument *doc, QTextParagraph *, int, bool = TRUE ) = 0; @@ -1396,24 +1399,24 @@ class Q_EXPORT QTextFormat { friend class QTextFormatCollection; friend class QTextDocument; public: enum Flags { - NoFlags, - Bold = 1, - Italic = 2, - Underline = 4, - Family = 8, - Size = 16, - Color = 32, - Misspelled = 64, - VAlign = 128, - StrikeOut= 256, - Font = Bold | Italic | Underline | Family | Size | StrikeOut, - Format = Font | Color | Misspelled | VAlign + NoFlags, + Bold = 1, + Italic = 2, + Underline = 4, + Family = 8, + Size = 16, + Color = 32, + Misspelled = 64, + VAlign = 128, + StrikeOut= 256, + Font = Bold | Italic | Underline | Family | Size | StrikeOut, + Format = Font | Color | Misspelled | VAlign }; enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript }; QTextFormat(); virtual ~QTextFormat(); @@ -1726,20 +1729,20 @@ inline void QTextDocument::setTabStops( int tw ) tStopWidth = tw; } inline QString QTextDocument::originalText() const { if ( oTextValid ) - return oText; + return oText; return text(); } inline void QTextDocument::setFlow( QTextFlow *f ) { if ( flow_ ) - delete flow_; + delete flow_; flow_ = f; } inline void QTextDocument::takeFlow() { flow_ = 0; @@ -1783,17 +1786,17 @@ inline void QTextFormat::addRef() } inline void QTextFormat::removeRef() { ref--; if ( !collection ) - return; + return; if ( this == collection->defFormat ) - return; + return; if ( ref == 0 ) - collection->remove( this ); + collection->remove( this ); } inline QString QTextFormat::key() const { return k; } @@ -1840,15 +1843,15 @@ inline void QTextParagraph::clearBackgroundColor() delete bgcol; bgcol = 0; setChanged( TRUE ); } inline void QTextParagraph::append( const QString &s, bool reallyAtEnd ) { if ( reallyAtEnd ) - insert( str->length(), s ); + insert( str->length(), s ); else - insert( QMAX( str->length() - 1, 0 ), s ); + insert( QMAX( str->length() - 1, 0 ), s ); } inline QTextParagraph *QTextParagraph::prev() const { return p; } @@ -1863,13 +1866,13 @@ inline bool QTextParagraph::hasAnySelection() const return mSelections ? !selections().isEmpty() : FALSE; } inline void QTextParagraph::setEndState( int s ) { if ( s == state ) - return; + return; state = s; } inline int QTextParagraph::endState() const { return state; @@ -1880,13 +1883,13 @@ inline void QTextParagraph::setParagId( int i ) id = i; } inline int QTextParagraph::paragId() const { if ( id == -1 ) - qWarning( "invalid parag id!!!!!!!! (%p)", (void*)this ); + owarn << "invalid parag id!!!!!!!! (" << (void*)this << ")" << oendl; return id; } inline bool QTextParagraph::firstPreProcess() const { return firstPProcess; @@ -1907,20 +1910,20 @@ inline QTextString *QTextParagraph::string() const return str; } inline QTextDocument *QTextParagraph::document() const { if ( hasdoc ) - return (QTextDocument*) docOrPseudo; + return (QTextDocument*) docOrPseudo; return 0; } inline QTextParagraphPseudoDocument *QTextParagraph::pseudoDocument() const { if ( hasdoc ) - return 0; + return 0; return (QTextParagraphPseudoDocument*) docOrPseudo; } inline QTextTableCell *QTextParagraph::tableCell() const { |