~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to lib/kotext/KoTextDocument.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

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