PoDoFo 1.2.0
Loading...
Searching...
No Matches
PdfAnnotation_Types.h
1// SPDX-FileCopyrightText: 2022 Francesco Pretto <ceztko@gmail.com>
2// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
3
4#ifndef PDF_ANNOTATION_TYPES_H
5#define PDF_ANNOTATION_TYPES_H
6
7#include "PdfAnnotationActionBase.h"
8#include "PdfFileSpec.h"
9#include "PdfDestination.h"
10#include "PdfDictionary.h"
11
12namespace PoDoFo {
13
14 template <typename T>
15 class PdfQuadPointsProvider
16 {
17 friend class PdfAnnotationLink;
18 friend class PdfAnnotationTextMarkupBase;
19 friend class PdfAnnotationRedact;
20
21 public:
31 nullable<const PdfArray&> GetQuadPoints() const
32 {
33 auto& dict = static_cast<const T&>(*this).GetDictionary();
34 const PdfArray* arr;
35 auto obj = dict.FindKey("QuadPoints");
36 if (obj == nullptr || !obj->TryGetArray(arr))
37 return { };
38
39 return *arr;
40 }
41
50 void SetQuadPoints(nullable<const PdfArray&> quadPoints)
51 {
52 auto& dict = static_cast<T&>(*this).GetDictionary();
53 if (quadPoints == nullptr)
54 dict.RemoveKey("QuadPoints");
55 else
56 dict.AddKey("QuadPoints"_n, *quadPoints);
57 }
58 };
59
60 class PODOFO_API PdfAnnotationTextMarkupBase : public PdfAnnotation, public PdfQuadPointsProvider<PdfAnnotationTextMarkupBase>
61 {
62 friend class PdfAnnotationSquiggly;
63 friend class PdfAnnotationHighlight;
64 friend class PdfAnnotationStrikeOut;
65 friend class PdfAnnotationUnderline;
66 private:
67 PdfAnnotationTextMarkupBase(PdfPage& page, PdfAnnotationType annotType, const Rect& rect);
68 PdfAnnotationTextMarkupBase(PdfObject& obj, PdfAnnotationType annotType);
69
70 };
71
72 class PODOFO_API PdfAnnotationCaret final : public PdfAnnotation
73 {
74 friend class PdfAnnotation;
75 private:
76 PdfAnnotationCaret(PdfPage& page, const Rect& rect);
77 PdfAnnotationCaret(PdfObject& obj);
78 };
79
80
81 class PODOFO_API PdfAnnotationFileAttachment final : public PdfAnnotation
82 {
83 friend class PdfAnnotation;
84 private:
85 PdfAnnotationFileAttachment(PdfPage& page, const Rect& rect);
86 PdfAnnotationFileAttachment(PdfObject& obj);
87
88 public:
95 void SetFileAttachment(const nullable<PdfFileSpec&>& fileSpec);
96
102 nullable<PdfFileSpec&> GetFileAttachment();
103 nullable<const PdfFileSpec&> GetFileAttachment() const;
104
105 private:
106 nullable<PdfFileSpec&> getFileAttachment();
107
108 private:
109 nullable<std::unique_ptr<PdfFileSpec>> m_FileSpec;
110 };
111
112 class PODOFO_API PdfAnnotationFreeText final : public PdfAnnotation
113 {
114 friend class PdfAnnotation;
115 private:
116 PdfAnnotationFreeText(PdfPage& page, const Rect& rect);
117 PdfAnnotationFreeText(PdfObject& obj);
118 };
119
120 class PODOFO_API PdfAnnotationHighlight final : public PdfAnnotationTextMarkupBase
121 {
122 friend class PdfAnnotation;
123 private:
124 PdfAnnotationHighlight(PdfPage& page, const Rect& rect);
125 PdfAnnotationHighlight(PdfObject& obj);
126 };
127
128 class PODOFO_API PdfAnnotationInk final : public PdfAnnotation
129 {
130 friend class PdfAnnotation;
131 private:
132 PdfAnnotationInk(PdfPage& page, const Rect& rect);
133 PdfAnnotationInk(PdfObject& obj);
134 };
135
136 class PODOFO_API PdfAnnotationLine final : public PdfAnnotation
137 {
138 friend class PdfAnnotation;
139 private:
140 PdfAnnotationLine(PdfPage& page, const Rect& rect);
141 PdfAnnotationLine(PdfObject& obj);
142 };
143
144 class PODOFO_API PdfAnnotationLink final : public PdfAnnotationActionBase, public PdfQuadPointsProvider<PdfAnnotationLink>
145 {
146 friend class PdfAnnotation;
147 private:
148 PdfAnnotationLink(PdfPage& page, const Rect& rect);
149 PdfAnnotationLink(PdfObject& obj);
150 public:
155 void SetDestination(nullable<const PdfDestination&> destination);
156
161 nullable<PdfDestination&> GetDestination();
162 nullable<const PdfDestination&> GetDestination() const;
163
164 private:
165 nullable<PdfDestination&> getDestination();
166 void onActionSet() override;
167
168 private:
169 nullable<std::unique_ptr<PdfDestination>> m_Destination;
170 };
171
172 class PODOFO_API PdfAnnotationModel3D final : public PdfAnnotation
173 {
174 friend class PdfAnnotation;
175 private:
176 PdfAnnotationModel3D(PdfPage& page, const Rect& rect);
177 PdfAnnotationModel3D(PdfObject& obj);
178 };
179
180 class PODOFO_API PdfAnnotationMovie final : public PdfAnnotation
181 {
182 friend class PdfAnnotation;
183 private:
184 PdfAnnotationMovie(PdfPage& page, const Rect& rect);
185 PdfAnnotationMovie(PdfObject& obj);
186 };
187
188 class PODOFO_API PdfAnnotationPolygon final : public PdfAnnotation
189 {
190 friend class PdfAnnotation;
191 private:
192 PdfAnnotationPolygon(PdfPage& page, const Rect& rect);
193 PdfAnnotationPolygon(PdfObject& obj);
194 };
195
196 class PODOFO_API PdfAnnotationPolyLine final : public PdfAnnotation
197 {
198 friend class PdfAnnotation;
199 private:
200 PdfAnnotationPolyLine(PdfPage& page, const Rect& rect);
201 PdfAnnotationPolyLine(PdfObject& obj);
202 };
203
204 class PODOFO_API PdfAnnotationPopup final : public PdfAnnotation
205 {
206 friend class PdfAnnotation;
207 private:
208 PdfAnnotationPopup(PdfPage& page, const Rect& rect);
209 PdfAnnotationPopup(PdfObject& obj);
210 public:
214 void SetOpen(const nullable<bool>& value);
215
218 bool GetOpen() const;
219 };
220
221 class PODOFO_API PdfAnnotationPrinterMark final : public PdfAnnotation
222 {
223 friend class PdfAnnotation;
224 private:
225 PdfAnnotationPrinterMark(PdfPage& page, const Rect& rect);
226 PdfAnnotationPrinterMark(PdfObject& obj);
227 };
228
229 class PODOFO_API PdfAnnotationScreen final :
230 public PdfAnnotationActionBase,
231 public PdfAppearanceCharacteristicsProvider<PdfAnnotationScreen>
232 {
233 friend class PdfAnnotation;
234 private:
235 PdfAnnotationScreen(PdfPage& page, const Rect& rect);
236 PdfAnnotationScreen(PdfObject& obj);
237 };
238
239 class PODOFO_API PdfAnnotationSquiggly final : public PdfAnnotationTextMarkupBase
240 {
241 friend class PdfAnnotation;
242 private:
243 PdfAnnotationSquiggly(PdfPage& page, const Rect& rect);
244 PdfAnnotationSquiggly(PdfObject& obj);
245
246 };
247
248 class PODOFO_API PdfAnnotationStrikeOut final : public PdfAnnotationTextMarkupBase
249 {
250 friend class PdfAnnotation;
251 private:
252 PdfAnnotationStrikeOut(PdfPage& page, const Rect& rect);
253 PdfAnnotationStrikeOut(PdfObject& obj);
254 };
255
256 class PODOFO_API PdfAnnotationSound final : public PdfAnnotation
257 {
258 friend class PdfAnnotation;
259 private:
260 PdfAnnotationSound(PdfPage& page, const Rect& rect);
261 PdfAnnotationSound(PdfObject& obj);
262 };
263
264 class PODOFO_API PdfAnnotationSquare final : public PdfAnnotation
265 {
266 friend class PdfAnnotation;
267 private:
268 PdfAnnotationSquare(PdfPage& page, const Rect& rect);
269 PdfAnnotationSquare(PdfObject& obj);
270 };
271
272 class PODOFO_API PdfAnnotationCircle final : public PdfAnnotation
273 {
274 friend class PdfAnnotation;
275 private:
276 PdfAnnotationCircle(PdfPage& page, const Rect& rect);
277 PdfAnnotationCircle(PdfObject& obj);
278 };
279
280 class PODOFO_API PdfAnnotationStamp final : public PdfAnnotation
281 {
282 friend class PdfAnnotation;
283 private:
284 PdfAnnotationStamp(PdfPage& page, const Rect& rect);
285 PdfAnnotationStamp(PdfObject& obj);
286 };
287
288 class PODOFO_API PdfAnnotationText final : public PdfAnnotation
289 {
290 friend class PdfAnnotation;
291 private:
292 PdfAnnotationText(PdfPage& page, const Rect& rect);
293 PdfAnnotationText(PdfObject& obj);
294 public:
298 void SetOpen(const nullable<bool>& value);
299
302 bool GetOpen() const;
303 };
304
305 class PODOFO_API PdfAnnotationTrapNet final : public PdfAnnotation
306 {
307 friend class PdfAnnotation;
308 private:
309 PdfAnnotationTrapNet(PdfPage& page, const Rect& rect);
310 PdfAnnotationTrapNet(PdfObject& obj);
311 };
312
313 class PODOFO_API PdfAnnotationUnderline final : public PdfAnnotationTextMarkupBase
314 {
315 friend class PdfAnnotation;
316 private:
317 PdfAnnotationUnderline(PdfPage& page, const Rect& rect);
318 PdfAnnotationUnderline(PdfObject& obj);
319
320 };
321
322 class PODOFO_API PdfAnnotationWatermark final : public PdfAnnotation
323 {
324 friend class PdfAnnotation;
325 private:
326 PdfAnnotationWatermark(PdfPage& page, const Rect& rect);
327 PdfAnnotationWatermark(PdfObject& obj);
328 };
329
330 class PODOFO_API PdfAnnotationWebMedia final : public PdfAnnotation
331 {
332 friend class PdfAnnotation;
333 private:
334 PdfAnnotationWebMedia(PdfPage& page, const Rect& rect);
335 PdfAnnotationWebMedia(PdfObject& obj);
336 };
337
338 class PODOFO_API PdfAnnotationRedact final : public PdfAnnotation, public PdfQuadPointsProvider<PdfAnnotationRedact>
339 {
340 friend class PdfAnnotation;
341 private:
342 PdfAnnotationRedact(PdfPage& page, const Rect& rect);
343 PdfAnnotationRedact(PdfObject& obj);
344 };
345
346 class PODOFO_API PdfAnnotationProjection final : public PdfAnnotation
347 {
348 friend class PdfAnnotation;
349 private:
350 PdfAnnotationProjection(PdfPage& page, const Rect& rect);
351 PdfAnnotationProjection(PdfObject& obj);
352 };
353
354 class PODOFO_API PdfAnnotationRichMedia final : public PdfAnnotation
355 {
356 friend class PdfAnnotation;
357 private:
358 PdfAnnotationRichMedia(PdfPage& page, const Rect& rect);
359 PdfAnnotationRichMedia(PdfObject& obj);
360 };
361}
362
363#endif // PDF_ANNOTATION_TYPES_H
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13