22#include "KoParagLayout.h"
24#include "KoTextFormat.h"
25#include "KoRichText.h"
26class KoTextFormatterBase;
27class KoTextParagLineStart;
37struct KoTextParagSelection
42#if defined(TQ_TEMPLATEDLL)
44template class TQMap<int, KoTextParagSelection>;
45template class TQMap<int, KoTextParagLineStart*>;
49class KOTEXT_EXPORT KoTextParag
51 friend class KoTextDocument;
52 friend class KoTextCursor;
55 KoTextParag( KoTextDocument *d, KoTextParag *pr = 0, KoTextParag *nx = 0, bool updateIds = true );
56 virtual ~KoTextParag();
58 KoTextString *string() const;
59 KoTextStringChar *at( int i ) const;
64 int lastCharPos() const { return str->length()-2; }
69 KoTextDocument *document() const;
72 void setRect( const TQRect& rect ) { r = rect; }
73 void setHeight( int h ) { r.setHeight( h ); }
74 void setWidth( int w ) { r.setWidth( w ); }
77 bool isVisible() const { return visible; }
79 KoTextParag *prev() const;
80 KoTextParag * next() const;
81 void setPrev( KoTextParag *s );
82 void setNext( KoTextParag *s );
84 void insert( int index, const TQString &s );
85 void append( const TQString &s, bool reallyAtEnd = false );
86 void truncate( int index );
87 void remove( int index, int len );
90 void format( int start = -1, bool doMove = true );
93 void invalidate( int chr = 0 );
98 bool hasChanged() const;
99 void setChanged( bool b, bool recursive = false );
100 short int lineChanged();
101 void setLineChanged( short int line );
103 int lineHeightOfChar( int i, int *bl = 0, int *y = 0 ) const;
104 KoTextStringChar *lineStartOfChar( int i, int *index = 0, int *line = 0 ) const;
106 KoTextStringChar *lineStartOfLine( int line, int *index = 0 ) const;
107 int lineY( int l ) const;
108 int lineBaseLine( int l ) const;
109 int lineHeight( int l ) const;
110 void lineInfo( int l, int &y, int &h, int &bl ) const;
112 void setSelection( int id, int start, int end );
113 void removeSelection( int id );
114 int selectionStart( int id ) const;
115 int selectionEnd( int id ) const;
116 bool hasSelection( int id ) const;
117 bool hasAnySelection() const;
118 bool fullSelected( int id ) const;
123 void setParagId( int i );
126 TQMap<int, KoTextParagLineStart*> &lineStartList();
128 void setFormat( int index, int len, const KoTextFormat *f, bool useCollection = true, int flags = -1 );
130 void setAlignment( uint a );
131 void setAlignmentDirect( uint a ) { align = a; }
132 uint alignment() const;
134 virtual void paint( TQPainter &painter, const TQColorGroup &cg, KoTextCursor *cursor, bool drawSelections,
135 int clipx, int clipy, int clipw, int cliph );
138 int topMargin() const;
139 int bottomMargin() const;
140 int leftMargin() const;
141 int firstLineMargin() const;
142 int rightMargin() const;
143 int lineSpacing( int line ) const;
144 int calculateLineSpacing( int line, int start, int last ) const;
149 void setFullWidth( bool b ) { fullWidth = b; }
150 bool isFullWidth() const { return fullWidth; }
152 int customItems() const;
154 void setDocumentRect( const TQRect &r );
155 int documentWidth() const;
157 int documentX() const;
158 int documentY() const;
159 KoTextFormatCollection *formatCollection() const;
161 KoTextFormatterBase *formatter() const;
163 int widthUsed() const;
165 int nextTabDefault( int i, int x );
166 int nextTab( int i, int x, int availableWidth );
167 int *tabArray() const;
168 void setTabArray( int *a );
169 void setTabStops( int tw );
173 void setNewLinesAllowed( bool b );
175 bool isNewLinesAllowed() const;
177 virtual void join( KoTextParag *s );
178 virtual void copyParagData( KoTextParag *parag );
183 void setMovedDown( bool b ) { movedDown = b; }
184 bool wasMovedDown() const { return movedDown; }
186 void setDirection( TQChar::Direction d );
187 TQChar::Direction direction() const;
190 void setPartOfTableOfContents( bool b ) { m_toc = b; }
191 bool partOfTableOfContents() const { return m_toc; }
194 void insertLineStart( int index, KoTextParagLineStart *ls );
197 void drawLabel( TQPainter* p, int x, int y, int w, int h, int base, const TQColorGroup& cg );
198 void drawCursorDefault( TQPainter &painter, KoTextCursor *cursor, int curx, int cury, int curh, const TQColorGroup &cg );
199 void drawCursor( TQPainter &painter, KoTextCursor *cursor, int curx, int cury, int curh, const TQColorGroup &cg );
207 KoTextDocument * textDocument() const { return document(); }
210 { return static_cast<KoTextFormat * >( paragFormat() ); }
214 virtual void setParagLayout( const KoParagLayout &layout, int flags = KoParagLayout::All,
215 int marginIndex = -1 );
220 double margin( TQStyleSheetItem::Margin m ) { return m_layout. margins[m]; }
221 const double * margins() const { return m_layout.margins; }
222 void setMargin( TQStyleSheetItem::Margin m, double _i );
223 void setMargins( const double * _i );
226 double kwLineSpacing() const { return m_layout.lineSpacingValue(); }
228 void setLineSpacing( double _i );
236 void setAlign( int align );
238 int resolveAlignment() const;
242 int breakableTopMargin() const;
245 KoBorder leftBorder() const { return m_layout.leftBorder; }
246 KoBorder rightBorder() const { return m_layout.rightBorder; }
247 KoBorder topBorder() const { return m_layout.topBorder; }
248 KoBorder bottomBorder() const { return m_layout.bottomBorder; }
249 bool hasBorder() const { return m_layout.hasBorder(); }
250 bool joinBorder() const { return m_layout.joinBorder; }
252 void setLeftBorder( const KoBorder & _brd ) { m_layout.leftBorder = _brd; }
253 void setRightBorder( const KoBorder & _brd ) { m_layout.rightBorder = _brd; }
254 void setTopBorder( const KoBorder & _brd );
255 void setBottomBorder( const KoBorder & _brd );
256 void setJoinBorder( bool join );
259 TQColor backgroundColor() { return m_layout.backgroundColor; }
260 void setBackgroundColor( const TQColor& color);
271 int counterWidth() const;
276 void setStyle( KoParagStyle *style ) { m_layout.style = style; }
281 const KoTabulatorList& tabList() const { return m_layout.tabList(); }
283 void setTabList( const KoTabulatorList &tabList );
290 double shadowDistanceY() const;
295 void removeCustomItem( int index );
302 TQMap<int, int>& tabCache() { return m_tabCache; }
310 static void drawFontEffects( TQPainter * p, KoTextFormat *format, KoTextZoomHandler *zh, TQFont font, const TQColor & color, int startX, int baseLine, int bw, int y, int h, TQChar firstChar );
313 TQString toString( int from = 0, int length = 0xffffffff) const;
316 void fixParagWidth( bool viewFormattingChars );
324 int from, int to, bool saveAnchorsFramesets = false ) const;
332 void loadOasisSpan( const TQDomElement& parent, KoOasisContext& context, uint& pos, bool stripLeadingSpace = false );
341 void loadOasisSpan( const TQDomElement& parent, KoOasisContext& context, uint& pos, bool stripLeadingSpace, bool *hasTrailingSpace );
343 void applyListStyle( KoOasisContext& context, int restartNumbering, bool orderedList, bool heading, int level );
346 void printRTDebug( int );
350 void invalidateCounters();
351 bool lineHyphenated( int l ) const;
353 void paintLines( TQPainter &painter, const TQColorGroup &cg, KoTextCursor *cursor, bool drawSelections,
354 int clipx, int clipy, int clipw, int cliph );
356 void drawParagString( TQPainter &painter, const TQString &str, int start, int len, int startX,
357 int lastY, int baseLine, int bw, int h, bool drawSelections,
358 KoTextFormat *lastFormat, const TQMemArray<int> &selectionStarts,
359 const TQMemArray<int> &selectionEnds, const TQColorGroup &cg, bool rightToLeft, int line );
360 void drawParagStringInternal( TQPainter &painter, const TQString &s, int start, int len, int startX,
361 int lastY, int baseLine, int bw, int h, bool drawSelections,
362 KoTextFormat *lastFormat, const TQMemArray<int> &selectionStarts,
363 const TQMemArray<int> &selectionEnds, const TQColorGroup &cg, bool rightToLeft, int line, KoTextZoomHandler* zh, bool drawingShadow );
366 enum { FormattingSpace = 1, FormattingBreak = 2, FormattingEndParag = 4, FormattingTabs = 8,
367 AllFormattingChars = FormattingSpace | FormattingBreak | FormattingEndParag | FormattingTabs };
373 virtual void drawFormattingChars( TQPainter &painter, int start, int len,
374 int lastY_pix, int baseLine_pix, int h_pix,
376 KoTextFormat *format, const TQMemArray<int> &selectionStarts,
377 const TQMemArray<int> &selectionEnds, const TQColorGroup &cg,
379 int whichFormattingChars );
383 TQMap<int, int> m_tabCache;
392 TQMap<int, KoTextParagSelection> &selections() const;
393 TQPtrList<KoTextCustomItem> &floatingItems() const;
395 int heightForLineSpacing( int startChar, int lastChar ) const;
397 TQMap<int, KoTextParagLineStart*> lineStarts;
404 bool newLinesAllowed : 1;
409 short int m_lineChanged;
413 TQMap<int, KoTextParagSelection> *mSelections;
414 TQPtrList<KoTextCustomItem> *mFloatingItems;
428inline int KoTextParag::length() const
430 return str->length();
433inline TQRect KoTextParag::rect() const
438inline KoTextStringChar *KoTextParag::at( int i ) const
440 return &str->at( i );
443inline bool KoTextParag::isValid() const
448inline bool KoTextParag::hasChanged() const
453inline short int KoTextParag::lineChanged()
455 return m_lineChanged;
458inline void KoTextParag::append( const TQString &s, bool reallyAtEnd )
461 insert( str->length(), s );
463 insert( TQMAX( str->length() - 1, 0 ), s );
466inline KoTextParag *KoTextParag::prev() const
471inline KoTextParag *KoTextParag::next() const
476inline bool KoTextParag::hasAnySelection() const
478 return mSelections ? !selections().isEmpty() : false;
493inline void KoTextParag::setParagId( int i )
498inline int KoTextParag::paragId() const
505inline TQMap<int, KoTextParagLineStart*> &KoTextParag::lineStartList()
510inline KoTextString *KoTextParag::string() const
515inline KoTextDocument *KoTextParag::document() const
520inline void KoTextParag::setAlignment( uint a )
546 floatingItems().append( i );
551 floatingItems().removeRef( i );
564inline int KoTextParag::customItems() const
566 return mFloatingItems ? mFloatingItems->count() : 0;
570inline void KoTextParag::setNewLinesAllowed( bool b )
575inline bool KoTextParag::isNewLinesAllowed() const
577 return newLinesAllowed;
This class represents a border - for anything, like paragraph, or frame.
Used during loading of Oasis format (and discarded at the end of the loading).
This is the structure associated with a paragraph (KoTextParag), to define the bullet or numbering of...
This class holds the paragraph-specific formatting information It's separated from KoTextParag so tha...
SpacingType Line spacing values Assuming h is the height of the biggest char in the line, and v is the linespacin...
double margins[5] left, right, top, bottom, firstLineSpacing - in pt
A paragraph style is a combination of a character style and paragraph-layout attributes,...
Used during saving to Oasis format (and discarded at the end of the saving).
TODO rename to KoParagStyleCollection - or should char styles be part of it too?
KoTextCustomItem is the base class for custom items (i.e.
Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that charac...
This class extends KoZoomHandler to add support for WYSIWYG text layouting.
A class for writing out XML (to any TQIODevice), with a special attention on performance.
TDEAction * next(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
|