summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp39
-rw-r--r--xfa/fxfa/parser/cxfa_node.h2
2 files changed, 19 insertions, 22 deletions
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<WideString> 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<WideString> CXFA_Node::GetLocaleName() {
CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode();
CXFA_Subform* pTopSubform =
pForm->GetFirstChildByClass<CXFA_Subform>(XFA_Element::Subform);
@@ -636,35 +636,32 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) {
CXFA_Node* pLocaleNode = this;
do {
- Optional<WideString> ret =
+ Optional<WideString> 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<WideString> localeName = {
+ WideString(GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig))};
+ if (localeName && !localeName->IsEmpty())
+ return localeName;
if (pTopSubform) {
- Optional<WideString> 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<WideString> GetLocaleName();
XFA_AttributeEnum GetIntact();
CXFA_Node* GetFirstChildByName(const WideStringView& wsNodeName) const;