diff options
author | Lei Zhang <thestig@chromium.org> | 2017-06-15 12:37:33 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-15 20:42:01 +0000 |
commit | 77e3fc5cebfb19aed09f920536200e017cff9a0b (patch) | |
tree | 64700810faf138812cdcf7573a9caff08fb0411b /fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | |
parent | b7384b5b997975c36bb37d25c63e2c900eca41f9 (diff) | |
download | pdfium-77e3fc5cebfb19aed09f920536200e017cff9a0b.tar.xz |
Change some CFFL classes to use early returns.chromium/3132
Also switch C-style casts to the appropriate C++ casts, and add helper
functions in some cases.
Change-Id: I73f1ab36c6c89ced9d2b7b98393805142661dcac
Reviewed-on: https://pdfium-review.googlesource.com/6650
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/formfiller/cffl_interactiveformfiller.cpp')
-rw-r--r-- | fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 108 |
1 files changed, 52 insertions, 56 deletions
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index dca3194b7b..7647fb19ff 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -917,67 +917,63 @@ void CFFL_InteractiveFormFiller::OnBeforeKeyStroke( } #endif // PDF_ENABLE_XFA - if (!m_bNotifying) { - if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) { - m_bNotifying = true; - int nAge = pData->pWidget->GetAppearanceAge(); - int nValueAge = pData->pWidget->GetValueAge(); + if (m_bNotifying) + return; - CPDFSDK_FormFillEnvironment* pFormFillEnv = - pData->pPageView->GetFormFillEnv(); + if (!pData->pWidget->GetAAction(CPDF_AAction::KeyStroke).GetDict()) + return; - PDFSDK_FieldAction fa; - fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); - fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); - fa.sChange = strChange; - fa.sChangeEx = strChangeEx; - fa.bKeyDown = bKeyDown; - fa.bWillCommit = false; - fa.bRC = true; - fa.nSelStart = nSelStart; - fa.nSelEnd = nSelEnd; - - pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); - pFormFiller->SaveState(pData->pPageView); - - CPDFSDK_Annot::ObservedPtr pObserved(pData->pWidget); - if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, - pData->pPageView)) { - if (!pObserved || !IsValidAnnot(pData->pPageView, pData->pWidget)) { - bExit = true; - m_bNotifying = false; - return; - } + CFX_AutoRestorer<bool> restorer(&m_bNotifying); + m_bNotifying = true; + int nAge = pData->pWidget->GetAppearanceAge(); + int nValueAge = pData->pWidget->GetValueAge(); - if (nAge != pData->pWidget->GetAppearanceAge()) { - CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow( - pData->pPageView, nValueAge == pData->pWidget->GetValueAge()); - pData = reinterpret_cast<CFFL_PrivateData*>(pWnd->GetAttachedData()); - bExit = true; - } + CPDFSDK_FormFillEnvironment* pFormFillEnv = + pData->pPageView->GetFormFillEnv(); - if (fa.bRC) { - pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, - fa); - bRC = false; - } else { - pFormFiller->RestoreState(pData->pPageView); - bRC = false; - } + PDFSDK_FieldAction fa; + fa.bModifier = m_pFormFillEnv->IsCTRLKeyDown(nFlag); + fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(nFlag); + fa.sChange = strChange; + fa.sChangeEx = strChangeEx; + fa.bKeyDown = bKeyDown; + fa.bWillCommit = false; + fa.bRC = true; + fa.nSelStart = nSelStart; + fa.nSelEnd = nSelEnd; - if (pFormFillEnv->GetFocusAnnot() != pData->pWidget) { - pFormFiller->CommitData(pData->pPageView, nFlag); - bExit = true; - } - } else { - if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { - bExit = true; - m_bNotifying = false; - return; - } - } + pFormFiller->GetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); + pFormFiller->SaveState(pData->pPageView); - m_bNotifying = false; - } + CPDFSDK_Annot::ObservedPtr pObserved(pData->pWidget); + if (!pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, + pData->pPageView)) { + if (!IsValidAnnot(pData->pPageView, pData->pWidget)) + bExit = true; + return; + } + + if (!pObserved || !IsValidAnnot(pData->pPageView, pData->pWidget)) { + bExit = true; + return; } + + if (nAge != pData->pWidget->GetAppearanceAge()) { + CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow( + pData->pPageView, nValueAge == pData->pWidget->GetValueAge()); + pData = reinterpret_cast<CFFL_PrivateData*>(pWnd->GetAttachedData()); + bExit = true; + } + + if (fa.bRC) + pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); + else + pFormFiller->RestoreState(pData->pPageView); + bRC = false; + + if (pFormFillEnv->GetFocusAnnot() == pData->pWidget) + return; + + pFormFiller->CommitData(pData->pPageView, nFlag); + bExit = true; } |