1/* poppler-annotation-private.h: qt interface to poppler
2 * Copyright (C) 2007, Pino Toscano <pino@kde.org>
3 * Copyright (C) 2012, Tobias Koenig <tokoe@kdab.com>
4 * Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it>
5 * Copyright (C) 2012, 2014, 2018-2020, Albert Astals Cid <aacid@kde.org>
6 * Copyright (C) 2020, Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by Technische Universität Dresden
7 * Copyright (C) 2021, Oliver Sander <oliver.sander@tu-dresden.de>
8 * Copyright (C) 2021, Mahmoud Ahmed Khalil <mahmoudkhalil11@gmail.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24
25#ifndef _POPPLER_ANNOTATION_PRIVATE_H_
26#define _POPPLER_ANNOTATION_PRIVATE_H_
27
28#include <memory>
29
30#include <QtCore/QPointF>
31#include <QtCore/QSharedDataPointer>
32
33#include "poppler-annotation.h"
34
35#include <Object.h>
36#include <AnnotStampImageHelper.h>
37
38class Annot;
39class AnnotPath;
40class Page;
41class PDFRectangle;
42
43namespace Poppler {
44class DocumentData;
45
46PDFRectangle boundaryToPdfRectangle(::Page *pdfPage, const QRectF &r, int flags);
47void getRawDataFromQImage(const QImage &qimg, int bitsPerPixel, QByteArray *data, QByteArray *sMaskData);
48
49class AnnotationPrivate : public QSharedData
50{
51public:
52 AnnotationPrivate();
53 virtual ~AnnotationPrivate();
54
55 AnnotationPrivate(const AnnotationPrivate &) = delete;
56 AnnotationPrivate &operator=(const AnnotationPrivate &) = delete;
57
58 void addRevision(Annotation *ann, Annotation::RevScope scope, Annotation::RevType type);
59
60 /* Returns an Annotation of the right subclass whose d_ptr points to
61 * this AnnotationPrivate */
62 virtual Annotation *makeAlias() = 0;
63
64 /* properties: contents related */
65 QString author;
66 QString contents;
67 QString uniqueName;
68 QDateTime modDate; // before or equal to currentDateTime()
69 QDateTime creationDate; // before or equal to modifyDate
70
71 /* properties: look/interaction related */
72 Annotation::Flags flags;
73 QRectF boundary;
74
75 /* style and popup */
76 Annotation::Style style;
77 Annotation::Popup popup;
78
79 /* revisions */
80 Annotation::RevScope revisionScope;
81 Annotation::RevType revisionType;
82 QList<Annotation *> revisions;
83
84 /* After this call, the Annotation object will behave like a wrapper for
85 * the specified Annot object. All cached values are discarded */
86 void tieToNativeAnnot(Annot *ann, ::Page *page, DocumentData *doc);
87
88 /* Creates a new Annot object on the specified page, flushes current
89 * values to that object and ties this Annotation to that object */
90 virtual Annot *createNativeAnnot(::Page *destPage, DocumentData *doc) = 0;
91
92 /* Inited to 0 (i.e. untied annotation) */
93 Annot *pdfAnnot;
94 ::Page *pdfPage;
95 DocumentData *parentDoc;
96
97 /* The following helpers only work if pdfPage is set */
98 void flushBaseAnnotationProperties();
99 void fillTransformationMTX(double MTX[6]) const;
100 QRectF fromPdfRectangle(const PDFRectangle &r) const;
101 PDFRectangle boundaryToPdfRectangle(const QRectF &r, int flags) const;
102 AnnotPath *toAnnotPath(const QVector<QPointF> &l) const;
103
104 /* Scan page for annotations, parentId=0 searches for root annotations, subtypes empty means all subtypes */
105 static std::vector<std::unique_ptr<Annotation>> findAnnotations(::Page *pdfPage, DocumentData *doc, const QSet<Annotation::SubType> &subtypes, int parentId = -1);
106
107 /* Add given annotation to given page */
108 static void addAnnotationToPage(::Page *pdfPage, DocumentData *doc, const Annotation *ann);
109
110 /* Remove annotation from page and destroy ann */
111 static void removeAnnotationFromPage(::Page *pdfPage, const Annotation *ann);
112
113 Ref pdfObjectReference() const;
114
115 std::unique_ptr<Link> additionalAction(Annotation::AdditionalActionType type) const;
116
117 Object annotationAppearance;
118};
119
120class AnnotationAppearancePrivate
121{
122public:
123 explicit AnnotationAppearancePrivate(Annot *annot);
124
125 Object appearance;
126};
127
128}
129
130#endif
131

source code of poppler/qt6/src/poppler-annotation-private.h