OLD | NEW |
| (Empty) |
1 // Copyright 2016 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ | |
8 #define CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ | |
9 | |
10 #include <map> | |
11 #include <memory> | |
12 | |
13 #include "core/fxcrt/include/fx_coordinates.h" | |
14 #include "core/fxcrt/include/fx_string.h" | |
15 #include "core/fxcrt/include/fx_system.h" | |
16 | |
17 class CFX_RenderDevice; | |
18 class CPDF_Dictionary; | |
19 class CPDF_Document; | |
20 class CPDF_Form; | |
21 class CPDF_Page; | |
22 class CPDF_RenderContext; | |
23 class CPDF_RenderOptions; | |
24 class CPDF_Stream; | |
25 | |
26 #define ANNOTFLAG_INVISIBLE 0x0001 | |
27 #define ANNOTFLAG_HIDDEN 0x0002 | |
28 #define ANNOTFLAG_PRINT 0x0004 | |
29 #define ANNOTFLAG_NOZOOM 0x0008 | |
30 #define ANNOTFLAG_NOROTATE 0x0010 | |
31 #define ANNOTFLAG_NOVIEW 0x0020 | |
32 #define ANNOTFLAG_READONLY 0x0040 | |
33 #define ANNOTFLAG_LOCKED 0x0080 | |
34 #define ANNOTFLAG_TOGGLENOVIEW 0x0100 | |
35 | |
36 class CPDF_Annot { | |
37 public: | |
38 enum AppearanceMode { Normal, Rollover, Down }; | |
39 enum class Subtype { | |
40 UNKNOWN = 0, | |
41 TEXT, | |
42 LINK, | |
43 FREETEXT, | |
44 LINE, | |
45 SQUARE, | |
46 CIRCLE, | |
47 POLYGON, | |
48 POLYLINE, | |
49 HIGHLIGHT, | |
50 UNDERLINE, | |
51 SQUIGGLY, | |
52 STRIKEOUT, | |
53 STAMP, | |
54 CARET, | |
55 INK, | |
56 POPUP, | |
57 FILEATTACHMENT, | |
58 SOUND, | |
59 MOVIE, | |
60 WIDGET, | |
61 SCREEN, | |
62 PRINTERMARK, | |
63 TRAPNET, | |
64 WATERMARK, | |
65 THREED, | |
66 RICHMEDIA, | |
67 XFAWIDGET | |
68 }; | |
69 | |
70 static bool IsAnnotationHidden(CPDF_Dictionary* pAnnotDict); | |
71 static CPDF_Annot::Subtype StringToAnnotSubtype( | |
72 const CFX_ByteString& sSubtype); | |
73 static CFX_ByteString AnnotSubtypeToString(CPDF_Annot::Subtype nSubtype); | |
74 static CFX_FloatRect RectFromQuadPoints(CPDF_Dictionary* pAnnotDict); | |
75 | |
76 CPDF_Annot(CPDF_Dictionary* pDict, CPDF_Document* pDocument, bool bToOwnDict); | |
77 ~CPDF_Annot(); | |
78 | |
79 CPDF_Annot::Subtype GetSubtype() const; | |
80 uint32_t GetFlags() const; | |
81 CFX_FloatRect GetRect() const; | |
82 const CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict; } | |
83 CPDF_Dictionary* GetAnnotDict() { return m_pAnnotDict; } | |
84 CPDF_Document* GetDocument() const { return m_pDocument; } | |
85 | |
86 FX_BOOL DrawAppearance(CPDF_Page* pPage, | |
87 CFX_RenderDevice* pDevice, | |
88 const CFX_Matrix* pUser2Device, | |
89 AppearanceMode mode, | |
90 const CPDF_RenderOptions* pOptions); | |
91 FX_BOOL DrawInContext(const CPDF_Page* pPage, | |
92 CPDF_RenderContext* pContext, | |
93 const CFX_Matrix* pUser2Device, | |
94 AppearanceMode mode); | |
95 | |
96 void ClearCachedAP(); | |
97 void DrawBorder(CFX_RenderDevice* pDevice, | |
98 const CFX_Matrix* pUser2Device, | |
99 const CPDF_RenderOptions* pOptions); | |
100 CPDF_Form* GetAPForm(const CPDF_Page* pPage, AppearanceMode mode); | |
101 void SetOpenState(bool bOpenState) { m_bOpenState = bOpenState; } | |
102 CPDF_Annot* GetPopupAnnot() const { return m_pPopupAnnot; } | |
103 void SetPopupAnnot(CPDF_Annot* pAnnot) { m_pPopupAnnot = pAnnot; } | |
104 | |
105 private: | |
106 void GenerateAPIfNeeded(); | |
107 bool ShouldDrawAnnotation(); | |
108 | |
109 CFX_FloatRect RectForDrawing() const; | |
110 | |
111 // For regular annotations, |m_pAnnotDict| is not owned. For | |
112 // our artificially created popup annotations, |m_pAnnotDict| | |
113 // is owned by this class. | |
114 bool m_bOwnedAnnotDict; | |
115 CPDF_Dictionary* m_pAnnotDict; | |
116 CPDF_Document* const m_pDocument; | |
117 CPDF_Annot::Subtype m_nSubtype; | |
118 std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap; | |
119 // |m_bOpenState| is only set for popup annotations. | |
120 bool m_bOpenState; | |
121 bool m_bHasGeneratedAP; | |
122 bool m_bIsTextMarkupAnnotation; | |
123 // Not owned. If there is a valid pointer in |m_pPopupAnnot|, | |
124 // then this annot is never a popup. | |
125 CPDF_Annot* m_pPopupAnnot; | |
126 }; | |
127 | |
128 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, | |
129 CPDF_Annot::AppearanceMode mode); | |
130 | |
131 #endif // CORE_FPDFDOC_INCLUDE_CPDF_ANNOT_H_ | |
OLD | NEW |