Warning, file /office/calligra/libs/text/KoSection.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2011 Boudewijn Rempt <boud@valdyas.org> 0003 * Copyright (c) 2014-2015 Denis Kuplyakov <dener.kup@gmail.com> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Lesser General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2.1 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Lesser General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Lesser General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 #ifndef KOSECTION_H 0021 #define KOSECTION_H 0022 0023 #include "kotext_export.h" 0024 0025 #include <QMetaType> 0026 #include <QList> 0027 #include <QString> 0028 #include <QPair> 0029 #include <QScopedPointer> 0030 #include <QTextCursor> 0031 0032 class KoXmlElement; 0033 class KoShapeSavingContext; 0034 class KoTextSharedLoadingData; 0035 class KoSectionEnd; 0036 class KoElementReference; 0037 class KoTextInlineRdf; 0038 0039 class KoSectionPrivate; 0040 /** 0041 * Contains the information about the current text:section. 0042 * 0043 * The <text:section> element has the following attributes: 0044 * 0045 * <ul> 0046 * <li>text:condition 0047 * <li>text:display 0048 * <li>text:name 0049 * <li>text:protected 0050 * <li>text:protection-key 0051 * <li>text:protection-key-digest-algorithm 0052 * <li>text:style-name 0053 * <li>xml:id 0054 * </ul> 0055 * (odf spec v.12) 0056 */ 0057 class KOTEXT_EXPORT KoSection 0058 { 0059 public: 0060 ~KoSection(); 0061 0062 /// Returns section name 0063 QString name() const; 0064 /// Returns starting and ending position of section in QTextDocument 0065 QPair<int, int> bounds() const; 0066 /// Returns section level. Root section has @c 0 level. 0067 int level() const; 0068 0069 /** Returns inlineRdf associated with section 0070 * @return pointer to the KoTextInlineRdf for this section 0071 */ 0072 KoTextInlineRdf *inlineRdf() const; 0073 0074 /** Sets KoTextInlineRdf for this section 0075 * @param inlineRdf pointer to KoTextInlineRdf to set 0076 */ 0077 void setInlineRdf(KoTextInlineRdf *inlineRdf); 0078 0079 bool loadOdf(const KoXmlElement &element, KoTextSharedLoadingData *sharedData, bool stylesDotXml); 0080 void saveOdf(KoShapeSavingContext &context) const; 0081 0082 protected: 0083 const QScopedPointer<KoSectionPrivate> d_ptr; 0084 0085 private: 0086 Q_DISABLE_COPY(KoSection) 0087 Q_DECLARE_PRIVATE(KoSection) 0088 0089 explicit KoSection(const QTextCursor &cursor, const QString &name, KoSection *parent); 0090 0091 /// Changes section's name to @param name 0092 void setName(const QString &name); 0093 0094 /// Sets paired KoSectionsEnd for this section. 0095 void setSectionEnd(KoSectionEnd *sectionEnd); 0096 0097 /** 0098 * Sets level of section in section tree. 0099 * Root sections have @c 0 level. 0100 */ 0101 void setLevel(int level); 0102 0103 /// Returns a pointer to the parent of the section in tree. 0104 KoSection *parent() const; 0105 0106 /// Returns a vector of pointers to the children of the section. 0107 QVector<KoSection *> children() const; 0108 0109 /** 0110 * Specifies if end bound of section should stay on place when inserting text. 0111 * Used by KoTextLoader on document loading. 0112 * @see QTextCursor::setKeepPositionOnInsert(bool) 0113 */ 0114 void setKeepEndBound(bool state); 0115 0116 /** 0117 * Inserts @param section to position @param childIdx of children 0118 */ 0119 void insertChild(int childIdx, KoSection *section); 0120 0121 /** 0122 * Removes child on position @param childIdx 0123 */ 0124 void removeChild(int childIdx); 0125 0126 friend class KoSectionModel; 0127 friend class KoTextLoader; // accesses setKeepEndBound() function 0128 friend class KoSectionEnd; 0129 friend class TestKoTextEditor; // accesses setKeepEndBound() function 0130 }; 0131 0132 Q_DECLARE_METATYPE(KoSection *) 0133 Q_DECLARE_METATYPE(QList<KoSection *>) 0134 0135 #endif // KOSECTION_H