void CXFA_FFNotify::RunSubformIndexChange(CXFA_Node* pSubformNode) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) { return; } pDocView->AddIndexChangedSubform(pSubformNode); }
FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, const CFX_FloatPoint& point) { if (!pPageView || !pAnnot) return FALSE; CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); if (!pSDKDoc) return FALSE; CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); if (!pDoc) return FALSE; CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); if (!pDocView) return FALSE; CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); if (!pWidgetHandler) return FALSE; FWL_WidgetHit dwHitTest = pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); return dwHitTest != FWL_WidgetHit::Unknown; }
bool CPDFSDK_XFAWidgetHandler::HitTest(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, const CFX_FloatPoint& point) { if (!pPageView || !pAnnot) return false; CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv(); if (!pFormFillEnv) return false; CPDFXFA_Context* pContext = pFormFillEnv->GetXFAContext(); if (!pContext) return false; CXFA_FFDocView* pDocView = pContext->GetXFADocView(); if (!pDocView) return false; CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); if (!pWidgetHandler) return false; FWL_WidgetHit dwHitTest = pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); return dwHitTest != FWL_WidgetHit::Unknown; }
void CXFA_FFNotify::RunNodeInitialize(CXFA_Node* pNode) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) { return; } pDocView->AddNewFormNode(pNode); }
void CXFA_FFNotify::ResetData(CXFA_WidgetData* pWidgetData) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) { return; } pDocView->ResetWidgetData(static_cast<CXFA_WidgetAcc*>(pWidgetData)); }
void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) { if (eAttr != XFA_ATTRIBUTE_Presence) return; if (pSender->GetPacketID() & XFA_XDPPACKET_Datasets) return; if (!pSender->IsFormContainer()) return; CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) return; if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) return; CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData()); if (!pWidgetAcc) return; CXFA_FFWidget* pWidget = nullptr; while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { if (pWidget->IsLoaded()) pWidget->AddInvalidateRect(); } }
CXFA_Node* CXFA_FFNotify::GetFocusWidgetNode() { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) { return nullptr; } CXFA_WidgetAcc* pAcc = pDocView->GetFocusWidgetAcc(); return pAcc ? pAcc->GetNode() : nullptr; }
void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) { return; } CXFA_WidgetAcc* pAcc = pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr; pDocView->SetFocusWidgetAcc(pAcc); }
void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) { if (hWidget->GetDataAcc()->GetUIType() != XFA_Element::ChoiceList) { return; } CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); pDocView->LockUpdate(); static_cast<CXFA_FFComboBox*>(hWidget)->OpenDropDownList(); pDocView->UnlockUpdate(); pDocView->UpdateDocView(); }
void CXFA_FFNotify::OnChildRemoved() { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) return; bool bLayoutReady = !(pDocView->m_bInLayoutStatus) && (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); if (bLayoutReady) m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); }
void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) { return; } CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); if (!pWidgetAcc) { return; } pDocView->AddCalculateWidgetAcc(pWidgetAcc); pDocView->AddValidateWidget(pWidgetAcc); }
int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, FX_BOOL bIsFormReady, FX_BOOL bRecursive, CXFA_WidgetAcc* pExclude) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) { return XFA_EVENTERROR_NotExist; } return pDocView->ExecEventActivityByDeepFirst( pFormNode, eEventType, bIsFormReady, bRecursive, pExclude ? pExclude->GetNode() : nullptr); }
void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, CXFA_LayoutItem* pSender) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); if (!pDocView) return; CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); if (!pWidget) return; pDocView->DeleteLayoutItem(pWidget); m_pDoc->GetDocProvider()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); pWidget->AddInvalidateRect(nullptr); }
void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { if (!pSender->IsFormContainer()) { return; } CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) { return; } FX_BOOL bLayoutReady = !(pDocView->m_bInLayoutStatus) && (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); if (bLayoutReady) m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); }
FX_BOOL CPDFXFA_Page::LoadXFAPageView() { if (!m_pDocument) return FALSE; CXFA_FFDoc* pXFADoc = m_pDocument->GetXFADoc(); if (!pXFADoc) return FALSE; CXFA_FFDocView* pXFADocView = m_pDocument->GetXFADocView(); if (!pXFADocView) return FALSE; CXFA_FFPageView* pPageView = pXFADocView->GetPageView(m_iPageIndex); if (!pPageView) return FALSE; m_pXFAPageView = pPageView; return TRUE; }
CXFA_FFWidgetHandler* CPDFSDK_XFAWidgetHandler::GetXFAWidgetHandler( CPDFSDK_Annot* pAnnot) { if (!pAnnot) return nullptr; CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); if (!pPageView) return nullptr; CPDFSDK_FormFillEnvironment* pFormFillEnv = pPageView->GetFormFillEnv(); if (!pFormFillEnv) return nullptr; CPDFXFA_Context* pDoc = pFormFillEnv->GetXFAContext(); if (!pDoc) return nullptr; CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); if (!pDocView) return nullptr; return pDocView->GetWidgetHandler(); }
CXFA_FFWidgetHandler* CPDFSDK_XFAAnnotHandler::GetXFAWidgetHandler( CPDFSDK_Annot* pAnnot) { if (!pAnnot) return nullptr; CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); if (!pPageView) return nullptr; CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); if (!pSDKDoc) return nullptr; CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); if (!pDoc) return nullptr; CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); if (!pDocView) return nullptr; return pDocView->GetWidgetHandler(); }
void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, CXFA_LayoutItem* pSender, int32_t iPageIdx, uint32_t dwStatus) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); if (!pDocView) return; CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); if (!pWidget) return; CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); uint32_t dwFilter = XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable; pWidget->ModifyStatus(dwStatus, dwFilter); CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); if (pPrePageView != pNewPageView || (dwStatus & (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) == (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) { pWidget->SetPageView(pNewPageView); m_pDoc->GetDocProvider()->WidgetPostAdd(pWidget, pWidget->GetDataAcc()); } if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || !(dwStatus & XFA_WidgetStatus_Visible)) { return; } if (pWidget->IsLoaded()) { CFX_RectF rtOld; pWidget->GetWidgetRect(rtOld); if (rtOld != pWidget->ReCacheWidgetRect()) pWidget->PerformLayout(); } else { pWidget->LoadWidget(); } pWidget->AddInvalidateRect(nullptr); }
void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) { CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); if (!pFormFillEnv) return; if (m_pContext->GetLoadStatus() == FXFA_LOADSTATUS_LOADING || m_pContext->GetLoadStatus() == FXFA_LOADSTATUS_CLOSING || XFA_PAGEVIEWEVENT_StopLayout != dwFlags) return; int nNewCount = m_pContext->GetPageCount(); if (nNewCount == m_pContext->GetOriginalPageCount()) return; CXFA_FFDocView* pXFADocView = m_pContext->GetXFADocView(); if (!pXFADocView) return; for (int iPageIter = 0; iPageIter < m_pContext->GetOriginalPageCount(); iPageIter++) { CPDFXFA_Page* pPage = (*m_pContext->GetXFAPageList())[iPageIter]; if (!pPage) continue; m_pContext->GetFormFillEnv()->RemovePageView(pPage); pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); } int flag = (nNewCount < m_pContext->GetOriginalPageCount()) ? FXFA_PAGEVIEWEVENT_POSTREMOVED : FXFA_PAGEVIEWEVENT_POSTADDED; int count = FXSYS_abs(nNewCount - m_pContext->GetOriginalPageCount()); m_pContext->SetOriginalPageCount(nNewCount); pFormFillEnv->PageEvent(count, flag); }
CXFA_FFWidgetHandler* CXFA_FFNotify::GetWidgetHandler() { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); return pDocView ? pDocView->GetWidgetHandler() : nullptr; }
DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, double page_x, double page_y) { if (!hHandle) return -1; CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (pPage) { CPDF_InterForm interform(pPage->m_pDocument); CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint(pPage, static_cast<FX_FLOAT>(page_x), static_cast<FX_FLOAT>(page_y), nullptr); if (!pFormCtrl) return -1; CPDF_FormField* pFormField = pFormCtrl->GetField(); return pFormField ? pFormField->GetFieldType() : -1; } #ifdef PDF_ENABLE_XFA CPDFXFA_Page* pXFAPage = UnderlyingFromFPDFPage(page); if (!pXFAPage) return -1; CXFA_FFPageView* pPageView = pXFAPage->GetXFAPageView(); if (!pPageView) return -1; CXFA_FFDocView* pDocView = pPageView->GetDocView(); if (!pDocView) return -1; CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); if (!pWidgetHandler) return -1; std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, XFA_WidgetStatus_Viewable)); if (!pWidgetIterator) return -1; CXFA_FFWidget* pXFAAnnot = pWidgetIterator->MoveToNext(); while (pXFAAnnot) { CFX_RectF rcBBox; pXFAAnnot->GetBBox(rcBBox, 0); CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, rcBBox.top + rcBBox.height); rcWidget.left -= 1.0f; rcWidget.right += 1.0f; rcWidget.bottom -= 1.0f; rcWidget.top += 1.0f; if (rcWidget.Contains(static_cast<FX_FLOAT>(page_x), static_cast<FX_FLOAT>(page_y))) { return FPDF_FORMFIELD_XFA; } pXFAAnnot = pWidgetIterator->MoveToNext(); } #endif // PDF_ENABLE_XFA return -1; }
int32_t CXFA_FFNotify::GetLayoutStatus() { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); return pDocView ? pDocView->GetLayoutStatus() : 0; }
void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr, CXFA_Node* pParentNode, CXFA_Node* pWidgetNode) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) return; if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) { if (eAttr == XFA_ATTRIBUTE_Value) pDocView->AddCalculateNodeNotify(pSender); return; } XFA_Element eType = pParentNode->GetElementType(); FX_BOOL bIsContainerNode = pParentNode->IsContainerNode(); CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); if (!pWidgetAcc) return; bool bUpdateProperty = false; pDocView->SetChangeMark(); switch (eType) { case XFA_Element::Caption: { CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); if (!pCapOut) return; pCapOut->Unload(); } break; case XFA_Element::Ui: case XFA_Element::Para: bUpdateProperty = true; break; default: break; } if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) bUpdateProperty = true; if (eAttr == XFA_ATTRIBUTE_Value) { pDocView->AddCalculateNodeNotify(pSender); if (eType == XFA_Element::Value || bIsContainerNode) { if (bIsContainerNode) { pWidgetAcc->UpdateUIDisplay(); pDocView->AddCalculateWidgetAcc(pWidgetAcc); pDocView->AddValidateWidget(pWidgetAcc); } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) ->GetElementType() == XFA_Element::ExclGroup) { pWidgetAcc->UpdateUIDisplay(); } return; } } CXFA_FFWidget* pWidget = nullptr; while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { if (!pWidget->IsLoaded()) continue; if (bUpdateProperty) pWidget->UpdateWidgetProperty(); pWidget->PerformLayout(); pWidget->AddInvalidateRect(); } }
void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); if (pDocView) pDocView->OnPageEvent(pSender, dwEvent); }