| 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, 2019, 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, Mahmoud Ahmed Khalil <[email protected]> |
| 8 |
* Copyright (C) 2024, 2025, g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]> |
| 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 <QtCore/QLinkedList> |
| 29 |
#include <QtCore/QPointF> |
| 30 |
#include <QtCore/QSharedDataPointer> |
| 31 |
|
| 32 |
#include "poppler-annotation.h" |
| 33 |
|
| 34 |
#include <Object.h> |
| 35 |
#include <AnnotStampImageHelper.h> |
| 36 |
|
| 37 |
class Annot; |
| 38 |
class AnnotPath; |
| 39 |
class Page; |
| 40 |
class PDFRectangle; |
| 41 |
|
| 42 |
namespace Poppler { |
| 43 |
class DocumentData; |
| 44 |
|
| 45 |
PDFRectangle boundaryToPdfRectangle(::Page *pdfPage, const QRectF &r, int flags); |
| 46 |
void getRawDataFromQImage(const QImage &qimg, int bitsPerPixel, QByteArray *data, QByteArray *sMaskData); |
| 47 |
|
| 48 |
class AnnotationPrivate : public QSharedData |
| 49 |
{ |
| 50 |
public: |
| 51 |
AnnotationPrivate(); |
| 52 |
virtual ~AnnotationPrivate(); |
| 53 |
|
| 54 |
AnnotationPrivate(const AnnotationPrivate &) = delete; |
| 55 |
AnnotationPrivate &operator=(const AnnotationPrivate &) = delete; |
| 56 |
|
| 57 |
void addRevision(Annotation *ann, Annotation::RevScope scope, Annotation::RevType type); |
| 58 |
|
| 59 |
/* Returns an Annotation of the right subclass whose d_ptr points to |
| 60 |
* this AnnotationPrivate */ |
| 61 |
virtual std::unique_ptr<Annotation> makeAlias() = 0; |
| 62 |
|
| 63 |
/* properties: contents related */ |
| 64 |
QString author; |
| 65 |
QString contents; |
| 66 |
QString uniqueName; |
| 67 |
QDateTime modDate; // before or equal to currentDateTime() |
| 68 |
QDateTime creationDate; // before or equal to modifyDate |
| 69 |
|
| 70 |
/* properties: look/interaction related */ |
| 71 |
int flags; |
| 72 |
QRectF boundary; |
| 73 |
|
| 74 |
/* style and popup */ |
| 75 |
Annotation::Style style; |
| 76 |
Annotation::Popup popup; |
| 77 |
|
| 78 |
/* revisions */ |
| 79 |
Annotation::RevScope revisionScope; |
| 80 |
Annotation::RevType revisionType; |
| 81 |
std::vector<std::unique_ptr<Annotation>> revisions; |
| 82 |
|
| 83 |
/* After this call, the Annotation object will behave like a wrapper for |
| 84 |
* the specified Annot object. All cached values are discarded */ |
| 85 |
void tieToNativeAnnot(std::shared_ptr<Annot> ann, ::Page *page, DocumentData *doc); |
| 86 |
|
| 87 |
/* Creates a new Annot object on the specified page, flushes current |
| 88 |
* values to that object and ties this Annotation to that object */ |
| 89 |
virtual std::shared_ptr<Annot> createNativeAnnot(::Page *destPage, DocumentData *doc) = 0; |
| 90 |
|
| 91 |
/* Inited to 0 (i.e. untied annotation) */ |
| 92 |
std::shared_ptr<Annot> pdfAnnot; |
| 93 |
::Page *pdfPage; |
| 94 |
DocumentData *parentDoc; |
| 95 |
|
| 96 |
/* The following helpers only work if pdfPage is set */ |
| 97 |
void flushBaseAnnotationProperties(); |
| 98 |
void fillTransformationMTX(double MTX[6]) const; |
| 99 |
QRectF fromPdfRectangle(const PDFRectangle &r) const; |
| 100 |
PDFRectangle boundaryToPdfRectangle(const QRectF &r, int flags) const; |
| 101 |
std::unique_ptr<AnnotPath> toAnnotPath(const QLinkedList<QPointF> &l) const; |
| 102 |
|
| 103 |
/* Scan page for annotations, parentId=0 searches for root annotations, subtypes empty means all subtypes */ |
| 104 |
static QList<Annotation *> findAnnotations(::Page *pdfPage, DocumentData *doc, const QSet<Annotation::SubType> &subtypes, int parentId = -1); |
| 105 |
|
| 106 |
/* Add given annotation to given page */ |
| 107 |
static void addAnnotationToPage(::Page *pdfPage, DocumentData *doc, const Annotation *ann); |
| 108 |
|
| 109 |
/* Remove annotation from page and destroy ann */ |
| 110 |
static void removeAnnotationFromPage(::Page *pdfPage, const Annotation *ann); |
| 111 |
|
| 112 |
Ref pdfObjectReference() const; |
| 113 |
|
| 114 |
Link *additionalAction(Annotation::AdditionalActionType type) const; |
| 115 |
|
| 116 |
Object annotationAppearance; |
| 117 |
}; |
| 118 |
|
| 119 |
class AnnotationAppearancePrivate |
| 120 |
{ |
| 121 |
public: |
| 122 |
explicit AnnotationAppearancePrivate(Annot *annot); |
| 123 |
|
| 124 |
Object appearance; |
| 125 |
}; |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
#endif |