File indexing completed on 2024-05-12 16:34:57

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2013 Mojtaba Shahi Senobari <mojtaba.shahi3000@gmail.com>
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 
0020 #ifndef ANNOTATIONTEXTSHAPE_H
0021 #define ANNOTATIONTEXTSHAPE_H
0022 
0023 #include "TextShape.h"
0024 #include <KoShapeContainer.h>
0025 #include <KoTextShapeData.h>
0026 
0027 #include <QTextDocument>
0028 #include <QPainter>
0029 
0030 class KoInlineTextObjectManager;
0031 class KoTextRangeManager;
0032 
0033 #define AnnotationShape_SHAPEID "AnnotationTextShapeID"
0034 
0035 class AnnotationTextShape : public TextShape
0036 {
0037 public:
0038     // Some constants
0039     static const qreal  HeaderSpace; // The space needed for the annotation header.
0040     static const qreal  HeaderFontSize;
0041 
0042     // For now we should give these parameters for TextShape.
0043     AnnotationTextShape(KoInlineTextObjectManager *inlineTextObjectManager,
0044                         KoTextRangeManager *textRangeManager);
0045     ~AnnotationTextShape() override;
0046 
0047     void setAnnotationTextData(KoTextShapeData *textShape);
0048 
0049     // reimplemented
0050     void paintComponent(QPainter &painter, const KoViewConverter &converter,
0051                         KoShapePaintingContext &paintcontext) override;
0052 
0053     /**
0054      * From KoShape reimplemented method to load the TextShape from ODF.
0055      *
0056      * This method redirects the call to the KoTextShapeData::loadOdf() method which
0057      * in turn will call the KoTextLoader::loadBody() method that reads the element
0058      * into a QTextCursor.
0059      *
0060      * @param element element which represents the shape in odf.
0061      * @param context the KoShapeLoadingContext used for loading.
0062      * @return false if loading failed.
0063      */
0064     bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) override;
0065 
0066     /**
0067      * From KoShape reimplemented method to store the TextShape data as ODF.
0068      *
0069      * @param context the KoShapeSavingContext used for saving.
0070      */
0071     void saveOdf(KoShapeSavingContext &context) const override;
0072 
0073     void setCreator(const QString &creator);
0074     QString creator() const;
0075     void setDate(const QString &date);
0076     QString date() const;
0077     void setDateString(const QString &date);
0078     QString dateString() const;
0079 
0080 private:
0081     KoTextShapeData *m_textShapeData;
0082 
0083     QString m_creator;
0084     QString m_date;
0085     QString m_dateString;       // another way of storing the date. Not sure when it is used.
0086 };
0087 
0088 #endif // ANNOTATIONTEXTSHAPE_H