Index: xfa/fxfa/app/xfa_ffnotify.cpp |
diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp |
index ac4cc27f8d4672465a1fde85bba61665091d2eef..cb935b94b0e5a4dd630c24d01707b623bd4b571e 100644 |
--- a/xfa/fxfa/app/xfa_ffnotify.cpp |
+++ b/xfa/fxfa/app/xfa_ffnotify.cpp |
@@ -39,114 +39,54 @@ static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = { |
CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} |
CXFA_FFNotify::~CXFA_FFNotify() {} |
+ |
void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender, |
- XFA_PAGEEVENT eEvent, |
- void* pParam) { |
+ uint32_t dwEvent) { |
CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); |
- if (!pDocView) { |
+ if (pDocView) |
+ pDocView->OnPageEvent(pSender, dwEvent); |
+} |
+ |
+void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender, |
+ const FX_WCHAR* pLabel, |
+ const FX_WCHAR* pValue, |
+ int32_t iIndex) { |
+ CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); |
+ if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) { |
return; |
} |
- pDocView->OnPageEvent(pSender, eEvent, (int32_t)(uintptr_t)pParam); |
-} |
-void CXFA_FFNotify::OnNodeEvent(CXFA_Node* pSender, |
- XFA_NODEEVENT eEvent, |
- void* pParam, |
- void* pParam2, |
- void* pParam3, |
- void* pParam4) { |
- switch (eEvent) { |
- case XFA_NODEEVENT_Ready: |
- OnNodeReady(pSender); |
- break; |
- case XFA_NODEEVENT_ValueChanging: |
- OnValueChanging(pSender, pParam, pParam2); |
- break; |
- case XFA_NODEEVENT_ValueChanged: |
- OnValueChanged(pSender, pParam, pParam2, pParam3, pParam4); |
- break; |
- case XFA_NODEEVENT_ChildAdded: |
- OnChildAdded(pSender, pParam, pParam2); |
- break; |
- case XFA_NODEEVENT_ChildRemoved: |
- OnChildRemoved(pSender, pParam, pParam2); |
- break; |
+ CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL); |
+ while (pWidget) { |
Tom Sepez
2016/04/14 22:45:44
nit: rewrite loop in while ((pWidget = pWidgetAcc-
Lei Zhang
2016/04/15 01:16:40
Done. Same for line 77.
|
+ if (pWidget->IsLoaded()) { |
+ if (pWidgetAcc->IsListBox()) { |
+ static_cast<CXFA_FFListBox*>(pWidget)->InsertItem(pLabel, iIndex); |
+ } else { |
+ static_cast<CXFA_FFComboBox*>(pWidget)->InsertItem(pLabel, iIndex); |
+ } |
+ } |
+ pWidget = pWidgetAcc->GetNextWidget(pWidget); |
} |
} |
-void CXFA_FFNotify::OnWidgetDataEvent(CXFA_WidgetData* pSender, |
- uint32_t dwEvent, |
- void* pParam, |
- void* pAdditional, |
- void* pAdditional2) { |
+ |
+void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender, |
+ int32_t iIndex) { |
CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); |
- switch (dwEvent) { |
- case XFA_WIDGETEVENT_ListItemAdded: { |
- if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) { |
- return; |
- } |
- FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify(); |
- CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL); |
- if (!pWidget) { |
- if (bStaticNotify) { |
- pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent( |
- pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam, |
- pAdditional); |
- } |
- return; |
- } |
- while (pWidget) { |
- if (pWidget->IsLoaded()) { |
- if (pWidgetAcc->IsListBox()) { |
- static_cast<CXFA_FFListBox*>(pWidget) |
- ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam, |
- (int32_t)(uintptr_t)pAdditional2); |
- } else { |
- static_cast<CXFA_FFComboBox*>(pWidget) |
- ->InsertItem((const CFX_WideStringC&)(const FX_WCHAR*)pParam, |
- (int32_t)(uintptr_t)pAdditional2); |
- } |
- } |
- if (bStaticNotify) { |
- pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent( |
- pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemAdded, pParam, |
- pAdditional); |
- } |
- pWidget = pWidgetAcc->GetNextWidget(pWidget); |
- } |
- } break; |
- case XFA_WIDGETEVENT_ListItemRemoved: { |
- if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) { |
- return; |
- } |
- FX_BOOL bStaticNotify = pWidgetAcc->GetDocView()->IsStaticNotify(); |
- CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL); |
- if (!pWidget) { |
- if (bStaticNotify) { |
- pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent( |
- pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam, |
- pAdditional); |
- } |
- return; |
- } |
- while (pWidget) { |
- if (pWidget->IsLoaded()) { |
- if (pWidgetAcc->IsListBox()) { |
- static_cast<CXFA_FFListBox*>(pWidget) |
- ->DeleteItem((int32_t)(uintptr_t)pParam); |
- } else { |
- static_cast<CXFA_FFComboBox*>(pWidget) |
- ->DeleteItem((int32_t)(uintptr_t)pParam); |
- } |
- } |
- if (bStaticNotify) { |
- pWidgetAcc->GetDoc()->GetDocProvider()->WidgetEvent( |
- pWidget, pWidgetAcc, XFA_WIDGETEVENT_ListItemRemoved, pParam, |
- pAdditional); |
- } |
- pWidget = pWidgetAcc->GetNextWidget(pWidget); |
+ if (pWidgetAcc->GetUIType() != XFA_ELEMENT_ChoiceList) { |
+ return; |
+ } |
+ CXFA_FFWidget* pWidget = pWidgetAcc->GetNextWidget(NULL); |
+ while (pWidget) { |
+ if (pWidget->IsLoaded()) { |
+ if (pWidgetAcc->IsListBox()) { |
+ static_cast<CXFA_FFListBox*>(pWidget)->DeleteItem(iIndex); |
+ } else { |
+ static_cast<CXFA_FFComboBox*>(pWidget)->DeleteItem(iIndex); |
} |
- } break; |
+ } |
+ pWidget = pWidgetAcc->GetNextWidget(pWidget); |
} |
} |
+ |
CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { |
CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); |
CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
@@ -233,30 +173,7 @@ CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { |
pWidget->SetDocView(pDocView); |
return pWidget; |
} |
-void CXFA_FFNotify::OnLayoutEvent(CXFA_LayoutProcessor* pLayout, |
- CXFA_LayoutItem* pSender, |
- XFA_LAYOUTEVENT eEvent, |
- void* pParam, |
- void* pParam2) { |
- CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
- if (!pDocView || !XFA_GetWidgetFromLayoutItem(pSender)) { |
- return; |
- } |
- switch (eEvent) { |
- case XFA_LAYOUTEVENT_ItemAdded: |
- OnLayoutItemAdd(pDocView, pLayout, pSender, pParam, pParam2); |
- break; |
- case XFA_LAYOUTEVENT_ItemRemoving: |
- OnLayoutItemRemoving(pDocView, pLayout, pSender, pParam, pParam2); |
- break; |
- case XFA_LAYOUTEVENT_RectChanged: |
- OnLayoutItemRectChanged(pDocView, pLayout, pSender, pParam, pParam2); |
- break; |
- case XFA_LAYOUTEVENT_StatusChanged: |
- OnLayoutItemStatustChanged(pDocView, pLayout, pSender, pParam, pParam2); |
- break; |
- } |
-} |
+ |
void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, |
FX_FLOAT& fCalcWidth, |
FX_FLOAT& fCalcHeight) { |
@@ -400,6 +317,7 @@ void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { |
pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr; |
pDocView->SetFocusWidgetAcc(pAcc); |
} |
+ |
void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { |
CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
if (!pDocView) { |
@@ -422,9 +340,8 @@ void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { |
break; |
} |
} |
-void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, |
- void* pParam, |
- void* pParam2) { |
+ |
+void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) { |
CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
if (!pDocView) { |
return; |
@@ -435,7 +352,6 @@ void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, |
uint32_t dwPacket = pSender->GetPacketID(); |
if (dwPacket & XFA_XDPPACKET_Datasets) { |
} else if (pSender->IsFormContainer()) { |
- XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam; |
if (eAttr == XFA_ATTRIBUTE_Presence) { |
CXFA_WidgetAcc* pWidgetAcc = |
static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData()); |
@@ -451,20 +367,17 @@ void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, |
} |
} |
} |
+ |
void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, |
- void* pParam, |
- void* pParam2, |
- void* pParam3, |
- void* pParam4) { |
+ XFA_ATTRIBUTE eAttr, |
+ CXFA_Node* pParentNode, |
+ CXFA_Node* pWidgetNode) { |
CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
if (!pDocView) { |
return; |
} |
uint32_t dwPacket = pSender->GetPacketID(); |
- XFA_ATTRIBUTE eAttr = (XFA_ATTRIBUTE)(uintptr_t)pParam; |
if (dwPacket & XFA_XDPPACKET_Form) { |
- CXFA_Node* pParentNode = static_cast<CXFA_Node*>(pParam3); |
- CXFA_Node* pWidgetNode = static_cast<CXFA_Node*>(pParam4); |
XFA_ELEMENT ePType = pParentNode->GetClassID(); |
FX_BOOL bIsContainerNode = pParentNode->IsContainerNode(); |
CXFA_WidgetAcc* pWidgetAcc = |
@@ -494,18 +407,12 @@ void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, |
default: |
break; |
} |
- if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) { |
+ if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) |
bUpdateProperty = TRUE; |
- FX_BOOL bNotify = pDocView->IsStaticNotify(); |
- if (bNotify) { |
- pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_AccessChanged, NULL, pParam2, |
- NULL); |
- } |
- } |
+ |
if (eAttr == XFA_ATTRIBUTE_Value) { |
pDocView->AddCalculateNodeNotify(pSender); |
if (ePType == XFA_ELEMENT_Value || bIsContainerNode) { |
- FX_BOOL bNotify = pDocView->IsStaticNotify(); |
if (bIsContainerNode) { |
pWidgetAcc->UpdateUIDisplay(); |
pDocView->AddCalculateWidgetAcc(pWidgetAcc); |
@@ -514,10 +421,6 @@ void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, |
->GetClassID() == XFA_ELEMENT_ExclGroup) { |
pWidgetAcc->UpdateUIDisplay(); |
} |
- if (bNotify) { |
- pWidgetAcc->NotifyEvent(XFA_WIDGETEVENT_PostContentChanged, NULL, |
- NULL, NULL); |
- } |
return; |
} |
} |
@@ -538,9 +441,8 @@ void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, |
} |
} |
} |
-void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender, |
- void* pParam, |
- void* pParam2) { |
+ |
+void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { |
if (!pSender->IsFormContainer()) { |
return; |
} |
@@ -555,9 +457,8 @@ void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender, |
m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); |
} |
} |
-void CXFA_FFNotify::OnChildRemoved(CXFA_Node* pSender, |
- void* pParam, |
- void* pParam2) { |
+ |
+void CXFA_FFNotify::OnChildRemoved() { |
if (CXFA_FFDocView* pDocView = m_pDoc->GetDocView()) { |
FX_BOOL bLayoutReady = |
!(pDocView->m_bInLayoutStatus) && |
@@ -567,15 +468,20 @@ void CXFA_FFNotify::OnChildRemoved(CXFA_Node* pSender, |
} |
} |
} |
-void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView, |
- CXFA_LayoutProcessor* pLayout, |
+ |
+void CXFA_FFNotify::OnLayoutItemAdd(CXFA_LayoutProcessor* pLayout, |
CXFA_LayoutItem* pSender, |
- void* pParam, |
- void* pParam2) { |
- CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); |
- int32_t iPageIdx = (int32_t)(uintptr_t)pParam; |
+ 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 dwStatus = (uint32_t)(uintptr_t)pParam2; |
uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | |
XFA_WIDGETSTATUS_Printable; |
pWidget->ModifyStatus(dwStatus, dwFilter); |
@@ -585,8 +491,7 @@ void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView, |
(XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { |
pWidget->SetPageView(pNewPageView); |
m_pDoc->GetDocProvider()->WidgetEvent(pWidget, pWidget->GetDataAcc(), |
- XFA_WIDGETEVENT_PostAdded, |
- pNewPageView, pPrePageView); |
+ XFA_WIDGETEVENT_PostAdded); |
} |
if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || |
!(dwStatus & XFA_WIDGETSTATUS_Visible)) { |
@@ -602,47 +507,19 @@ void CXFA_FFNotify::OnLayoutItemAdd(CXFA_FFDocView* pDocView, |
} |
pWidget->AddInvalidateRect(nullptr); |
} |
-void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_FFDocView* pDocView, |
- CXFA_LayoutProcessor* pLayout, |
- CXFA_LayoutItem* pSender, |
- void* pParam, |
- void* pParam2) { |
- CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); |
+ |
+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()->WidgetEvent(pWidget, pWidget->GetDataAcc(), |
- XFA_WIDGETEVENT_PreRemoved, nullptr, |
- pWidget->GetPageView()); |
+ XFA_WIDGETEVENT_PreRemoved); |
pWidget->AddInvalidateRect(nullptr); |
} |
-void CXFA_FFNotify::OnLayoutItemRectChanged(CXFA_FFDocView* pDocView, |
- CXFA_LayoutProcessor* pLayout, |
- CXFA_LayoutItem* pSender, |
- void* pParam, |
- void* pParam2) {} |
-void CXFA_FFNotify::OnLayoutItemStatustChanged(CXFA_FFDocView* pDocView, |
- CXFA_LayoutProcessor* pLayout, |
- CXFA_LayoutItem* pSender, |
- void* pParam, |
- void* pParam2) { |
- CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(pSender); |
- if (!pWidget) { |
- return; |
- } |
- uint32_t dwStatus = (uint32_t)(uintptr_t)pParam; |
- if (dwStatus == 0) { |
- CXFA_LayoutItem* pPreItem = pSender->GetPrev(); |
- if (pPreItem) { |
- CXFA_FFWidget* pPreWidget = static_cast<CXFA_FFWidget*>(pPreItem); |
- if (pPreWidget) { |
- dwStatus = pPreWidget->GetStatus(); |
- } |
- } |
- } |
- uint32_t dwOldStatus = pWidget->GetStatus(); |
- uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | |
- XFA_WIDGETSTATUS_Printable; |
- if ((dwOldStatus & dwFilter) == dwStatus) { |
- return; |
- } |
- pWidget->ModifyStatus(dwStatus, dwFilter); |
-} |