Warning, file /office/calligra/libs/textlayout/KoTextShapeData.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) 2006, 2009-2010 Thomas Zander <zander@kde.org> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KOTEXTSHAPEDATA_H 0021 #define KOTEXTSHAPEDATA_H 0022 0023 #include "KoText.h" 0024 #include "kotextlayout_export.h" 0025 0026 #include <KoTextShapeDataBase.h> 0027 #include <KoXmlReaderForward.h> 0028 0029 class QTextDocument; 0030 class KoShapeLoadingContext; 0031 class KoShapeSavingContext; 0032 class KoTextShapeDataPrivate; 0033 class KoDocumentRdfBase; 0034 class KoTextLayoutRootArea; 0035 0036 /** 0037 * The data store that is held by each TextShape instance. 0038 * This is a separate object to allow Words proper to use this class' API and 0039 * access the internals of the text shape. 0040 * 0041 * This class holds a QTextDocument pointer and is built so multiple shapes (and thus 0042 * multiple instances of this shape data) can share one QTextDocument by providing a 0043 * different view on (a different part of) the QTextDocument. 0044 */ 0045 class KOTEXTLAYOUT_EXPORT KoTextShapeData : public KoTextShapeDataBase 0046 { 0047 Q_OBJECT 0048 public: 0049 /// constructor 0050 KoTextShapeData(); 0051 ~KoTextShapeData() override; 0052 0053 /** 0054 * Replace the QTextDocument this shape will render. 0055 * @param document the new document. If there was an old document owned, it will be deleted. 0056 * @param transferOwnership if true then the document will be considered the responsibility 0057 * of this data and the doc will be deleted when this shapeData dies. 0058 */ 0059 void setDocument(QTextDocument *document, bool transferOwnership = true); 0060 0061 /** 0062 * return the amount of points into the document (y) this shape will display. 0063 */ 0064 qreal documentOffset() const; 0065 0066 /// mark shape as dirty triggering a re-layout of its text. 0067 void setDirty(); 0068 0069 /// return if the shape is marked dirty and its text content needs to be relayout 0070 bool isDirty() const; 0071 0072 /// Set the rootArea that is associated to the textshape 0073 void setRootArea(KoTextLayoutRootArea *rootArea); 0074 0075 /// the rootArea that is associated to the textshape 0076 KoTextLayoutRootArea *rootArea(); 0077 0078 void setLeftPadding(qreal padding); 0079 qreal leftPadding() const; 0080 void setTopPadding(qreal padding); 0081 qreal topPadding() const; 0082 void setRightPadding(qreal padding); 0083 qreal rightPadding() const; 0084 void setBottomPadding(qreal padding); 0085 qreal bottomPadding() const; 0086 void setPadding(qreal padding); 0087 0088 /** 0089 * Load the TextShape from ODF. 0090 * 0091 * @see the @a TextShape::loadOdf() method which calls this method. 0092 * @see the @a KoTextLoader::loadBody() method which got called by this method 0093 * to load the ODF. 0094 */ 0095 bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context, KoDocumentRdfBase *rdfData, KoShape *shape = 0); 0096 0097 /** 0098 * Load the TextShape from ODF. 0099 * Overloaded method provided for your convenience. 0100 */ 0101 bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) override { 0102 return loadOdf(element, context, 0); 0103 } 0104 0105 /** 0106 * Store the TextShape data as ODF. 0107 * @see TextShape::saveOdf() 0108 */ 0109 void saveOdf(KoShapeSavingContext &context, KoDocumentRdfBase *rdfData, int from = 0, int to = -1) const; 0110 0111 /** 0112 * Store the TextShape data as ODF. 0113 * Overloaded method provided for your convenience. 0114 */ 0115 void saveOdf(KoShapeSavingContext &context, int from = 0, int to = -1) const override { 0116 saveOdf(context, 0, from, to); 0117 } 0118 0119 // reimplemented 0120 void loadStyle(const KoXmlElement &element, KoShapeLoadingContext &context) override; 0121 0122 // reimplemented 0123 void saveStyle(KoGenStyle &style, KoShapeSavingContext &context) const override; 0124 0125 /** 0126 * Set the page direction. 0127 * The page direction will determine behavior on the insertion of new text and those 0128 * new paragraphs default direction. 0129 */ 0130 void setPageDirection(KoText::Direction direction); 0131 /** 0132 * Return the direction set on the page. 0133 * The page direction will determine behavior on the insertion of new text and those 0134 * new paragraphs default direction. 0135 */ 0136 KoText::Direction pageDirection() const; 0137 0138 private: 0139 Q_DECLARE_PRIVATE(KoTextShapeData) 0140 }; 0141 0142 #endif