summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/xfa_utils.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/xfa_utils.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/xfa_utils.cpp')
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 6706bb64ee..5f00f3e926 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -22,6 +22,8 @@
#include "xfa/fxfa/parser/cxfa_localevalue.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_ui.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
namespace {
@@ -422,15 +424,15 @@ int XFA_GetMaxFractionalScale() {
}
CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetData* pWidgetData) {
- CXFA_Node* pNodeValue =
- pWidgetData->GetNode()->GetChild(0, XFA_Element::Value, false);
- if (!pNodeValue) {
+ CXFA_Value* pNodeValue = pWidgetData->GetNode()->GetChild<CXFA_Value>(
+ 0, XFA_Element::Value, false);
+ if (!pNodeValue)
return CXFA_LocaleValue();
- }
+
CXFA_Node* pValueChild = pNodeValue->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pValueChild) {
+ if (!pValueChild)
return CXFA_LocaleValue();
- }
+
int32_t iVTType = XFA_VT_NULL;
switch (pValueChild->GetElementType()) {
case XFA_Element::Decimal:
@@ -564,20 +566,21 @@ void XFA_DataExporter_RegenerateFormFile(
}
bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) {
- bool bRet = false;
if (!pFieldNode)
- return bRet;
-
- CXFA_Node* pUIChild = pFieldNode->GetChild(0, XFA_Element::Ui, false);
- if (pUIChild) {
- CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (pFirstChild &&
- pFirstChild->GetElementType() == XFA_Element::ChoiceList) {
- bRet = pFirstChild->JSObject()->GetEnum(XFA_Attribute::Open) ==
- XFA_AttributeEnum::MultiSelect;
- }
+ return false;
+
+ CXFA_Ui* pUIChild = pFieldNode->GetChild<CXFA_Ui>(0, XFA_Element::Ui, false);
+ if (!pUIChild)
+ return false;
+
+ CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (!pFirstChild ||
+ pFirstChild->GetElementType() != XFA_Element::ChoiceList) {
+ return false;
}
- return bRet;
+
+ return pFirstChild->JSObject()->GetEnum(XFA_Attribute::Open) ==
+ XFA_AttributeEnum::MultiSelect;
}
int32_t XFA_MapRotation(int32_t nRotation) {