Warning, file /office/calligra/libs/text/KoAnchorTextRange.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) 2007, 2009 Thomas Zander <zander@kde.org>
0003  * Copyright (C) 2011 Matus Hanzes <matus.hanzes@ixonos.com>
0004  * Copyright (C) 2013 C. Boemann <cbo@boemann.dk>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Library General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Library General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Library General Public License
0017  * along with this library; see the file COPYING.LIB.  If not, write to
0018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020  */
0021 #ifndef KOANCHORTEXTRANGE_H
0022 #define KOANCHORTEXTRANGE_H
0023 
0024 #include "KoTextRange.h"
0025 
0026 #include "KoShapeAnchor.h"
0027 
0028 #include "kotext_export.h"
0029 
0030 class KoAnchorTextRangePrivate;
0031 class QTextCursor;
0032 
0033 /**
0034  * This class connects KoShapeAnchor to a position in the text document.
0035  *
0036  * This class is used when the shape anchor is of type: char or paragraph
0037  *
0038  * It has to be registered to the textrange manager and thus forms the connection between the text
0039  * and the KoShapeAnchor and by extension the so called 'anchored-shape' (any kind of shape)
0040  *
0041  * The KoAnchorTextRange is placed at a position in text. As with all KoTextRange it will change
0042  * it's position in the text when the user edits text before it. The user is also able to delete it if
0043  * deleting the text where it is positioned.
0044  *
0045  * The anchored-shape can be repositioned on the canvas if the text is relayouted (for example after
0046  * editing the text. This is dependent on how the text layout is implemented.
0047  *
0048  * Steps to use a KoAnchorTextRange are
0049  * <ol>
0050  * <li> Create KoShapeAnchor *anchor = new KoShapeAnchor(shape);
0051  * <li> Use anchor->loadOdf() to load additional attributes like the "text:anchor-type"
0052  * <li> if type is char or paragraph create KoAnchorTextRange *anchorRange = new KoAnchorTextRange(anchor);
0053  * </ol>
0054  */
0055 class KOTEXT_EXPORT KoAnchorTextRange : public KoTextRange, public KoShapeAnchor::TextLocation
0056 {
0057     Q_OBJECT
0058 public:
0059     /**
0060      * Constructor for a char or paragraph anchor.
0061      * @param parent the shapeanchor.
0062      * @param cursor the cursor.
0063      */
0064     KoAnchorTextRange(KoShapeAnchor *parent, const QTextCursor &cursor);
0065     ~KoAnchorTextRange() override;
0066 
0067     /// returns the parent anchor
0068     KoShapeAnchor *anchor() const;
0069 
0070     /// reimplemented from KoShapeAnchor::TextLocation
0071     const QTextDocument *document() const override;
0072 
0073     /// reimplemented from KoShapeAnchor::TextLocation
0074     int position() const override;
0075 
0076     void updateContainerModel();
0077 
0078     /// reimplemented from KoTextRange - should not do anything
0079     bool loadOdf(const KoXmlElement &, KoShapeLoadingContext &) override;
0080 
0081     /// reimplemented from KoTextRange
0082     void saveOdf(KoShapeSavingContext &context, int position, KoTextRange::TagType tagType) const override;
0083 
0084 private:
0085     KoAnchorTextRangePrivate * const d_ptr;
0086     Q_DECLARE_PRIVATE(KoAnchorTextRange)
0087 };
0088 
0089 #endif