summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_widgetdata.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-16 14:07:17 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-16 14:07:17 +0000
commit9d47de6b27b167db46b6aba38352fc42a8b6adae (patch)
tree5e29b94aa126a890cf9c2741b505c4dce9dae42e /xfa/fxfa/parser/cxfa_widgetdata.cpp
parent0bf9aef229ae2c4f2f16ab753d6d2e9e6d718a44 (diff)
downloadpdfium-9d47de6b27b167db46b6aba38352fc42a8b6adae.tar.xz
Convert TryEnum to return an optional
This CL converts CJX_Node::TryEnum to return a pdfium::Optional instead of a bool with an out parameter. Change-Id: Icc1b063ce51656cc5e467aba358eb9e7d6754fea Reviewed-on: https://pdfium-review.googlesource.com/18512 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_widgetdata.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp81
1 files changed, 40 insertions, 41 deletions
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 90d02994de..9613383879 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -1144,25 +1144,23 @@ bool CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t* val) {
}
bool CXFA_WidgetData::GetBarcodeAttribute_Checksum(bool* val) {
- CXFA_Node* pUIChild = GetUIChild();
- XFA_ATTRIBUTEENUM eChecksum;
- if (pUIChild->JSNode()->TryEnum(XFA_Attribute::Checksum, eChecksum, true)) {
- switch (eChecksum) {
- case XFA_ATTRIBUTEENUM_None:
- *val = false;
- return true;
- case XFA_ATTRIBUTEENUM_Auto:
- *val = true;
- return true;
- case XFA_ATTRIBUTEENUM_1mod10:
- break;
- case XFA_ATTRIBUTEENUM_1mod10_1mod11:
- break;
- case XFA_ATTRIBUTEENUM_2mod10:
- break;
- default:
- break;
- }
+ pdfium::Optional<XFA_ATTRIBUTEENUM> checksum =
+ GetUIChild()->JSNode()->TryEnum(XFA_Attribute::Checksum, true);
+ if (!checksum)
+ return false;
+
+ switch (*checksum) {
+ case XFA_ATTRIBUTEENUM_None:
+ *val = false;
+ return true;
+ case XFA_ATTRIBUTEENUM_Auto:
+ *val = true;
+ return true;
+ case XFA_ATTRIBUTEENUM_1mod10:
+ case XFA_ATTRIBUTEENUM_1mod10_1mod11:
+ case XFA_ATTRIBUTEENUM_2mod10:
+ default:
+ break;
}
return false;
}
@@ -1238,28 +1236,29 @@ bool CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(bool* val) {
}
bool CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t* val) {
- XFA_ATTRIBUTEENUM eTextLocation;
- if (GetUIChild()->JSNode()->TryEnum(XFA_Attribute::TextLocation,
- eTextLocation, true)) {
- switch (eTextLocation) {
- case XFA_ATTRIBUTEENUM_None:
- *val = BC_TEXT_LOC_NONE;
- return true;
- case XFA_ATTRIBUTEENUM_Above:
- *val = BC_TEXT_LOC_ABOVE;
- return true;
- case XFA_ATTRIBUTEENUM_Below:
- *val = BC_TEXT_LOC_BELOW;
- return true;
- case XFA_ATTRIBUTEENUM_AboveEmbedded:
- *val = BC_TEXT_LOC_ABOVEEMBED;
- return true;
- case XFA_ATTRIBUTEENUM_BelowEmbedded:
- *val = BC_TEXT_LOC_BELOWEMBED;
- return true;
- default:
- break;
- }
+ pdfium::Optional<XFA_ATTRIBUTEENUM> textLocation =
+ GetUIChild()->JSNode()->TryEnum(XFA_Attribute::TextLocation, true);
+ if (!textLocation)
+ return false;
+
+ switch (*textLocation) {
+ case XFA_ATTRIBUTEENUM_None:
+ *val = BC_TEXT_LOC_NONE;
+ return true;
+ case XFA_ATTRIBUTEENUM_Above:
+ *val = BC_TEXT_LOC_ABOVE;
+ return true;
+ case XFA_ATTRIBUTEENUM_Below:
+ *val = BC_TEXT_LOC_BELOW;
+ return true;
+ case XFA_ATTRIBUTEENUM_AboveEmbedded:
+ *val = BC_TEXT_LOC_ABOVEEMBED;
+ return true;
+ case XFA_ATTRIBUTEENUM_BelowEmbedded:
+ *val = BC_TEXT_LOC_BELOWEMBED;
+ return true;
+ default:
+ break;
}
return false;
}