summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fxjs/cjx_node.cpp28
-rw-r--r--fxjs/cjx_node.h5
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp9
-rw-r--r--xfa/fxfa/parser/cxfa_calculatedata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_captiondata.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_filldata.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_fontdata.cpp16
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp25
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp32
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.h2
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp28
-rw-r--r--xfa/fxfa/parser/cxfa_paradata.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp81
13 files changed, 127 insertions, 141 deletions
diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp
index 0e0f2d0274..860171a6f1 100644
--- a/fxjs/cjx_node.cpp
+++ b/fxjs/cjx_node.cpp
@@ -270,11 +270,12 @@ bool CJX_Node::GetAttribute(XFA_Attribute eAttr,
}
switch (eType) {
case XFA_AttributeType::Enum: {
- XFA_ATTRIBUTEENUM eValue;
- if (!TryEnum(pAttr->eName, eValue, bUseDefault))
+ pdfium::Optional<XFA_ATTRIBUTEENUM> value =
+ TryEnum(pAttr->eName, bUseDefault);
+ if (!value)
return false;
- wsValue = GetAttributeEnumByID(eValue)->pName;
+ wsValue = GetAttributeEnumByID(*value)->pName;
return true;
}
case XFA_AttributeType::CData: {
@@ -3053,24 +3054,18 @@ pdfium::Optional<int32_t> CJX_Node::TryInteger(XFA_Attribute eAttr,
return GetXFANode()->GetDefaultInteger(eAttr);
}
-bool CJX_Node::TryEnum(XFA_Attribute eAttr,
- XFA_ATTRIBUTEENUM& eValue,
- bool bUseDefault) {
+pdfium::Optional<XFA_ATTRIBUTEENUM> CJX_Node::TryEnum(XFA_Attribute eAttr,
+ bool bUseDefault) {
void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr);
void* pValue = nullptr;
if (GetMapModuleValue(pKey, pValue)) {
- eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue;
- return true;
+ return {
+ static_cast<XFA_ATTRIBUTEENUM>(reinterpret_cast<uintptr_t>(pValue))};
}
if (!bUseDefault)
- return false;
-
- pdfium::Optional<XFA_ATTRIBUTEENUM> ret = GetXFANode()->GetDefaultEnum(eAttr);
- if (!ret)
- return false;
+ return {};
- eValue = *ret;
- return true;
+ return GetXFANode()->GetDefaultEnum(eAttr);
}
bool CJX_Node::SetEnum(XFA_Attribute eAttr,
@@ -3081,8 +3076,7 @@ bool CJX_Node::SetEnum(XFA_Attribute eAttr,
}
XFA_ATTRIBUTEENUM CJX_Node::GetEnum(XFA_Attribute eAttr) {
- XFA_ATTRIBUTEENUM eValue;
- return TryEnum(eAttr, eValue, true) ? eValue : XFA_ATTRIBUTEENUM_Unknown;
+ return TryEnum(eAttr, true).value_or(XFA_ATTRIBUTEENUM_Unknown);
}
bool CJX_Node::SetMeasure(XFA_Attribute eAttr,
diff --git a/fxjs/cjx_node.h b/fxjs/cjx_node.h
index 6c95673d25..fca3c9f8a7 100644
--- a/fxjs/cjx_node.h
+++ b/fxjs/cjx_node.h
@@ -80,9 +80,8 @@ class CJX_Node : public CJX_Object {
bool bScriptModify);
WideString GetCData(XFA_Attribute eAttr);
- bool TryEnum(XFA_Attribute eAttr,
- XFA_ATTRIBUTEENUM& eValue,
- bool bUseDefault);
+ pdfium::Optional<XFA_ATTRIBUTEENUM> TryEnum(XFA_Attribute eAttr,
+ bool bUseDefault);
bool SetEnum(XFA_Attribute eAttr, XFA_ATTRIBUTEENUM eValue, bool bNotify);
XFA_ATTRIBUTEENUM GetEnum(XFA_Attribute eAttr);
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index a7d28cb5aa..a579646fd9 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -1275,11 +1275,10 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) {
XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode();
bool bCanSplitNoContent = false;
- XFA_ATTRIBUTEENUM eLayoutMode;
- GetNode()
- ->GetNodeItem(XFA_NODEITEM_Parent)
- ->JSNode()
- ->TryEnum(XFA_Attribute::Layout, eLayoutMode, true);
+ XFA_ATTRIBUTEENUM eLayoutMode = GetNode()
+ ->GetNodeItem(XFA_NODEITEM_Parent)
+ ->JSNode()
+ ->GetEnum(XFA_Attribute::Layout);
if ((eLayoutMode == XFA_ATTRIBUTEENUM_Position ||
eLayoutMode == XFA_ATTRIBUTEENUM_Tb ||
eLayoutMode == XFA_ATTRIBUTEENUM_Row ||
diff --git a/xfa/fxfa/parser/cxfa_calculatedata.cpp b/xfa/fxfa/parser/cxfa_calculatedata.cpp
index ef152f48d7..b468be77db 100644
--- a/xfa/fxfa/parser/cxfa_calculatedata.cpp
+++ b/xfa/fxfa/parser/cxfa_calculatedata.cpp
@@ -13,9 +13,9 @@ CXFA_CalculateData::CXFA_CalculateData(CXFA_Node* pNode)
: CXFA_DataData(pNode) {}
int32_t CXFA_CalculateData::GetOverride() {
- XFA_ATTRIBUTEENUM eAtt = XFA_ATTRIBUTEENUM_Error;
- m_pNode->JSNode()->TryEnum(XFA_Attribute::Override, eAtt, false);
- return eAtt;
+ return m_pNode->JSNode()
+ ->TryEnum(XFA_Attribute::Override, false)
+ .value_or(XFA_ATTRIBUTEENUM_Error);
}
CXFA_ScriptData CXFA_CalculateData::GetScriptData() {
diff --git a/xfa/fxfa/parser/cxfa_captiondata.cpp b/xfa/fxfa/parser/cxfa_captiondata.cpp
index c898a763ac..db7ca9d875 100644
--- a/xfa/fxfa/parser/cxfa_captiondata.cpp
+++ b/xfa/fxfa/parser/cxfa_captiondata.cpp
@@ -12,15 +12,15 @@
CXFA_CaptionData::CXFA_CaptionData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
int32_t CXFA_CaptionData::GetPresence() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Visible;
- m_pNode->JSNode()->TryEnum(XFA_Attribute::Presence, eAttr, true);
- return eAttr;
+ return m_pNode->JSNode()
+ ->TryEnum(XFA_Attribute::Presence, true)
+ .value_or(XFA_ATTRIBUTEENUM_Visible);
}
int32_t CXFA_CaptionData::GetPlacementType() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
- m_pNode->JSNode()->TryEnum(XFA_Attribute::Placement, eAttr, true);
- return eAttr;
+ return m_pNode->JSNode()
+ ->TryEnum(XFA_Attribute::Placement, true)
+ .value_or(XFA_ATTRIBUTEENUM_Left);
}
float CXFA_CaptionData::GetReserve() {
diff --git a/xfa/fxfa/parser/cxfa_filldata.cpp b/xfa/fxfa/parser/cxfa_filldata.cpp
index 4e1e5f1af2..da249548f9 100644
--- a/xfa/fxfa/parser/cxfa_filldata.cpp
+++ b/xfa/fxfa/parser/cxfa_filldata.cpp
@@ -86,15 +86,15 @@ int32_t CXFA_FillData::GetLinear(FX_ARGB& endColor) {
CXFA_Node* pNode =
m_pNode->JSNode()->GetProperty(0, XFA_Element::Linear, true);
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight;
- pNode->JSNode()->TryEnum(XFA_Attribute::Type, eAttr, true);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
endColor = CXFA_DataData::ToColor(wsColor->AsStringView());
}
- return eAttr;
+ return pNode->JSNode()
+ ->TryEnum(XFA_Attribute::Type, true)
+ .value_or(XFA_ATTRIBUTEENUM_ToRight);
}
int32_t CXFA_FillData::GetRadial(FX_ARGB& endColor) {
@@ -102,13 +102,13 @@ int32_t CXFA_FillData::GetRadial(FX_ARGB& endColor) {
CXFA_Node* pNode =
m_pNode->JSNode()->GetProperty(0, XFA_Element::Radial, true);
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge;
- pNode->JSNode()->TryEnum(XFA_Attribute::Type, eAttr, true);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
pdfium::Optional<WideString> wsColor =
pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
if (wsColor)
endColor = CXFA_DataData::ToColor(wsColor->AsStringView());
}
- return eAttr;
+ return pNode->JSNode()
+ ->TryEnum(XFA_Attribute::Type, true)
+ .value_or(XFA_ATTRIBUTEENUM_ToEdge);
}
diff --git a/xfa/fxfa/parser/cxfa_fontdata.cpp b/xfa/fxfa/parser/cxfa_fontdata.cpp
index f5600f24df..5ca845f056 100644
--- a/xfa/fxfa/parser/cxfa_fontdata.cpp
+++ b/xfa/fxfa/parser/cxfa_fontdata.cpp
@@ -51,9 +51,9 @@ int32_t CXFA_FontData::GetUnderline() {
}
int32_t CXFA_FontData::GetUnderlinePeriod() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All;
- m_pNode->JSNode()->TryEnum(XFA_Attribute::UnderlinePeriod, eAttr, true);
- return eAttr;
+ return m_pNode->JSNode()
+ ->TryEnum(XFA_Attribute::UnderlinePeriod, true)
+ .value_or(XFA_ATTRIBUTEENUM_All);
}
float CXFA_FontData::GetFontSize() {
@@ -67,15 +67,13 @@ void CXFA_FontData::GetTypeface(WideString& wsTypeFace) {
}
bool CXFA_FontData::IsBold() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
- m_pNode->JSNode()->TryEnum(XFA_Attribute::Weight, eAttr, true);
- return eAttr == XFA_ATTRIBUTEENUM_Bold;
+ return m_pNode->JSNode()->GetEnum(XFA_Attribute::Weight) ==
+ XFA_ATTRIBUTEENUM_Bold;
}
bool CXFA_FontData::IsItalic() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
- m_pNode->JSNode()->TryEnum(XFA_Attribute::Posture, eAttr, true);
- return eAttr == XFA_ATTRIBUTEENUM_Italic;
+ return m_pNode->JSNode()->GetEnum(XFA_Attribute::Posture) ==
+ XFA_ATTRIBUTEENUM_Italic;
}
void CXFA_FontData::SetColor(FX_ARGB color) {
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index 332bed2a9f..bf950ab543 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -483,9 +483,10 @@ float InsertPendingItems(CXFA_ItemLayoutProcessor* pProcessor,
XFA_ATTRIBUTEENUM GetLayout(CXFA_Node* pFormNode, bool* bRootForceTb) {
*bRootForceTb = false;
- XFA_ATTRIBUTEENUM eLayoutMode;
- if (pFormNode->JSNode()->TryEnum(XFA_Attribute::Layout, eLayoutMode, false))
- return eLayoutMode;
+ pdfium::Optional<XFA_ATTRIBUTEENUM> layoutMode =
+ pFormNode->JSNode()->TryEnum(XFA_Attribute::Layout, false);
+ if (layoutMode)
+ return *layoutMode;
CXFA_Node* pParentNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent);
if (pParentNode && pParentNode->GetElementType() == XFA_Element::Form) {
@@ -510,14 +511,15 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
CXFA_Node* pKeep = pCurNode->GetFirstChildByClass(XFA_Element::Keep);
if (pKeep) {
- XFA_ATTRIBUTEENUM ePrevious;
XFA_Attribute eKeepType = XFA_Attribute::Previous;
if (!bPreFind)
eKeepType = XFA_Attribute::Next;
- if (pKeep->JSNode()->TryEnum(eKeepType, ePrevious, false)) {
- if (ePrevious == XFA_ATTRIBUTEENUM_ContentArea ||
- ePrevious == XFA_ATTRIBUTEENUM_PageArea) {
+ pdfium::Optional<XFA_ATTRIBUTEENUM> previous =
+ pKeep->JSNode()->TryEnum(eKeepType, false);
+ if (previous) {
+ if (*previous == XFA_ATTRIBUTEENUM_ContentArea ||
+ *previous == XFA_ATTRIBUTEENUM_PageArea) {
return true;
}
}
@@ -531,11 +533,12 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
if (!bPreFind)
eKeepType = XFA_Attribute::Previous;
- XFA_ATTRIBUTEENUM eNext;
- if (!pKeep->JSNode()->TryEnum(eKeepType, eNext, false))
+ pdfium::Optional<XFA_ATTRIBUTEENUM> next =
+ pKeep->JSNode()->TryEnum(eKeepType, false);
+ if (!next)
return false;
- if (eNext == XFA_ATTRIBUTEENUM_ContentArea ||
- eNext == XFA_ATTRIBUTEENUM_PageArea) {
+ if (*next == XFA_ATTRIBUTEENUM_ContentArea ||
+ *next == XFA_ATTRIBUTEENUM_PageArea) {
return true;
}
return false;
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index e301825735..72f5594982 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -645,9 +645,8 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
XFA_ATTRIBUTEENUM eCurChoice =
pNode->JSNode()->GetEnum(XFA_Attribute::PagePosition);
if (eCurChoice == XFA_ATTRIBUTEENUM_Last) {
- XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any;
- pNode->JSNode()->TryEnum(XFA_Attribute::OddOrEven, eOddOrEven,
- true);
+ XFA_ATTRIBUTEENUM eOddOrEven =
+ pNode->JSNode()->GetEnum(XFA_Attribute::OddOrEven);
XFA_ATTRIBUTEENUM eLastChoice =
pLastPageAreaLayoutItem->m_pFormNode->JSNode()->GetEnum(
XFA_Attribute::PagePosition);
@@ -1216,7 +1215,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
for (; pCurrentNode;
pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pCurrentNode->GetElementType() == XFA_Element::PageArea) {
- if (!MatchPageAreaOddOrEven(pCurrentNode, false))
+ if (!MatchPageAreaOddOrEven(pCurrentNode))
continue;
XFA_ATTRIBUTEENUM eCurPagePosition =
@@ -1266,8 +1265,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
!pFallbackPageArea) {
pFallbackPageArea = pCurrentNode;
}
- } else if (pTargetPageArea &&
- !MatchPageAreaOddOrEven(pTargetPageArea, false)) {
+ } else if (pTargetPageArea && !MatchPageAreaOddOrEven(pTargetPageArea)) {
CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass(
@@ -1304,23 +1302,17 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
return true;
}
-bool CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea,
- bool bLastMatch) {
+bool CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea) {
if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated)
return true;
- XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any;
- pPageArea->JSNode()->TryEnum(XFA_Attribute::OddOrEven, eOddOrEven, true);
- if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) {
- int32_t iPageCount = GetPageCount();
- if (bLastMatch) {
- return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 1
- : iPageCount % 2 == 0;
- }
- return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0
- : iPageCount % 2 == 1;
- }
- return true;
+ pdfium::Optional<XFA_ATTRIBUTEENUM> ret =
+ pPageArea->JSNode()->TryEnum(XFA_Attribute::OddOrEven, true);
+ if (!ret || *ret == XFA_ATTRIBUTEENUM_Any)
+ return true;
+
+ int32_t iPageLast = GetPageCount() % 2;
+ return *ret == XFA_ATTRIBUTEENUM_Odd ? iPageLast == 0 : iPageLast == 1;
}
CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea(
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.h b/xfa/fxfa/parser/cxfa_layoutpagemgr.h
index 085ea89671..7ab1d4f82c 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.h
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.h
@@ -112,7 +112,7 @@ class CXFA_LayoutPageMgr {
bool bNewPage = false,
bool bQuery = false,
XFA_ATTRIBUTEENUM ePreferredPosition = XFA_ATTRIBUTEENUM_First);
- bool MatchPageAreaOddOrEven(CXFA_Node* pPageArea, bool bLastMatch);
+ bool MatchPageAreaOddOrEven(CXFA_Node* pPageArea);
CXFA_Node* GetNextAvailPageArea(CXFA_Node* pTargetPageArea,
CXFA_Node* pTargetContentArea = nullptr,
bool bNewPage = false,
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 5a375c7f2a..90579ff5e2 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -568,9 +568,10 @@ XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
CXFA_Node* pKeep = GetFirstChildByClass(XFA_Element::Keep);
XFA_ATTRIBUTEENUM eLayoutType = JSNode()->GetEnum(XFA_Attribute::Layout);
if (pKeep) {
- XFA_ATTRIBUTEENUM eIntact;
- if (pKeep->JSNode()->TryEnum(XFA_Attribute::Intact, eIntact, false)) {
- if (eIntact == XFA_ATTRIBUTEENUM_None &&
+ pdfium::Optional<XFA_ATTRIBUTEENUM> intact =
+ pKeep->JSNode()->TryEnum(XFA_Attribute::Intact, false);
+ if (intact) {
+ if (*intact == XFA_ATTRIBUTEENUM_None &&
eLayoutType == XFA_ATTRIBUTEENUM_Row &&
m_pDocument->GetCurVersionMode() < XFA_VERSION_208) {
CXFA_Node* pPreviewRow = GetNodeItem(XFA_NODEITEM_PrevSibling,
@@ -578,24 +579,25 @@ XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
if (pPreviewRow &&
pPreviewRow->JSNode()->GetEnum(XFA_Attribute::Layout) ==
XFA_ATTRIBUTEENUM_Row) {
- XFA_ATTRIBUTEENUM eValue;
- if (pKeep->JSNode()->TryEnum(XFA_Attribute::Previous, eValue,
- false) &&
- (eValue == XFA_ATTRIBUTEENUM_ContentArea ||
- eValue == XFA_ATTRIBUTEENUM_PageArea)) {
+ pdfium::Optional<XFA_ATTRIBUTEENUM> value =
+ pKeep->JSNode()->TryEnum(XFA_Attribute::Previous, false);
+ if (value && (*value == XFA_ATTRIBUTEENUM_ContentArea ||
+ *value == XFA_ATTRIBUTEENUM_PageArea)) {
return XFA_ATTRIBUTEENUM_ContentArea;
}
+
CXFA_Node* pNode =
pPreviewRow->GetFirstChildByClass(XFA_Element::Keep);
- if (pNode &&
- pNode->JSNode()->TryEnum(XFA_Attribute::Next, eValue, false) &&
- (eValue == XFA_ATTRIBUTEENUM_ContentArea ||
- eValue == XFA_ATTRIBUTEENUM_PageArea)) {
+ pdfium::Optional<XFA_ATTRIBUTEENUM> ret;
+ if (pNode)
+ ret = pNode->JSNode()->TryEnum(XFA_Attribute::Next, false);
+ if (ret && (*ret == XFA_ATTRIBUTEENUM_ContentArea ||
+ *ret == XFA_ATTRIBUTEENUM_PageArea)) {
return XFA_ATTRIBUTEENUM_ContentArea;
}
}
}
- return eIntact;
+ return *intact;
}
}
switch (GetElementType()) {
diff --git a/xfa/fxfa/parser/cxfa_paradata.cpp b/xfa/fxfa/parser/cxfa_paradata.cpp
index 55db1313f2..a04c195ba6 100644
--- a/xfa/fxfa/parser/cxfa_paradata.cpp
+++ b/xfa/fxfa/parser/cxfa_paradata.cpp
@@ -12,15 +12,15 @@
CXFA_ParaData::CXFA_ParaData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
int32_t CXFA_ParaData::GetHorizontalAlign() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
- m_pNode->JSNode()->TryEnum(XFA_Attribute::HAlign, eAttr, true);
- return eAttr;
+ return m_pNode->JSNode()
+ ->TryEnum(XFA_Attribute::HAlign, true)
+ .value_or(XFA_ATTRIBUTEENUM_Left);
}
int32_t CXFA_ParaData::GetVerticalAlign() {
- XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Top;
- m_pNode->JSNode()->TryEnum(XFA_Attribute::VAlign, eAttr, true);
- return eAttr;
+ return m_pNode->JSNode()
+ ->TryEnum(XFA_Attribute::VAlign, true)
+ .value_or(XFA_ATTRIBUTEENUM_Top);
}
float CXFA_ParaData::GetLineHeight() {
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;
}