diff options
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 07d9f84916..5a375c7f2a 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -530,31 +530,38 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) { CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode(); CXFA_Node* pTopSubform = pForm->GetFirstChildByClass(XFA_Element::Subform); ASSERT(pTopSubform); + CXFA_Node* pLocaleNode = this; - bool bLocale = false; do { - bLocale = pLocaleNode->JSNode()->TryCData(XFA_Attribute::Locale, - wsLocaleName, false); - if (!bLocale) { - pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent); + pdfium::Optional<WideString> ret = + pLocaleNode->JSNode()->TryCData(XFA_Attribute::Locale, false); + if (ret) { + wsLocaleName = *ret; + return true; } - } while (pLocaleNode && pLocaleNode != pTopSubform && !bLocale); - if (bLocale) - return true; + 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; - if (pTopSubform && pTopSubform->JSNode()->TryCData(XFA_Attribute::Locale, - wsLocaleName, false)) { - return true; + + if (pTopSubform) { + pdfium::Optional<WideString> ret = + pTopSubform->JSNode()->TryCData(XFA_Attribute::Locale, false); + if (ret) { + wsLocaleName = *ret; + return true; + } } + IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale(); - if (pLocale) { - wsLocaleName = pLocale->GetName(); - return true; - } - return false; + if (!pLocale) + return false; + + wsLocaleName = pLocale->GetName(); + return true; } XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { |