std::pair<bool, bool> CFFL_InteractiveFormFiller::OnBeforeKeyStroke( const CPWL_Wnd::PrivateData* pAttached, WideString& strChange, const WideString& strChangeEx, int nSelStart, int nSelEnd, bool bKeyDown, uint32_t nFlag) { // Copy the private data since the window owning it may not survive. CFFL_PrivateData privateData = *static_cast<const CFFL_PrivateData*>(pAttached); ASSERT(privateData.pWidget); CFFL_FormFiller* pFormFiller = GetFormFiller(privateData.pWidget, false); #ifdef PDF_ENABLE_XFA if (pFormFiller->IsFieldFull(privateData.pPageView)) { CPDFSDK_Annot::ObservedPtr pObserved(privateData.pWidget); if (OnFull(&pObserved, privateData.pPageView, nFlag) || !pObserved) return {true, true}; } #endif // PDF_ENABLE_XFA if (m_bNotifying || !privateData.pWidget->GetAAction(CPDF_AAction::kKeyStroke).GetDict()) { return {true, false}; } AutoRestorer<bool> restorer(&m_bNotifying); m_bNotifying = true; uint32_t nAge = privateData.pWidget->GetAppearanceAge(); uint32_t nValueAge = privateData.pWidget->GetValueAge(); CPDFSDK_FormFillEnvironment* pFormFillEnv = privateData.pPageView->GetFormFillEnv(); CPDFSDK_FieldAction fa; fa.bModifier = CPDFSDK_FormFillEnvironment::IsCTRLKeyDown(nFlag); fa.bShift = CPDFSDK_FormFillEnvironment::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(privateData.pPageView, CPDF_AAction::kKeyStroke, fa); pFormFiller->SaveState(privateData.pPageView); CPDFSDK_Annot::ObservedPtr pObserved(privateData.pWidget); bool action_status = privateData.pWidget->OnAAction( CPDF_AAction::kKeyStroke, &fa, privateData.pPageView); if (!pObserved || !IsValidAnnot(privateData.pPageView, privateData.pWidget)) return {true, true}; if (!action_status) return {true, false}; bool bExit = false; if (nAge != privateData.pWidget->GetAppearanceAge()) { CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow( privateData.pPageView, nValueAge == privateData.pWidget->GetValueAge()); if (!pWnd) return {true, true}; privateData = *static_cast<const CFFL_PrivateData*>(pWnd->GetAttachedData()); bExit = true; } if (fa.bRC) { pFormFiller->SetActionData(privateData.pPageView, CPDF_AAction::kKeyStroke, fa); } else { pFormFiller->RestoreState(privateData.pPageView); } if (pFormFillEnv->GetFocusAnnot() == privateData.pWidget) return {false, bExit}; pFormFiller->CommitData(privateData.pPageView, nFlag); return {false, true}; }
void CFFL_IFormFiller::OnBeforeKeyStroke(void* pPrivateData, CFX_WideString& strChange, const CFX_WideString& strChangeEx, int nSelStart, int nSelEnd, FX_BOOL bKeyDown, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag) { CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; ASSERT(pData->pWidget); CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); #ifdef PDF_ENABLE_XFA if (pFormFiller->IsFieldFull(pData->pPageView)) { FX_BOOL bFullExit = FALSE; FX_BOOL bFullReset = FALSE; OnFull(pData->pWidget, pData->pPageView, bFullReset, bFullExit, nFlag); if (bFullReset || bFullExit) { bExit = TRUE; return; } } #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(); CPDFSDK_Document* pDocument = pData->pPageView->GetSDKDocument(); PDFSDK_FieldAction fa; fa.bModifier = m_pApp->FFI_IsCTRLKeyDown(nFlag); fa.bShift = m_pApp->FFI_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); if (pData->pWidget->OnAAction(CPDF_AAction::KeyStroke, fa, pData->pPageView)) { if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { bExit = TRUE; m_bNotifying = FALSE; return; } if (nAge != pData->pWidget->GetAppearanceAge()) { CPWL_Wnd* pWnd = pFormFiller->ResetPDFWindow( pData->pPageView, nValueAge == pData->pWidget->GetValueAge()); pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); bExit = TRUE; } if (fa.bRC) { pFormFiller->SetActionData(pData->pPageView, CPDF_AAction::KeyStroke, fa); bRC = FALSE; } else { pFormFiller->RestoreState(pData->pPageView); bRC = FALSE; } if (pDocument->GetFocusAnnot() != pData->pWidget) { pFormFiller->CommitData(pData->pPageView, nFlag); bExit = TRUE; } } else { if (!IsValidAnnot(pData->pPageView, pData->pWidget)) { bExit = TRUE; m_bNotifying = FALSE; return; } } m_bNotifying = FALSE; } } }