summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_nodelocale.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-12-14 20:43:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-14 20:43:53 +0000
commit51ef4a6ca3b4ae9b618cb1c96f84697a2bf4a2b1 (patch)
treea365a0c3f25fff2f6511fbc23fd0e4d6b8d4eada /xfa/fxfa/parser/cxfa_nodelocale.cpp
parent8489e901fb16fe508e23a36cd3eff93d8332c2a2 (diff)
downloadpdfium-51ef4a6ca3b4ae9b618cb1c96f84697a2bf4a2b1.tar.xz
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 <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_nodelocale.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_nodelocale.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/xfa/fxfa/parser/cxfa_nodelocale.cpp b/xfa/fxfa/parser/cxfa_nodelocale.cpp
index 54440d5834..e7bba363cf 100644
--- a/xfa/fxfa/parser/cxfa_nodelocale.cpp
+++ b/xfa/fxfa/parser/cxfa_nodelocale.cpp
@@ -9,6 +9,8 @@
#include <utility>
#include "core/fxcrt/xml/cxml_element.h"
+#include "xfa/fxfa/parser/cxfa_calendarsymbols.h"
+#include "xfa/fxfa/parser/cxfa_datetimesymbols.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -69,8 +71,9 @@ WideString CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const {
}
WideString CXFA_NodeLocale::GetDateTimeSymbols() const {
- CXFA_Node* pSymbols =
- m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols, false)
+ CXFA_DateTimeSymbols* pSymbols =
+ m_pLocale ? m_pLocale->GetChild<CXFA_DateTimeSymbols>(
+ 0, XFA_Element::DateTimeSymbols, false)
: nullptr;
return pSymbols ? pSymbols->JSObject()->GetContent(false) : WideString();
}
@@ -147,7 +150,7 @@ CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent,
WideString CXFA_NodeLocale::GetSymbol(XFA_Element eElement,
const WideStringView& symbol_type) const {
CXFA_Node* pSymbols =
- m_pLocale ? m_pLocale->GetChild(0, eElement, false) : nullptr;
+ m_pLocale ? m_pLocale->GetChild<CXFA_Node>(0, eElement, false) : nullptr;
CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type);
return pSymbol ? pSymbol->JSObject()->GetContent(false) : WideString();
}
@@ -155,8 +158,9 @@ WideString CXFA_NodeLocale::GetSymbol(XFA_Element eElement,
WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
int index,
bool bAbbr) const {
- CXFA_Node* pCalendar =
- m_pLocale ? m_pLocale->GetChild(0, XFA_Element::CalendarSymbols, false)
+ CXFA_CalendarSymbols* pCalendar =
+ m_pLocale ? m_pLocale->GetChild<CXFA_CalendarSymbols>(
+ 0, XFA_Element::CalendarSymbols, false)
: nullptr;
if (!pCalendar)
return WideString();
@@ -164,7 +168,8 @@ WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement);
for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) {
if (pNode->JSObject()->GetBoolean(XFA_Attribute::Abbr) == bAbbr) {
- CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown, false);
+ CXFA_Node* pSymbol =
+ pNode->GetChild<CXFA_Node>(index, XFA_Element::Unknown, false);
return pSymbol ? pSymbol->JSObject()->GetContent(false) : WideString();
}
}