summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp30
-rw-r--r--fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h8
-rw-r--r--xfa/fxfa/app/xfa_ffnotify.cpp6
-rw-r--r--xfa/fxfa/include/fxfa.h9
4 files changed, 28 insertions, 25 deletions
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index b2f752e8b9..4d2a559a39 100644
--- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
+++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
@@ -527,14 +527,25 @@ void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView,
}
}
-void CPDFXFA_Document::WidgetEvent(CXFA_FFWidget* hWidget,
- CXFA_WidgetAcc* pWidgetData,
- uint32_t dwEvent) {
+void CPDFXFA_Document::WidgetPostAdd(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData) {
if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget)
return;
- CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- if (!pEnv)
+ CXFA_FFPageView* pPageView = hWidget->GetPageView();
+ if (!pPageView)
+ return;
+
+ CPDFXFA_Page* pXFAPage = GetPage(pPageView);
+ if (!pXFAPage)
+ return;
+
+ m_pSDKDoc->GetPageView(pXFAPage)->AddAnnot(hWidget);
+}
+
+void CPDFXFA_Document::WidgetPreRemove(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData) {
+ if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget)
return;
CXFA_FFPageView* pPageView = hWidget->GetPageView();
@@ -546,13 +557,8 @@ void CPDFXFA_Document::WidgetEvent(CXFA_FFWidget* hWidget,
return;
CPDFSDK_PageView* pSdkPageView = m_pSDKDoc->GetPageView(pXFAPage);
- if (dwEvent == XFA_WIDGETEVENT_PostAdded) {
- pSdkPageView->AddAnnot(hWidget);
- } else if (dwEvent == XFA_WIDGETEVENT_PreRemoved) {
- CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget);
- if (pAnnot)
- pSdkPageView->DeleteAnnot(pAnnot);
- }
+ if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget))
+ pSdkPageView->DeleteAnnot(pAnnot);
}
int32_t CPDFXFA_Document::CountPages(CXFA_FFDoc* hDoc) {
diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h
index 416e4b9de3..d54b77abea 100644
--- a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h
+++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h
@@ -70,10 +70,10 @@ class CPDFXFA_Document : public IXFA_DocProvider {
// dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing
virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags);
- // dwEvent refer to XFA_WIDGETEVENT_XXX
- virtual void WidgetEvent(CXFA_FFWidget* hWidget,
- CXFA_WidgetAcc* pWidgetData,
- uint32_t dwEvent);
+ virtual void WidgetPostAdd(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData);
+ virtual void WidgetPreRemove(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData);
// return true if render it.
virtual FX_BOOL RenderCustomWidget(CXFA_FFWidget* hWidget,
diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp
index b6e64d04b7..a28888e7d8 100644
--- a/xfa/fxfa/app/xfa_ffnotify.cpp
+++ b/xfa/fxfa/app/xfa_ffnotify.cpp
@@ -481,8 +481,7 @@ void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout,
(dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) ==
(XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) {
pWidget->SetPageView(pNewPageView);
- m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
- XFA_WIDGETEVENT_PostAdded);
+ m_pDoc->GetDocProvider()->WidgetPostAdd(pWidget, pWidget->GetDataAcc());
}
if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End ||
!(dwStatus & XFA_WIDGETSTATUS_Visible)) {
@@ -510,7 +509,6 @@ void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout,
return;
pDocView->DeleteLayoutItem(pWidget);
- m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(),
- XFA_WIDGETEVENT_PreRemoved);
+ m_pDoc->GetDocProvider()->WidgetPreRemove(pWidget, pWidget->GetDataAcc());
pWidget->AddInvalidateRect(nullptr);
}
diff --git a/xfa/fxfa/include/fxfa.h b/xfa/fxfa/include/fxfa.h
index a173a0e299..582702220f 100644
--- a/xfa/fxfa/include/fxfa.h
+++ b/xfa/fxfa/include/fxfa.h
@@ -164,8 +164,6 @@ class IXFA_WidgetIterator;
#define XFA_PAGEVIEWEVENT_PostAdded 1
#define XFA_PAGEVIEWEVENT_PostRemoved 3
#define XFA_PAGEVIEWEVENT_StopLayout 4
-#define XFA_WIDGETEVENT_PostAdded 2
-#define XFA_WIDGETEVENT_PreRemoved 3
#define XFA_EVENTERROR_Success 1
#define XFA_EVENTERROR_Error -1
@@ -404,9 +402,10 @@ class IXFA_DocProvider {
CFX_PointF ptPopup,
const CFX_RectF* pRectExclude = NULL) = 0;
virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) = 0;
- virtual void WidgetEvent(CXFA_FFWidget* hWidget,
- CXFA_WidgetAcc* pWidgetData,
- uint32_t dwEvent) = 0;
+ virtual void WidgetPostAdd(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData) = 0;
+ virtual void WidgetPreRemove(CXFA_FFWidget* hWidget,
+ CXFA_WidgetAcc* pWidgetData) = 0;
virtual FX_BOOL RenderCustomWidget(CXFA_FFWidget* hWidget,
CFX_Graphics* pGS,
CFX_Matrix* pMatrix,