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_interform.h" | 7 #include "fpdfsdk/include/cpdfsdk_interform.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 340 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
341 ASSERT(pFormCtrl); | 341 ASSERT(pFormCtrl); |
342 | 342 |
343 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) { | 343 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) { |
344 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); | 344 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); |
345 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); | 345 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); |
346 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 346 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
347 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, false); | 347 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, false); |
348 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); | 348 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); |
349 | 349 |
350 pEnv->FFI_Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, | 350 pEnv->Invalidate(pPage, rcBBox.left, rcBBox.top, rcBBox.right, |
351 rcBBox.bottom); | 351 rcBBox.bottom); |
352 } | 352 } |
353 } | 353 } |
354 } | 354 } |
355 | 355 |
356 FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, | 356 FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, |
357 const CFX_WideString& csValue) { | 357 const CFX_WideString& csValue) { |
358 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 358 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
359 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke)) | 359 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::KeyStroke)) |
360 return TRUE; | 360 return TRUE; |
361 | 361 |
362 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); | 362 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); |
363 if (!action.GetDict()) | 363 if (!action.GetDict()) |
364 return TRUE; | 364 return TRUE; |
365 | 365 |
366 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); | 366 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); |
367 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | 367 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
368 PDFSDK_FieldAction fa; | 368 PDFSDK_FieldAction fa; |
369 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | 369 fa.bModifier = pEnv->IsCTRLKeyDown(0); |
370 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | 370 fa.bShift = pEnv->IsSHIFTKeyDown(0); |
371 fa.sValue = csValue; | 371 fa.sValue = csValue; |
372 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, | 372 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke, |
373 m_pDocument, pFormField, fa); | 373 m_pDocument, pFormField, fa); |
374 return fa.bRC; | 374 return fa.bRC; |
375 } | 375 } |
376 | 376 |
377 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, | 377 FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, |
378 const CFX_WideString& csValue) { | 378 const CFX_WideString& csValue) { |
379 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 379 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
380 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) | 380 if (!aAction.GetDict() || !aAction.ActionExist(CPDF_AAction::Validate)) |
381 return TRUE; | 381 return TRUE; |
382 | 382 |
383 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); | 383 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); |
384 if (!action.GetDict()) | 384 if (!action.GetDict()) |
385 return TRUE; | 385 return TRUE; |
386 | 386 |
387 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); | 387 CPDFSDK_Environment* pEnv = m_pDocument->GetEnv(); |
388 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); | 388 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
389 PDFSDK_FieldAction fa; | 389 PDFSDK_FieldAction fa; |
390 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | 390 fa.bModifier = pEnv->IsCTRLKeyDown(0); |
391 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | 391 fa.bShift = pEnv->IsSHIFTKeyDown(0); |
392 fa.sValue = csValue; | 392 fa.sValue = csValue; |
393 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, | 393 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate, |
394 m_pDocument, pFormField, fa); | 394 m_pDocument, pFormField, fa); |
395 return fa.bRC; | 395 return fa.bRC; |
396 } | 396 } |
397 | 397 |
398 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { | 398 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { |
399 ASSERT(action.GetDict()); | 399 ASSERT(action.GetDict()); |
400 | 400 |
401 CPDF_ActionFields af(&action); | 401 CPDF_ActionFields af(&action); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 } | 719 } |
720 } | 720 } |
721 | 721 |
722 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { | 722 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { |
723 if (nFieldType < 0 || nFieldType > kNumFieldTypes) | 723 if (nFieldType < 0 || nFieldType > kNumFieldTypes) |
724 return FXSYS_RGB(255, 255, 255); | 724 return FXSYS_RGB(255, 255, 255); |
725 if (nFieldType == 0) | 725 if (nFieldType == 0) |
726 return m_aHighlightColor[0]; | 726 return m_aHighlightColor[0]; |
727 return m_aHighlightColor[nFieldType - 1]; | 727 return m_aHighlightColor[nFieldType - 1]; |
728 } | 728 } |
OLD | NEW |