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_textprovider.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'xfa/fxfa/cxfa_textprovider.cpp') diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp index 5e242a459b..4795ab8cfb 100644 --- a/xfa/fxfa/cxfa_textprovider.cpp +++ b/xfa/fxfa/cxfa_textprovider.cpp @@ -27,9 +27,14 @@ #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/cxfa_fontmgr.h" #include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h" +#include "xfa/fxfa/parser/cxfa_caption.h" +#include "xfa/fxfa/parser/cxfa_font.h" +#include "xfa/fxfa/parser/cxfa_items.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" #include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_para.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" @@ -38,8 +43,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { if (m_eType == XFA_TEXTPROVIDERTYPE_Text) { CXFA_Node* pElementNode = m_pWidgetAcc->GetNode(); - CXFA_Node* pValueNode = - pElementNode->GetChild(0, XFA_Element::Value, false); + CXFA_Value* pValueNode = + pElementNode->GetChild(0, XFA_Element::Value, false); if (!pValueNode) return nullptr; @@ -72,13 +77,14 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { } if (m_eType == XFA_TEXTPROVIDERTYPE_Caption) { - CXFA_Node* pCaptionNode = - m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption, false); + CXFA_Caption* pCaptionNode = + m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption, + false); if (!pCaptionNode) return nullptr; - CXFA_Node* pValueNode = - pCaptionNode->GetChild(0, XFA_Element::Value, false); + CXFA_Value* pValueNode = + pCaptionNode->GetChild(0, XFA_Element::Value, false); if (!pValueNode) return nullptr; @@ -93,8 +99,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) { return pChildNode; } - CXFA_Node* pItemNode = - m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Items, false); + CXFA_Items* pItemNode = m_pWidgetAcc->GetNode()->GetChild( + 0, XFA_Element::Items, false); if (!pItemNode) return nullptr; @@ -115,19 +121,19 @@ CXFA_ParaData CXFA_TextProvider::GetParaData() { if (m_eType == XFA_TEXTPROVIDERTYPE_Text) return m_pWidgetAcc->GetParaData(); - CXFA_Node* pNode = - m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption, false); - return CXFA_ParaData(pNode->GetChild(0, XFA_Element::Para, false)); + CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild( + 0, XFA_Element::Caption, false); + return CXFA_ParaData(pNode->GetChild(0, XFA_Element::Para, false)); } CXFA_FontData CXFA_TextProvider::GetFontData() { if (m_eType == XFA_TEXTPROVIDERTYPE_Text) return m_pWidgetAcc->GetFontData(false); - CXFA_Node* pNode = - m_pWidgetAcc->GetNode()->GetChild(0, XFA_Element::Caption, false); - pNode = pNode->GetChild(0, XFA_Element::Font, false); - return pNode ? CXFA_FontData(pNode) : m_pWidgetAcc->GetFontData(false); + CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild( + 0, XFA_Element::Caption, false); + CXFA_Font* font = pNode->GetChild(0, XFA_Element::Font, false); + return font ? CXFA_FontData(font) : m_pWidgetAcc->GetFontData(false); } bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() { -- cgit v1.2.3