1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "fpdfsdk/cpdfsdk_baannothandler.h"
#include <memory>
#include <vector>
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfdoc/cpdf_interform.h"
#include "fpdfsdk/cpdfsdk_annot.h"
#include "fpdfsdk/cpdfsdk_baannot.h"
#include "fpdfsdk/cpdfsdk_pageview.h"
#include "fpdfsdk/formfiller/cffl_formfiller.h"
#ifdef PDF_ENABLE_XFA
#include "fpdfsdk/fpdfxfa/fpdfxfa_doc.h"
#endif // PDF_ENABLE_XFA
namespace {
void UpdateAnnotRects(CPDFSDK_PageView* pPageView, CPDFSDK_BAAnnot* pBAAnnot) {
std::vector<CFX_FloatRect> rects;
rects.push_back(pBAAnnot->GetRect());
if (CPDF_Annot* pPopupAnnot = pBAAnnot->GetPDFPopupAnnot())
rects.push_back(pPopupAnnot->GetRect());
pPageView->UpdateRects(rects);
}
} // namespace
CPDFSDK_BAAnnotHandler::CPDFSDK_BAAnnotHandler() {}
CPDFSDK_BAAnnotHandler::~CPDFSDK_BAAnnotHandler() {}
FX_BOOL CPDFSDK_BAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
return FALSE;
}
CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CPDF_Annot* pAnnot,
CPDFSDK_PageView* pPage) {
return new CPDFSDK_BAAnnot(pAnnot, pPage);
}
#ifdef PDF_ENABLE_XFA
CPDFSDK_Annot* CPDFSDK_BAAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget,
CPDFSDK_PageView* pPage) {
return nullptr;
}
#endif // PDF_ENABLE_XFA
void CPDFSDK_BAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) {
delete pAnnot;
}
void CPDFSDK_BAAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {}
void CPDFSDK_BAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
bool bDrawAnnots) {
#ifdef PDF_ENABLE_XFA
if (pAnnot->IsXFAField())
return;
#endif // PDF_ENABLE_XFA
if (bDrawAnnots && pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP) {
static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance(
pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
}
}
void CPDFSDK_BAAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {}
void CPDFSDK_BAAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {}
void CPDFSDK_BAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot->Get());
pBAAnnot->SetOpenState(true);
UpdateAnnotRects(pPageView, pBAAnnot);
}
void CPDFSDK_BAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
CPDFSDK_BAAnnot* pBAAnnot = static_cast<CPDFSDK_BAAnnot*>(pAnnot->Get());
pBAAnnot->SetOpenState(false);
UpdateAnnotRects(pPageView, pBAAnnot);
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDown(
CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_FloatPoint& point) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_FloatPoint& point) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnLButtonDblClk(
CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_FloatPoint& point) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_FloatPoint& point) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
short zDelta,
const CFX_FloatPoint& point) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDown(
CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_FloatPoint& point) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_FloatPoint& point) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnRButtonDblClk(
CPDFSDK_PageView* pPageView,
CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlags,
const CFX_FloatPoint& point) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot,
uint32_t nChar,
uint32_t nFlags) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
int nKeyCode,
int nFlag) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
int nKeyCode,
int nFlag) {
return FALSE;
}
void CPDFSDK_BAAnnotHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {}
void CPDFSDK_BAAnnotHandler::OnSelected(CPDFSDK_Annot* pAnnot) {}
void CPDFSDK_BAAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {}
void CPDFSDK_BAAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {}
FX_BOOL CPDFSDK_BAAnnotHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
return FALSE;
}
FX_BOOL CPDFSDK_BAAnnotHandler::OnKillFocus(CPDFSDK_Annot::ObservedPtr* pAnnot,
uint32_t nFlag) {
return FALSE;
}
#ifdef PDF_ENABLE_XFA
FX_BOOL CPDFSDK_BAAnnotHandler::OnXFAChangedFocus(
CPDFSDK_Annot::ObservedPtr* pOldAnnot,
CPDFSDK_Annot::ObservedPtr* pNewAnnot) {
return TRUE;
}
#endif // PDF_ENABLE_XFA
CFX_FloatRect CPDFSDK_BAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot) {
return pAnnot->GetRect();
}
FX_BOOL CPDFSDK_BAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot,
const CFX_FloatPoint& point) {
ASSERT(pPageView);
ASSERT(pAnnot);
CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot);
return rect.Contains(point.x, point.y);
}
|