Warning, file /office/calligra/libs/text/KoTextDocument.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2008 Girish Ramakrishnan <girish@forwardbias.in> 0003 * Copyright (C) 2009 Thomas Zander <zander@kde.org> 0004 * Copyright (C) 2008 Pierre Stirnweiss <pierre.stirnweiss_calligra@gadz.org> 0005 * Copyright (C) 2014-2015 Denis Kuplyakov <dener.kup@gmail.com> 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Library General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Library General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Library General Public License 0018 * along with this library; see the file COPYING.LIB. If not, write to 0019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #ifndef KOTEXTDOCUMENT_H 0024 #define KOTEXTDOCUMENT_H 0025 0026 #include <QTextDocument> 0027 #include <QPointer> 0028 #include <QAbstractTextDocumentLayout> 0029 #include <QUrl> 0030 0031 #include "KoListStyle.h" 0032 0033 class KoList; 0034 class KoStyleManager; 0035 class KoInlineTextObjectManager; 0036 class KoTextRangeManager; 0037 class KUndo2Stack; 0038 class KoTextEditor; 0039 class KoOdfLineNumberingConfiguration; 0040 class KoChangeTracker; 0041 class KoShapeController; 0042 class KoSectionModel; 0043 0044 class QTextCharFormat; 0045 0046 /** 0047 * KoTextDocument provides an easy mechanism to set and access the 0048 * editing members of a QTextDocument. The meta data are stored as resources 0049 * in the QTextDocument using QTextDocument::addResource() and fetched 0050 * using QTextDocument::resource(). 0051 * 0052 */ 0053 class KOTEXT_EXPORT KoTextDocument 0054 { 0055 public: 0056 /// Constructor 0057 KoTextDocument(QTextDocument *document); // krazy:exclude=explicit 0058 /// Constructor 0059 KoTextDocument(const QTextDocument *document); // krazy:exclude=explicit 0060 /// Constructor 0061 KoTextDocument(QPointer<QTextDocument> document); // krazy:exclude=explicit 0062 0063 /// Destructor 0064 ~KoTextDocument(); 0065 0066 /// Returns the document that was passed in the constructor 0067 QTextDocument *document() const; 0068 0069 ///Returns the text editor for that document 0070 KoTextEditor *textEditor() const; 0071 0072 ///Sets the text editor for the document 0073 void setTextEditor(KoTextEditor *textEditor); 0074 0075 /// Sets the style manager that defines the named styles in the document 0076 void setStyleManager(KoStyleManager *styleManager); 0077 0078 /// Returns the style manager 0079 KoStyleManager *styleManager() const; 0080 0081 /// Sets the change tracker of the document 0082 void setChangeTracker(KoChangeTracker *changeTracker); 0083 0084 ///Returns the change tracker of the document 0085 KoChangeTracker *changeTracker() const; 0086 0087 void setLineNumberingConfiguration(KoOdfLineNumberingConfiguration *lineNumberingConfiguration); 0088 0089 /// @return the notes configuration 0090 KoOdfLineNumberingConfiguration *lineNumberingConfiguration() const; 0091 0092 ///Sets the global undo stack 0093 void setUndoStack(KUndo2Stack *undoStack); 0094 0095 ///Returns the global undo stack 0096 KUndo2Stack *undoStack() const; 0097 0098 ///Sets the global heading list 0099 void setHeadingList(KoList *list); 0100 0101 ///Returns the global heading list 0102 KoList *headingList() const; 0103 0104 /// Sets the lists of the document 0105 void setLists(const QList<KoList *> &lists); 0106 0107 /// Returns the lists in the document 0108 QList<KoList *> lists() const; 0109 0110 /// Adds a list to the document 0111 void addList(KoList *list); 0112 0113 /// Removes a list from the document 0114 void removeList(KoList *list); 0115 0116 /// Returns the KoList that holds \a block; 0 if block is not part of any list 0117 KoList *list(const QTextBlock &block) const; 0118 0119 /// Returns the KoList that holds \a list 0120 KoList *list(QTextList *textList) const; 0121 0122 /// Return the KoList that holds \a listId 0123 KoList *list(KoListStyle::ListIdType listId) const; 0124 0125 /// Return the selections used during painting. 0126 QVector<QAbstractTextDocumentLayout::Selection> selections() const; 0127 0128 /** 0129 * Set the selections to use for painting. 0130 * 0131 * The selections are used to apply temporary styling to 0132 * parts of a document. 0133 * 0134 * \param selections The new selections to use. 0135 */ 0136 void setSelections(const QVector<QAbstractTextDocumentLayout::Selection> &selections); 0137 0138 /// Returns the KoInlineTextObjectManager 0139 KoInlineTextObjectManager *inlineTextObjectManager() const; 0140 0141 /// Set the KoInlineTextObjectManager 0142 void setInlineTextObjectManager(KoInlineTextObjectManager *manager); 0143 0144 /// @return section model for the document 0145 KoSectionModel *sectionModel(); 0146 0147 /// Sets the section model for the document 0148 void setSectionModel(KoSectionModel *model); 0149 0150 /// Returns the KoTextRangeManager 0151 KoTextRangeManager *textRangeManager() const; 0152 0153 /// Set the KoTextRangeManager 0154 void setTextRangeManager(KoTextRangeManager *manager); 0155 0156 /// Set the KoDocument's shapeController. This controller exists as long as KoDocument exists. It should only be used for deleting shapes. 0157 void setShapeController(KoShapeController *controller); 0158 0159 /// Returns the shapeController 0160 KoShapeController *shapeController() const; 0161 0162 QTextFrame* auxillaryFrame(); 0163 0164 /** 0165 * Specifies if tabs are relative to paragraph indent. 0166 * 0167 * By default it's false. 0168 */ 0169 void setRelativeTabs(bool relative); 0170 0171 /** 0172 * Returns if tabs are placed relative to paragraph indent. 0173 * 0174 * By default, this is false. 0175 * 0176 * @see setRelativeTabs 0177 */ 0178 bool relativeTabs() const; 0179 0180 void setParaTableSpacingAtStart(bool spacingAtStart); 0181 bool paraTableSpacingAtStart() const; 0182 0183 /** 0184 * Returns the character format for the frame of this document. 0185 * 0186 * @return the character format for the frame of this document. 0187 * @see setFrameCharFormat 0188 */ 0189 QTextCharFormat frameCharFormat() const; 0190 0191 /** 0192 * Sets the character format for the frame of this document. 0193 * 0194 * @param format the character format for the frame of this document. 0195 * @see frameCharFormat 0196 */ 0197 void setFrameCharFormat(const QTextCharFormat &format); 0198 0199 /** 0200 * Returns the block format for the frame of this document. 0201 * 0202 * @return the block format for the frame of this document. 0203 * @see setFrameBlockFormat 0204 */ 0205 QTextBlockFormat frameBlockFormat() const; 0206 0207 /** 0208 * Sets the block format for the frame of this document. 0209 * 0210 * @param format the block format for the frame of this document. 0211 * @see frameBlockFormat 0212 */ 0213 void setFrameBlockFormat(const QTextBlockFormat &format); 0214 0215 /** 0216 * Clears the text in the document. Unlike QTextDocument::clear(), this 0217 * function does not clear the resources of the QTextDocument. 0218 */ 0219 void clearText(); 0220 0221 /// Enum (type) used to add resources using QTextDocument::addResource() 0222 enum ResourceType { 0223 StyleManager = QTextDocument::UserResource, 0224 Lists, 0225 TextRangeManager, 0226 InlineTextManager, 0227 ChangeTrackerResource, 0228 UndoStack, 0229 TextEditor, 0230 LineNumberingConfiguration, 0231 RelativeTabs, 0232 HeadingList, 0233 Selections, 0234 LayoutTextPage, /// this is used for setting the correct page variable on the first resize and should not be used for other purposes 0235 ParaTableSpacingAtStart, /// this is used during layouting to specify if at the first paragraph margin-top should be applied. 0236 IndexGeneratorManager, 0237 FrameCharFormat, 0238 FrameBlockFormat, 0239 ShapeController, 0240 SectionModel 0241 }; 0242 0243 static const QUrl StyleManagerURL; 0244 static const QUrl ListsURL; 0245 static const QUrl TextRangeManagerURL; 0246 static const QUrl InlineObjectTextManagerURL; 0247 static const QUrl ChangeTrackerURL; 0248 static const QUrl UndoStackURL; 0249 static const QUrl TextEditorURL; 0250 static const QUrl LineNumberingConfigurationURL; 0251 static const QUrl BibliographyConfigurationURL; 0252 static const QUrl RelativeTabsURL; 0253 static const QUrl HeadingListURL; 0254 static const QUrl SelectionsURL; 0255 static const QUrl LayoutTextPageUrl; 0256 static const QUrl ParaTableSpacingAtStartUrl; 0257 static const QUrl IndexGeneratorManagerUrl; 0258 static const QUrl FrameCharFormatUrl; 0259 static const QUrl FrameBlockFormatUrl; 0260 static const QUrl ShapeControllerUrl; 0261 static const QUrl SectionModelUrl; 0262 0263 private: 0264 QTextDocument *m_document; 0265 }; 0266 0267 #endif // KOTEXTDOCUMENT_H