From 51ef4a6ca3b4ae9b618cb1c96f84697a2bf4a2b1 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 14 Dec 2017 20:43:53 +0000 Subject: Change CXFA_Node::GetChild to return proper types Currently CXFA_Node::GetChild always returns a CXFA_Node* object. We know the type we want when we call GetChild, so this CL changes the code to add a template parameter to GetChild and return the correct CXFA_Node subtype for the desired element. Change-Id: I5aecf2e840504235dc246483abee48e0564841fe Reviewed-on: https://pdfium-review.googlesource.com/21210 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffdocview.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'xfa/fxfa/cxfa_ffdocview.cpp') diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 30ae7124de..ed91020dff 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -29,8 +29,11 @@ #include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h" #include "xfa/fxfa/cxfa_textprovider.h" #include "xfa/fxfa/cxfa_widgetacciterator.h" +#include "xfa/fxfa/parser/cxfa_acrobat.h" #include "xfa/fxfa/parser/cxfa_binditemsdata.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" +#include "xfa/fxfa/parser/cxfa_present.h" +#include "xfa/fxfa/parser/cxfa_subform.h" #include "xfa/fxfa/parser/cxfa_validate.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" @@ -112,7 +115,8 @@ void CXFA_FFDocView::StopLayout() { if (!pRootItem) return; - CXFA_Node* pSubformNode = pRootItem->GetChild(0, XFA_Element::Subform, false); + CXFA_Subform* pSubformNode = + pRootItem->GetChild(0, XFA_Element::Subform, false); if (!pSubformNode) return; @@ -267,16 +271,16 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, CXFA_Node* pConfigItem = ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Config)); if (pConfigItem) { - CXFA_Node* pValidateNode = nullptr; - CXFA_Node* pAcrobatNode = - pConfigItem->GetChild(0, XFA_Element::Acrobat, false); - pValidateNode = - pAcrobatNode ? pAcrobatNode->GetChild(0, XFA_Element::Validate, false) + CXFA_Acrobat* pAcrobatNode = + pConfigItem->GetChild(0, XFA_Element::Acrobat, false); + CXFA_Validate* pValidateNode = + pAcrobatNode ? pAcrobatNode->GetChild( + 0, XFA_Element::Validate, false) : nullptr; if (!pValidateNode) { - CXFA_Node* pPresentNode = - pConfigItem->GetChild(0, XFA_Element::Present, false); - pValidateNode = pPresentNode ? pPresentNode->GetChild( + CXFA_Present* pPresentNode = + pConfigItem->GetChild(0, XFA_Element::Present, false); + pValidateNode = pPresentNode ? pPresentNode->GetChild( 0, XFA_Element::Validate, false) : nullptr; } @@ -295,7 +299,7 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, if (!pRootItem) return XFA_EVENTERROR_Error; - pNode = pRootItem->GetChild(0, XFA_Element::Subform, false); + pNode = pRootItem->GetChild(0, XFA_Element::Subform, false); } ExecEventActivityByDeepFirst(pNode, pParam->m_eType, pParam->m_bIsFormReady, -- cgit v1.2.3