From bc948ce8d553422ef2a6285356e09e0261702583 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 22 Jan 2018 21:28:58 +0000 Subject: Remove CXFA_WidgetAcc from CXFA_FFNotify This CL updates CXFA_FFNotify to use CXFA_Node instead of CXFA_WidgetAcc in its methods. Change-Id: I5036767f439ba0794a7b2b9df1898aad8390f987 Reviewed-on: https://pdfium-review.googlesource.com/23411 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffdocview.cpp | 64 ++++++++++++++++++--------------------------- xfa/fxfa/cxfa_ffdocview.h | 7 +++-- xfa/fxfa/cxfa_ffnotify.cpp | 12 ++++----- xfa/fxfa/cxfa_ffnotify.h | 7 +++-- 4 files changed, 37 insertions(+), 53 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index b13aa3a0ac..f55733fe94 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -72,10 +72,8 @@ CXFA_FFDocView::~CXFA_FFDocView() { void CXFA_FFDocView::InitLayout(CXFA_Node* pNode) { RunBindItems(); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize, false, true, - nullptr); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange, false, true, - nullptr); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Initialize, false, true); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_IndexChange, false, true); } int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { @@ -97,7 +95,7 @@ int32_t CXFA_FFDocView::StartLayout(int32_t iStartPage) { InitCalculate(pRootItem); InitValidate(pRootItem); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, true, true, nullptr); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, true, true); m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_Start; return iStatus; } @@ -135,20 +133,15 @@ void CXFA_FFDocView::StopLayout() { InitCalculate(pPageSetNode); InitValidate(pPageSetNode); - ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, true, true, - nullptr); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, - nullptr); - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady, false, true, - nullptr); + ExecEventActivityByDeepFirst(pPageSetNode, XFA_EVENT_Ready, true, true); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocReady, false, true); RunCalculateWidgets(); RunValidate(); - if (RunLayout()) { - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, - nullptr); - } + if (RunLayout()) + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true); m_CalculateAccs.clear(); if (m_pFocusAcc && !m_pFocusWidget) @@ -188,7 +181,7 @@ void CXFA_FFDocView::UpdateDocView() { for (CXFA_Node* pNode : m_NewAddedNodes) { InitCalculate(pNode); InitValidate(pNode); - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, true, true, nullptr); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, true, true); } m_NewAddedNodes.clear(); @@ -221,30 +214,29 @@ CXFA_LayoutProcessor* CXFA_FFDocView::GetXFALayout() const { return m_pDoc->GetXFADoc()->GetDocLayout(); } -bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) { - CXFA_Node* pNode = pWidgetAcc->GetNode(); +bool CXFA_FFDocView::ResetSingleNodeData(CXFA_Node* pNode) { XFA_Element eType = pNode->GetElementType(); if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) return false; - pWidgetAcc->ResetData(); - pWidgetAcc->UpdateUIDisplay(this, nullptr); + pNode->GetWidgetAcc()->ResetData(); + pNode->GetWidgetAcc()->UpdateUIDisplay(this, nullptr); CXFA_Validate* validate = pNode->GetValidateIfExists(); if (!validate) return true; - AddValidateWidget(pWidgetAcc); + AddValidateWidget(pNode->GetWidgetAcc()); validate->SetFlag(XFA_NodeFlag_NeedsInitApp, false); return true; } -void CXFA_FFDocView::ResetWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { +void CXFA_FFDocView::ResetNode(CXFA_Node* pNode) { m_bLayoutEvent = true; bool bChanged = false; CXFA_Node* pFormNode = nullptr; - if (pWidgetAcc) { - bChanged = ResetSingleWidgetAccData(pWidgetAcc); - pFormNode = pWidgetAcc->GetNode(); + if (pNode) { + bChanged = ResetSingleNodeData(pNode); + pFormNode = pNode; } else { pFormNode = GetRootSubform(); } @@ -255,7 +247,7 @@ void CXFA_FFDocView::ResetWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { pFormNode->GetElementType() != XFA_Element::ExclGroup) { CXFA_WidgetAccIterator Iterator(pFormNode); while (CXFA_WidgetAcc* pAcc = Iterator.MoveToNext()) { - bChanged |= ResetSingleWidgetAccData(pAcc); + bChanged |= ResetSingleNodeData(pAcc->GetNode()); if (pAcc->GetNode()->GetElementType() == XFA_Element::ExclGroup) Iterator.SkipTree(); } @@ -306,7 +298,7 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, } ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady, - true, nullptr); + true); return XFA_EVENTERROR_Success; } @@ -450,9 +442,8 @@ static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, bool bIsFormReady, - bool bRecursive, - CXFA_Node* pExclude) { - if (pFormNode == pExclude) + bool bRecursive) { + if (!pFormNode) return XFA_EVENTERROR_NotExist; XFA_Element elementType = pFormNode->GetElementType(); @@ -479,7 +470,7 @@ int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, if (elementType != XFA_Element::Variables && elementType != XFA_Element::Draw) { iRet |= ExecEventActivityByDeepFirst(pNode, eEventType, bIsFormReady, - bRecursive, pExclude); + bRecursive); } } } @@ -619,8 +610,7 @@ void CXFA_FFDocView::RunDocClose() { if (!pRootItem) return; - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, false, true, - nullptr); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose, false, true); } void CXFA_FFDocView::DestroyDocView() { @@ -688,8 +678,7 @@ void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { } void CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, false, true, - nullptr); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate, false, true); } void CXFA_FFDocView::ProcessValueChanged(CXFA_WidgetAcc* widgetAcc) { @@ -703,7 +692,7 @@ bool CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc.Get())) return false; - ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, false, true, nullptr); + ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, false, true); m_ValidateAccs.clear(); return true; } @@ -727,8 +716,7 @@ bool CXFA_FFDocView::RunEventLayoutReady() { if (!pRootItem) return false; - ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true, - nullptr); + ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready, false, true); RunLayout(); return true; } diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h index 5c8f0176d8..e80a0acdca 100644 --- a/xfa/fxfa/cxfa_ffdocview.h +++ b/xfa/fxfa/cxfa_ffdocview.h @@ -54,7 +54,7 @@ class CXFA_FFDocView { int32_t CountPageViews() const; CXFA_FFPageView* GetPageView(int32_t nIndex) const; - void ResetWidgetAcc(CXFA_WidgetAcc* pWidgetAcc); + void ResetNode(CXFA_Node* pNode); int32_t ProcessWidgetEvent(CXFA_EventParam* pParam, CXFA_WidgetAcc* pWidgetAcc); CXFA_FFWidgetHandler* GetWidgetHandler(); @@ -104,8 +104,7 @@ class CXFA_FFDocView { int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, bool bIsFormReady, - bool bRecursive, - CXFA_Node* pExclude); + bool bRecursive); void AddBindItem(CXFA_BindItems* item) { m_BindItems.push_back(item); } @@ -121,7 +120,7 @@ class CXFA_FFDocView { void InitLayout(CXFA_Node* pNode); size_t RunCalculateRecursive(size_t index); void ShowNullTestMsg(); - bool ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc); + bool ResetSingleNodeData(CXFA_Node* pNode); CXFA_Subform* GetRootSubform(); UnownedPtr const m_pDoc; diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index 64acc5bfdc..0d9c8518eb 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -225,14 +225,12 @@ bool CXFA_FFNotify::RunScript(CXFA_Script* script, CXFA_Node* item) { int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, bool bIsFormReady, - bool bRecursive, - CXFA_WidgetAcc* pExclude) { + bool bRecursive) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) return XFA_EVENTERROR_NotExist; - return pDocView->ExecEventActivityByDeepFirst( - pFormNode, eEventType, bIsFormReady, bRecursive, - pExclude ? pExclude->GetNode() : nullptr); + return pDocView->ExecEventActivityByDeepFirst(pFormNode, eEventType, + bIsFormReady, bRecursive); } void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { @@ -288,12 +286,12 @@ WideString CXFA_FFNotify::GetCurrentDateTime() { dataTime.GetSecond()); } -void CXFA_FFNotify::ResetData(CXFA_WidgetAcc* pWidgetAcc) { +void CXFA_FFNotify::ResetData(CXFA_Node* pNode) { CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); if (!pDocView) return; - pDocView->ResetWidgetAcc(pWidgetAcc); + pDocView->ResetNode(pNode); } int32_t CXFA_FFNotify::GetLayoutStatus() { diff --git a/xfa/fxfa/cxfa_ffnotify.h b/xfa/fxfa/cxfa_ffnotify.h index c9a97859b6..94d8ebd552 100644 --- a/xfa/fxfa/cxfa_ffnotify.h +++ b/xfa/fxfa/cxfa_ffnotify.h @@ -57,9 +57,8 @@ class CXFA_FFNotify { bool RunScript(CXFA_Script* pScript, CXFA_Node* pFormItem); int32_t ExecEventByDeepFirst(CXFA_Node* pFormNode, XFA_EVENTTYPE eEventType, - bool bIsFormReady = false, - bool bRecursive = true, - CXFA_WidgetAcc* pExclude = nullptr); + bool bIsFormReady, + bool bRecursive); void AddCalcValidate(CXFA_Node* pNode); CXFA_FFDoc* GetHDOC(); IXFA_DocEnvironment* GetDocEnvironment() const; @@ -68,7 +67,7 @@ class CXFA_FFNotify { CXFA_FFWidget* GetHWidget(CXFA_LayoutItem* pLayoutItem); void OpenDropDownList(CXFA_FFWidget* hWidget); WideString GetCurrentDateTime(); - void ResetData(CXFA_WidgetAcc* pWidgetAcc = nullptr); + void ResetData(CXFA_Node* pNode); int32_t GetLayoutStatus(); void RunNodeInitialize(CXFA_Node* pNode); void RunSubformIndexChange(CXFA_Node* pSubformNode); -- cgit v1.2.3