1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
/* This file is part of the KDE project
* Copyright (C) 2007, 2009 Thomas Zander <zander@kde.org>
* Copyright (C) 2011 Matus Hanzes <matus.hanzes@ixonos.com>
* Copyright (C) 2013 C. Boemann <cbo@boemann.dk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOANCHORTEXTRANGE_H
#define KOANCHORTEXTRANGE_H
#include "KoTextRange.h"
#include "KoShapeAnchor.h"
#include "kritatext_export.h"
class KoAnchorTextRangePrivate;
class QTextCursor;
/**
* This class connects KoShapeAnchor to a position in the text document.
*
* This class is used when the shape anchor is of type: char or paragraph
*
* It has to be registered to the textrange manager and thus forms the connection between the text
* and the KoShapeAnchor and by extension the so called 'anchored-shape' (any kind of shape)
*
* The KoAnchorTextRange is placed at a position in text. As with all KoTextRange it will change
* it's position in the text when the user edits text before it. The user is also able to delete it if
* deleting the text where it is positioned.
*
* The anchored-shape can be repositioned on the canvas if the text is relayouted (for example after
* editing the text. This is dependent on how the text layout is implemented.
*
* Steps to use a KoAnchorTextRange are; <ol>
* <li> Create KoShapeAnchor *anchor = new KoShapeAnchor(shape);
* <li> Use anchor->loadOdf() to load additional attributes like the "text:anchor-type"
* <li> if type is char or paragraph create KoAnchorTextRange *anchorRange = new KoAnchorTextRange(anchor);
*/
class KRITATEXT_EXPORT KoAnchorTextRange : public KoTextRange, public KoShapeAnchor::TextLocation
{
Q_OBJECT
public:
/**
* Constructor for a char or paragraph anchor.
* @param parent the shapeanchor.
*/
KoAnchorTextRange(KoShapeAnchor *parent, const QTextCursor &cursor);
virtual ~KoAnchorTextRange();
/// returns the parent anchor
KoShapeAnchor *anchor() const;
/// reimplemented from KoShapeAnchor::TextLocation
const QTextDocument *document() const;
/// reimplemented from KoShapeAnchor::TextLocation
int position() const;
void updateContainerModel();
/// reimplemented from KoTextRange - should not do anything
bool loadOdf(const KoXmlElement &, KoShapeLoadingContext &);
/// reimplemented from KoTextRange
void saveOdf(KoShapeSavingContext &context, int position, KoTextRange::TagType tagType) const;
private:
KoAnchorTextRangePrivate * const d_ptr;
Q_DECLARE_PRIVATE(KoAnchorTextRange)
};
#endif
|