Warning, file /office/calligra/libs/text/KoTextMeta.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) 2010 KO GmbH <ben.martin@kogmbh.com>
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 KOTEXTMETA_H
0021 #define KOTEXTMETA_H
0022 
0023 #include "KoInlineObject.h"
0024 #include "kotext_export.h"
0025 
0026 /**
0027  * Used to indicate an ODF text:meta container. This is very similar to a KoBookmark
0028  * in that a specific start-end is marked.
0029  */
0030 class KOTEXT_EXPORT KoTextMeta : public KoInlineObject
0031 {
0032     Q_OBJECT
0033 public:
0034     enum BookmarkType {
0035         StartBookmark,      ///< start position
0036         EndBookmark         ///< end position
0037     };
0038 
0039     /**
0040      * Constructor
0041      * @param name the name for this bookmark
0042      * @param document the text document where this bookmark is located
0043      */
0044     explicit KoTextMeta(const QTextDocument *document);
0045 
0046     ~KoTextMeta() override;
0047 
0048     /// reimplemented from super
0049     void saveOdf(KoShapeSavingContext &context) override;
0050     bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) override;
0051 
0052     /// reimplemented from super
0053     void updatePosition(const QTextDocument *document,
0054                                 int posInDocument, const QTextCharFormat &format) override;
0055     /// reimplemented from super
0056     void resize(const QTextDocument *document, QTextInlineObject &object,
0057                         int posInDocument, const QTextCharFormat &format, QPaintDevice *pd) override;
0058     /// reimplemented from super
0059     void paint(QPainter &painter, QPaintDevice *pd, const QTextDocument *document,
0060                        const QRectF &rect, const QTextInlineObject &object, int posInDocument, const QTextCharFormat &format) override;
0061 
0062     void setType(BookmarkType type);
0063 
0064     /// @return the current type of this bookmark
0065     BookmarkType type() const;
0066 
0067     void setEndBookmark(KoTextMeta *bookmark);
0068 
0069     /// @return the end bookmark if the type is StartBookmark
0070     KoTextMeta* endBookmark() const;
0071 
0072     /// @return the exact cursor position of this bookmark in document
0073     int position() const;
0074 
0075 private:
0076     class Private; // TODO share the private with super
0077     Private *const d;
0078 };
0079 
0080 #endif
0081