Debian Codegraph @

qt6/src/poppler-annotation-private.h

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