OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/include/cpdfsdk_bfannothandler.h" | 7 #include "fpdfsdk/include/cpdfsdk_widgethandler.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
14 #include "core/fpdfdoc/include/cpdf_interform.h" | 14 #include "core/fpdfdoc/include/cpdf_interform.h" |
15 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 15 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
16 #include "fpdfsdk/include/cpdfsdk_annot.h" | 16 #include "fpdfsdk/include/cpdfsdk_annot.h" |
17 #include "fpdfsdk/include/cpdfsdk_interform.h" | 17 #include "fpdfsdk/include/cpdfsdk_interform.h" |
18 #include "fpdfsdk/include/cpdfsdk_widget.h" | 18 #include "fpdfsdk/include/cpdfsdk_widget.h" |
19 #include "fpdfsdk/include/fsdk_mgr.h" | 19 #include "fpdfsdk/include/fsdk_mgr.h" |
20 | 20 |
21 #ifdef PDF_ENABLE_XFA | 21 #ifdef PDF_ENABLE_XFA |
22 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 22 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
23 #endif // PDF_ENABLE_XFA | 23 #endif // PDF_ENABLE_XFA |
24 | 24 |
25 CPDFSDK_BFAnnotHandler::CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) | 25 CPDFSDK_WidgetHandler::CPDFSDK_WidgetHandler(CPDFDoc_Environment* pApp) |
26 : m_pApp(pApp), m_pFormFiller(nullptr) {} | 26 : m_pApp(pApp), m_pFormFiller(nullptr) {} |
27 | 27 |
28 CPDFSDK_BFAnnotHandler::~CPDFSDK_BFAnnotHandler() {} | 28 CPDFSDK_WidgetHandler::~CPDFSDK_WidgetHandler() {} |
29 | 29 |
30 CFX_ByteString CPDFSDK_BFAnnotHandler::GetType() { | 30 CFX_ByteString CPDFSDK_WidgetHandler::GetType() { |
31 return CFX_ByteString("Widget"); | 31 return CFX_ByteString("Widget"); |
32 } | 32 } |
33 | 33 |
34 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { | 34 FX_BOOL CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
35 ASSERT(pAnnot->GetAnnotSubtype() == "Widget"); | 35 ASSERT(pAnnot->GetAnnotSubtype() == "Widget"); |
36 if (pAnnot->IsSignatureWidget()) | 36 if (pAnnot->IsSignatureWidget()) |
37 return FALSE; | 37 return FALSE; |
38 | 38 |
39 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); | 39 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); |
40 if (!pWidget->IsVisible()) | 40 if (!pWidget->IsVisible()) |
41 return FALSE; | 41 return FALSE; |
42 | 42 |
43 int nFieldFlags = pWidget->GetFieldFlags(); | 43 int nFieldFlags = pWidget->GetFieldFlags(); |
44 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 44 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
45 return FALSE; | 45 return FALSE; |
46 | 46 |
47 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) | 47 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
48 return TRUE; | 48 return TRUE; |
49 | 49 |
50 CPDF_Page* pPage = pWidget->GetPDFPage(); | 50 CPDF_Page* pPage = pWidget->GetPDFPage(); |
51 CPDF_Document* pDocument = pPage->m_pDocument; | 51 CPDF_Document* pDocument = pPage->m_pDocument; |
52 uint32_t dwPermissions = pDocument->GetUserPermissions(); | 52 uint32_t dwPermissions = pDocument->GetUserPermissions(); |
53 return (dwPermissions & FPDFPERM_FILL_FORM) || | 53 return (dwPermissions & FPDFPERM_FILL_FORM) || |
54 (dwPermissions & FPDFPERM_ANNOT_FORM); | 54 (dwPermissions & FPDFPERM_ANNOT_FORM); |
55 } | 55 } |
56 | 56 |
57 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, | 57 CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CPDF_Annot* pAnnot, |
58 CPDFSDK_PageView* pPage) { | 58 CPDFSDK_PageView* pPage) { |
59 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); | 59 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
60 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); | 60 CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
61 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( | 61 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( |
62 pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); | 62 pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); |
63 if (!pCtrl) | 63 if (!pCtrl) |
64 return nullptr; | 64 return nullptr; |
65 | 65 |
66 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); | 66 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); |
67 pInterForm->AddMap(pCtrl, pWidget); | 67 pInterForm->AddMap(pCtrl, pWidget); |
68 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 68 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
69 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) | 69 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) |
70 pWidget->ResetAppearance(nullptr, FALSE); | 70 pWidget->ResetAppearance(nullptr, FALSE); |
71 | 71 |
72 return pWidget; | 72 return pWidget; |
73 } | 73 } |
74 | 74 |
75 #ifdef PDF_ENABLE_XFA | 75 #ifdef PDF_ENABLE_XFA |
76 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget, | 76 CPDFSDK_Annot* CPDFSDK_WidgetHandler::NewAnnot(CXFA_FFWidget* hWidget, |
77 CPDFSDK_PageView* pPage) { | 77 CPDFSDK_PageView* pPage) { |
78 return nullptr; | 78 return nullptr; |
79 } | 79 } |
80 #endif // PDF_ENABLE_XFA | 80 #endif // PDF_ENABLE_XFA |
81 | 81 |
82 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 82 void CPDFSDK_WidgetHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
83 ASSERT(pAnnot); | 83 ASSERT(pAnnot); |
84 | 84 |
85 if (m_pFormFiller) | 85 if (m_pFormFiller) |
86 m_pFormFiller->OnDelete(pAnnot); | 86 m_pFormFiller->OnDelete(pAnnot); |
87 | 87 |
88 std::unique_ptr<CPDFSDK_Widget> pWidget(static_cast<CPDFSDK_Widget*>(pAnnot)); | 88 std::unique_ptr<CPDFSDK_Widget> pWidget(static_cast<CPDFSDK_Widget*>(pAnnot)); |
89 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | 89 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
90 CPDF_FormControl* pControl = pWidget->GetFormControl(); | 90 CPDF_FormControl* pControl = pWidget->GetFormControl(); |
91 pInterForm->RemoveMap(pControl); | 91 pInterForm->RemoveMap(pControl); |
92 } | 92 } |
93 | 93 |
94 void CPDFSDK_BFAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} | 94 void CPDFSDK_WidgetHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} |
95 | 95 |
96 void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, | 96 void CPDFSDK_WidgetHandler::OnDraw(CPDFSDK_PageView* pPageView, |
97 CPDFSDK_Annot* pAnnot, | 97 CPDFSDK_Annot* pAnnot, |
98 CFX_RenderDevice* pDevice, | 98 CFX_RenderDevice* pDevice, |
99 CFX_Matrix* pUser2Device, | 99 CFX_Matrix* pUser2Device, |
100 uint32_t dwFlags) { | 100 uint32_t dwFlags) { |
101 if (pAnnot->IsSignatureWidget()) { | 101 if (pAnnot->IsSignatureWidget()) { |
102 static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance( | 102 static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance( |
103 pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | 103 pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
104 } else { | 104 } else { |
105 if (m_pFormFiller) | 105 if (m_pFormFiller) |
106 m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 106 m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 void CPDFSDK_BFAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, | 110 void CPDFSDK_WidgetHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, |
| 111 CPDFSDK_Annot* pAnnot, |
| 112 CFX_RenderDevice* pDevice, |
| 113 CFX_Matrix* pUser2Device, |
| 114 const CFX_FloatRect& rcWindow, |
| 115 uint32_t dwFlags) {} |
| 116 |
| 117 void CPDFSDK_WidgetHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} |
| 118 |
| 119 void CPDFSDK_WidgetHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} |
| 120 |
| 121 void CPDFSDK_WidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
111 CPDFSDK_Annot* pAnnot, | 122 CPDFSDK_Annot* pAnnot, |
112 CFX_RenderDevice* pDevice, | 123 uint32_t nFlag) { |
113 CFX_Matrix* pUser2Device, | |
114 const CFX_FloatRect& rcWindow, | |
115 uint32_t dwFlags) {} | |
116 | |
117 void CPDFSDK_BFAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} | |
118 | |
119 void CPDFSDK_BFAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} | |
120 | |
121 void CPDFSDK_BFAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, | |
122 CPDFSDK_Annot* pAnnot, | |
123 uint32_t nFlag) { | |
124 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 124 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
125 m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag); | 125 m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag); |
126 } | 126 } |
127 | 127 |
128 void CPDFSDK_BFAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView, | 128 void CPDFSDK_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
129 CPDFSDK_Annot* pAnnot, | 129 CPDFSDK_Annot* pAnnot, |
130 uint32_t nFlag) { | 130 uint32_t nFlag) { |
131 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 131 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
132 m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag); | 132 m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag); |
133 } | 133 } |
134 | 134 |
135 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, | 135 FX_BOOL CPDFSDK_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, |
136 CPDFSDK_Annot* pAnnot, | 136 CPDFSDK_Annot* pAnnot, |
137 uint32_t nFlags, | 137 uint32_t nFlags, |
138 const CFX_FloatPoint& point) { | 138 const CFX_FloatPoint& point) { |
139 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 139 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
140 return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); | 140 return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
141 | 141 |
142 return FALSE; | 142 return FALSE; |
143 } | 143 } |
144 | 144 |
145 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, | 145 FX_BOOL CPDFSDK_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, |
146 CPDFSDK_Annot* pAnnot, | 146 CPDFSDK_Annot* pAnnot, |
147 uint32_t nFlags, | 147 uint32_t nFlags, |
148 const CFX_FloatPoint& point) { | 148 const CFX_FloatPoint& point) { |
149 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 149 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
150 return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); | 150 return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
151 | 151 |
152 return FALSE; | 152 return FALSE; |
153 } | 153 } |
154 | 154 |
155 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 155 FX_BOOL CPDFSDK_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
156 CPDFSDK_Annot* pAnnot, | 156 CPDFSDK_Annot* pAnnot, |
157 uint32_t nFlags, | 157 uint32_t nFlags, |
158 const CFX_FloatPoint& point) { | 158 const CFX_FloatPoint& point) { |
159 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 159 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
160 return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); | 160 return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
161 | 161 |
162 return FALSE; | 162 return FALSE; |
163 } | 163 } |
164 | 164 |
165 FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView, | 165 FX_BOOL CPDFSDK_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView, |
166 CPDFSDK_Annot* pAnnot, | 166 CPDFSDK_Annot* pAnnot, |
167 uint32_t nFlags, | 167 uint32_t nFlags, |
168 const CFX_FloatPoint& point) { | 168 const CFX_FloatPoint& point) { |
169 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 169 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
170 return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); | 170 return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); |
171 | 171 |
172 return FALSE; | 172 return FALSE; |
173 } | 173 } |
174 | 174 |
175 FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, | 175 FX_BOOL CPDFSDK_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, |
176 CPDFSDK_Annot* pAnnot, | 176 CPDFSDK_Annot* pAnnot, |
177 uint32_t nFlags, | 177 uint32_t nFlags, |
178 short zDelta, | 178 short zDelta, |
179 const CFX_FloatPoint& point) { | 179 const CFX_FloatPoint& point) { |
180 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 180 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
181 return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, | 181 return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, |
182 point); | 182 point); |
183 | 183 |
184 return FALSE; | 184 return FALSE; |
185 } | 185 } |
186 | 186 |
187 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, | 187 FX_BOOL CPDFSDK_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, |
188 CPDFSDK_Annot* pAnnot, | 188 CPDFSDK_Annot* pAnnot, |
189 uint32_t nFlags, | 189 uint32_t nFlags, |
190 const CFX_FloatPoint& point) { | 190 const CFX_FloatPoint& point) { |
191 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 191 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
192 return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); | 192 return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
193 | 193 |
194 return FALSE; | 194 return FALSE; |
195 } | 195 } |
196 | 196 |
197 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, | 197 FX_BOOL CPDFSDK_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, |
198 CPDFSDK_Annot* pAnnot, | 198 CPDFSDK_Annot* pAnnot, |
199 uint32_t nFlags, | 199 uint32_t nFlags, |
200 const CFX_FloatPoint& point) { | 200 const CFX_FloatPoint& point) { |
201 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 201 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
202 return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); | 202 return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
203 | 203 |
204 return FALSE; | 204 return FALSE; |
205 } | 205 } |
206 | 206 |
207 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, | 207 FX_BOOL CPDFSDK_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, |
208 CPDFSDK_Annot* pAnnot, | 208 CPDFSDK_Annot* pAnnot, |
209 uint32_t nFlags, | 209 uint32_t nFlags, |
210 const CFX_FloatPoint& point) { | 210 const CFX_FloatPoint& point) { |
211 return FALSE; | 211 return FALSE; |
212 } | 212 } |
213 | 213 |
214 FX_BOOL CPDFSDK_BFAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, | 214 FX_BOOL CPDFSDK_WidgetHandler::OnChar(CPDFSDK_Annot* pAnnot, |
215 uint32_t nChar, | 215 uint32_t nChar, |
216 uint32_t nFlags) { | 216 uint32_t nFlags) { |
217 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 217 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
218 return m_pFormFiller->OnChar(pAnnot, nChar, nFlags); | 218 return m_pFormFiller->OnChar(pAnnot, nChar, nFlags); |
219 | 219 |
220 return FALSE; | 220 return FALSE; |
221 } | 221 } |
222 | 222 |
223 FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, | 223 FX_BOOL CPDFSDK_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, |
224 int nKeyCode, | 224 int nKeyCode, |
225 int nFlag) { | 225 int nFlag) { |
226 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 226 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
227 return m_pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag); | 227 return m_pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag); |
228 | 228 |
229 return FALSE; | 229 return FALSE; |
230 } | 230 } |
231 | 231 |
232 FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, | 232 FX_BOOL CPDFSDK_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, |
233 int nKeyCode, | 233 int nKeyCode, |
234 int nFlag) { | 234 int nFlag) { |
235 return FALSE; | 235 return FALSE; |
236 } | 236 } |
237 | 237 |
238 void CPDFSDK_BFAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) { | 238 void CPDFSDK_WidgetHandler::OnCreate(CPDFSDK_Annot* pAnnot) { |
239 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 239 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
240 m_pFormFiller->OnCreate(pAnnot); | 240 m_pFormFiller->OnCreate(pAnnot); |
241 } | 241 } |
242 | 242 |
243 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) { | 243 void CPDFSDK_WidgetHandler::OnLoad(CPDFSDK_Annot* pAnnot) { |
244 if (pAnnot->IsSignatureWidget()) | 244 if (pAnnot->IsSignatureWidget()) |
245 return; | 245 return; |
246 | 246 |
247 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); | 247 CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); |
248 if (!pWidget->IsAppearanceValid()) | 248 if (!pWidget->IsAppearanceValid()) |
249 pWidget->ResetAppearance(nullptr, FALSE); | 249 pWidget->ResetAppearance(nullptr, FALSE); |
250 | 250 |
251 int nFieldType = pWidget->GetFieldType(); | 251 int nFieldType = pWidget->GetFieldType(); |
252 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { | 252 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { |
253 FX_BOOL bFormated = FALSE; | 253 FX_BOOL bFormated = FALSE; |
254 CFX_WideString sValue = pWidget->OnFormat(bFormated); | 254 CFX_WideString sValue = pWidget->OnFormat(bFormated); |
255 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) | 255 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) |
256 pWidget->ResetAppearance(sValue.c_str(), FALSE); | 256 pWidget->ResetAppearance(sValue.c_str(), FALSE); |
257 } | 257 } |
258 | 258 |
259 #ifdef PDF_ENABLE_XFA | 259 #ifdef PDF_ENABLE_XFA |
260 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 260 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
261 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); | 261 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
262 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 262 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
263 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 263 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
264 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) | 264 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) |
265 pWidget->ResetAppearance(FALSE); | 265 pWidget->ResetAppearance(FALSE); |
266 } | 266 } |
267 #endif // PDF_ENABLE_XFA | 267 #endif // PDF_ENABLE_XFA |
268 if (m_pFormFiller) | 268 if (m_pFormFiller) |
269 m_pFormFiller->OnLoad(pAnnot); | 269 m_pFormFiller->OnLoad(pAnnot); |
270 } | 270 } |
271 | 271 |
272 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, | 272 FX_BOOL CPDFSDK_WidgetHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, |
273 uint32_t nFlag) { | 273 uint32_t nFlag) { |
274 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 274 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
275 return m_pFormFiller->OnSetFocus(pAnnot, nFlag); | 275 return m_pFormFiller->OnSetFocus(pAnnot, nFlag); |
276 | 276 |
277 return TRUE; | 277 return TRUE; |
278 } | 278 } |
279 | 279 |
280 FX_BOOL CPDFSDK_BFAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, | 280 FX_BOOL CPDFSDK_WidgetHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, |
281 uint32_t nFlag) { | 281 uint32_t nFlag) { |
282 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 282 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
283 return m_pFormFiller->OnKillFocus(pAnnot, nFlag); | 283 return m_pFormFiller->OnKillFocus(pAnnot, nFlag); |
284 | 284 |
285 return TRUE; | 285 return TRUE; |
286 } | 286 } |
287 | 287 |
288 #ifdef PDF_ENABLE_XFA | 288 #ifdef PDF_ENABLE_XFA |
289 FX_BOOL CPDFSDK_BFAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, | 289 FX_BOOL CPDFSDK_WidgetHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
290 CPDFSDK_Annot* pNewAnnot) { | 290 CPDFSDK_Annot* pNewAnnot) { |
291 return TRUE; | 291 return TRUE; |
292 } | 292 } |
293 #endif // PDF_ENABLE_XFA | 293 #endif // PDF_ENABLE_XFA |
294 | 294 |
295 CFX_FloatRect CPDFSDK_BFAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, | 295 CFX_FloatRect CPDFSDK_WidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
296 CPDFSDK_Annot* pAnnot) { | 296 CPDFSDK_Annot* pAnnot) { |
297 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) | 297 if (!pAnnot->IsSignatureWidget() && m_pFormFiller) |
298 return CFX_FloatRect(m_pFormFiller->GetViewBBox(pPageView, pAnnot)); | 298 return CFX_FloatRect(m_pFormFiller->GetViewBBox(pPageView, pAnnot)); |
299 | 299 |
300 return CFX_FloatRect(0, 0, 0, 0); | 300 return CFX_FloatRect(0, 0, 0, 0); |
301 } | 301 } |
302 | 302 |
303 FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, | 303 FX_BOOL CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView, |
304 CPDFSDK_Annot* pAnnot, | 304 CPDFSDK_Annot* pAnnot, |
305 const CFX_FloatPoint& point) { | 305 const CFX_FloatPoint& point) { |
306 ASSERT(pPageView); | 306 ASSERT(pPageView); |
307 ASSERT(pAnnot); | 307 ASSERT(pAnnot); |
308 | 308 |
309 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); | 309 CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); |
310 return rect.Contains(point.x, point.y); | 310 return rect.Contains(point.x, point.y); |
311 } | 311 } |
OLD | NEW |