Warning, file /office/calligra/libs/text/KoAnchorInlineObject.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 KOANCHORINLINEOBJECT_H
0022 #define KOANCHORINLINEOBJECT_H
0023 
0024 #include "KoInlineObject.h"
0025 
0026 #include "KoShapeAnchor.h"
0027 
0028 #include "kotext_export.h"
0029 
0030 class KoAnchorInlineObjectPrivate;
0031 
0032 /**
0033  * This class connects KoShapeAnchor to an inline character in the text document.
0034  *
0035  * This class is used when the shape anchor is of type: as-char
0036  *
0037  * It has to be registered to the inlineobjectmanager and thus forms the connection between the text
0038  * and the KoShapeAnchor and by extension the so called 'anchored-shape' (any kind of shape)
0039  *
0040  * The KoAnchorInlineObject is placed as a character in text. As such it will move and be
0041  * editable like any other character, including deletion.
0042  *
0043  * Since this is a real character it will be positioned by the textlayout engine and anything that
0044  * will change the position of the text will thus also change the KoAnchorInlineObject character.
0045  *
0046  * The anchored-shape can be repositioned on the canvas if the text is relayouted (for example after
0047  * editing the text. This is dependent on how the text layout is implemented.
0048  *
0049  * Steps to use a KoAnchorInlineObject are
0050  * <ol>
0051  * <li> Create KoShapeAnchor *anchor = new KoShapeAnchor(shape);
0052  * <li> Use anchor->loadOdf() to load additional attributes like the "text:anchor-type"
0053  * <li> if type is as-char create KoAnchorInlineObject *anchorObj = new KoAnchorInlineObject(anchor);
0054  * </ol>
0055  */
0056 class KOTEXT_EXPORT KoAnchorInlineObject : public KoInlineObject, public KoShapeAnchor::TextLocation
0057 {
0058     Q_OBJECT
0059 public:
0060     /**
0061      * Constructor for an as-char anchor.
0062      * @param parent the shapeanchor.
0063      */
0064     explicit  KoAnchorInlineObject(KoShapeAnchor *parent);
0065     ~KoAnchorInlineObject() override;
0066 
0067     /// returns the parent anchor
0068     KoShapeAnchor *anchor() const;
0069 
0070     /// returns the cursor position in the document where this anchor is positioned.
0071     int position() const override;
0072 
0073     /// returns the document that this anchor is associated with.
0074     const QTextDocument *document() const override;
0075 
0076     /// reimplemented from KoInlineObject
0077     void updatePosition(const QTextDocument *document,
0078                                 int posInDocument, const QTextCharFormat &format) override;
0079     /// reimplemented from KoInlineObject
0080     void resize(const QTextDocument *document, QTextInlineObject &object,
0081                         int posInDocument, const QTextCharFormat &format, QPaintDevice *pd) override;
0082     /// reimplemented from KoInlineObject
0083     void paint(QPainter &painter, QPaintDevice *pd, const QTextDocument *document,
0084                        const QRectF &rect, const QTextInlineObject &object, int posInDocument, const QTextCharFormat &format) override;
0085 
0086     qreal inlineObjectAscent() const;
0087 
0088     qreal inlineObjectDescent() const;
0089 
0090     /// reimplemented from KoInlineObject - should not do anything
0091     bool loadOdf(const KoXmlElement &, KoShapeLoadingContext &) override;
0092 
0093     /// reimplemented from KoInlineObject
0094     void saveOdf(KoShapeSavingContext &context) override;
0095 
0096 
0097 private:
0098     Q_DECLARE_PRIVATE(KoAnchorInlineObject)
0099 };
0100 
0101 #endif