CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew) { ASSERT(pPageView); auto it = m_Maps.find(pPageView); const bool found = it != m_Maps.end(); CPWL_Wnd* pWnd = found ? it->second : nullptr; if (!bNew) return pWnd; if (found) { CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pWnd->GetAttachedData(); if (pPrivateData->nWidgetAge != m_pWidget->GetAppearanceAge()) { return ResetPDFWindow( pPageView, m_pWidget->GetValueAge() == pPrivateData->nValueAge); } } else { PWL_CREATEPARAM cp = GetCreateParam(); cp.hAttachedWnd = (FX_HWND)m_pWidget; CFFL_PrivateData* pPrivateData = new CFFL_PrivateData; pPrivateData->pWidget = m_pWidget; pPrivateData->pPageView = pPageView; pPrivateData->nWidgetAge = m_pWidget->GetAppearanceAge(); pPrivateData->nValueAge = 0; cp.pAttachedData = pPrivateData; pWnd = NewPDFWindow(cp, pPageView); m_Maps[pPageView] = pWnd; } return pWnd; }
CFFL_FormFiller::~CFFL_FormFiller() { for (auto& it : m_Maps) { CPWL_Wnd* pWnd = it.second; CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); pWnd->Destroy(); delete pWnd; delete pData; } m_Maps.clear(); }
void CFFL_FormFiller::DestroyPDFWindow(CPDFSDK_PageView* pPageView) { auto it = m_Maps.find(pPageView); if (it == m_Maps.end()) return; CPWL_Wnd* pWnd = it->second; CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); pWnd->Destroy(); delete pWnd; delete pData; m_Maps.erase(it); }
void SetCapture(CPWL_Wnd* pWnd) { m_aMousePath.RemoveAll(); if (pWnd) { m_pMainMouseWnd = pWnd; CPWL_Wnd* pParent = pWnd; while (pParent) { m_aMousePath.Add(pParent); pParent = pParent->GetParentWindow(); } } }
void SetFocus(CPWL_Wnd* pWnd) { m_aKeyboardPath.RemoveAll(); if (pWnd) { m_pMainKeyboardWnd = pWnd; CPWL_Wnd* pParent = pWnd; while (pParent) { m_aKeyboardPath.Add(pParent); pParent = pParent->GetParentWindow(); } pWnd->OnSetFocus(); } }
void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode, CFX_WideString & strChange, const CFX_WideString& strChangeEx, int nSelStart, int nSelEnd, FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag) { ASSERT(pPrivateData != NULL); CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData; ASSERT(pData->pWidget != NULL); CFFL_FormFiller* pFormFiller = GetFormFiller(pData->pWidget, FALSE); ASSERT(pFormFiller != NULL); if (!m_bNotifying) { if (pData->pWidget->GetAAction(CPDF_AAction::KeyStroke)) { m_bNotifying = TRUE; int nAge = pData->pWidget->GetAppearanceAge(); int nValueAge = pData->pWidget->GetValueAge(); ASSERT(pData->pPageView != NULL); 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; } } }
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, uint32_t 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; } } }