Warning, file /office/calligra/libs/text/KoInlineNote.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 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 KOINLINENOTE_H
0020 #define KOINLINENOTE_H
0021 
0022 #include "KoInlineObject.h"
0023 #include "kotext_export.h"
0024 
0025 class QTextFrame;
0026 
0027 /**
0028  * This object is an inline object, which means it is anchored in the text-flow and it can hold note info.
0029  * Typical notes that use this are Footnotes, Endnotes and Annotations (also known as comments).
0030  */
0031 class KOTEXT_EXPORT KoInlineNote : public KoInlineObject
0032 {
0033     Q_OBJECT
0034 public:
0035     /// The type of note specifies how the application will use the text from the note.
0036     enum Type {
0037         Footnote,      ///< Notes of this type will have their text placed at the bottom of a shape.
0038         Endnote,       ///< Notes of this type are used as endnotes in applications that support it.
0039         Annotation     ///< Notes of this type will have their text placed in the document margin.
0040     };
0041 
0042     /**
0043      * Construct a new note to be inserted in the text using KoTextEditor::insertInlineObject() for example.
0044      * @param type the type of note, which specifies how the application will use the text from the new note.
0045      */
0046     explicit KoInlineNote(Type type);
0047     // destructor
0048     ~KoInlineNote() override;
0049 
0050     /**
0051      * Set the textframe where we will create our own textframe within
0052      * Our textframe is the one containing the real note contents.
0053      * @param text the new text
0054      */
0055     void setMotherFrame(QTextFrame *text);
0056 
0057     /**
0058      * Set the label that is shown at the spot this inline note is inserted.
0059      * @param text the new label
0060      */
0061     void setLabel(const QString &text);
0062 
0063     /**
0064      * Indirectly set the label that is shown at the spot this inline note is inserted.
0065      * @param autoNumber the number that the label will portray. 0 should be the first
0066      */
0067     void setAutoNumber(int autoNumber);
0068 
0069     /// return the current text
0070     QTextFrame *textFrame() const;
0071 
0072     /// return the current label
0073     QString label() const;
0074 
0075     /**
0076      * @return whether the label should be automatically recreated or if the label is static.
0077      */
0078     bool autoNumbering() const;
0079 
0080     /**
0081      * Set whether the label should be automatically recreated.
0082      * @param on if true then changes in footnote-ordering will recalcualte the label.
0083      */
0084     void setAutoNumbering(bool on);
0085 
0086     /// return the type of note.
0087     Type type() const;
0088 
0089     bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) override;
0090 
0091     ///reimplemented
0092     void saveOdf(KoShapeSavingContext &context) override;
0093 
0094     int getPosInDocument() const;
0095 
0096 protected:
0097     /// reimplemented
0098     void updatePosition(const QTextDocument *document,
0099                                 int posInDocument, const QTextCharFormat &format) override;
0100     /// reimplemented
0101     void resize(const QTextDocument *document, QTextInlineObject &object,
0102                         int posInDocument, const QTextCharFormat &format, QPaintDevice *pd) override;
0103     /// reimplemented
0104     void paint(QPainter &painter, QPaintDevice *pd, const QTextDocument *document,
0105                        const QRectF &rect, const QTextInlineObject &object, int posInDocument, const QTextCharFormat &format) override;
0106 
0107 private:
0108     friend class InsertNoteCommand;
0109 
0110     // only to be used on subsequent redo of insertion
0111     void setTextFrame(QTextFrame *textFrame);
0112 
0113     class Private;
0114     Private * const d;
0115 };
0116 
0117 #endif