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/cpdfsdk_interform.h" | 7 #include "fpdfsdk/cpdfsdk_interform.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "xfa/fxfa/cxfa_eventparam.h" | 42 #include "xfa/fxfa/cxfa_eventparam.h" |
43 #include "xfa/fxfa/xfa_ffdocview.h" | 43 #include "xfa/fxfa/xfa_ffdocview.h" |
44 #include "xfa/fxfa/xfa_ffwidget.h" | 44 #include "xfa/fxfa/xfa_ffwidget.h" |
45 #include "xfa/fxfa/xfa_ffwidgethandler.h" | 45 #include "xfa/fxfa/xfa_ffwidgethandler.h" |
46 #endif // PDF_ENABLE_XFA | 46 #endif // PDF_ENABLE_XFA |
47 | 47 |
48 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) | 48 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) |
49 : m_pFormFillEnv(pFormFillEnv), | 49 : m_pFormFillEnv(pFormFillEnv), |
50 m_pInterForm(new CPDF_InterForm(m_pFormFillEnv->GetPDFDocument())), | 50 m_pInterForm(new CPDF_InterForm(m_pFormFillEnv->GetPDFDocument())), |
51 #ifdef PDF_ENABLE_XFA | 51 #ifdef PDF_ENABLE_XFA |
52 m_bXfaCalculate(TRUE), | 52 m_bXfaCalculate(true), |
53 m_bXfaValidationsEnabled(TRUE), | 53 m_bXfaValidationsEnabled(true), |
54 #endif // PDF_ENABLE_XFA | 54 #endif // PDF_ENABLE_XFA |
55 m_bCalculate(TRUE), | 55 m_bCalculate(true), |
56 m_bBusy(FALSE), | 56 m_bBusy(false), |
57 m_iHighlightAlpha(0) { | 57 m_iHighlightAlpha(0) { |
58 m_pInterForm->SetFormNotify(this); | 58 m_pInterForm->SetFormNotify(this); |
59 for (int i = 0; i < kNumFieldTypes; ++i) | 59 for (int i = 0; i < kNumFieldTypes; ++i) |
60 m_bNeedHightlight[i] = FALSE; | 60 m_bNeedHightlight[i] = false; |
61 } | 61 } |
62 | 62 |
63 CPDFSDK_InterForm::~CPDFSDK_InterForm() { | 63 CPDFSDK_InterForm::~CPDFSDK_InterForm() { |
64 m_Map.clear(); | 64 m_Map.clear(); |
65 #ifdef PDF_ENABLE_XFA | 65 #ifdef PDF_ENABLE_XFA |
66 m_XFAMap.clear(); | 66 m_XFAMap.clear(); |
67 #endif // PDF_ENABLE_XFA | 67 #endif // PDF_ENABLE_XFA |
68 } | 68 } |
69 | 69 |
70 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { | 70 bool CPDFSDK_InterForm::HighlightWidgets() { |
71 return FALSE; | 71 return false; |
72 } | 72 } |
73 | 73 |
74 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, | 74 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, |
75 FX_BOOL bNext) const { | 75 bool bNext) const { |
76 std::unique_ptr<CBA_AnnotIterator> pIterator(new CBA_AnnotIterator( | 76 std::unique_ptr<CBA_AnnotIterator> pIterator(new CBA_AnnotIterator( |
77 pWidget->GetPageView(), CPDF_Annot::Subtype::WIDGET)); | 77 pWidget->GetPageView(), CPDF_Annot::Subtype::WIDGET)); |
78 | 78 |
79 if (bNext) | 79 if (bNext) |
80 return static_cast<CPDFSDK_Widget*>(pIterator->GetNextAnnot(pWidget)); | 80 return static_cast<CPDFSDK_Widget*>(pIterator->GetNextAnnot(pWidget)); |
81 | 81 |
82 return static_cast<CPDFSDK_Widget*>(pIterator->GetPrevAnnot(pWidget)); | 82 return static_cast<CPDFSDK_Widget*>(pIterator->GetPrevAnnot(pWidget)); |
83 } | 83 } |
84 | 84 |
85 CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl, | 85 CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, | 163 void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, |
164 CPDFSDK_Widget* pWidget) { | 164 CPDFSDK_Widget* pWidget) { |
165 m_Map[pControl] = pWidget; | 165 m_Map[pControl] = pWidget; |
166 } | 166 } |
167 | 167 |
168 void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) { | 168 void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) { |
169 m_Map.erase(pControl); | 169 m_Map.erase(pControl); |
170 } | 170 } |
171 | 171 |
172 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { | 172 void CPDFSDK_InterForm::EnableCalculate(bool bEnabled) { |
173 m_bCalculate = bEnabled; | 173 m_bCalculate = bEnabled; |
174 } | 174 } |
175 | 175 |
176 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { | 176 bool CPDFSDK_InterForm::IsCalculateEnabled() const { |
177 return m_bCalculate; | 177 return m_bCalculate; |
178 } | 178 } |
179 | 179 |
180 #ifdef PDF_ENABLE_XFA | 180 #ifdef PDF_ENABLE_XFA |
181 void CPDFSDK_InterForm::AddXFAMap(CXFA_FFWidget* hWidget, | 181 void CPDFSDK_InterForm::AddXFAMap(CXFA_FFWidget* hWidget, |
182 CPDFSDK_XFAWidget* pWidget) { | 182 CPDFSDK_XFAWidget* pWidget) { |
183 ASSERT(hWidget); | 183 ASSERT(hWidget); |
184 m_XFAMap[hWidget] = pWidget; | 184 m_XFAMap[hWidget] = pWidget; |
185 } | 185 } |
186 | 186 |
187 void CPDFSDK_InterForm::RemoveXFAMap(CXFA_FFWidget* hWidget) { | 187 void CPDFSDK_InterForm::RemoveXFAMap(CXFA_FFWidget* hWidget) { |
188 ASSERT(hWidget); | 188 ASSERT(hWidget); |
189 m_XFAMap.erase(hWidget); | 189 m_XFAMap.erase(hWidget); |
190 } | 190 } |
191 | 191 |
192 CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(CXFA_FFWidget* hWidget) { | 192 CPDFSDK_XFAWidget* CPDFSDK_InterForm::GetXFAWidget(CXFA_FFWidget* hWidget) { |
193 ASSERT(hWidget); | 193 ASSERT(hWidget); |
194 auto it = m_XFAMap.find(hWidget); | 194 auto it = m_XFAMap.find(hWidget); |
195 return it != m_XFAMap.end() ? it->second : nullptr; | 195 return it != m_XFAMap.end() ? it->second : nullptr; |
196 } | 196 } |
197 | 197 |
198 void CPDFSDK_InterForm::XfaEnableCalculate(FX_BOOL bEnabled) { | 198 void CPDFSDK_InterForm::XfaEnableCalculate(bool bEnabled) { |
199 m_bXfaCalculate = bEnabled; | 199 m_bXfaCalculate = bEnabled; |
200 } | 200 } |
201 FX_BOOL CPDFSDK_InterForm::IsXfaCalculateEnabled() const { | 201 bool CPDFSDK_InterForm::IsXfaCalculateEnabled() const { |
202 return m_bXfaCalculate; | 202 return m_bXfaCalculate; |
203 } | 203 } |
204 | 204 |
205 FX_BOOL CPDFSDK_InterForm::IsXfaValidationsEnabled() { | 205 bool CPDFSDK_InterForm::IsXfaValidationsEnabled() { |
206 return m_bXfaValidationsEnabled; | 206 return m_bXfaValidationsEnabled; |
207 } | 207 } |
208 void CPDFSDK_InterForm::XfaSetValidationsEnabled(FX_BOOL bEnabled) { | 208 void CPDFSDK_InterForm::XfaSetValidationsEnabled(bool bEnabled) { |
209 m_bXfaValidationsEnabled = bEnabled; | 209 m_bXfaValidationsEnabled = bEnabled; |
210 } | 210 } |
211 | 211 |
212 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, | 212 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, |
213 FX_BOOL bSynchronizeElse) { | 213 bool bSynchronizeElse) { |
214 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 214 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
215 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 215 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
216 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) | 216 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) |
217 pWidget->Synchronize(bSynchronizeElse); | 217 pWidget->Synchronize(bSynchronizeElse); |
218 } | 218 } |
219 } | 219 } |
220 #endif // PDF_ENABLE_XFA | 220 #endif // PDF_ENABLE_XFA |
221 | 221 |
222 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { | 222 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { |
223 if (!m_pFormFillEnv->IsJSInitiated()) | 223 if (!m_pFormFillEnv->IsJSInitiated()) |
224 return; | 224 return; |
225 | 225 |
226 if (m_bBusy) | 226 if (m_bBusy) |
227 return; | 227 return; |
228 | 228 |
229 m_bBusy = TRUE; | 229 m_bBusy = true; |
230 | 230 |
231 if (!IsCalculateEnabled()) { | 231 if (!IsCalculateEnabled()) { |
232 m_bBusy = FALSE; | 232 m_bBusy = false; |
233 return; | 233 return; |
234 } | 234 } |
235 | 235 |
236 IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); | 236 IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); |
237 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 237 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
238 for (int i = 0; i < nSize; i++) { | 238 for (int i = 0; i < nSize; i++) { |
239 CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i); | 239 CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i); |
240 if (!pField) | 240 if (!pField) |
241 continue; | 241 continue; |
242 | 242 |
243 int nType = pField->GetFieldType(); | 243 int nType = pField->GetFieldType(); |
244 if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD) | 244 if (nType != FIELDTYPE_COMBOBOX && nType != FIELDTYPE_TEXTFIELD) |
245 continue; | 245 continue; |
246 | 246 |
247 CPDF_AAction aAction = pField->GetAdditionalAction(); | 247 CPDF_AAction aAction = pField->GetAdditionalAction(); |
248 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Calculate)) | 248 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Calculate)) |
249 continue; | 249 continue; |
250 | 250 |
251 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); | 251 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); |
252 if (!action.GetDict()) | 252 if (!action.GetDict()) |
253 continue; | 253 continue; |
254 | 254 |
255 CFX_WideString csJS = action.GetJavaScript(); | 255 CFX_WideString csJS = action.GetJavaScript(); |
256 if (csJS.IsEmpty()) | 256 if (csJS.IsEmpty()) |
257 continue; | 257 continue; |
258 | 258 |
259 IJS_Context* pContext = pRuntime->NewContext(); | 259 IJS_Context* pContext = pRuntime->NewContext(); |
260 CFX_WideString sOldValue = pField->GetValue(); | 260 CFX_WideString sOldValue = pField->GetValue(); |
261 CFX_WideString sValue = sOldValue; | 261 CFX_WideString sValue = sOldValue; |
262 FX_BOOL bRC = TRUE; | 262 bool bRC = true; |
263 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); | 263 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); |
264 | 264 |
265 CFX_WideString sInfo; | 265 CFX_WideString sInfo; |
266 FX_BOOL bRet = pContext->RunScript(csJS, &sInfo); | 266 bool bRet = pContext->RunScript(csJS, &sInfo); |
267 pRuntime->ReleaseContext(pContext); | 267 pRuntime->ReleaseContext(pContext); |
268 | 268 |
269 if (bRet && bRC && sValue.Compare(sOldValue) != 0) | 269 if (bRet && bRC && sValue.Compare(sOldValue) != 0) |
270 pField->SetValue(sValue, TRUE); | 270 pField->SetValue(sValue, true); |
271 } | 271 } |
272 | 272 |
273 m_bBusy = FALSE; | 273 m_bBusy = false; |
274 } | 274 } |
275 | 275 |
276 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, | 276 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, |
277 FX_BOOL& bFormatted) { | 277 bool& bFormatted) { |
278 CFX_WideString sValue = pFormField->GetValue(); | 278 CFX_WideString sValue = pFormField->GetValue(); |
279 if (!m_pFormFillEnv->IsJSInitiated()) { | 279 if (!m_pFormFillEnv->IsJSInitiated()) { |
280 bFormatted = FALSE; | 280 bFormatted = false; |
281 return sValue; | 281 return sValue; |
282 } | 282 } |
283 | 283 |
284 IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); | 284 IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); |
285 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX && | 285 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX && |
286 pFormField->CountSelectedItems() > 0) { | 286 pFormField->CountSelectedItems() > 0) { |
287 int index = pFormField->GetSelectedIndex(0); | 287 int index = pFormField->GetSelectedIndex(0); |
288 if (index >= 0) | 288 if (index >= 0) |
289 sValue = pFormField->GetOptionLabel(index); | 289 sValue = pFormField->GetOptionLabel(index); |
290 } | 290 } |
291 | 291 |
292 bFormatted = FALSE; | 292 bFormatted = false; |
293 | 293 |
294 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 294 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
295 if (aAction.GetDict() && aAction.ActionExist(CPDF_AAction::Format)) { | 295 if (aAction.GetDict() && aAction.ActionExist(CPDF_AAction::Format)) { |
296 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); | 296 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); |
297 if (action.GetDict()) { | 297 if (action.GetDict()) { |
298 CFX_WideString script = action.GetJavaScript(); | 298 CFX_WideString script = action.GetJavaScript(); |
299 if (!script.IsEmpty()) { | 299 if (!script.IsEmpty()) { |
300 CFX_WideString Value = sValue; | 300 CFX_WideString Value = sValue; |
301 | 301 |
302 IJS_Context* pContext = pRuntime->NewContext(); | 302 IJS_Context* pContext = pRuntime->NewContext(); |
303 pContext->OnField_Format(pFormField, Value, TRUE); | 303 pContext->OnField_Format(pFormField, Value, true); |
304 CFX_WideString sInfo; | 304 CFX_WideString sInfo; |
305 FX_BOOL bRet = pContext->RunScript(script, &sInfo); | 305 bool bRet = pContext->RunScript(script, &sInfo); |
306 pRuntime->ReleaseContext(pContext); | 306 pRuntime->ReleaseContext(pContext); |
307 | 307 |
308 if (bRet) { | 308 if (bRet) { |
309 sValue = Value; | 309 sValue = Value; |
310 bFormatted = TRUE; | 310 bFormatted = true; |
311 } | 311 } |
312 } | 312 } |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 return sValue; | 316 return sValue; |
317 } | 317 } |
318 | 318 |
319 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, | 319 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, |
320 const CFX_WideString* sValue, | 320 const CFX_WideString* sValue, |
321 FX_BOOL bValueChanged) { | 321 bool bValueChanged) { |
322 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 322 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
323 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 323 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
324 ASSERT(pFormCtrl); | 324 ASSERT(pFormCtrl); |
325 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) | 325 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) |
326 pWidget->ResetAppearance(sValue, bValueChanged); | 326 pWidget->ResetAppearance(sValue, bValueChanged); |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { | 330 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { |
331 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { | 331 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
332 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 332 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
333 ASSERT(pFormCtrl); | 333 ASSERT(pFormCtrl); |
334 | 334 |
335 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) { | 335 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) { |
336 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 336 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
337 CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, false); | 337 CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, false); |
338 FX_RECT rcBBox = m_pFormFillEnv->GetInteractiveFormFiller()->GetViewBBox( | 338 FX_RECT rcBBox = m_pFormFillEnv->GetInteractiveFormFiller()->GetViewBBox( |
339 pPageView, pWidget); | 339 pPageView, pWidget); |
340 | 340 |
341 m_pFormFillEnv->Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, | 341 m_pFormFillEnv->Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, |
342 rcBBox.bottom); | 342 rcBBox.bottom); |
343 } | 343 } |
344 } | 344 } |
345 } | 345 } |
346 | 346 |
347 FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, | 347 bool CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, |
348 const CFX_WideString& csValue) { | 348 const CFX_WideString& csValue) { |
349 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 349 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
350 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke)) | 350 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke)) |
351 return TRUE; | 351 return true; |
352 | 352 |
353 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); | 353 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); |
354 if (!action.GetDict()) | 354 if (!action.GetDict()) |
355 return TRUE; | 355 return true; |
356 | 356 |
357 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); | 357 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); |
358 PDFSDK_FieldAction fa; | 358 PDFSDK_FieldAction fa; |
359 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); | 359 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); |
360 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); | 360 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); |
361 fa.sValue = csValue; | 361 fa.sValue = csValue; |
362 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, | 362 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, |
363 m_pFormFillEnv, pFormField, fa); | 363 m_pFormFillEnv, pFormField, fa); |
364 return fa.bRC; | 364 return fa.bRC; |
365 } | 365 } |
366 | 366 |
367 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, | 367 bool CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, |
368 const CFX_WideString& csValue) { | 368 const CFX_WideString& csValue) { |
369 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 369 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
370 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) | 370 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) |
371 return TRUE; | 371 return true; |
372 | 372 |
373 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); | 373 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); |
374 if (!action.GetDict()) | 374 if (!action.GetDict()) |
375 return TRUE; | 375 return true; |
376 | 376 |
377 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); | 377 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); |
378 PDFSDK_FieldAction fa; | 378 PDFSDK_FieldAction fa; |
379 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); | 379 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); |
380 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); | 380 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); |
381 fa.sValue = csValue; | 381 fa.sValue = csValue; |
382 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, | 382 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, |
383 m_pFormFillEnv, pFormField, fa); | 383 m_pFormFillEnv, pFormField, fa); |
384 return fa.bRC; | 384 return fa.bRC; |
385 } | 385 } |
386 | 386 |
387 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { | 387 bool CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { |
388 ASSERT(action.GetDict()); | 388 ASSERT(action.GetDict()); |
389 | 389 |
390 CPDF_ActionFields af(&action); | 390 CPDF_ActionFields af(&action); |
391 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 391 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
392 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 392 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
393 | 393 |
394 bool bHide = action.GetHideStatus(); | 394 bool bHide = action.GetHideStatus(); |
395 FX_BOOL bChanged = FALSE; | 395 bool bChanged = false; |
396 | 396 |
397 for (CPDF_FormField* pField : fields) { | 397 for (CPDF_FormField* pField : fields) { |
398 for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { | 398 for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { |
399 CPDF_FormControl* pControl = pField->GetControl(i); | 399 CPDF_FormControl* pControl = pField->GetControl(i); |
400 ASSERT(pControl); | 400 ASSERT(pControl); |
401 | 401 |
402 if (CPDFSDK_Widget* pWidget = GetWidget(pControl, false)) { | 402 if (CPDFSDK_Widget* pWidget = GetWidget(pControl, false)) { |
403 uint32_t nFlags = pWidget->GetFlags(); | 403 uint32_t nFlags = pWidget->GetFlags(); |
404 nFlags &= ~ANNOTFLAG_INVISIBLE; | 404 nFlags &= ~ANNOTFLAG_INVISIBLE; |
405 nFlags &= ~ANNOTFLAG_NOVIEW; | 405 nFlags &= ~ANNOTFLAG_NOVIEW; |
406 if (bHide) | 406 if (bHide) |
407 nFlags |= ANNOTFLAG_HIDDEN; | 407 nFlags |= ANNOTFLAG_HIDDEN; |
408 else | 408 else |
409 nFlags &= ~ANNOTFLAG_HIDDEN; | 409 nFlags &= ~ANNOTFLAG_HIDDEN; |
410 pWidget->SetFlags(nFlags); | 410 pWidget->SetFlags(nFlags); |
411 pWidget->GetPageView()->UpdateView(pWidget); | 411 pWidget->GetPageView()->UpdateView(pWidget); |
412 bChanged = TRUE; | 412 bChanged = true; |
413 } | 413 } |
414 } | 414 } |
415 } | 415 } |
416 | 416 |
417 return bChanged; | 417 return bChanged; |
418 } | 418 } |
419 | 419 |
420 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { | 420 bool CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { |
421 CFX_WideString sDestination = action.GetFilePath(); | 421 CFX_WideString sDestination = action.GetFilePath(); |
422 if (sDestination.IsEmpty()) | 422 if (sDestination.IsEmpty()) |
423 return FALSE; | 423 return false; |
424 | 424 |
425 CPDF_Dictionary* pActionDict = action.GetDict(); | 425 CPDF_Dictionary* pActionDict = action.GetDict(); |
426 if (pActionDict->KeyExist("Fields")) { | 426 if (pActionDict->KeyExist("Fields")) { |
427 CPDF_ActionFields af(&action); | 427 CPDF_ActionFields af(&action); |
428 uint32_t dwFlags = action.GetFlags(); | 428 uint32_t dwFlags = action.GetFlags(); |
429 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 429 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
430 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 430 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
431 if (!fields.empty()) { | 431 if (!fields.empty()) { |
432 bool bIncludeOrExclude = !(dwFlags & 0x01); | 432 bool bIncludeOrExclude = !(dwFlags & 0x01); |
433 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) | 433 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) |
434 return FALSE; | 434 return false; |
435 | 435 |
436 return SubmitFields(sDestination, fields, bIncludeOrExclude, false); | 436 return SubmitFields(sDestination, fields, bIncludeOrExclude, false); |
437 } | 437 } |
438 } | 438 } |
439 if (m_pInterForm->CheckRequiredFields(nullptr, true)) | 439 if (m_pInterForm->CheckRequiredFields(nullptr, true)) |
440 return FALSE; | 440 return false; |
441 | 441 |
442 return SubmitForm(sDestination, FALSE); | 442 return SubmitForm(sDestination, false); |
443 } | 443 } |
444 | 444 |
445 FX_BOOL CPDFSDK_InterForm::SubmitFields( | 445 bool CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, |
446 const CFX_WideString& csDestination, | 446 const std::vector<CPDF_FormField*>& fields, |
447 const std::vector<CPDF_FormField*>& fields, | 447 bool bIncludeOrExclude, |
448 bool bIncludeOrExclude, | 448 bool bUrlEncoded) { |
449 bool bUrlEncoded) { | |
450 CFX_ByteTextBuf textBuf; | 449 CFX_ByteTextBuf textBuf; |
451 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); | 450 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); |
452 | 451 |
453 uint8_t* pBuffer = textBuf.GetBuffer(); | 452 uint8_t* pBuffer = textBuf.GetBuffer(); |
454 FX_STRSIZE nBufSize = textBuf.GetLength(); | 453 FX_STRSIZE nBufSize = textBuf.GetLength(); |
455 | 454 |
456 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) | 455 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) |
457 return FALSE; | 456 return false; |
458 | 457 |
459 m_pFormFillEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); | 458 m_pFormFillEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); |
460 return TRUE; | 459 return true; |
461 } | 460 } |
462 | 461 |
463 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, | 462 bool CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, |
464 CFX_WideString csTxtFile) { | 463 CFX_WideString csTxtFile) { |
465 return TRUE; | 464 return true; |
466 } | 465 } |
467 | 466 |
468 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, | 467 bool CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, |
469 FX_STRSIZE& nBufSize) { | 468 FX_STRSIZE& nBufSize) { |
470 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); | 469 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); |
471 if (!pFDF) | 470 if (!pFDF) |
472 return TRUE; | 471 return true; |
473 | 472 |
474 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictFor("FDF"); | 473 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictFor("FDF"); |
475 if (!pMainDict) | 474 if (!pMainDict) |
476 return FALSE; | 475 return false; |
477 | 476 |
478 CPDF_Array* pFields = pMainDict->GetArrayFor("Fields"); | 477 CPDF_Array* pFields = pMainDict->GetArrayFor("Fields"); |
479 if (!pFields) | 478 if (!pFields) |
480 return FALSE; | 479 return false; |
481 | 480 |
482 CFX_ByteTextBuf fdfEncodedData; | 481 CFX_ByteTextBuf fdfEncodedData; |
483 for (uint32_t i = 0; i < pFields->GetCount(); i++) { | 482 for (uint32_t i = 0; i < pFields->GetCount(); i++) { |
484 CPDF_Dictionary* pField = pFields->GetDictAt(i); | 483 CPDF_Dictionary* pField = pFields->GetDictAt(i); |
485 if (!pField) | 484 if (!pField) |
486 continue; | 485 continue; |
487 CFX_WideString name; | 486 CFX_WideString name; |
488 name = pField->GetUnicodeTextFor("T"); | 487 name = pField->GetUnicodeTextFor("T"); |
489 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); | 488 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); |
490 CFX_ByteString csBValue = pField->GetStringFor("V"); | 489 CFX_ByteString csBValue = pField->GetStringFor("V"); |
491 CFX_WideString csWValue = PDF_DecodeText(csBValue); | 490 CFX_WideString csWValue = PDF_DecodeText(csBValue); |
492 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); | 491 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); |
493 | 492 |
494 fdfEncodedData << name_b.GetBuffer(name_b.GetLength()); | 493 fdfEncodedData << name_b.GetBuffer(name_b.GetLength()); |
495 name_b.ReleaseBuffer(); | 494 name_b.ReleaseBuffer(); |
496 fdfEncodedData << "="; | 495 fdfEncodedData << "="; |
497 fdfEncodedData << csValue_b.GetBuffer(csValue_b.GetLength()); | 496 fdfEncodedData << csValue_b.GetBuffer(csValue_b.GetLength()); |
498 csValue_b.ReleaseBuffer(); | 497 csValue_b.ReleaseBuffer(); |
499 if (i != pFields->GetCount() - 1) | 498 if (i != pFields->GetCount() - 1) |
500 fdfEncodedData << "&"; | 499 fdfEncodedData << "&"; |
501 } | 500 } |
502 | 501 |
503 nBufSize = fdfEncodedData.GetLength(); | 502 nBufSize = fdfEncodedData.GetLength(); |
504 pBuf = FX_Alloc(uint8_t, nBufSize); | 503 pBuf = FX_Alloc(uint8_t, nBufSize); |
505 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); | 504 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); |
506 return TRUE; | 505 return true; |
507 } | 506 } |
508 | 507 |
509 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( | 508 bool CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( |
510 const std::vector<CPDF_FormField*>& fields, | 509 const std::vector<CPDF_FormField*>& fields, |
511 bool bIncludeOrExclude, | 510 bool bIncludeOrExclude, |
512 CFX_ByteTextBuf& textBuf) { | 511 CFX_ByteTextBuf& textBuf) { |
513 std::unique_ptr<CFDF_Document> pFDF( | 512 std::unique_ptr<CFDF_Document> pFDF( |
514 m_pInterForm->ExportToFDF(m_pFormFillEnv->JS_docGetFilePath().AsStringC(), | 513 m_pInterForm->ExportToFDF(m_pFormFillEnv->JS_docGetFilePath().AsStringC(), |
515 fields, bIncludeOrExclude, false)); | 514 fields, bIncludeOrExclude, false)); |
516 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; | 515 return pFDF ? pFDF->WriteBuf(textBuf) : false; |
517 } | 516 } |
518 | 517 |
519 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( | 518 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( |
520 const CFX_WideString& sFileExt) { | 519 const CFX_WideString& sFileExt) { |
521 return L""; | 520 return L""; |
522 } | 521 } |
523 | 522 |
524 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, | 523 bool CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, |
525 FX_BOOL bUrlEncoded) { | 524 bool bUrlEncoded) { |
526 if (sDestination.IsEmpty()) | 525 if (sDestination.IsEmpty()) |
527 return FALSE; | 526 return false; |
528 | 527 |
529 if (!m_pFormFillEnv || !m_pInterForm) | 528 if (!m_pFormFillEnv || !m_pInterForm) |
530 return FALSE; | 529 return false; |
531 | 530 |
532 CFX_WideString wsPDFFilePath = m_pFormFillEnv->JS_docGetFilePath(); | 531 CFX_WideString wsPDFFilePath = m_pFormFillEnv->JS_docGetFilePath(); |
533 CFDF_Document* pFDFDoc = | 532 CFDF_Document* pFDFDoc = |
534 m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC(), false); | 533 m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC(), false); |
535 if (!pFDFDoc) | 534 if (!pFDFDoc) |
536 return FALSE; | 535 return false; |
537 | 536 |
538 CFX_ByteTextBuf FdfBuffer; | 537 CFX_ByteTextBuf FdfBuffer; |
539 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); | 538 bool bRet = pFDFDoc->WriteBuf(FdfBuffer); |
540 delete pFDFDoc; | 539 delete pFDFDoc; |
541 if (!bRet) | 540 if (!bRet) |
542 return FALSE; | 541 return false; |
543 | 542 |
544 uint8_t* pBuffer = FdfBuffer.GetBuffer(); | 543 uint8_t* pBuffer = FdfBuffer.GetBuffer(); |
545 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 544 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); |
546 | 545 |
547 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) | 546 if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) |
548 return FALSE; | 547 return false; |
549 | 548 |
550 m_pFormFillEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 549 m_pFormFillEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); |
551 | 550 |
552 if (bUrlEncoded) | 551 if (bUrlEncoded) |
553 FX_Free(pBuffer); | 552 FX_Free(pBuffer); |
554 | 553 |
555 return TRUE; | 554 return true; |
556 } | 555 } |
557 | 556 |
558 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { | 557 bool CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { |
559 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( | 558 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( |
560 m_pFormFillEnv->JS_docGetFilePath().AsStringC(), false); | 559 m_pFormFillEnv->JS_docGetFilePath().AsStringC(), false); |
561 if (!pFDF) | 560 if (!pFDF) |
562 return FALSE; | 561 return false; |
563 | 562 |
564 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | 563 bool bRet = pFDF->WriteBuf(textBuf); |
565 delete pFDF; | 564 delete pFDF; |
566 | 565 |
567 return bRet; | 566 return bRet; |
568 } | 567 } |
569 | 568 |
570 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { | 569 bool CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { |
571 ASSERT(action.GetDict()); | 570 ASSERT(action.GetDict()); |
572 | 571 |
573 CPDF_Dictionary* pActionDict = action.GetDict(); | 572 CPDF_Dictionary* pActionDict = action.GetDict(); |
574 if (!pActionDict->KeyExist("Fields")) | 573 if (!pActionDict->KeyExist("Fields")) |
575 return m_pInterForm->ResetForm(true); | 574 return m_pInterForm->ResetForm(true); |
576 | 575 |
577 CPDF_ActionFields af(&action); | 576 CPDF_ActionFields af(&action); |
578 uint32_t dwFlags = action.GetFlags(); | 577 uint32_t dwFlags = action.GetFlags(); |
579 | 578 |
580 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 579 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
581 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 580 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
582 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true); | 581 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true); |
583 } | 582 } |
584 | 583 |
585 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) { | 584 bool CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) { |
586 return FALSE; | 585 return false; |
587 } | 586 } |
588 | 587 |
589 std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects( | 588 std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects( |
590 const std::vector<CPDF_Object*>& objects) const { | 589 const std::vector<CPDF_Object*>& objects) const { |
591 std::vector<CPDF_FormField*> fields; | 590 std::vector<CPDF_FormField*> fields; |
592 for (CPDF_Object* pObject : objects) { | 591 for (CPDF_Object* pObject : objects) { |
593 if (pObject && pObject->IsString()) { | 592 if (pObject && pObject->IsString()) { |
594 CFX_WideString csName = pObject->GetUnicodeText(); | 593 CFX_WideString csName = pObject->GetUnicodeText(); |
595 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); | 594 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); |
596 if (pField) | 595 if (pField) |
(...skipping 13 matching lines...) Expand all Loading... |
610 return -1; | 609 return -1; |
611 | 610 |
612 if (!OnValidate(pField, csValue)) | 611 if (!OnValidate(pField, csValue)) |
613 return -1; | 612 return -1; |
614 | 613 |
615 return 1; | 614 return 1; |
616 } | 615 } |
617 | 616 |
618 void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) { | 617 void CPDFSDK_InterForm::AfterValueChange(CPDF_FormField* pField) { |
619 #ifdef PDF_ENABLE_XFA | 618 #ifdef PDF_ENABLE_XFA |
620 SynchronizeField(pField, FALSE); | 619 SynchronizeField(pField, false); |
621 #endif // PDF_ENABLE_XFA | 620 #endif // PDF_ENABLE_XFA |
622 int nType = pField->GetFieldType(); | 621 int nType = pField->GetFieldType(); |
623 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { | 622 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
624 OnCalculate(pField); | 623 OnCalculate(pField); |
625 FX_BOOL bFormatted = FALSE; | 624 bool bFormatted = false; |
626 CFX_WideString sValue = OnFormat(pField, bFormatted); | 625 CFX_WideString sValue = OnFormat(pField, bFormatted); |
627 ResetFieldAppearance(pField, bFormatted ? &sValue : nullptr, TRUE); | 626 ResetFieldAppearance(pField, bFormatted ? &sValue : nullptr, true); |
628 UpdateField(pField); | 627 UpdateField(pField); |
629 } | 628 } |
630 } | 629 } |
631 | 630 |
632 int CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField, | 631 int CPDFSDK_InterForm::BeforeSelectionChange(CPDF_FormField* pField, |
633 const CFX_WideString& csValue) { | 632 const CFX_WideString& csValue) { |
634 if (pField->GetFieldType() != FIELDTYPE_LISTBOX) | 633 if (pField->GetFieldType() != FIELDTYPE_LISTBOX) |
635 return 0; | 634 return 0; |
636 | 635 |
637 if (!OnKeyStrokeCommit(pField, csValue)) | 636 if (!OnKeyStrokeCommit(pField, csValue)) |
638 return -1; | 637 return -1; |
639 | 638 |
640 if (!OnValidate(pField, csValue)) | 639 if (!OnValidate(pField, csValue)) |
641 return -1; | 640 return -1; |
642 | 641 |
643 return 1; | 642 return 1; |
644 } | 643 } |
645 | 644 |
646 void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) { | 645 void CPDFSDK_InterForm::AfterSelectionChange(CPDF_FormField* pField) { |
647 if (pField->GetFieldType() != FIELDTYPE_LISTBOX) | 646 if (pField->GetFieldType() != FIELDTYPE_LISTBOX) |
648 return; | 647 return; |
649 | 648 |
650 OnCalculate(pField); | 649 OnCalculate(pField); |
651 ResetFieldAppearance(pField, nullptr, TRUE); | 650 ResetFieldAppearance(pField, nullptr, true); |
652 UpdateField(pField); | 651 UpdateField(pField); |
653 } | 652 } |
654 | 653 |
655 void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) { | 654 void CPDFSDK_InterForm::AfterCheckedStatusChange(CPDF_FormField* pField) { |
656 int nType = pField->GetFieldType(); | 655 int nType = pField->GetFieldType(); |
657 if (nType != FIELDTYPE_CHECKBOX && nType != FIELDTYPE_RADIOBUTTON) | 656 if (nType != FIELDTYPE_CHECKBOX && nType != FIELDTYPE_RADIOBUTTON) |
658 return; | 657 return; |
659 | 658 |
660 OnCalculate(pField); | 659 OnCalculate(pField); |
661 UpdateField(pField); | 660 UpdateField(pField); |
662 } | 661 } |
663 | 662 |
664 int CPDFSDK_InterForm::BeforeFormReset(CPDF_InterForm* pForm) { | 663 int CPDFSDK_InterForm::BeforeFormReset(CPDF_InterForm* pForm) { |
665 return 0; | 664 return 0; |
666 } | 665 } |
667 | 666 |
668 void CPDFSDK_InterForm::AfterFormReset(CPDF_InterForm* pForm) { | 667 void CPDFSDK_InterForm::AfterFormReset(CPDF_InterForm* pForm) { |
669 OnCalculate(nullptr); | 668 OnCalculate(nullptr); |
670 } | 669 } |
671 | 670 |
672 int CPDFSDK_InterForm::BeforeFormImportData(CPDF_InterForm* pForm) { | 671 int CPDFSDK_InterForm::BeforeFormImportData(CPDF_InterForm* pForm) { |
673 return 0; | 672 return 0; |
674 } | 673 } |
675 | 674 |
676 void CPDFSDK_InterForm::AfterFormImportData(CPDF_InterForm* pForm) { | 675 void CPDFSDK_InterForm::AfterFormImportData(CPDF_InterForm* pForm) { |
677 OnCalculate(nullptr); | 676 OnCalculate(nullptr); |
678 } | 677 } |
679 | 678 |
680 FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) { | 679 bool CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) { |
681 if (nFieldType < 1 || nFieldType > kNumFieldTypes) | 680 if (nFieldType < 1 || nFieldType > kNumFieldTypes) |
682 return FALSE; | 681 return false; |
683 return m_bNeedHightlight[nFieldType - 1]; | 682 return m_bNeedHightlight[nFieldType - 1]; |
684 } | 683 } |
685 | 684 |
686 void CPDFSDK_InterForm::RemoveAllHighLight() { | 685 void CPDFSDK_InterForm::RemoveAllHighLight() { |
687 for (int i = 0; i < kNumFieldTypes; ++i) | 686 for (int i = 0; i < kNumFieldTypes; ++i) |
688 m_bNeedHightlight[i] = FALSE; | 687 m_bNeedHightlight[i] = false; |
689 } | 688 } |
690 | 689 |
691 void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) { | 690 void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) { |
692 if (nFieldType < 0 || nFieldType > kNumFieldTypes) | 691 if (nFieldType < 0 || nFieldType > kNumFieldTypes) |
693 return; | 692 return; |
694 switch (nFieldType) { | 693 switch (nFieldType) { |
695 case 0: { | 694 case 0: { |
696 for (int i = 0; i < kNumFieldTypes; ++i) { | 695 for (int i = 0; i < kNumFieldTypes; ++i) { |
697 m_aHighlightColor[i] = clr; | 696 m_aHighlightColor[i] = clr; |
698 m_bNeedHightlight[i] = TRUE; | 697 m_bNeedHightlight[i] = true; |
699 } | 698 } |
700 break; | 699 break; |
701 } | 700 } |
702 default: { | 701 default: { |
703 m_aHighlightColor[nFieldType - 1] = clr; | 702 m_aHighlightColor[nFieldType - 1] = clr; |
704 m_bNeedHightlight[nFieldType - 1] = TRUE; | 703 m_bNeedHightlight[nFieldType - 1] = true; |
705 break; | 704 break; |
706 } | 705 } |
707 } | 706 } |
708 } | 707 } |
709 | 708 |
710 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { | 709 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { |
711 if (nFieldType < 0 || nFieldType > kNumFieldTypes) | 710 if (nFieldType < 0 || nFieldType > kNumFieldTypes) |
712 return FXSYS_RGB(255, 255, 255); | 711 return FXSYS_RGB(255, 255, 255); |
713 if (nFieldType == 0) | 712 if (nFieldType == 0) |
714 return m_aHighlightColor[0]; | 713 return m_aHighlightColor[0]; |
715 return m_aHighlightColor[nFieldType - 1]; | 714 return m_aHighlightColor[nFieldType - 1]; |
716 } | 715 } |
OLD | NEW |