PoDoFo 1.0.0-dev
Loading...
Searching...
No Matches
PdfAnnotationActionBase.h
1
7#ifndef PDF_ANNOTATION_ACTION_BASE_H
8#define PDF_ANNOTATION_ACTION_BASE_H
9
10#include "PdfAnnotation.h"
11#include "PdfAction.h"
12#include "PdfDictionary.h"
13
14namespace PoDoFo {
15
16 class PODOFO_API PdfAppearanceCharacteristics final : public PdfDictionaryElement
17 {
18 template<typename T>
19 friend class PdfAppearanceCharacteristicsProvider;
20
21 private:
22 PdfAppearanceCharacteristics(PdfDocument& parent);
23 PdfAppearanceCharacteristics(PdfObject& obj);
24
25 public:
26 void SetBorderColor(nullable<const PdfColor&> color);
27
28 PdfColor GetBorderColor() const;
29
30 void SetBackgroundColor(nullable<const PdfColor&> color);
31
32 PdfColor GetBackgroundColor() const;
33
34 void SetRolloverCaption(nullable<const PdfString&> text);
35
36 nullable<const PdfString&> GetRolloverCaption() const;
37
38 void SetAlternateCaption(nullable<const PdfString&> text);
39
40 nullable<const PdfString&> GetAlternateCaption() const;
41
42 void SetCaption(nullable<const PdfString&> text);
43
44 nullable<const PdfString&> GetCaption() const;
45 };
46
47 template <typename T>
48 class PdfAppearanceCharacteristicsProvider
49 {
50 friend class PdfAnnotationWidget;
51 friend class PdfAnnotationScreen;
52
53 public:
54 PdfAppearanceCharacteristicsProvider()
55 {
56 auto& dict = static_cast<T&>(*this).GetDictionary();
57 auto mkObj = dict.FindKey("MK");
58 if (mkObj != nullptr)
59 m_AppearanceCharacteristics.reset(new PdfAppearanceCharacteristics(*mkObj));
60 }
61
62 public:
63 PdfAppearanceCharacteristics& GetOrCreateAppearanceCharacteristics()
64 {
65 if (m_AppearanceCharacteristics == nullptr)
66 {
67 auto& ref = static_cast<T&>(*this);
68 m_AppearanceCharacteristics.reset(new PdfAppearanceCharacteristics(ref.GetDocument()));
69 ref.GetDictionary().AddKeyIndirect("MK"_n, m_AppearanceCharacteristics->GetObject());
70 }
71
72 return *m_AppearanceCharacteristics;
73 }
74
75 PdfAppearanceCharacteristics* GetAppearanceCharacteristics()
76 {
77 return m_AppearanceCharacteristics.get();
78 }
79
80 const PdfAppearanceCharacteristics* GetAppearanceCharacteristics() const
81 {
82 return m_AppearanceCharacteristics.get();
83 }
84
85 private:
86 std::unique_ptr<PdfAppearanceCharacteristics> m_AppearanceCharacteristics;
87 };
88
89 class PODOFO_API PdfAnnotationActionBase : public PdfAnnotation
90 {
91 friend class PdfAnnotationWidget;
92 friend class PdfAnnotationLink;
93 friend class PdfAnnotationScreen;
94
95 private:
96 PdfAnnotationActionBase(PdfPage& page, PdfAnnotationType annotType, const Rect& rect);
97 PdfAnnotationActionBase(PdfObject& obj, PdfAnnotationType annotType);
98
99 public:
105 void SetAction(nullable<const PdfAction&> action);
106
113 nullable<PdfAction&> GetAction();
114 nullable<const PdfAction&> GetAction() const;
115
116 protected:
117 virtual void onActionSet();
118 void ResetAction();
119
120 private:
121 nullable<PdfAction&> getAction();
122
123 private:
124 nullable<std::unique_ptr<PdfAction>> m_Action;
125 };
126}
127
128#endif // PDF_ANNOTATION_ACTION_BASE_H
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition basetypes.h:16