summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-write/qrichtext_p.h
Unidiff
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.h157
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
@@ -50,6 +50,9 @@
50// 50//
51// 51//
52 52
53#include <opie2/odebug.h>
54using namespace Opie::Core;
55
53#ifndef QT_H 56#ifndef QT_H
54#include "qstring.h" 57#include "qstring.h"
55#include "qlist.h" 58#include "qlist.h"
@@ -124,17 +127,17 @@ public:
124 void setCustomItem( QTextCustomItem *i ); 127 void setCustomItem( QTextCustomItem *i );
125 struct CustomData 128 struct CustomData
126 { 129 {
127 QTextFormat *format; 130 QTextFormat *format;
128 QTextCustomItem *custom; 131 QTextCustomItem *custom;
129 QString anchorName; 132 QString anchorName;
130 QString anchorHref; 133 QString anchorHref;
131 }; 134 };
132 135
133 void loseCustomItem(); 136 void loseCustomItem();
134 137
135 union { 138 union {
136 QTextFormat* format; 139 QTextFormat* format;
137 CustomData* custom; 140 CustomData* custom;
138 } d; 141 } d;
139 142
140 bool isAnchor() const { return ( type & Anchor) != 0; } 143 bool isAnchor() const { return ( type & Anchor) != 0; }
@@ -144,8 +147,8 @@ public:
144 147
145private: 148private:
146 QTextStringChar &operator=( const QTextStringChar & ) { 149 QTextStringChar &operator=( const QTextStringChar & ) {
147 //abort(); 150 //abort();
148 return *this; 151 return *this;
149 } 152 }
150 friend class QComplexText; 153 friend class QComplexText;
151 friend class QTextParagraph; 154 friend class QTextParagraph;
@@ -208,14 +211,14 @@ private:
208inline bool QTextString::isBidi() const 211inline bool QTextString::isBidi() const
209{ 212{
210 if ( bidiDirty ) 213 if ( bidiDirty )
211 checkBidi(); 214 checkBidi();
212 return bidi; 215 return bidi;
213} 216}
214 217
215inline bool QTextString::isRightToLeft() const 218inline bool QTextString::isRightToLeft() const
216{ 219{
217 if ( bidiDirty ) 220 if ( bidiDirty )
218 checkBidi(); 221 checkBidi();
219 return rightToLeft; 222 return rightToLeft;
220} 223}
221 224
@@ -384,7 +387,7 @@ class Q_EXPORT QTextCustomItem
384{ 387{
385public: 388public:
386 QTextCustomItem( QTextDocument *p ) 389 QTextCustomItem( QTextDocument *p )
387 : xpos(0), ypos(-1), width(-1), height(0), parent( p ) 390 : xpos(0), ypos(-1), width(-1), height(0), parent( p )
388 {} 391 {}
389 virtual ~QTextCustomItem(); 392 virtual ~QTextCustomItem();
390 virtual void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) = 0; 393 virtual void draw(QPainter* p, int x, int y, int cx, int cy, int cw, int ch, const QColorGroup& cg, bool selected ) = 0;
@@ -438,7 +441,7 @@ class Q_EXPORT QTextImage : public QTextCustomItem
438{ 441{
439public: 442public:
440 QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, 443 QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
441 QMimeSourceFactory &factory ); 444 QMimeSourceFactory &factory );
442 virtual ~QTextImage(); 445 virtual ~QTextImage();
443 446
444 Placement placement() const { return place; } 447 Placement placement() const { return place; }
@@ -463,7 +466,7 @@ class Q_EXPORT QTextHorizontalLine : public QTextCustomItem
463{ 466{
464public: 467public:
465 QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, 468 QTextHorizontalLine( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context,
466 QMimeSourceFactory &factory ); 469 QMimeSourceFactory &factory );
467 virtual ~QTextHorizontalLine(); 470 virtual ~QTextHorizontalLine();
468 471
469 void adjustToPainter( QPainter* ); 472 void adjustToPainter( QPainter* );
@@ -532,11 +535,11 @@ class Q_EXPORT QTextTableCell : public QLayoutItem
532 535
533public: 536public:
534 QTextTableCell( QTextTable* table, 537 QTextTableCell( QTextTable* table,
535 int row, int column, 538 int row, int column,
536 const QMap<QString, QString> &attr, 539 const QMap<QString, QString> &attr,
537 const QStyleSheetItem* style, 540 const QStyleSheetItem* style,
538 const QTextFormat& fmt, const QString& context, 541 const QTextFormat& fmt, const QString& context,
539 QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc ); 542 QMimeSourceFactory &factory, QStyleSheet *sheet, const QString& doc );
540 virtual ~QTextTableCell(); 543 virtual ~QTextTableCell();
541 544
542 QSize sizeHint() const ; 545 QSize sizeHint() const ;
@@ -606,7 +609,7 @@ public:
606 void adjustToPainter( QPainter *p ); 609 void adjustToPainter( QPainter *p );
607 void pageBreak( int y, QTextFlow* flow ); 610 void pageBreak( int y, QTextFlow* flow );
608 void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch, 611 void draw( QPainter* p, int x, int y, int cx, int cy, int cw, int ch,
609 const QColorGroup& cg, bool selected ); 612 const QColorGroup& cg, bool selected );
610 613
611 bool noErase() const { return TRUE; } 614 bool noErase() const { return TRUE; }
612 bool ownLine() const { return TRUE; } 615 bool ownLine() const { return TRUE; }
@@ -684,9 +687,9 @@ class Q_EXPORT QTextDocument : public QObject
684 687
685public: 688public:
686 enum SelectionIds { 689 enum SelectionIds {
687 Standard = 0, 690 Standard = 0,
688 Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to 691 Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to
689 // remove multiple lines with removeSelectedText() 692 // remove multiple lines with removeSelectedText()
690 }; 693 };
691 694
692 QTextDocument( QTextDocument *p ); 695 QTextDocument( QTextDocument *p );
@@ -791,11 +794,11 @@ public:
791 void doLayout( QPainter *p, int w ); 794 void doLayout( QPainter *p, int w );
792 void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 ); 795 void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 );
793 void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch, 796 void drawParagraph( QPainter *p, QTextParagraph *parag, int cx, int cy, int cw, int ch,
794 QPixmap *&doubleBuffer, const QColorGroup &cg, 797 QPixmap *&doubleBuffer, const QColorGroup &cg,
795 bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE ); 798 bool drawCursor, QTextCursor *cursor, bool resetChanged = TRUE );
796 QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg, 799 QTextParagraph *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg,
797 bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0, 800 bool onlyChanged = FALSE, bool drawCursor = FALSE, QTextCursor *cursor = 0,
798 bool resetChanged = TRUE ); 801 bool resetChanged = TRUE );
799 802
800 void registerCustomItem( QTextCustomItem *i, QTextParagraph *p ); 803 void registerCustomItem( QTextCustomItem *i, QTextParagraph *p );
801 void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p ); 804 void unregisterCustomItem( QTextCustomItem *i, QTextParagraph *p );
@@ -858,7 +861,7 @@ private:
858 bool hasPrefix(const QChar* doc, int length, int pos, QChar c); 861 bool hasPrefix(const QChar* doc, int length, int pos, QChar c);
859 bool hasPrefix(const QChar* doc, int length, int pos, const QString& s); 862 bool hasPrefix(const QChar* doc, int length, int pos, const QString& s);
860 QTextCustomItem* parseTable( const QMap<QString, QString> &attr, const QTextFormat &fmt, 863 QTextCustomItem* parseTable( const QMap<QString, QString> &attr, const QTextFormat &fmt,
861 const QChar* doc, int length, int& pos, QTextParagraph *curpar ); 864 const QChar* doc, int length, int& pos, QTextParagraph *curpar );
862 bool eatSpace(const QChar* doc, int length, int& pos, bool includeNbsp = FALSE ); 865 bool eatSpace(const QChar* doc, int length, int& pos, bool includeNbsp = FALSE );
863 bool eat(const QChar* doc, int length, int& pos, QChar c); 866 bool eat(const QChar* doc, int length, int& pos, QChar c);
864 QString parseOpenTag(const QChar* doc, int length, int& pos, QMap<QString, QString> &attr, bool& emptyTag); 867 QString parseOpenTag(const QChar* doc, int length, int& pos, QMap<QString, QString> &attr, bool& emptyTag);
@@ -871,9 +874,9 @@ private:
871 874
872private: 875private:
873 struct Q_EXPORT Focus { 876 struct Q_EXPORT Focus {
874 QTextParagraph *parag; 877 QTextParagraph *parag;
875 int start, len; 878 int start, len;
876 QString href; 879 QString href;
877 }; 880 };
878 881
879 int cx, cy, cw, vw; 882 int cx, cy, cw, vw;
@@ -931,7 +934,7 @@ class Q_EXPORT QTextDeleteCommand : public QTextCommand
931{ 934{
932public: 935public:
933 QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, 936 QTextDeleteCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str,
934 const QByteArray& oldStyle ); 937 const QByteArray& oldStyle );
935 QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ); 938 QTextDeleteCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str );
936 virtual ~QTextDeleteCommand(); 939 virtual ~QTextDeleteCommand();
937 940
@@ -951,10 +954,10 @@ class Q_EXPORT QTextInsertCommand : public QTextDeleteCommand
951{ 954{
952public: 955public:
953 QTextInsertCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str, 956 QTextInsertCommand( QTextDocument *d, int i, int idx, const QMemArray<QTextStringChar> &str,
954 const QByteArray& oldStyleInfo ) 957 const QByteArray& oldStyleInfo )
955 : QTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {} 958 : QTextDeleteCommand( d, i, idx, str, oldStyleInfo ) {}
956 QTextInsertCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str ) 959 QTextInsertCommand( QTextParagraph *p, int idx, const QMemArray<QTextStringChar> &str )
957 : QTextDeleteCommand( p, idx, str ) {} 960 : QTextDeleteCommand( p, idx, str ) {}
958 virtual ~QTextInsertCommand() {} 961 virtual ~QTextInsertCommand() {}
959 962
960 Commands type() const { return Insert; } 963 Commands type() const { return Insert; }
@@ -1011,37 +1014,37 @@ struct Q_EXPORT QTextLineStart
1011{ 1014{
1012 QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 ) 1015 QTextLineStart() : y( 0 ), baseLine( 0 ), h( 0 )
1013#ifndef QT_NO_COMPLEXTEXT 1016#ifndef QT_NO_COMPLEXTEXT
1014 , bidicontext( 0 ) 1017 , bidicontext( 0 )
1015#endif 1018#endif
1016 { } 1019 { }
1017 QTextLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ), 1020 QTextLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ),
1018 w( 0 ) 1021 w( 0 )
1019#ifndef QT_NO_COMPLEXTEXT 1022#ifndef QT_NO_COMPLEXTEXT
1020 , bidicontext( 0 ) 1023 , bidicontext( 0 )
1021#endif 1024#endif
1022 { } 1025 { }
1023#ifndef QT_NO_COMPLEXTEXT 1026#ifndef QT_NO_COMPLEXTEXT
1024 QTextLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0), 1027 QTextLineStart( QBidiContext *c, QBidiStatus s ) : y(0), baseLine(0), h(0),
1025 status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); } 1028 status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); }
1026#endif 1029#endif
1027 1030
1028 virtual ~QTextLineStart() 1031 virtual ~QTextLineStart()
1029 { 1032 {
1030#ifndef QT_NO_COMPLEXTEXT 1033#ifndef QT_NO_COMPLEXTEXT
1031 if ( bidicontext && bidicontext->deref() ) 1034 if ( bidicontext && bidicontext->deref() )
1032 delete bidicontext; 1035 delete bidicontext;
1033#endif 1036#endif
1034 } 1037 }
1035 1038
1036#ifndef QT_NO_COMPLEXTEXT 1039#ifndef QT_NO_COMPLEXTEXT
1037 void setContext( QBidiContext *c ) { 1040 void setContext( QBidiContext *c ) {
1038 if ( c == bidicontext ) 1041 if ( c == bidicontext )
1039 return; 1042 return;
1040 if ( bidicontext && bidicontext->deref() ) 1043 if ( bidicontext && bidicontext->deref() )
1041 delete bidicontext; 1044 delete bidicontext;
1042 bidicontext = c; 1045 bidicontext = c;
1043 if ( bidicontext ) 1046 if ( bidicontext )
1044 bidicontext->ref(); 1047 bidicontext->ref();
1045 } 1048 }
1046 QBidiContext *context() const { return bidicontext; } 1049 QBidiContext *context() const { return bidicontext; }
1047#endif 1050#endif
@@ -1183,7 +1186,7 @@ public:
1183 int alignment() const; 1186 int alignment() const;
1184 1187
1185 virtual void paint( QPainter &painter, const QColorGroup &cg, QTextCursor *cursor = 0, bool drawSelections = FALSE, 1188 virtual void paint( QPainter &painter, const QColorGroup &cg, QTextCursor *cursor = 0, bool drawSelections = FALSE,
1186 int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 ); 1189 int clipx = -1, int clipy = -1, int clipw = -1, int cliph = -1 );
1187 1190
1188 virtual int topMargin() const; 1191 virtual int topMargin() const;
1189 virtual int bottomMargin() const; 1192 virtual int bottomMargin() const;
@@ -1246,9 +1249,9 @@ public:
1246protected: 1249protected:
1247 virtual void drawLabel( QPainter* p, int x, int y, int w, int h, int base, const QColorGroup& cg ); 1250 virtual void drawLabel( QPainter* p, int x, int y, int w, int h, int base, const QColorGroup& cg );
1248 virtual void drawString( QPainter &painter, const QString &str, int start, int len, int xstart, 1251 virtual void drawString( QPainter &painter, const QString &str, int start, int len, int xstart,
1249 int y, int baseLine, int w, int h, int selection, 1252 int y, int baseLine, int w, int h, int selection,
1250 QTextStringChar *formatChar, const QColorGroup& cg, 1253 QTextStringChar *formatChar, const QColorGroup& cg,
1251 bool rightToLeft ); 1254 bool rightToLeft );
1252 1255
1253private: 1256private:
1254 QMap<int, QTextParagraphSelection> &selections() const; 1257 QMap<int, QTextParagraphSelection> &selections() const;
@@ -1315,10 +1318,10 @@ public:
1315 1318
1316protected: 1319protected:
1317 virtual QTextLineStart *formatLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start, 1320 virtual QTextLineStart *formatLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start,
1318 QTextStringChar *last, int align = Qt3::AlignAuto, int space = 0 ); 1321 QTextStringChar *last, int align = Qt3::AlignAuto, int space = 0 );
1319#ifndef QT_NO_COMPLEXTEXT 1322#ifndef QT_NO_COMPLEXTEXT
1320 virtual QTextLineStart *bidiReorderLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start, 1323 virtual QTextLineStart *bidiReorderLine( QTextParagraph *parag, QTextString *string, QTextLineStart *line, QTextStringChar *start,
1321 QTextStringChar *last, int align, int space ); 1324 QTextStringChar *last, int align, int space );
1322#endif 1325#endif
1323 void insertLineStart( QTextParagraph *parag, int index, QTextLineStart *ls ); 1326 void insertLineStart( QTextParagraph *parag, int index, QTextLineStart *ls );
1324 1327
@@ -1379,7 +1382,7 @@ class Q_EXPORT QTextPreProcessor
1379{ 1382{
1380public: 1383public:
1381 enum Ids { 1384 enum Ids {
1382 Standard = 0 1385 Standard = 0
1383 }; 1386 };
1384 1387
1385 QTextPreProcessor(); 1388 QTextPreProcessor();
@@ -1399,18 +1402,18 @@ class Q_EXPORT QTextFormat
1399 1402
1400public: 1403public:
1401 enum Flags { 1404 enum Flags {
1402 NoFlags, 1405 NoFlags,
1403 Bold = 1, 1406 Bold = 1,
1404 Italic = 2, 1407 Italic = 2,
1405 Underline = 4, 1408 Underline = 4,
1406 Family = 8, 1409 Family = 8,
1407 Size = 16, 1410 Size = 16,
1408 Color = 32, 1411 Color = 32,
1409 Misspelled = 64, 1412 Misspelled = 64,
1410 VAlign = 128, 1413 VAlign = 128,
1411 StrikeOut= 256, 1414 StrikeOut= 256,
1412 Font = Bold | Italic | Underline | Family | Size | StrikeOut, 1415 Font = Bold | Italic | Underline | Family | Size | StrikeOut,
1413 Format = Font | Color | Misspelled | VAlign 1416 Format = Font | Color | Misspelled | VAlign
1414 }; 1417 };
1415 1418
1416 enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript }; 1419 enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript };
@@ -1729,14 +1732,14 @@ inline void QTextDocument::setTabStops( int tw )
1729inline QString QTextDocument::originalText() const 1732inline QString QTextDocument::originalText() const
1730{ 1733{
1731 if ( oTextValid ) 1734 if ( oTextValid )
1732 return oText; 1735 return oText;
1733 return text(); 1736 return text();
1734} 1737}
1735 1738
1736inline void QTextDocument::setFlow( QTextFlow *f ) 1739inline void QTextDocument::setFlow( QTextFlow *f )
1737{ 1740{
1738 if ( flow_ ) 1741 if ( flow_ )
1739 delete flow_; 1742 delete flow_;
1740 flow_ = f; 1743 flow_ = f;
1741} 1744}
1742 1745
@@ -1786,11 +1789,11 @@ inline void QTextFormat::removeRef()
1786{ 1789{
1787 ref--; 1790 ref--;
1788 if ( !collection ) 1791 if ( !collection )
1789 return; 1792 return;
1790 if ( this == collection->defFormat ) 1793 if ( this == collection->defFormat )
1791 return; 1794 return;
1792 if ( ref == 0 ) 1795 if ( ref == 0 )
1793 collection->remove( this ); 1796 collection->remove( this );
1794} 1797}
1795 1798
1796inline QString QTextFormat::key() const 1799inline QString QTextFormat::key() const
@@ -1843,9 +1846,9 @@ inline void QTextParagraph::clearBackgroundColor()
1843inline void QTextParagraph::append( const QString &s, bool reallyAtEnd ) 1846inline void QTextParagraph::append( const QString &s, bool reallyAtEnd )
1844{ 1847{
1845 if ( reallyAtEnd ) 1848 if ( reallyAtEnd )
1846 insert( str->length(), s ); 1849 insert( str->length(), s );
1847 else 1850 else
1848 insert( QMAX( str->length() - 1, 0 ), s ); 1851 insert( QMAX( str->length() - 1, 0 ), s );
1849} 1852}
1850 1853
1851inline QTextParagraph *QTextParagraph::prev() const 1854inline QTextParagraph *QTextParagraph::prev() const
@@ -1866,7 +1869,7 @@ inline bool QTextParagraph::hasAnySelection() const
1866inline void QTextParagraph::setEndState( int s ) 1869inline void QTextParagraph::setEndState( int s )
1867{ 1870{
1868 if ( s == state ) 1871 if ( s == state )
1869 return; 1872 return;
1870 state = s; 1873 state = s;
1871} 1874}
1872 1875
@@ -1883,7 +1886,7 @@ inline void QTextParagraph::setParagId( int i )
1883inline int QTextParagraph::paragId() const 1886inline int QTextParagraph::paragId() const
1884{ 1887{
1885 if ( id == -1 ) 1888 if ( id == -1 )
1886 qWarning( "invalid parag id!!!!!!!! (%p)", (void*)this ); 1889 owarn << "invalid parag id!!!!!!!! (" << (void*)this << ")" << oendl;
1887 return id; 1890 return id;
1888} 1891}
1889 1892
@@ -1910,14 +1913,14 @@ inline QTextString *QTextParagraph::string() const
1910inline QTextDocument *QTextParagraph::document() const 1913inline QTextDocument *QTextParagraph::document() const
1911{ 1914{
1912 if ( hasdoc ) 1915 if ( hasdoc )
1913 return (QTextDocument*) docOrPseudo; 1916 return (QTextDocument*) docOrPseudo;
1914 return 0; 1917 return 0;
1915} 1918}
1916 1919
1917inline QTextParagraphPseudoDocument *QTextParagraph::pseudoDocument() const 1920inline QTextParagraphPseudoDocument *QTextParagraph::pseudoDocument() const
1918{ 1921{
1919 if ( hasdoc ) 1922 if ( hasdoc )
1920 return 0; 1923 return 0;
1921 return (QTextParagraphPseudoDocument*) docOrPseudo; 1924 return (QTextParagraphPseudoDocument*) docOrPseudo;
1922} 1925}
1923 1926