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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); | 356 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); |
357 if (!action.GetDict()) | 357 if (!action.GetDict()) |
358 return TRUE; | 358 return TRUE; |
359 | 359 |
360 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); | 360 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); |
361 PDFSDK_FieldAction fa; | 361 PDFSDK_FieldAction fa; |
362 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); | 362 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); |
363 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); | 363 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); |
364 fa.sValue = csValue; | 364 fa.sValue = csValue; |
365 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, | 365 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, |
366 m_pFormFillEnv->GetSDKDocument(), | 366 m_pFormFillEnv, pFormField, fa); |
367 pFormField, fa); | |
368 return fa.bRC; | 367 return fa.bRC; |
369 } | 368 } |
370 | 369 |
371 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, | 370 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, |
372 const CFX_WideString& csValue) { | 371 const CFX_WideString& csValue) { |
373 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 372 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
374 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) | 373 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) |
375 return TRUE; | 374 return TRUE; |
376 | 375 |
377 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); | 376 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); |
378 if (!action.GetDict()) | 377 if (!action.GetDict()) |
379 return TRUE; | 378 return TRUE; |
380 | 379 |
381 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); | 380 CPDFSDK_ActionHandler* pActionHandler = m_pFormFillEnv->GetActionHander(); |
382 PDFSDK_FieldAction fa; | 381 PDFSDK_FieldAction fa; |
383 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); | 382 fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(0); |
384 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); | 383 fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0); |
385 fa.sValue = csValue; | 384 fa.sValue = csValue; |
386 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, | 385 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, |
387 m_pFormFillEnv->GetSDKDocument(), | 386 m_pFormFillEnv, pFormField, fa); |
388 pFormField, fa); | |
389 return fa.bRC; | 387 return fa.bRC; |
390 } | 388 } |
391 | 389 |
392 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { | 390 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { |
393 ASSERT(action.GetDict()); | 391 ASSERT(action.GetDict()); |
394 | 392 |
395 CPDF_ActionFields af(&action); | 393 CPDF_ActionFields af(&action); |
396 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); | 394 std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); |
397 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); | 395 std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); |
398 | 396 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 } | 710 } |
713 } | 711 } |
714 | 712 |
715 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { | 713 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { |
716 if (nFieldType < 0 || nFieldType > kNumFieldTypes) | 714 if (nFieldType < 0 || nFieldType > kNumFieldTypes) |
717 return FXSYS_RGB(255, 255, 255); | 715 return FXSYS_RGB(255, 255, 255); |
718 if (nFieldType == 0) | 716 if (nFieldType == 0) |
719 return m_aHighlightColor[0]; | 717 return m_aHighlightColor[0]; |
720 return m_aHighlightColor[nFieldType - 1]; | 718 return m_aHighlightColor[nFieldType - 1]; |
721 } | 719 } |
OLD | NEW |