lib

KoRichText.h
1/****************************************************************************
2**
3** Definition of internal rich text classes
4**
5** Created : 990124
6**
7** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
8**
9** This file is part of the kernel module of the TQt GUI Toolkit.
10**
11** This file may be distributed under the terms of the Q Public License
12** as defined by Trolltech AS of Norway and appearing in the file
13** LICENSE.TQPL included in the packaging of this file.
14**
15** This file may be distributed and/or modified under the terms of the
16** GNU General Public License version 2 as publish by the Free Software
17** Foundation and appearing in the file LICENSE.GPL included in the
18** packaging of this file.
19**
20** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
21** licenses may use this file in accordance with the TQt Commercial License
22** Agreement provided with the Software.
23**
24** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26**
27** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
28** information about TQt Commercial License Agreements.
29** See http://www.trolltech.com/qpl/ for TQPL licensing information.
30** See http://www.trolltech.com/gpl/ for GPL licensing information.
31**
32** Contact info@trolltech.com if any conditions of this licensing are
33** not clear to you.
34**
35**********************************************************************/
36
37#ifndef KORICHTEXT_H
38#define KORICHTEXT_H
39
40#include <tqptrlist.h>
41#include <tqrect.h>
42#include <tqmap.h>
43#include <tqstringlist.h>
44#include <tqcolor.h>
45#include <tqsize.h>
46#include <tqvaluelist.h>
47#include <tqobject.h>
48#include <tqstylesheet.h>
49#include <tqpainter.h>
50#include "KoComplexText.h"
51
52#include <koffice_export.h>
53class KoXmlWriter;
54class KoGenStyles;
55class KoTextParag;
56class KoTextString;
57class KoTextCursor;
59class KoTextFlow;
60class KoTextDocument;
61//class KoTextPreProcessor;
62class KoTextFormatterBase;
63class KoTextFormat;
64class KoTextFormatCollection;
65struct KoBidiContext;
66
68class KCommand;
69class TQDomElement;
71class KoTextFormatter;
72class KoParagVisitor;
73class KoTextDocCommand;
74class KoXmlWriter;
75class KoSavingContext;
76
77#include <tqmemarray.h>
78#include "KoParagLayout.h"
80
81// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
82
83class KOTEXT_EXPORT KoTextStringChar
84{
85 friend class KoTextString;
86
87public:
88 // this is never called, initialize variables in KoTextString::insert()!!!
89 KoTextStringChar() : lineStart( 0 ), type( Regular ), startOfRun( 0 ) {d.format=0; }
90 ~KoTextStringChar();
91
92 TQChar c;
93
94 // this is the same struct as in qtextengine_p.h. Don't change!
95 uchar softBreak :1; // Potential linebreak point
96 uchar whiteSpace :1; // A unicode whitespace character, except NBSP, ZWNBSP
97 uchar charStop :1; // Valid cursor position (for left/right arrow)
98 uchar wordStop :1; // Valid cursor position (for ctrl + left/right arrow) (TODO: use)
99 //uchar nobreak :1;
100
101 enum Type { Regular, Custom };
102 uint lineStart : 1;
103 Type type : 1;
104 uint startOfRun : 1;
105 uint rightToLeft : 1;
106
107 // --- added for WYSIWYG ---
108 TQ_INT8 pixelxadj; // adjustment to apply to lu2pixel(x)
109 short int pixelwidth; // width in pixels
110 short int width; // width in LU
111
112 int x;
113 int height() const;
114 int ascent() const;
115 int descent() const;
116 bool isCustom() const { return type == Custom; }
117 KoTextFormat *format() const;
118 KoTextCustomItem *customItem() const;
119 void setFormat( KoTextFormat *f,bool setFormatAgain=true );
120 void setCustomItem( KoTextCustomItem *i );
121 void loseCustomItem();
122 struct CustomData
123 {
124 KoTextFormat *format;
125 KoTextCustomItem *custom;
126 };
127
128 union {
129 KoTextFormat* format;
130 CustomData* custom;
131 } d;
132
133private:
134 KoTextStringChar &operator=( const KoTextStringChar & ) {
135 //abort();
136 return *this;
137 }
138 KoTextStringChar( const KoTextStringChar & ); // copy-constructor, forbidden
139 friend class KoComplexText;
140 friend class KoTextParag;
141};
142
143#if defined(TQ_TEMPLATEDLL)
144// MOC_SKIP_BEGIN
145template class TQMemArray<KoTextStringChar>;
146// MOC_SKIP_END
147#endif
148
149class KOTEXT_EXPORT KoTextString
150{
151public:
152
153 KoTextString();
154 KoTextString( const KoTextString &s );
155 virtual ~KoTextString();
156
157 TQString toString() const;
158 static TQString toString( const TQMemArray<KoTextStringChar> &data );
159 TQString toReverseString() const;
160
161 TQString stringToSpellCheck();
162
163 KoTextStringChar &at( int i ) const;
164 int length() const;
165
166 //int width( int idx ) const; // moved to KoTextFormat
167
168 void insert( int index, const TQString &s, KoTextFormat *f );
169 void insert( int index, KoTextStringChar *c );
170 void truncate( int index );
171 void remove( int index, int len );
172 void clear();
173
174 void setFormat( int index, KoTextFormat *f, bool useCollection, bool setFormatAgain = false );
175
176 void setBidi( bool b ) { bidi = b; }
177 bool isBidi() const;
178 bool isRightToLeft() const;
179 TQChar::Direction direction() const;
180 void setDirection( TQChar::Direction d ) { dir = d; bidiDirty = true; }
181
183 void setNeedsSpellCheck( bool b ) { bNeedsSpellCheck = b; }
184 bool needsSpellCheck() const { return bNeedsSpellCheck; }
185
186 TQMemArray<KoTextStringChar> subString( int start = 0, int len = 0xFFFFFF ) const;
187 TQString mid( int start = 0, int len = 0xFFFFFF ) const; // kotext addition
188 TQMemArray<KoTextStringChar> rawData() const { return data.copy(); }
189
190 void operator=( const TQString &s ) { clear(); insert( 0, s, 0 ); }
191 void operator+=( const TQString &s );
192 void prepend( const TQString &s ) { insert( 0, s, 0 ); }
193
194 // return next and previous valid cursor positions.
195 bool validCursorPosition( int idx );
196 int nextCursorPosition( int idx );
197 int previousCursorPosition( int idx );
198
199private:
200 void checkBidi() const;
201
202 TQMemArray<KoTextStringChar> data;
203 uint bidiDirty : 1;
204 uint bidi : 1; // true when the paragraph has right to left characters
205 uint rightToLeft : 1;
206 uint dir : 5;
207 uint bNeedsSpellCheck : 1;
208};
209
210inline bool KoTextString::isBidi() const
211{
212 if ( bidiDirty )
213 checkBidi();
214 return bidi;
215}
216
217inline bool KoTextString::isRightToLeft() const
218{
219 if ( bidiDirty )
220 checkBidi();
221 return rightToLeft;
222}
223
224inline TQChar::Direction KoTextString::direction() const
225{
226 return (TQChar::Direction) dir;
227}
228
229// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
230
231class KOTEXT_EXPORT KoTextCursor
232{
233public:
234 KoTextCursor( KoTextDocument *d );
235 KoTextCursor();
236 KoTextCursor( const KoTextCursor &c );
237 KoTextCursor &operator=( const KoTextCursor &c );
238 virtual ~KoTextCursor() {}
239
240 bool operator==( const KoTextCursor &c ) const;
241 bool operator!=( const KoTextCursor &c ) const { return !(*this == c); }
242
243 KoTextDocument *document() const { return doc; }
244 void setDocument( KoTextDocument *d );
245
246 KoTextParag *parag() const;
247 int index() const;
248 void setParag( KoTextParag *s, bool restore = true );
249
250 void gotoLeft();
251 void gotoRight();
252 void gotoNextLetter();
253 void gotoPreviousLetter();
254 void gotoUp();
255 void gotoDown();
256 void gotoLineEnd();
257 void gotoLineStart();
258 void gotoHome();
259 void gotoEnd();
260 void gotoPageUp( int visibleHeight );
261 void gotoPageDown( int visibleHeight );
262 void gotoNextWord();
263 void gotoPreviousWord();
264 void gotoWordLeft();
265 void gotoWordRight();
266
267 void insert( const TQString &s, bool checkNewLine, TQMemArray<KoTextStringChar> *formatting = 0 );
268 void splitAndInsertEmptyParag( bool ind = true, bool updateIds = true );
269 bool remove();
270 bool removePreviousChar();
271 void killLine();
272 //void indent();
273
274 bool atParagStart() const;
275 bool atParagEnd() const;
276
277 void setIndex( int i, bool restore = true );
278
279 //void checkIndex();
280
281 //int offsetX() const { return ox; }
282 //int offsetY() const { return oy; }
283
284 bool place( const TQPoint &pos, KoTextParag *s, bool link = false, int *customItemIndex = 0 );
285
286 int x() const;
287 int y() const;
288 void fixCursorPosition();
289
290private:
291 KoTextParag *string;
292 KoTextDocument *doc;
293 int idx, tmpIndex;
294 //int ox, oy;
295};
296
297// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
298
299class KoTextDocCommand
300{
301public:
302 enum Commands { Invalid, Insert, Delete, Format, Alignment, ParagType };
303
304 KoTextDocCommand( KoTextDocument *d ) : doc( d ), cursor( d ) {}
305 virtual ~KoTextDocCommand() {}
306 virtual Commands type() const { return Invalid; };
307
308 virtual KoTextCursor *execute( KoTextCursor *c ) = 0;
309 virtual KoTextCursor *unexecute( KoTextCursor *c ) = 0;
310
311protected:
312 KoTextDocument *doc;
313 KoTextCursor cursor;
314
315};
316
317#if defined(TQ_TEMPLATEDLL)
318// MOC_SKIP_BEGIN
319template class TQPtrList<KoTextDocCommand>;
320// MOC_SKIP_END
321#endif
322
323class KoTextDocCommandHistory
324{
325public:
326 KoTextDocCommandHistory( int s ) : current( -1 ), steps( s ) { history.setAutoDelete( true ); }
327 virtual ~KoTextDocCommandHistory() { clear(); }
328
329 void clear() { history.clear(); current = -1; }
330
331 void addCommand( KoTextDocCommand *cmd );
332 KoTextCursor *undo( KoTextCursor *c );
333 KoTextCursor *redo( KoTextCursor *c );
334
335 bool isUndoAvailable();
336 bool isRedoAvailable();
337
338 void setUndoDepth( int d ) { steps = d; }
339 int undoDepth() const { return steps; }
340
341 int historySize() const { return history.count(); }
342 int currentPosition() const { return current; }
343
344private:
345 TQPtrList<KoTextDocCommand> history;
346 int current, steps;
347
348};
349
350// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
351
352#include "KoTextCustomItem.h"
353
354#if defined(TQ_TEMPLATEDLL)
355// MOC_SKIP_BEGIN
356template class TQMap<TQString, TQString>;
357// MOC_SKIP_END
358#endif
359
360#if 0
361class KoTextImage : public KoTextCustomItem
362{
363public:
364 KoTextImage( KoTextDocument *p, const TQMap<TQString, TQString> &attr, const TQString& context,
365 TQMimeSourceFactory &factory );
366 virtual ~KoTextImage();
367
368 Placement placement() const { return place; }
369 //void setPainter( TQPainter*, bool );
370 int widthHint() const { return width; }
371 int minimumWidth() const { return width; }
372
373 TQString richText() const;
374
375 void draw( TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected );
376
377private:
378 TQRegion* reg;
379 TQPixmap pm;
380 Placement place;
381 int tmpwidth, tmpheight;
382 TQMap<TQString, TQString> attributes;
383 TQString imgId;
384
385};
386#endif
387
388class KoTextHorizontalLine : public KoTextCustomItem
389{
390public:
391 KoTextHorizontalLine( KoTextDocument *p, const TQMap<TQString, TQString> &attr, const TQString& context,
392 TQMimeSourceFactory &factory );
393 virtual ~KoTextHorizontalLine();
394
395 //void setPainter( TQPainter*, bool );
396 void draw(TQPainter* p, int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected );
397 TQString richText() const;
398
399 bool ownLine() const { return true; }
400
401private:
402 int tmpheight;
403 TQColor color;
404
405};
406
407#if defined(TQ_TEMPLATEDLL)
408// MOC_SKIP_BEGIN
409template class TQPtrList<KoTextCustomItem>;
410// MOC_SKIP_END
411#endif
412
413class KOTEXT_EXPORT KoTextFlow
414{
415 friend class KoTextDocument;
416 friend class KoTextTableCell;
417
418public:
419 KoTextFlow();
420 virtual ~KoTextFlow();
421
422 // Called by KoTextDocument::setWidth()
423 virtual void setWidth( int width );
424
425 // This is the value returned by KoTextDocument::width()
426 int width() const { return w; }
427
428 //virtual void setPageSize( int ps );
429 //int pageSize() const { return pagesize; }
430
438 virtual void adjustMargins( int yp, int h, int reqMinWidth, int& leftMargin, int& rightMargin, int& pageWidth, KoTextParag* parag );
439
440 virtual void registerFloatingItem( KoTextCustomItem* item );
441 virtual void unregisterFloatingItem( KoTextCustomItem* item );
442 //virtual TQRect boundingRect() const;
443
445 virtual int availableHeight() const;
446 virtual void drawFloatingItems(TQPainter* p, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected );
447
448 virtual int adjustFlow( int y, int w, int h ); // adjusts y according to the defined pagesize. Returns the shift.
449
450 virtual bool isEmpty();
451
452 void clear();
453
454private:
455 int w;
456 //int pagesize;
457
458 TQPtrList<KoTextCustomItem> leftItems;
459 TQPtrList<KoTextCustomItem> rightItems;
460
461};
462
463#ifdef TQTEXTTABLE_AVAILABLE
464class KoTextTable;
465
466class KoTextTableCell : public TQLayoutItem
467{
468 friend class KoTextTable;
469
470public:
471 KoTextTableCell( KoTextTable* table,
472 int row, int column,
473 const TQMap<TQString, TQString> &attr,
474 const TQStyleSheetItem* style,
475 const KoTextFormat& fmt, const TQString& context,
476 TQMimeSourceFactory &factory, TQStyleSheet *sheet, const TQString& doc );
477 KoTextTableCell( KoTextTable* table, int row, int column );
478 virtual ~KoTextTableCell();
479
480 TQSize sizeHint() const ;
481 TQSize minimumSize() const ;
482 TQSize maximumSize() const ;
483 TQSizePolicy::ExpandData expanding() const;
484 bool isEmpty() const;
485 void setGeometry( const TQRect& ) ;
486 TQRect geometry() const;
487
488 bool hasHeightForWidth() const;
489 int heightForWidth( int ) const;
490
491 void setPainter( TQPainter*, bool );
492
493 int row() const { return row_; }
494 int column() const { return col_; }
495 int rowspan() const { return rowspan_; }
496 int colspan() const { return colspan_; }
497 int stretch() const { return stretch_; }
498
499 KoTextDocument* richText() const { return richtext; }
500 KoTextTable* table() const { return parent; }
501
502 void draw( int x, int y, int cx, int cy, int cw, int ch, const TQColorGroup& cg, bool selected );
503
504 TQBrush *backGround() const { return background; }
505 virtual void invalidate();
506
507 int verticalAlignmentOffset() const;
508 int horizontalAlignmentOffset() const;
509
510private:
511 TQPainter* painter() const;
512 TQRect geom;
513 KoTextTable* parent;
514 KoTextDocument* richtext;
515 int row_;
516 int col_;
517 int rowspan_;
518 int colspan_;
519 int stretch_;
520 int maxw;
521 int minw;
522 bool hasFixedWidth;
523 TQBrush *background;
524 int cached_width;
525 int cached_sizehint;
526 TQMap<TQString, TQString> attributes;
527 int align;
528};
529
530#if defined(TQ_TEMPLATEDLL)
531// MOC_SKIP_BEGIN
532template class TQPtrList<KoTextTableCell>;
533template class TQMap<KoTextCursor*, int>;
534// MOC_SKIP_END
535#endif
536
537class KoTextTable: public KoTextCustomItem
538{
539 friend class KoTextTableCell;
540
541public:
542 KoTextTable( KoTextDocument *p, const TQMap<TQString, TQString> &attr );
543 virtual ~KoTextTable();
544
545 void setPainter( TQPainter *p, bool adjust );
546 void pageBreak( int y, KoTextFlow* flow );
547 void draw( TQPainter* p, int x, int y, int cx, int cy, int cw, int ch,
548 const TQColorGroup& cg, bool selected );
549
550 bool noErase() const { return true; }
551 bool ownLine() const { return true; }
552 Placement placement() const { return place; }
553 bool isNested() const { return true; }
554 void resize( int nwidth );
555 virtual void invalidate();
557
558 virtual bool enter( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy, bool atEnd = false );
559 virtual bool enterAt( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy, const TQPoint &pos );
560 virtual bool next( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy );
561 virtual bool prev( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy );
562 virtual bool down( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy );
563 virtual bool up( KoTextCursor *c, KoTextDocument *&doc, KoTextParag *&parag, int &idx, int &ox, int &oy );
564
565 TQString richText() const;
566
567 int minimumWidth() const { return layout ? layout->minimumSize().width() : 0; }
568 int widthHint() const { return ( layout ? layout->sizeHint().width() : 0 ) + 2 * outerborder; }
569
570 TQPtrList<KoTextTableCell> tableCells() const { return cells; }
571
572 TQRect geometry() const { return layout ? layout->geometry() : TQRect(); }
573 bool isStretching() const { return stretch; }
574
575private:
576 void format( int &w );
577 void addCell( KoTextTableCell* cell );
578
579private:
580 TQGridLayout* layout;
581 TQPtrList<KoTextTableCell> cells;
582 TQPainter* painter;
583 int cachewidth;
584 int fixwidth;
585 int cellpadding;
586 int cellspacing;
587 int border;
588 int outerborder;
589 int stretch;
590 int innerborder;
591 int us_cp, us_ib, us_b, us_ob, us_cs;
592 TQMap<TQString, TQString> attributes;
593 TQMap<KoTextCursor*, int> currCell;
594 Placement place;
595 void adjustCells( int y , int shift );
596 int pageBreakFor;
597};
598#endif // TQTEXTTABLE_AVAILABLE
599
600// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
601
602class KoTextTableCell;
603
604struct KoTextDocumentSelection
605{
606 KoTextCursor startCursor, endCursor;
607 bool swapped;
608};
609
610// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
611
612
613class KOTEXT_EXPORT KoTextDocDeleteCommand : public KoTextDocCommand
614{
615public:
616 KoTextDocDeleteCommand( KoTextDocument *d, int i, int idx, const TQMemArray<KoTextStringChar> &str );
617 //KoTextDocDeleteCommand( KoTextParag *p, int idx, const TQMemArray<KoTextStringChar> &str );
618 virtual ~KoTextDocDeleteCommand();
619
620 Commands type() const { return Delete; }
621 KoTextCursor *execute( KoTextCursor *c );
622 KoTextCursor *unexecute( KoTextCursor *c );
623
624protected:
625 int id, index;
626 KoTextParag *parag;
627 TQMemArray<KoTextStringChar> text;
628
629};
630
631#if 0
632class KoTextDocInsertCommand : public KoTextDocDeleteCommand
633{
634public:
635 KoTextDocInsertCommand( KoTextDocument *d, int i, int idx, const TQMemArray<KoTextStringChar> &str )
636 : KoTextDocDeleteCommand( d, i, idx, str ) {}
637 KoTextDocInsertCommand( KoTextParag *p, int idx, const TQMemArray<KoTextStringChar> &str )
638 : KoTextDocDeleteCommand( p, idx, str ) {}
639 virtual ~KoTextDocInsertCommand() {}
640
641 Commands type() const { return Insert; }
642 KoTextCursor *execute( KoTextCursor *c ) { return KoTextDocDeleteCommand::unexecute( c ); }
643 KoTextCursor *unexecute( KoTextCursor *c ) { return KoTextDocDeleteCommand::execute( c ); }
644
645};
646#endif
647
648class KoTextDocFormatCommand : public KoTextDocCommand
649{
650public:
651 KoTextDocFormatCommand( KoTextDocument *d, int sid, int sidx, int eid, int eidx, const TQMemArray<KoTextStringChar> &old, const KoTextFormat *f, int fl );
652 virtual ~KoTextDocFormatCommand();
653
654 Commands type() const { return Format; }
655 KoTextCursor *execute( KoTextCursor *c );
656 KoTextCursor *unexecute( KoTextCursor *c );
657
658protected:
659 int startId, startIndex, endId, endIndex;
660 KoTextFormat *format;
661 TQMemArray<KoTextStringChar> oldFormats;
662 int flags;
663
664};
665
666class KoTextAlignmentCommand : public KoTextDocCommand
667{
668public:
669 KoTextAlignmentCommand( KoTextDocument *d, int fParag, int lParag, int na, const TQMemArray<int> &oa );
670 virtual ~KoTextAlignmentCommand() {}
671
672 Commands type() const { return Alignment; }
673 KoTextCursor *execute( KoTextCursor *c );
674 KoTextCursor *unexecute( KoTextCursor *c );
675
676private:
677 int firstParag, lastParag;
678 int newAlign;
679 TQMemArray<int> oldAligns;
680
681};
682
683// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
684
685struct KoTextParagLineStart
686{
687 KoTextParagLineStart() : y( 0 ), baseLine( 0 ), h( 0 ), lineSpacing( 0 ), hyphenated( false )
688#ifndef TQT_NO_COMPLEXTEXT
689 , bidicontext( 0 )
690#endif
691 { }
692 KoTextParagLineStart( ushort y_, ushort bl, ushort h_ ) : y( y_ ), baseLine( bl ), h( h_ ),
693 lineSpacing( 0 ), hyphenated( false ),
694 w( 0 )
695#ifndef TQT_NO_COMPLEXTEXT
696 , bidicontext( 0 )
697#endif
698 { }
699#ifndef TQT_NO_COMPLEXTEXT
700 KoTextParagLineStart( KoBidiContext *c, KoBidiStatus s ) : y(0), baseLine(0), h(0),
701 lineSpacing( 0 ), hyphenated( false ),
702 status( s ), bidicontext( c ) { if ( bidicontext ) bidicontext->ref(); }
703#endif
704
705 virtual ~KoTextParagLineStart()
706 {
707#ifndef TQT_NO_COMPLEXTEXT
708 if ( bidicontext && bidicontext->deref() )
709 delete bidicontext;
710#endif
711 }
712
713#ifndef TQT_NO_COMPLEXTEXT
714 void setContext( KoBidiContext *c ) {
715 if ( c == bidicontext )
716 return;
717 if ( bidicontext && bidicontext->deref() )
718 delete bidicontext;
719 bidicontext = c;
720 if ( bidicontext )
721 bidicontext->ref();
722 }
723 KoBidiContext *context() const { return bidicontext; }
724#endif
725
726public:
727 ushort y, baseLine, h;
728 short lineSpacing;
729 bool hyphenated;
730#ifndef TQT_NO_COMPLEXTEXT
731 KoBidiStatus status;
732#endif
733 int w;
734
735private:
736#ifndef TQT_NO_COMPLEXTEXT
737 KoBidiContext *bidicontext;
738#endif
739};
740
741// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
742
743class KOTEXT_EXPORT KoTextFormatterBase
744{
745public:
746 KoTextFormatterBase();
747 virtual ~KoTextFormatterBase() {}
748 virtual bool format( KoTextDocument *doc, KoTextParag *parag, int start, const TQMap<int, KoTextParagLineStart*> &oldLineStarts, int& y, int& widthUsed ) = 0;
749 virtual int formatVertically( KoTextDocument* doc, KoTextParag* parag );
750
751 // Called after formatting a paragraph
752 virtual void postFormat( KoTextParag* parag ) = 0;
753
754 int wrapAtColumn() const { return wrapColumn;}
755 //virtual void setWrapEnabled( bool b ) { wrapEnabled = b; }
756 virtual void setWrapAtColumn( int c ) { wrapColumn = c; }
757 virtual void setAllowBreakInWords( bool b ) { biw = b; }
758 bool allowBreakInWords() const { return biw; }
759
760 // This setting is passed to KoTextParag::fixParagWidth by postFormat()
761 void setViewFormattingChars( bool b ) { m_bViewFormattingChars = b; }
762 bool viewFormattingChars() const { return m_bViewFormattingChars; }
763
764 /*virtual*/ bool isBreakable( KoTextString *string, int pos ) const;
765 /*virtual*/ bool isStretchable( KoTextString *string, int pos ) const;
766
767protected:
768 //virtual KoTextParagLineStart *formatLine( KoTextParag *parag, KoTextString *string, KoTextParagLineStart *line, KoTextStringChar *start,
769 // KoTextStringChar *last, int align = AlignAuto, int space = 0 );
770 //KoTextStringChar
771
772#ifndef TQT_NO_COMPLEXTEXT
773 virtual KoTextParagLineStart *bidiReorderLine( KoTextParag *parag, KoTextString *string, KoTextParagLineStart *line, KoTextStringChar *start,
774 KoTextStringChar *last, int align, int space );
775#endif
776
777private:
778 int wrapColumn;
779 //bool wrapEnabled;
780 bool m_bViewFormattingChars;
781 bool biw;
782 bool unused; // for future extensions
783};
784
785
786// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
787
788inline int KoTextString::length() const
789{
790 return data.size();
791}
792
793inline void KoTextString::operator+=( const TQString &s )
794{
795 insert( length(), s, 0 );
796}
797
798inline KoTextParag *KoTextCursor::parag() const
799{
800 return string;
801}
802
803inline int KoTextCursor::index() const
804{
805 return idx;
806}
807
808inline void KoTextCursor::setParag( KoTextParag *s, bool /*restore*/ )
809{
810 idx = 0;
811 string = s;
812 tmpIndex = -1;
813}
814
815//inline void KoTextCursor::checkIndex()
816//{
817// if ( idx >= string->length() )
818// idx = string->length() - 1;
819//}
820
821// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
822
823inline KoTextStringChar &KoTextString::at( int i ) const
824{
825 return data[ i ];
826}
827
828inline TQString KoTextString::toString() const
829{
830 return toString( data );
831}
832
833// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
834
835inline KoTextFormat *KoTextStringChar::format() const
836{
837 return (type == Regular) ? d.format : d.custom->format;
838}
839
840inline KoTextCustomItem *KoTextStringChar::customItem() const
841{
842 return isCustom() ? d.custom->custom : 0;
843}
844
845#endif
Repository of styles used during saving of OASIS/OOo file.
Definition KoGenStyles.h:60
Base class for "visitors".
Used during saving to Oasis format (and discarded at the end of the saving).
KoTextCustomItem is the base class for custom items (i.e.
Each character (KoTextStringChar) points to a KoTextFormat that defines the formatting of that charac...
We implement our own text formatter to implement WYSIWYG: It is heavily based on KoTextFormatterBaseB...
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.
Definition KoXmlWriter.h:37
TDEAction * next(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * undo(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * redo(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * up(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
@ Invalid
invalid property type
Definition property.h:68