File: KoTextDocument.h

package info (click to toggle)
calligra 1%3A3.2.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 260,432 kB
  • sloc: cpp: 650,911; xml: 27,662; python: 6,044; perl: 2,724; yacc: 1,817; ansic: 1,325; sh: 1,277; lex: 1,107; ruby: 1,010; javascript: 495; makefile: 24
file content (267 lines) | stat: -rw-r--r-- 8,646 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/* This file is part of the KDE project
 * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in>
 * Copyright (C) 2009 Thomas Zander <zander@kde.org>
 * Copyright (C) 2008 Pierre Stirnweiss <pierre.stirnweiss_calligra@gadz.org>
 * Copyright (C) 2014-2015 Denis Kuplyakov <dener.kup@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef KOTEXTDOCUMENT_H
#define KOTEXTDOCUMENT_H

#include <QTextDocument>
#include <QPointer>
#include <QAbstractTextDocumentLayout>
#include <QUrl>

#include "KoListStyle.h"

class KoList;
class KoStyleManager;
class KoInlineTextObjectManager;
class KoTextRangeManager;
class KUndo2Stack;
class KoTextEditor;
class KoOdfLineNumberingConfiguration;
class KoChangeTracker;
class KoShapeController;
class KoSectionModel;

class QTextCharFormat;

/**
 * KoTextDocument provides an easy mechanism to set and access the
 * editing members of a QTextDocument. The meta data are stored as resources
 * in the QTextDocument using QTextDocument::addResource() and fetched
 * using QTextDocument::resource().
 *
 */
class KOTEXT_EXPORT KoTextDocument
{
public:
    /// Constructor
    KoTextDocument(QTextDocument *document); // krazy:exclude=explicit
    /// Constructor
    KoTextDocument(const QTextDocument *document); // krazy:exclude=explicit
    /// Constructor
    KoTextDocument(QPointer<QTextDocument> document); // krazy:exclude=explicit

    /// Destructor
    ~KoTextDocument();

    /// Returns the document that was passed in the constructor
    QTextDocument *document() const;

    ///Returns the text editor for that document
    KoTextEditor *textEditor() const;

    ///Sets the text editor for the document
    void setTextEditor(KoTextEditor *textEditor);

    /// Sets the style manager that defines the named styles in the document
    void setStyleManager(KoStyleManager *styleManager);

    /// Returns the style manager
    KoStyleManager *styleManager() const;

    /// Sets the change tracker of the document
    void setChangeTracker(KoChangeTracker *changeTracker);

    ///Returns the change tracker of the document
    KoChangeTracker *changeTracker() const;

    void setLineNumberingConfiguration(KoOdfLineNumberingConfiguration *lineNumberingConfiguration);

    /// @return the notes configuration
    KoOdfLineNumberingConfiguration *lineNumberingConfiguration() const;

    ///Sets the global undo stack
    void setUndoStack(KUndo2Stack *undoStack);

    ///Returns the global undo stack
    KUndo2Stack *undoStack() const;

    ///Sets the global heading list
    void setHeadingList(KoList *list);

    ///Returns the global heading list
    KoList *headingList() const;

    /// Sets the lists of the document
    void setLists(const QList<KoList *> &lists);

    /// Returns the lists in the document
    QList<KoList *> lists() const;

    /// Adds a list to the document
    void addList(KoList *list);

    /// Removes a list from the document
    void removeList(KoList *list);

    /// Returns the KoList that holds \a block; 0 if block is not part of any list
    KoList *list(const QTextBlock &block) const;

    /// Returns the KoList that holds \a list
    KoList *list(QTextList *textList) const;

    /// Return the KoList that holds \a listId
    KoList *list(KoListStyle::ListIdType listId) const;

    /// Return the selections used during painting.
    QVector<QAbstractTextDocumentLayout::Selection> selections() const;

    /**
     * Set the selections to use for painting.
     *
     * The selections are used to apply temporary styling to
     * parts of a document.
     *
     * \param selections The new selections to use.
     */
    void setSelections(const QVector<QAbstractTextDocumentLayout::Selection> &selections);

    /// Returns the KoInlineTextObjectManager
    KoInlineTextObjectManager *inlineTextObjectManager() const;

    /// Set the KoInlineTextObjectManager
    void setInlineTextObjectManager(KoInlineTextObjectManager *manager);

    /// @return section model for the document
    KoSectionModel *sectionModel();

    /// Sets the section model for the document
    void setSectionModel(KoSectionModel *model);

    /// Returns the KoTextRangeManager
    KoTextRangeManager *textRangeManager() const;

    /// Set the KoTextRangeManager
    void setTextRangeManager(KoTextRangeManager *manager);

    /// Set the KoDocument's shapeController. This controller exists as long as KoDocument exists. It should only be used for deleting shapes.
    void setShapeController(KoShapeController *controller);

    /// Returns the shapeController
    KoShapeController *shapeController() const;

    QTextFrame* auxillaryFrame();

    /**
     * Specifies if tabs are relative to paragraph indent.
     *
     * By default it's false.
     */
    void setRelativeTabs(bool relative);

    /**
     * Returns if tabs are placed relative to paragraph indent.
     *
     * By default, this is false.
     *
     * @see setRelativeTabs
     */
    bool relativeTabs() const;

    void setParaTableSpacingAtStart(bool spacingAtStart);
    bool paraTableSpacingAtStart() const;

    /**
     * Returns the character format for the frame of this document.
     *
     * @return the character format for the frame of this document.
     * @see setFrameCharFormat
     */
    QTextCharFormat frameCharFormat() const;

    /**
     * Sets the character format for the frame of this document.
     *
     * @param format the character format for the frame of this document.
     * @see frameCharFormat
     */
    void setFrameCharFormat(const QTextCharFormat &format);

    /**
     * Returns the block format for the frame of this document.
     *
     * @return the block format for the frame of this document.
     * @see setFrameBlockFormat
     */
    QTextBlockFormat frameBlockFormat() const;

    /**
     * Sets the block format for the frame of this document.
     *
     * @param format the block format for the frame of this document.
     * @see frameBlockFormat
     */
    void setFrameBlockFormat(const QTextBlockFormat &format);

    /**
     * Clears the text in the document. Unlike QTextDocument::clear(), this
     * function does not clear the resources of the QTextDocument.
     */
    void clearText();

    /// Enum (type) used to add resources using QTextDocument::addResource()
    enum ResourceType {
        StyleManager = QTextDocument::UserResource,
        Lists,
        TextRangeManager,
        InlineTextManager,
        ChangeTrackerResource,
        UndoStack,
        TextEditor,
        LineNumberingConfiguration,
        RelativeTabs,
        HeadingList,
        Selections,
        LayoutTextPage, /// this is used for setting the correct page variable on the first resize and should not be used for other purposes
        ParaTableSpacingAtStart, /// this is used during layouting to specify if at the first paragraph margin-top should be applied.
        IndexGeneratorManager,
        FrameCharFormat,
        FrameBlockFormat,
        ShapeController,
        SectionModel
    };

    static const QUrl StyleManagerURL;
    static const QUrl ListsURL;
    static const QUrl TextRangeManagerURL;
    static const QUrl InlineObjectTextManagerURL;
    static const QUrl ChangeTrackerURL;
    static const QUrl UndoStackURL;
    static const QUrl TextEditorURL;
    static const QUrl LineNumberingConfigurationURL;
    static const QUrl BibliographyConfigurationURL;
    static const QUrl RelativeTabsURL;
    static const QUrl HeadingListURL;
    static const QUrl SelectionsURL;
    static const QUrl LayoutTextPageUrl;
    static const QUrl ParaTableSpacingAtStartUrl;
    static const QUrl IndexGeneratorManagerUrl;
    static const QUrl FrameCharFormatUrl;
    static const QUrl FrameBlockFormatUrl;
    static const QUrl ShapeControllerUrl;
    static const QUrl SectionModelUrl;

private:
    QTextDocument *m_document;
};

#endif // KOTEXTDOCUMENT_H