From 5183e8679844eeff2c5dda2a2e02762487429a1f Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 5 Jan 2018 15:46:40 -0500 Subject: Convert CXFA_Node::GetLocaleName out param to return Change-Id: Ia135db144c7037795fc1a1964b4f3eee57250caa Reviewed-on: https://pdfium-review.googlesource.com/22350 Commit-Queue: Ryan Harrison Reviewed-by: Henrique Nakashima --- xfa/fxfa/parser/cxfa_node.cpp | 39 ++++++++++++++++++--------------------- xfa/fxfa/parser/cxfa_node.h | 2 +- 2 files changed, 19 insertions(+), 22 deletions(-) (limited to 'xfa') diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 08af2004a1..141c9f1c6c 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -620,15 +620,15 @@ CXFA_WidgetAcc* CXFA_Node::GetContainerWidgetAcc() { } IFX_Locale* CXFA_Node::GetLocale() { - WideString wsLocaleName; - if (!GetLocaleName(wsLocaleName)) + Optional localeName = GetLocaleName(); + if (!localeName) return nullptr; - if (wsLocaleName == L"ambient") + if (localeName.value() == L"ambient") return GetDocument()->GetLocalMgr()->GetDefLocale(); - return GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName); + return GetDocument()->GetLocalMgr()->GetLocaleByName(localeName.value()); } -bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) { +Optional CXFA_Node::GetLocaleName() { CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode(); CXFA_Subform* pTopSubform = pForm->GetFirstChildByClass(XFA_Element::Subform); @@ -636,35 +636,32 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) { CXFA_Node* pLocaleNode = this; do { - Optional ret = + Optional localeName = pLocaleNode->JSObject()->TryCData(XFA_Attribute::Locale, false); - if (ret) { - wsLocaleName = *ret; - return true; - } + if (localeName) + return localeName; + pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent); } while (pLocaleNode && pLocaleNode != pTopSubform); CXFA_Node* pConfig = ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Config)); - wsLocaleName = GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig); - if (!wsLocaleName.IsEmpty()) - return true; + Optional localeName = { + WideString(GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig))}; + if (localeName && !localeName->IsEmpty()) + return localeName; if (pTopSubform) { - Optional ret = + localeName = pTopSubform->JSObject()->TryCData(XFA_Attribute::Locale, false); - if (ret) { - wsLocaleName = *ret; - return true; - } + if (localeName) + return localeName; } IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale(); if (!pLocale) - return false; + return {}; - wsLocaleName = pLocale->GetName(); - return true; + return {pLocale->GetName()}; } XFA_AttributeEnum CXFA_Node::GetIntact() { diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index dea53e4525..c8adbfe080 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -185,7 +185,7 @@ class CXFA_Node : public CXFA_Object { CXFA_WidgetAcc* GetWidgetAcc(); CXFA_WidgetAcc* GetContainerWidgetAcc(); IFX_Locale* GetLocale(); - bool GetLocaleName(WideString& wsLocaleName); + Optional GetLocaleName(); XFA_AttributeEnum GetIntact(); CXFA_Node* GetFirstChildByName(const WideStringView& wsNodeName) const; -- cgit v1.2.3