Warning, file /office/calligra/libs/text/KoTextRange.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 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 #ifndef KOTEXTRANGE_H
0020 #define KOTEXTRANGE_H
0021 
0022 #include "kotext_export.h"
0023 
0024 #include <QObject>
0025 #include <KoXmlReaderForward.h>
0026 
0027 class QTextDocument;
0028 class QTextCursor;
0029 
0030 class KoTextRangeManager;
0031 class KoTextRangePrivate;
0032 class KoShapeSavingContext;
0033 class KoTextInlineRdf;
0034 class KoShapeLoadingContext;
0035 
0036 /**
0037  * Base class for all text ranges.
0038  *
0039  * They are essentially anchored to a specific position or range in the text
0040  *
0041  * @see KoTextRangeManager
0042  */
0043 class KOTEXT_EXPORT KoTextRange : public QObject
0044 {
0045     Q_OBJECT
0046 public:
0047     enum TagType {StartTag = 0, EndTag = 1};
0048 
0049     /**
0050      * constructor
0051      */
0052     explicit KoTextRange(const QTextCursor &cursor);
0053     ~KoTextRange() override;
0054 
0055     /**
0056      * Will be called by the manager when this variable is added.
0057      * Remember that inheriting classes should not use the manager() in the constructor, since it will be 0
0058      * @param manager the object manager for this object.
0059      */
0060     void setManager(KoTextRangeManager *manager);
0061 
0062     /**
0063      * Return the object manager set on this inline object.
0064      */
0065     KoTextRangeManager *manager() const;
0066 
0067      /**
0068      * Return the textdocument the range points to.
0069      */
0070    QTextDocument *document() const;
0071 
0072     /**
0073      * Save the part of this text range corresponding to position as ODF
0074      * This may save a beginning tag, ending tag, or nothing at all
0075      * @param context the context for saving.
0076      * @param position a position in the qtextdocument we are currently saving for.
0077      * @param tagType the type of tag we are interested in
0078      */
0079     virtual void saveOdf(KoShapeSavingContext &context, int position, TagType tagType) const = 0;
0080 
0081     bool positionOnlyMode() const;
0082     void setPositionOnlyMode(bool m);
0083 
0084     bool hasRange() const;
0085     int rangeStart() const;
0086     int rangeEnd() const;
0087 
0088     void setRangeStart(int position);
0089     void setRangeEnd(int position);
0090 
0091     QString text() const;
0092 
0093     /**
0094      * A text range might have some Rdf metadata associated with it
0095      * in content.xml
0096      * Ownership of the rdf object is taken by the text range, and you should not
0097      * delete it.
0098      */
0099     void setInlineRdf(KoTextInlineRdf *rdf);
0100 
0101     /**
0102      * Get any Rdf which was stored in content.xml for this text range
0103      */
0104     KoTextInlineRdf *inlineRdf() const;
0105 
0106     /**
0107      * Load a variable from odf.
0108      *
0109      * @param element element which represents the shape in odf
0110      * @param context the KoShapeLoadingContext used for loading
0111      *
0112      * @return false if loading failed
0113      */
0114     virtual bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) =  0;
0115 
0116     void snapshot();
0117     void restore();
0118 
0119 protected:
0120     KoTextRangePrivate *d_ptr;
0121 
0122 private:
0123     Q_DECLARE_PRIVATE(KoTextRange)
0124 };
0125 
0126 KOTEXT_EXPORT QDebug operator<<(QDebug dbg, const KoTextRange *o);
0127 
0128 #endif