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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
/* This file is part of the KDE project
* Copyright (C) 2007 Thomas Zander <zander@kde.org>
*
* 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 KOINLINENOTE_H
#define KOINLINENOTE_H
#include "KoInlineObject.h"
#include "kotext_export.h"
class QTextFrame;
/**
* This object is an inline object, which means it is anchored in the text-flow and it can hold note info.
* Typical notes that use this are Footnotes, Endnotes and Annotations (also known as comments).
*/
class KOTEXT_EXPORT KoInlineNote : public KoInlineObject
{
Q_OBJECT
public:
/// The type of note specifies how the application will use the text from the note.
enum Type {
Footnote, ///< Notes of this type will have their text placed at the bottom of a shape.
Endnote, ///< Notes of this type are used as endnotes in applications that support it.
Annotation ///< Notes of this type will have their text placed in the document margin.
};
/**
* Construct a new note to be inserted in the text using KoTextEditor::insertInlineObject() for example.
* @param type the type of note, which specifies how the application will use the text from the new note.
*/
explicit KoInlineNote(Type type);
// destructor
~KoInlineNote() override;
/**
* Set the textframe where we will create our own textframe within
* Our textframe is the one containing the real note contents.
* @param text the new text
*/
void setMotherFrame(QTextFrame *text);
/**
* Set the label that is shown at the spot this inline note is inserted.
* @param text the new label
*/
void setLabel(const QString &text);
/**
* Indirectly set the label that is shown at the spot this inline note is inserted.
* @param autoNumber the number that the label will portray. 0 should be the first
*/
void setAutoNumber(int autoNumber);
/// return the current text
QTextFrame *textFrame() const;
/// return the current label
QString label() const;
/**
* @return whether the label should be automatically recreated or if the label is static.
*/
bool autoNumbering() const;
/**
* Set whether the label should be automatically recreated.
* @param on if true then changes in footnote-ordering will recalcualte the label.
*/
void setAutoNumbering(bool on);
/// return the type of note.
Type type() const;
bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) override;
///reimplemented
void saveOdf(KoShapeSavingContext &context) override;
int getPosInDocument() const;
protected:
/// reimplemented
void updatePosition(const QTextDocument *document,
int posInDocument, const QTextCharFormat &format) override;
/// reimplemented
void resize(const QTextDocument *document, QTextInlineObject &object,
int posInDocument, const QTextCharFormat &format, QPaintDevice *pd) override;
/// reimplemented
void paint(QPainter &painter, QPaintDevice *pd, const QTextDocument *document,
const QRectF &rect, const QTextInlineObject &object, int posInDocument, const QTextCharFormat &format) override;
private:
friend class InsertNoteCommand;
// only to be used on subsequent redo of insertion
void setTextFrame(QTextFrame *textFrame);
class Private;
Private * const d;
};
#endif
|