Warning, file /office/calligra/libs/flake/KoTextShapeDataBase.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-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 KOTEXTSHAPEDATABASE_H 0021 #define KOTEXTSHAPEDATABASE_H 0022 0023 #include "flake_export.h" 0024 0025 #include "KoShapeUserData.h" 0026 0027 class KoTextShapeDataBasePrivate; 0028 class KoXmlElement; 0029 class KoShapeLoadingContext; 0030 class KoShapeSavingContext; 0031 class KoGenStyle; 0032 struct KoInsets; 0033 0034 class QTextDocument; 0035 0036 /** 0037 * \internal 0038 */ 0039 class FLAKE_EXPORT KoTextShapeDataBase : public KoShapeUserData 0040 { 0041 Q_OBJECT 0042 public: 0043 /// constructor 0044 KoTextShapeDataBase(); 0045 ~KoTextShapeDataBase() override; 0046 0047 /// return the document 0048 QTextDocument *document() const; 0049 0050 /** 0051 * Set the margins that will make the shapes text area smaller. 0052 * The shape that owns this textShapeData object will layout text in an area 0053 * confined by the shape size made smaller by the margins set here. 0054 * @param margins the margins that shrink the text area. 0055 */ 0056 void setShapeMargins(const KoInsets &margins); 0057 /** 0058 * returns the currently set margins for the shape. 0059 */ 0060 KoInsets shapeMargins() const; 0061 0062 /** 0063 * Load the text from ODF. 0064 */ 0065 virtual bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) = 0; 0066 0067 /** 0068 * Save the text to ODF. 0069 */ 0070 virtual void saveOdf(KoShapeSavingContext &context, int from = 0, int to = -1) const = 0; 0071 0072 /** 0073 * Load the style of the element 0074 * 0075 * This method is used to load the style in case the TextShape is used as TOS. In this case 0076 * the paragraph style of the shape e.g. a custom-shape needs to be applied before we load the 0077 * text so all looks as it should look. 0078 */ 0079 virtual void loadStyle(const KoXmlElement &element, KoShapeLoadingContext &context) = 0; 0080 /** 0081 * Save the style of the element 0082 * 0083 * This method save the style in case the TextShape is used as TOS. In this case the paragraph 0084 * style of the shape e.g. a custom-shape needs to be saved with the style of the shape. 0085 */ 0086 virtual void saveStyle(KoGenStyle &style, KoShapeSavingContext &context) const = 0; 0087 0088 /** Sets the vertical alignment of all the text inside the shape. */ 0089 void setVerticalAlignment(Qt::Alignment alignment); 0090 /** Returns the vertical alignment of all the text in the shape */ 0091 Qt::Alignment verticalAlignment() const; 0092 0093 /** 0094 * Enum to describe the text document's automatic resizing behaviour. 0095 */ 0096 enum ResizeMethod { 0097 /// Resize the shape to fit the content. This makes sure that the text shape takes op 0098 /// only as much space as absolutely necessary to fit the entire text into its boundaries. 0099 AutoResize, 0100 /// Specifies whether or not to automatically increase the width of the drawing object 0101 /// if text is added to fit the entire width of the text into its boundaries. 0102 /// Compared to AutoResize above this only applied to the width whereas the height is 0103 /// not resized. Also this only grows but does not shrink again if text is removed again. 0104 AutoGrowWidth, 0105 /// Specifies whether or not to automatically increase the height of the drawing object 0106 /// if text is added to fit the entire height of the text into its boundaries. 0107 AutoGrowHeight, 0108 /// This combines the AutoGrowWidth and AutoGrowHeight and automatically increase width 0109 /// and height to fit the entire text into its boundaries. 0110 AutoGrowWidthAndHeight, 0111 /// Shrink the content displayed within the shape to match into the shape's boundaries. This 0112 /// will scale the content down as needed to display the whole document. 0113 ShrinkToFitResize, 0114 /// Deactivates auto-resizing. This is the default resizing method. 0115 NoResize 0116 }; 0117 0118 /** 0119 * Specifies how the document should be resized upon a change in the document. 0120 * 0121 * If auto-resizing is turned on, text will not be wrapped unless enforced by e.g. a newline. 0122 * 0123 * By default, NoResize is set. 0124 */ 0125 void setResizeMethod(ResizeMethod method); 0126 0127 /** 0128 * Returns the auto-resizing mode. By default, this is NoResize. 0129 * 0130 * @see setResizeMethod 0131 */ 0132 ResizeMethod resizeMethod() const; 0133 0134 protected: 0135 /// constructor 0136 KoTextShapeDataBase(KoTextShapeDataBasePrivate &); 0137 0138 KoTextShapeDataBasePrivate *d_ptr; 0139 0140 private: 0141 Q_DECLARE_PRIVATE(KoTextShapeDataBase) 0142 }; 0143 0144 #endif 0145