~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to lib/kotext/kotextdocument.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
/* This file is part of the KDE project
 
3
   Copyright (C) 2001 David Faure <faure@kde.org>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Library General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Library General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Library General Public License
 
16
   along with this library; see the file COPYING.LIB.  If not, write to
 
17
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
   Boston, MA 02111-1307, USA.
 
19
*/
 
20
 
 
21
#ifndef KOTEXTDOCUMENT_H
 
22
#define KOTEXTDOCUMENT_H
 
23
 
 
24
#include "korichtext.h"
 
25
 
 
26
#if defined(Q_TEMPLATEDLL)
 
27
// MOC_SKIP_BEGIN
 
28
template class Q_EXPORT QMap<int, QColor>;
 
29
template class Q_EXPORT QMap<int, bool>;
 
30
template class Q_EXPORT QMap<int, KoTextDocumentSelection>;
 
31
template class Q_EXPORT QPtrList<KoTextDocument>;
 
32
// MOC_SKIP_END
 
33
#endif
 
34
 
 
35
class KoZoomHandler;
 
36
class KoTextFormatCollection;
 
37
class KoParagVisitor;
 
38
class KoTextFormatter;
 
39
class KoTextParag;
 
40
class CustomItemsMap;
 
41
 
 
42
class Q_EXPORT KoTextDocument : public QObject
 
43
{
 
44
    Q_OBJECT
 
45
 
 
46
    friend class KoTextCursor;
 
47
    friend class KoTextParag;
 
48
 
 
49
public:
 
50
    enum SelectionIds {
 
51
        Standard = 0,
 
52
        Temp = 32000 // This selection must not be drawn, it's used e.g. by undo/redo to
 
53
        // remove multiple lines with removeSelectedText()
 
54
    };
 
55
 
 
56
    //KoTextDocument( KoTextDocument *p );
 
57
    //KoTextDocument( KoTextDocument *d, KoTextFormatCollection *f );
 
58
    // see below for constructor
 
59
    virtual ~KoTextDocument();
 
60
 
 
61
    //KoTextDocument *parent() const { return par; }
 
62
 
 
63
    void setText( const QString &text, const QString &context );
 
64
 
 
65
    QString text() const;
 
66
    QString text( int parag ) const;
 
67
    //QString originalText() const;
 
68
 
 
69
    int x() const;
 
70
    int y() const;
 
71
    int width() const;
 
72
    //int widthUsed() const;
 
73
    //int visibleWidth() const;
 
74
    int height() const;
 
75
    void setWidth( int w );
 
76
    //int minimumWidth() const;
 
77
    //virtual bool setMinimumWidth( int w, KoTextParag *parag );
 
78
 
 
79
    void setY( int y );
 
80
    int leftMargin() const;
 
81
    void setLeftMargin( int lm );
 
82
    int rightMargin() const;
 
83
    void setRightMargin( int rm );
 
84
 
 
85
    KoTextParag *firstParag() const;
 
86
    KoTextParag *lastParag() const;
 
87
    void setFirstParag( KoTextParag *p );
 
88
    void setLastParag( KoTextParag *p );
 
89
 
 
90
    void invalidate();
 
91
 
 
92
    //void setPreProcessor( KoTextPreProcessor *sh );
 
93
    //KoTextPreProcessor *preProcessor() const;
 
94
 
 
95
    void setFormatter( KoTextFormatterBase *f );
 
96
    KoTextFormatterBase *formatter() const;
 
97
 
 
98
    void setIndent( KoTextIndent *i );
 
99
    KoTextIndent *indent() const;
 
100
 
 
101
    QColor selectionColor( int id ) const;
 
102
    bool invertSelectionText( int id ) const;
 
103
    void setSelectionColor( int id, const QColor &c );
 
104
    void setInvertSelectionText( int id, bool b );
 
105
    bool hasSelection( int id, bool visible = false ) const;
 
106
    bool isSelectionSwapped( int id ); //// kotext
 
107
    void setSelectionStart( int id, KoTextCursor *cursor );
 
108
    bool setSelectionEnd( int id, KoTextCursor *cursor );
 
109
    void selectAll( int id );
 
110
    bool removeSelection( int id );
 
111
    void selectionStart( int id, int &paragId, int &index );
 
112
    KoTextCursor selectionStartCursor( int id );
 
113
    KoTextCursor selectionEndCursor( int id );
 
114
    void selectionEnd( int id, int &paragId, int &index );
 
115
    void setFormat( int id, const KoTextFormat *f, int flags );
 
116
    KoTextParag *selectionStart( int id );
 
117
    KoTextParag *selectionEnd( int id );
 
118
    int numSelections() const { return nSelections; }
 
119
    void addSelection( int id );
 
120
 
 
121
    QString selectedText( int id, bool withCustom = TRUE ) const;
 
122
    //void copySelectedText( int id );
 
123
    void removeSelectedText( int id, KoTextCursor *cursor );
 
124
    void indentSelection( int id );
 
125
 
 
126
    KoTextParag *paragAt( int i ) const;
 
127
 
 
128
    void addCommand( KoTextDocCommand *cmd );
 
129
    KoTextCursor *undo( KoTextCursor *c = 0 );
 
130
    KoTextCursor *redo( KoTextCursor *c  = 0 );
 
131
    KoTextDocCommandHistory *commands() const { return commandHistory; }
 
132
 
 
133
    KoTextFormatCollection *formatCollection() const;
 
134
 
 
135
    bool find( const QString &expr, bool cs, bool wo, bool forward, int *parag, int *index, KoTextCursor *cursor );
 
136
 
 
137
    //void setTextFormat( Qt::TextFormat f );
 
138
    //Qt::TextFormat textFormat() const;
 
139
 
 
140
    bool inSelection( int selId, const QPoint &pos ) const;
 
141
 
 
142
    void setUnderlineLinks( bool b ) { underlLinks = b; }
 
143
    bool underlineLinks() const { return underlLinks; }
 
144
 
 
145
    void setPaper( QBrush *brush ) { if ( backBrush ) delete backBrush; backBrush = brush; }
 
146
    QBrush *paper() const { return backBrush; }
 
147
 
 
148
    //void doLayout( QPainter *p, int w );
 
149
#if 0 // see KoTextDocument
 
150
    void draw( QPainter *p, const QRect& rect, const QColorGroup &cg, const QBrush *paper = 0 );
 
151
    void drawParag( QPainter *p, KoTextParag *parag, int cx, int cy, int cw, int ch,
 
152
                    QPixmap *&doubleBuffer, const QColorGroup &cg,
 
153
                    bool drawCursor, KoTextCursor *cursor, bool resetChanged = TRUE );
 
154
    KoTextParag *draw( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg,
 
155
                      bool onlyChanged = FALSE, bool drawCursor = FALSE, KoTextCursor *cursor = 0,
 
156
                      bool resetChanged = TRUE );
 
157
#endif
 
158
 
 
159
    //void setDefaultFont( const QFont &f );
 
160
 
 
161
    void registerCustomItem( KoTextCustomItem *i, KoTextParag *p );
 
162
    void unregisterCustomItem( KoTextCustomItem *i, KoTextParag *p );
 
163
    const QPtrList<KoTextCustomItem> & allCustomItems() const { return customItems; }
 
164
 
 
165
    void setFlow( KoTextFlow *f );
 
166
    void takeFlow();
 
167
    KoTextFlow *flow() const { return flow_; }
 
168
    bool isPageBreakEnabled() const { return m_pageBreakEnabled; }
 
169
    void setPageBreakEnabled( bool b ) { m_pageBreakEnabled = b; }
 
170
 
 
171
    void setWithoutDoubleBuffer( bool b ) { withoutDoubleBuffer = b; }
 
172
    bool isWithoutDoubleBuffer() const { return withoutDoubleBuffer; } // added for KWTextDocument
 
173
 
 
174
    void setUseFormatCollection( bool b ) { useFC = b; }
 
175
    bool useFormatCollection() const { return useFC; }
 
176
 
 
177
#ifdef QTEXTTABLE_AVAILABLE
 
178
    KoTextTableCell *tableCell() const { return tc; }
 
179
    void setTableCell( KoTextTableCell *c ) { tc = c; }
 
180
#endif
 
181
 
 
182
    void setPlainText( const QString &text );
 
183
    //void setRichText( const QString &text, const QString &context );
 
184
    QString richText( KoTextParag *p = 0 ) const;
 
185
    QString plainText( KoTextParag *p = 0 ) const;
 
186
 
 
187
    //bool focusNextPrevChild( bool next );
 
188
 
 
189
    int alignment() const;
 
190
    void setAlignment( int a );
 
191
 
 
192
    int *tabArray() const;
 
193
    int tabStopWidth() const;
 
194
    void setTabArray( int *a );
 
195
    void setTabStops( int tw );
 
196
 
 
197
    void setUndoDepth( int d ) { commandHistory->setUndoDepth( d ); }
 
198
    int undoDepth() const { return commandHistory->undoDepth(); }
 
199
 
 
200
    int length() const;
 
201
    void clear( bool createEmptyParag = FALSE );
 
202
 
 
203
    virtual KoTextParag *createParag( KoTextDocument *d, KoTextParag *pr = 0, KoTextParag *nx = 0, bool updateIds = TRUE );
 
204
    void insertChild( QObject *o ) { QObject::insertChild( o ); }
 
205
    void removeChild( QObject *o ) { QObject::removeChild( o ); }
 
206
    //void insertChild( KoTextDocument *d ) { childList.append( d ); }
 
207
    //void removeChild( KoTextDocument *d ) { childList.removeRef( d ); }
 
208
    //QPtrList<KoTextDocument> children() const { return childList; }
 
209
 
 
210
    void setAddMargins( bool b ) { addMargs = b; }
 
211
    int addMargins() const { return addMargs; }
 
212
 
 
213
    //bool hasFocusParagraph() const;
 
214
    //QString focusHref() const;
 
215
 
 
216
    //void invalidateOriginalText() { oTextValid = FALSE; }
 
217
    void informParagraphDeleted( KoTextParag* parag );
 
218
 
 
219
signals:
 
220
    //void minimumWidthChanged( int );
 
221
 
 
222
    /** Emitted when a paragraph is deleted (kotext addition) */
 
223
    void paragraphDeleted( KoTextParag* parag );
 
224
 
 
225
private:
 
226
    void init();
 
227
    QPixmap *bufferPixmap( const QSize &s );
 
228
 
 
229
    //// Beginning of kotext additions
 
230
 
 
231
public:
 
232
    /**
 
233
     * Construct a text document, i.e. a set of paragraphs
 
234
     *
 
235
     * @param zoomHandler The KoZoomHandler instance, to handle the zooming, as the name says :)
 
236
     * We need one here because KoTextFormatter needs one for formatting, currently.
 
237
     *
 
238
     * @param fc a format collection for this document. Ownership is transferred to the document. ###
 
239
     * @param formatter a text formatter for this document. If 0L, a KoTextFormatter is created.
 
240
     *  If not, ownership of the given one is transferred to the document.
 
241
     * @param createInitialParag if true, an initial KoTextParag is created. Set to false if you reimplement createParag,
 
242
     *  since the constructor can't call the reimplementation. In that case, make sure to call
 
243
     *  clear(true) in your constructor; QRT doesn't support documents without paragraphs.
 
244
     */
 
245
    KoTextDocument( KoZoomHandler *zoomHandler,
 
246
                    KoTextFormatCollection *fc, KoTextFormatter *formatter = 0L,
 
247
                    bool createInitialParag = true );
 
248
 
 
249
    /** Return the zoom handler associated with this document,
 
250
     * used when formatting. Don't use for any other purpose, it might disappear. */
 
251
    KoZoomHandler * formattingZoomHandler() const { return m_zoomHandler; }
 
252
 
 
253
    /**
 
254
     * Return the zoom handler currently used for drawing.
 
255
     * (This means, at a particular zoom level).
 
256
     * Don't call this in a method that isn't called by drawWYSIWYG, it will be 0L !
 
257
     * (a different one than zoomHandler(), in case it disappears one day,
 
258
     * to have different zoom levels in different views)
 
259
     */
 
260
    KoZoomHandler * paintingZoomHandler() const { return m_zoomHandler; }
 
261
 
 
262
 
 
263
    /** Visit all the parts of a selection.
 
264
     * Returns true, unless canceled. See KoParagVisitor. */
 
265
    bool visitSelection( int selectionId, KoParagVisitor *visitor, bool forward = true );
 
266
 
 
267
    /** Visit all paragraphs of the document.
 
268
     * Returns true, unless canceled. See KoParagVisitor. */
 
269
    bool visitDocument( KoParagVisitor *visitor, bool forward = true );
 
270
 
 
271
    /** Visit the document between those two point.
 
272
     * Returns true, unless canceled. See KoParagVisitor. */
 
273
    bool visitFromTo( KoTextParag *firstParag, int firstIndex, KoTextParag* lastParag, int lastIndex, KoParagVisitor* visitor, bool forw = true );
 
274
 
 
275
    /**
 
276
     * Used by ~KoTextParag to know if it should die quickly
 
277
     */
 
278
    bool isDestroying() const { return m_bDestroying; }
 
279
 
 
280
    /**
 
281
     * Flags for drawWYSIWYG and drawParagWYSIWYG
 
282
     */
 
283
    enum DrawingFlags {
 
284
        DrawMisspelledLine = 1,
 
285
        DrawFormattingChars = 2,
 
286
        DrawSelections = 4,
 
287
        DontDrawNoteVariable = 8
 
288
    };
 
289
    /** The main drawing method. Equivalent to KoTextDocument::draw, but reimplemented
 
290
     * for wysiwyg */
 
291
    KoTextParag *drawWYSIWYG( QPainter *p, int cx, int cy, int cw, int ch, const QColorGroup &cg,
 
292
                              KoZoomHandler* zoomHandler, bool onlyChanged = FALSE,
 
293
                              bool drawCursor = FALSE, KoTextCursor *cursor = 0,
 
294
                              bool resetChanged = TRUE, uint drawingFlags = KoTextDocument::DrawSelections );
 
295
 
 
296
    /** Draw a single paragraph (used by drawWYSIWYG and by KWTextFrameSet::drawCursor).
 
297
     * Equivalent to KoTextDocument::draw, but modified for wysiwyg */
 
298
    void drawParagWYSIWYG( QPainter *p, KoTextParag *parag, int cx, int cy, int cw, int ch,
 
299
                           QPixmap *&doubleBuffer, const QColorGroup &cg,
 
300
                           KoZoomHandler* zoomHandler,
 
301
                           bool drawCursor, KoTextCursor *cursor,
 
302
                           bool resetChanged = TRUE,
 
303
                           uint drawingFlags = KoTextDocument::DrawSelections );
 
304
 
 
305
    /** Set by drawParagWYSIWYG, used by KoTextParag::drawParagString */
 
306
    bool drawFormattingChars() const { return (m_drawingFlags & DrawFormattingChars); }
 
307
    /** Set by drawParagWYSIWYG, used by KoTextParag::drawParagStringInternal */
 
308
    bool drawingMissingSpellLine() const { return (m_drawingFlags & DrawMisspelledLine); }
 
309
 
 
310
    /** Set by drawParagWYSIWYG, used by KoTextParag::drawParagStringInternal */
 
311
    bool dontDrawingNoteVariable() const { return (m_drawingFlags & DontDrawNoteVariable); }
 
312
 
 
313
    virtual KoTextDocCommand *deleteTextCommand( KoTextDocument *textdoc, int id, int index, const QMemArray<KoTextStringChar> & str, const CustomItemsMap & customItemsMap, const QValueList<KoParagLayout> & oldParagLayouts );
 
314
 
 
315
    void emitNewCommand(KCommand *cmd) {
 
316
        emit newCommand( cmd );
 
317
    }
 
318
    void emitRepaintChanged() {
 
319
        emit repaintChanged();
 
320
    }
 
321
signals:
 
322
    /**
 
323
     * Emitted when a new command has been created and should be added to
 
324
     * the main list of commands (usually in the KoDocument).
 
325
     * KoTextObject connects (and forwards) that one.
 
326
     */
 
327
    void newCommand( KCommand *cmd );
 
328
    /**
 
329
     * Tell the world that we'd like some repainting to happen.
 
330
     * KoTextObject connects (and forwards) that one.
 
331
     */
 
332
    void repaintChanged();
 
333
 
 
334
protected:
 
335
    void drawWithoutDoubleBuffer( QPainter *p, const QRect &rect, const QColorGroup &cg,
 
336
                                  KoZoomHandler* zoomHandler, const QBrush *paper = 0 );
 
337
 
 
338
private:
 
339
    // The zoom handler used when formatting
 
340
    // (due to the pixelx/pixelww stuff in KoTextFormatter)
 
341
    KoZoomHandler * m_zoomHandler;
 
342
    bool m_bDestroying;
 
343
    uint m_drawingFlags;
 
344
 
 
345
    //// End of kotext additions
 
346
 
 
347
private:
 
348
    /*struct Q_EXPORT Focus {
 
349
        KoTextParag *parag;
 
350
        int start, len;
 
351
        QString href;
 
352
    };*/
 
353
 
 
354
    int cx, cy; //, cw, vw;
 
355
    KoTextParag *fParag, *lParag;
 
356
    //KoTextPreProcessor *pProcessor;
 
357
    QMap<int, QColor> selectionColors;
 
358
    QMap<int, KoTextDocumentSelection> selections;
 
359
    QMap<int, bool> selectionText;
 
360
    KoTextDocCommandHistory *commandHistory;
 
361
    KoTextFormatterBase *pFormatter;
 
362
    KoTextIndent *indenter;
 
363
    KoTextFormatCollection *fCollection;
 
364
    //Qt::TextFormat txtFormat;
 
365
    //bool preferRichText : 1;
 
366
    bool m_pageBreakEnabled : 1;
 
367
    bool useFC : 1;
 
368
    bool withoutDoubleBuffer : 1;
 
369
    bool underlLinks : 1;
 
370
    //bool nextDoubleBuffered : 1;
 
371
    bool addMargs : 1;
 
372
    //bool oTextValid : 1;
 
373
    int nSelections;
 
374
    KoTextFlow *flow_;
 
375
    QPtrList<KoTextCustomItem> customItems;
 
376
    //KoTextDocument *par;
 
377
#ifdef QTEXTTABLE_AVAILABLE
 
378
    KoTextTableCell *tc;
 
379
#endif
 
380
    KoTextCursor *tmpCursor;
 
381
    QBrush *backBrush;
 
382
    QPixmap *buf_pixmap;
 
383
    //Focus focusIndicator;
 
384
    //int minw;
 
385
    int leftmargin;
 
386
    int rightmargin;
 
387
    //KoTextParag *minwParag;
 
388
    int align;
 
389
    int *tArray;
 
390
    int tStopWidth;
 
391
    int uDepth; // ?
 
392
    //QString oText;
 
393
    //QColor linkColor;
 
394
};
 
395
 
 
396
inline int KoTextDocument::x() const
 
397
{
 
398
    return cx;
 
399
}
 
400
 
 
401
inline int KoTextDocument::y() const
 
402
{
 
403
    return cy;
 
404
}
 
405
 
 
406
inline int KoTextDocument::width() const
 
407
{
 
408
    return flow_->width();
 
409
    //return QMAX( cw, flow_->width() );
 
410
}
 
411
 
 
412
//inline int KoTextDocument::visibleWidth() const
 
413
//{
 
414
//    return vw;
 
415
//}
 
416
 
 
417
inline KoTextParag *KoTextDocument::firstParag() const
 
418
{
 
419
    return fParag;
 
420
}
 
421
 
 
422
inline KoTextParag *KoTextDocument::lastParag() const
 
423
{
 
424
    return lParag;
 
425
}
 
426
 
 
427
inline void KoTextDocument::setFirstParag( KoTextParag *p )
 
428
{
 
429
    fParag = p;
 
430
}
 
431
 
 
432
inline void KoTextDocument::setLastParag( KoTextParag *p )
 
433
{
 
434
    lParag = p;
 
435
}
 
436
 
 
437
inline void KoTextDocument::setWidth( int w )
 
438
{
 
439
    //cw = QMAX( w, minw );
 
440
    flow_->setWidth( w );
 
441
    //vw = w;
 
442
}
 
443
 
 
444
//inline int KoTextDocument::minimumWidth() const
 
445
//{
 
446
//    return minw;
 
447
//}
 
448
 
 
449
inline void KoTextDocument::setY( int y )
 
450
{
 
451
    cy = y;
 
452
}
 
453
 
 
454
inline int KoTextDocument::leftMargin() const
 
455
{
 
456
    return leftmargin;
 
457
}
 
458
 
 
459
inline void KoTextDocument::setLeftMargin( int lm )
 
460
{
 
461
    leftmargin = lm;
 
462
}
 
463
 
 
464
inline int KoTextDocument::rightMargin() const
 
465
{
 
466
    return rightmargin;
 
467
}
 
468
 
 
469
inline void KoTextDocument::setRightMargin( int rm )
 
470
{
 
471
    rightmargin = rm;
 
472
}
 
473
 
 
474
/*inline KoTextPreProcessor *KoTextDocument::preProcessor() const
 
475
{
 
476
    return pProcessor;
 
477
}
 
478
 
 
479
inline void KoTextDocument::setPreProcessor( KoTextPreProcessor * sh )
 
480
{
 
481
    pProcessor = sh;
 
482
}*/
 
483
 
 
484
inline void KoTextDocument::setFormatter( KoTextFormatterBase *f )
 
485
{
 
486
    delete pFormatter;
 
487
    pFormatter = f;
 
488
}
 
489
 
 
490
inline KoTextFormatterBase *KoTextDocument::formatter() const
 
491
{
 
492
    return pFormatter;
 
493
}
 
494
 
 
495
inline void KoTextDocument::setIndent( KoTextIndent *i )
 
496
{
 
497
    indenter = i;
 
498
}
 
499
 
 
500
inline KoTextIndent *KoTextDocument::indent() const
 
501
{
 
502
    return indenter;
 
503
}
 
504
 
 
505
inline QColor KoTextDocument::selectionColor( int id ) const
 
506
{
 
507
    return selectionColors[ id ];
 
508
}
 
509
 
 
510
inline bool KoTextDocument::invertSelectionText( int id ) const
 
511
{
 
512
    return selectionText[ id ];
 
513
}
 
514
 
 
515
inline void KoTextDocument::setSelectionColor( int id, const QColor &c )
 
516
{
 
517
    selectionColors[ id ] = c;
 
518
}
 
519
 
 
520
inline void KoTextDocument::setInvertSelectionText( int id, bool b )
 
521
{
 
522
    selectionText[ id ] = b;
 
523
}
 
524
 
 
525
inline KoTextFormatCollection *KoTextDocument::formatCollection() const
 
526
{
 
527
    return fCollection;
 
528
}
 
529
 
 
530
inline int KoTextDocument::alignment() const
 
531
{
 
532
    return align;
 
533
}
 
534
 
 
535
inline void KoTextDocument::setAlignment( int a )
 
536
{
 
537
    align = a;
 
538
}
 
539
 
 
540
inline int *KoTextDocument::tabArray() const
 
541
{
 
542
    return tArray;
 
543
}
 
544
 
 
545
inline int KoTextDocument::tabStopWidth() const
 
546
{
 
547
    return tStopWidth;
 
548
}
 
549
 
 
550
inline void KoTextDocument::setTabArray( int *a )
 
551
{
 
552
    tArray = a;
 
553
}
 
554
 
 
555
inline void KoTextDocument::setTabStops( int tw )
 
556
{
 
557
    tStopWidth = tw;
 
558
}
 
559
 
 
560
/*inline QString KoTextDocument::originalText() const
 
561
{
 
562
    if ( oTextValid )
 
563
        return oText;
 
564
    return text();
 
565
}*/
 
566
 
 
567
inline void KoTextDocument::setFlow( KoTextFlow *f )
 
568
{
 
569
    if ( flow_ )
 
570
        delete flow_;
 
571
    flow_ = f;
 
572
}
 
573
 
 
574
inline void KoTextDocument::takeFlow()
 
575
{
 
576
    flow_ = 0L;
 
577
}
 
578
 
 
579
/**
 
580
 * Base class for "visitors". Visitors are a well-designed way to
 
581
 * apply a given operation to all the paragraphs in a selection, or
 
582
 * in a document. The visitor needs to inherit KoParagVisitor, and implement visit().
 
583
 */
 
584
class KoParagVisitor
 
585
{
 
586
protected:
 
587
    /** protected since this is an abstract base class */
 
588
    KoParagVisitor() {}
 
589
    virtual ~KoParagVisitor() {}
 
590
public:
 
591
    /** Visit the paragraph @p parag, from index @p start to index @p end */
 
592
    virtual bool visit( KoTextParag *parag, int start, int end ) = 0;
 
593
};
 
594
 
 
595
class KCommand;
 
596
class QDomElement;
 
597
class KMacroCommand;
 
598
 
 
599
/** A CustomItemsMap associates a custom item to an index
 
600
 * Used in the undo/redo info for insert/delete text. */
 
601
class CustomItemsMap : public QMap<int, KoTextCustomItem *>
 
602
{
 
603
public:
 
604
 
 
605
    /** Insert all the items from the map, into the existing text */
 
606
    void insertItems( const KoTextCursor & startCursor, int size );
 
607
 
 
608
    /** Delete all the items from the map, adding their commands into macroCmd */
 
609
    void deleteAll( KMacroCommand *macroCmd );
 
610
};
 
611
 
 
612
#endif