summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_binddata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_binditemsdata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp62
-rw-r--r--xfa/fxfa/parser/cxfa_eventdata.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_filldata.cpp51
-rw-r--r--xfa/fxfa/parser/cxfa_fontdata.cpp17
-rw-r--r--xfa/fxfa/parser/cxfa_imagedata.cpp29
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp137
-rw-r--r--xfa/fxfa/parser/cxfa_localemgr.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp39
-rw-r--r--xfa/fxfa/parser/cxfa_scriptdata.cpp11
-rw-r--r--xfa/fxfa/parser/cxfa_strokedata.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_submitdata.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_textdata.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_validatedata.cpp14
-rw-r--r--xfa/fxfa/parser/cxfa_valuedata.cpp15
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp317
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp20
20 files changed, 385 insertions, 370 deletions
diff --git a/xfa/fxfa/parser/cxfa_binddata.cpp b/xfa/fxfa/parser/cxfa_binddata.cpp
index c47e6534d9..79f375fa6a 100644
--- a/xfa/fxfa/parser/cxfa_binddata.cpp
+++ b/xfa/fxfa/parser/cxfa_binddata.cpp
@@ -11,6 +11,8 @@
CXFA_BindData::CXFA_BindData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
void CXFA_BindData::GetPicture(WideString& wsPicture) {
- if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_Element::Picture, false))
- pPicture->JSNode()->TryContent(wsPicture, false, true);
+ CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_Element::Picture, false);
+ if (!pPicture)
+ return;
+ wsPicture = pPicture->JSNode()->GetContent(false);
}
diff --git a/xfa/fxfa/parser/cxfa_binditemsdata.cpp b/xfa/fxfa/parser/cxfa_binditemsdata.cpp
index ac6b765faa..3f0614fd6f 100644
--- a/xfa/fxfa/parser/cxfa_binditemsdata.cpp
+++ b/xfa/fxfa/parser/cxfa_binditemsdata.cpp
@@ -12,15 +12,15 @@ CXFA_BindItemsData::CXFA_BindItemsData(CXFA_Node* pNode)
: CXFA_DataData(pNode) {}
void CXFA_BindItemsData::GetLabelRef(WideString& wsLabelRef) {
- m_pNode->JSNode()->TryCData(XFA_Attribute::LabelRef, wsLabelRef, true);
+ wsLabelRef = m_pNode->JSNode()->GetCData(XFA_Attribute::LabelRef);
}
void CXFA_BindItemsData::GetValueRef(WideString& wsValueRef) {
- m_pNode->JSNode()->TryCData(XFA_Attribute::ValueRef, wsValueRef, true);
+ wsValueRef = m_pNode->JSNode()->GetCData(XFA_Attribute::ValueRef);
}
void CXFA_BindItemsData::GetRef(WideString& wsRef) {
- m_pNode->JSNode()->TryCData(XFA_Attribute::Ref, wsRef, true);
+ wsRef = m_pNode->JSNode()->GetCData(XFA_Attribute::Ref);
}
bool CXFA_BindItemsData::SetConnection(const WideString& wsConnection) {
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index c8b518c114..35ad4adccf 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -121,8 +121,9 @@ bool AttributeSaveInDataModel(CXFA_Node* pNode, XFA_Attribute eAttribute) {
}
bool ContentNodeNeedtoExport(CXFA_Node* pContentNode) {
- WideString wsContent;
- if (!pContentNode->JSNode()->TryContent(wsContent, false, false))
+ pdfium::Optional<WideString> wsContent =
+ pContentNode->JSNode()->TryContent(false, false);
+ if (!wsContent)
return false;
ASSERT(pContentNode->IsContentNode());
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index f5a72bde9a..82a71dea28 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -254,7 +254,6 @@ bool CXFA_Document::IsInteractive() {
if (!pConfig)
return false;
- WideString wsInteractive;
CXFA_Node* pPresent = pConfig->GetFirstChildByClass(XFA_Element::Present);
if (!pPresent)
return false;
@@ -266,8 +265,9 @@ bool CXFA_Document::IsInteractive() {
CXFA_Node* pFormFiller = pPDF->GetChild(0, XFA_Element::Interactive, false);
if (pFormFiller) {
m_dwDocFlags |= XFA_DOCFLAG_HasInteractive;
- if (pFormFiller->JSNode()->TryContent(wsInteractive, false, true) &&
- wsInteractive == L"1") {
+
+ WideString wsInteractive = pFormFiller->JSNode()->GetContent(false);
+ if (wsInteractive == L"1") {
m_dwDocFlags |= XFA_DOCFLAG_Interactive;
return true;
}
@@ -333,12 +333,9 @@ CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot,
CXFA_NodeIterator sIterator(pRoot);
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
- WideString wsIDVal;
- if (pNode->JSNode()->TryCData(XFA_Attribute::Id, wsIDVal, true) &&
- !wsIDVal.IsEmpty()) {
- if (wsIDVal == wsID)
- return pNode;
- }
+ WideString wsIDVal = pNode->JSNode()->GetCData(XFA_Attribute::Id);
+ if (!wsIDVal.IsEmpty() && wsIDVal == wsID)
+ return pNode;
}
return nullptr;
}
@@ -353,28 +350,28 @@ void CXFA_Document::DoProtoMerge() {
CXFA_NodeIterator sIterator(pTemplateRoot);
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
- WideString wsIDVal;
- if (pNode->JSNode()->TryCData(XFA_Attribute::Id, wsIDVal, true) &&
- !wsIDVal.IsEmpty()) {
+ WideString wsIDVal = pNode->JSNode()->GetCData(XFA_Attribute::Id);
+ if (!wsIDVal.IsEmpty())
mIDMap[FX_HashCode_GetW(wsIDVal.AsStringView(), false)] = pNode;
- }
- WideString wsUseVal;
- if (pNode->JSNode()->TryCData(XFA_Attribute::Use, wsUseVal, true) &&
- !wsUseVal.IsEmpty()) {
- sUseNodes.insert(pNode);
- } else if (pNode->JSNode()->TryCData(XFA_Attribute::Usehref, wsUseVal,
- true) &&
- !wsUseVal.IsEmpty()) {
+
+ WideString wsUseVal = pNode->JSNode()->GetCData(XFA_Attribute::Use);
+ if (!wsUseVal.IsEmpty()) {
sUseNodes.insert(pNode);
+ } else {
+ wsUseVal = pNode->JSNode()->GetCData(XFA_Attribute::Usehref);
+ if (!wsUseVal.IsEmpty())
+ sUseNodes.insert(pNode);
}
}
for (CXFA_Node* pUseHrefNode : sUseNodes) {
- WideString wsUseVal;
- WideStringView wsURI, wsID, wsSOM;
- if (pUseHrefNode->JSNode()->TryCData(XFA_Attribute::Usehref, wsUseVal,
- true) &&
- !wsUseVal.IsEmpty()) {
+ WideStringView wsURI;
+ WideStringView wsID;
+ WideStringView wsSOM;
+
+ WideString wsUseVal =
+ pUseHrefNode->JSNode()->GetCData(XFA_Attribute::Usehref);
+ if (!wsUseVal.IsEmpty()) {
auto uSharpPos = wsUseVal.Find('#');
if (!uSharpPos.has_value()) {
wsURI = wsUseVal.AsStringView();
@@ -392,13 +389,14 @@ void CXFA_Document::DoProtoMerge() {
uLen - uSharpPos.value() - 1);
}
}
- } else if (pUseHrefNode->JSNode()->TryCData(XFA_Attribute::Use, wsUseVal,
- true) &&
- !wsUseVal.IsEmpty()) {
- if (wsUseVal[0] == '#')
- wsID = WideStringView(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1);
- else
- wsSOM = WideStringView(wsUseVal.c_str(), wsUseVal.GetLength());
+ } else {
+ wsUseVal = pUseHrefNode->JSNode()->GetCData(XFA_Attribute::Use);
+ if (!wsUseVal.IsEmpty()) {
+ if (wsUseVal[0] == '#')
+ wsID = WideStringView(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1);
+ else
+ wsSOM = WideStringView(wsUseVal.c_str(), wsUseVal.GetLength());
+ }
}
if (!wsURI.IsEmpty() && wsURI != L".")
diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp
index 387b7328f0..b9b3c8c0c2 100644
--- a/xfa/fxfa/parser/cxfa_eventdata.cpp
+++ b/xfa/fxfa/parser/cxfa_eventdata.cpp
@@ -27,7 +27,7 @@ XFA_Element CXFA_EventData::GetEventType() const {
}
void CXFA_EventData::GetRef(WideString& wsRef) {
- m_pNode->JSNode()->TryCData(XFA_Attribute::Ref, wsRef, true);
+ wsRef = m_pNode->JSNode()->GetCData(XFA_Attribute::Ref);
}
CXFA_ScriptData CXFA_EventData::GetScriptData() const {
@@ -44,5 +44,5 @@ void CXFA_EventData::GetSignDataTarget(WideString& wsTarget) {
if (!pNode)
return;
- pNode->JSNode()->TryCData(XFA_Attribute::Target, wsTarget, true);
+ wsTarget = pNode->JSNode()->GetCData(XFA_Attribute::Target);
}
diff --git a/xfa/fxfa/parser/cxfa_filldata.cpp b/xfa/fxfa/parser/cxfa_filldata.cpp
index fbc79ad4d0..b55f24ad2a 100644
--- a/xfa/fxfa/parser/cxfa_filldata.cpp
+++ b/xfa/fxfa/parser/cxfa_filldata.cpp
@@ -31,9 +31,10 @@ void CXFA_FillData::SetColor(FX_ARGB color) {
FX_ARGB CXFA_FillData::GetColor(bool bText) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color, false)) {
- WideString wsColor;
- if (pNode->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false))
- return CXFA_DataData::ToColor(wsColor.AsStringView());
+ pdfium::Optional<WideString> wsColor =
+ pNode->JSNode()->TryCData(XFA_Attribute::Value, false);
+ if (wsColor)
+ return CXFA_DataData::ToColor(wsColor->AsStringView());
}
if (bText)
return 0xFF000000;
@@ -53,59 +54,63 @@ XFA_Element CXFA_FillData::GetFillType() {
}
int32_t CXFA_FillData::GetPattern(FX_ARGB& foreColor) {
+ foreColor = 0xFF000000;
+
CXFA_Node* pNode =
m_pNode->JSNode()->GetProperty(0, XFA_Element::Pattern, true);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
- WideString wsColor;
- pColor->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false);
- foreColor = CXFA_DataData::ToColor(wsColor.AsStringView());
- } else {
- foreColor = 0xFF000000;
+ pdfium::Optional<WideString> wsColor =
+ pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
+ if (wsColor)
+ foreColor = CXFA_DataData::ToColor(wsColor->AsStringView());
}
return pNode->JSNode()->GetEnum(XFA_Attribute::Type);
}
int32_t CXFA_FillData::GetStipple(FX_ARGB& stippleColor) {
+ stippleColor = 0xFF000000;
+
CXFA_Node* pNode =
m_pNode->JSNode()->GetProperty(0, XFA_Element::Stipple, true);
int32_t eAttr = 50;
pNode->JSNode()->TryInteger(XFA_Attribute::Rate, eAttr, true);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
- WideString wsColor;
- pColor->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false);
- stippleColor = CXFA_DataData::ToColor(wsColor.AsStringView());
- } else {
- stippleColor = 0xFF000000;
+ pdfium::Optional<WideString> wsColor =
+ pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
+ if (wsColor)
+ stippleColor = CXFA_DataData::ToColor(wsColor->AsStringView());
}
return eAttr;
}
int32_t CXFA_FillData::GetLinear(FX_ARGB& endColor) {
+ endColor = 0xFF000000;
+
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)) {
- WideString wsColor;
- pColor->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false);
- endColor = CXFA_DataData::ToColor(wsColor.AsStringView());
- } else {
- endColor = 0xFF000000;
+ pdfium::Optional<WideString> wsColor =
+ pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
+ if (wsColor)
+ endColor = CXFA_DataData::ToColor(wsColor->AsStringView());
}
return eAttr;
}
int32_t CXFA_FillData::GetRadial(FX_ARGB& endColor) {
+ endColor = 0xFF000000;
+
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)) {
- WideString wsColor;
- pColor->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false);
- endColor = CXFA_DataData::ToColor(wsColor.AsStringView());
- } else {
- endColor = 0xFF000000;
+ pdfium::Optional<WideString> wsColor =
+ pColor->JSNode()->TryCData(XFA_Attribute::Value, false);
+ if (wsColor)
+ endColor = CXFA_DataData::ToColor(wsColor->AsStringView());
}
return eAttr;
}
diff --git a/xfa/fxfa/parser/cxfa_fontdata.cpp b/xfa/fxfa/parser/cxfa_fontdata.cpp
index 87bea1714f..afe73538c8 100644
--- a/xfa/fxfa/parser/cxfa_fontdata.cpp
+++ b/xfa/fxfa/parser/cxfa_fontdata.cpp
@@ -20,25 +20,22 @@ float CXFA_FontData::GetBaselineShift() {
}
float CXFA_FontData::GetHorizontalScale() {
- WideString wsValue;
- m_pNode->JSNode()->TryCData(XFA_Attribute::FontHorizontalScale, wsValue,
- true);
+ WideString wsValue =
+ m_pNode->JSNode()->GetCData(XFA_Attribute::FontHorizontalScale);
int32_t iScale = FXSYS_wtoi(wsValue.c_str());
return iScale > 0 ? (float)iScale : 100.0f;
}
float CXFA_FontData::GetVerticalScale() {
- WideString wsValue;
- m_pNode->JSNode()->TryCData(XFA_Attribute::FontVerticalScale, wsValue, true);
+ WideString wsValue =
+ m_pNode->JSNode()->GetCData(XFA_Attribute::FontVerticalScale);
int32_t iScale = FXSYS_wtoi(wsValue.c_str());
return iScale > 0 ? (float)iScale : 100.0f;
}
float CXFA_FontData::GetLetterSpacing() {
- WideString wsValue;
- if (!m_pNode->JSNode()->TryCData(XFA_Attribute::LetterSpacing, wsValue, true))
- return 0;
-
+ WideString wsValue =
+ m_pNode->JSNode()->GetCData(XFA_Attribute::LetterSpacing);
CXFA_Measurement ms(wsValue.AsStringView());
if (ms.GetUnit() == XFA_Unit::Em)
return ms.GetValue() * GetFontSize();
@@ -70,7 +67,7 @@ float CXFA_FontData::GetFontSize() {
}
void CXFA_FontData::GetTypeface(WideString& wsTypeFace) {
- m_pNode->JSNode()->TryCData(XFA_Attribute::Typeface, wsTypeFace, true);
+ wsTypeFace = m_pNode->JSNode()->GetCData(XFA_Attribute::Typeface);
}
bool CXFA_FontData::IsBold() {
diff --git a/xfa/fxfa/parser/cxfa_imagedata.cpp b/xfa/fxfa/parser/cxfa_imagedata.cpp
index 7c5a06541a..2ad891d7ec 100644
--- a/xfa/fxfa/parser/cxfa_imagedata.cpp
+++ b/xfa/fxfa/parser/cxfa_imagedata.cpp
@@ -16,14 +16,26 @@ int32_t CXFA_ImageData::GetAspect() {
}
bool CXFA_ImageData::GetContentType(WideString& wsContentType) {
- return m_pNode->JSNode()->TryCData(XFA_Attribute::ContentType, wsContentType,
- true);
+ pdfium::Optional<WideString> content =
+ m_pNode->JSNode()->TryCData(XFA_Attribute::ContentType, true);
+ if (!content)
+ return false;
+
+ wsContentType = *content;
+ return true;
}
bool CXFA_ImageData::GetHref(WideString& wsHref) {
- if (m_bDefValue)
- return m_pNode->JSNode()->TryCData(XFA_Attribute::Href, wsHref, true);
- return m_pNode->JSNode()->GetAttribute(L"href", wsHref, true);
+ if (m_bDefValue) {
+ pdfium::Optional<WideString> ret =
+ m_pNode->JSNode()->TryCData(XFA_Attribute::Href, true);
+ if (!ret)
+ return false;
+
+ wsHref = *ret;
+ return true;
+ }
+ return m_pNode->JSNode()->GetAttribute(XFA_Attribute::Href, wsHref, true);
}
XFA_ATTRIBUTEENUM CXFA_ImageData::GetTransferEncoding() {
@@ -35,7 +47,12 @@ XFA_ATTRIBUTEENUM CXFA_ImageData::GetTransferEncoding() {
}
bool CXFA_ImageData::GetContent(WideString& wsText) {
- return m_pNode->JSNode()->TryContent(wsText, false, true);
+ pdfium::Optional<WideString> ret = m_pNode->JSNode()->TryContent(false, true);
+ if (!ret)
+ return false;
+
+ wsText = *ret;
+ return true;
}
bool CXFA_ImageData::SetContentType(const WideString& wsContentType) {
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index c30c8dd575..332bed2a9f 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -1780,9 +1780,9 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
float fContentWidthLimit =
bContainerWidthAutoSize ? FLT_MAX
: containerSize.width - fLeftInset - fRightInset;
- WideString wsColumnWidths;
- if (pLayoutNode->JSNode()->TryCData(XFA_Attribute::ColumnWidths,
- wsColumnWidths, true)) {
+ WideString wsColumnWidths =
+ pLayoutNode->JSNode()->GetCData(XFA_Attribute::ColumnWidths);
+ if (!wsColumnWidths.IsEmpty()) {
auto widths = SeparateStringW(wsColumnWidths.c_str(),
wsColumnWidths.GetLength(), L' ');
for (auto& width : widths) {
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 4ecbd048ed..09cb08a283 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -65,9 +65,9 @@ class PageSetContainerLayoutItem {
uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) {
uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable;
- WideString wsRelevant;
- if (pFormItem->JSNode()->TryCData(XFA_Attribute::Relevant, wsRelevant,
- true)) {
+ WideString wsRelevant =
+ pFormItem->JSNode()->GetCData(XFA_Attribute::Relevant);
+ if (!wsRelevant.IsEmpty()) {
if (wsRelevant == L"+print" || wsRelevant == L"print")
dwRelevant &= ~XFA_WidgetStatus_Viewable;
else if (wsRelevant == L"-print")
@@ -480,8 +480,7 @@ float CXFA_LayoutPageMgr::GetAvailHeight() {
}
bool XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) {
- WideString wsExpression;
- pTestScript->JSNode()->TryContent(wsExpression, false, true);
+ WideString wsExpression = pTestScript->JSNode()->GetContent(false);
if (wsExpression.IsEmpty())
return true;
return pTestScript->GetDocument()->GetNotify()->RunScript(
@@ -949,60 +948,49 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
->GetTemplateNode();
if (pOverflowNode->GetElementType() == XFA_Element::Break) {
- WideString wsOverflowLeader;
- WideString wsOverflowTarget;
- WideString wsOverflowTrailer;
- pOverflowNode->JSNode()->TryCData(XFA_Attribute::OverflowLeader,
- wsOverflowLeader, true);
- pOverflowNode->JSNode()->TryCData(XFA_Attribute::OverflowTrailer,
- wsOverflowTrailer, true);
- pOverflowNode->JSNode()->TryCData(XFA_Attribute::OverflowTarget,
- wsOverflowTarget, true);
- if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() ||
- !wsOverflowTarget.IsEmpty()) {
- if (!wsOverflowTarget.IsEmpty() && bCreatePage &&
- !m_bCreateOverFlowPage) {
- CXFA_Node* pTarget =
- ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsOverflowTarget);
- if (pTarget) {
- m_bCreateOverFlowPage = true;
- switch (pTarget->GetElementType()) {
- case XFA_Element::PageArea:
- RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_PageArea,
- pTarget, true);
- break;
- case XFA_Element::ContentArea:
- RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_ContentArea,
- pTarget, true);
- break;
- default:
- break;
- }
+ WideString wsOverflowLeader =
+ pOverflowNode->JSNode()->GetCData(XFA_Attribute::OverflowLeader);
+ WideString wsOverflowTarget =
+ pOverflowNode->JSNode()->GetCData(XFA_Attribute::OverflowTarget);
+ WideString wsOverflowTrailer =
+ pOverflowNode->JSNode()->GetCData(XFA_Attribute::OverflowTrailer);
+ if (wsOverflowTarget.IsEmpty() && wsOverflowLeader.IsEmpty() &&
+ wsOverflowTrailer.IsEmpty()) {
+ return nullptr;
+ }
+
+ if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) {
+ CXFA_Node* pTarget =
+ ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsOverflowTarget);
+ if (pTarget) {
+ m_bCreateOverFlowPage = true;
+ switch (pTarget->GetElementType()) {
+ case XFA_Element::PageArea:
+ RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget,
+ true);
+ break;
+ case XFA_Element::ContentArea:
+ RunBreak(XFA_Element::Overflow, XFA_ATTRIBUTEENUM_ContentArea,
+ pTarget, true);
+ break;
+ default:
+ break;
}
}
- if (!bCreatePage) {
- pLeaderTemplate =
- ResolveBreakTarget(pContainer, true, wsOverflowLeader);
- pTrailerTemplate =
- ResolveBreakTarget(pContainer, true, wsOverflowTrailer);
- }
- return pOverflowNode;
}
- return nullptr;
+ if (!bCreatePage) {
+ pLeaderTemplate = ResolveBreakTarget(pContainer, true, wsOverflowLeader);
+ pTrailerTemplate =
+ ResolveBreakTarget(pContainer, true, wsOverflowTrailer);
+ }
+ return pOverflowNode;
}
if (pOverflowNode->GetElementType() != XFA_Element::Overflow)
return nullptr;
- WideString wsOverflowLeader;
- WideString wsOverflowTrailer;
- WideString wsOverflowTarget;
- pOverflowNode->JSNode()->TryCData(XFA_Attribute::Leader, wsOverflowLeader,
- true);
- pOverflowNode->JSNode()->TryCData(XFA_Attribute::Trailer, wsOverflowTrailer,
- true);
- pOverflowNode->JSNode()->TryCData(XFA_Attribute::Target, wsOverflowTarget,
- true);
+ WideString wsOverflowTarget =
+ pOverflowNode->JSNode()->GetCData(XFA_Attribute::Target);
if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) {
CXFA_Node* pTarget =
ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsOverflowTarget);
@@ -1023,8 +1011,12 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
}
}
if (!bCreatePage) {
- pLeaderTemplate = ResolveBreakTarget(pContainer, true, wsOverflowLeader);
- pTrailerTemplate = ResolveBreakTarget(pContainer, true, wsOverflowTrailer);
+ WideString wsLeader =
+ pOverflowNode->JSNode()->GetCData(XFA_Attribute::Leader);
+ WideString wsTrailer =
+ pOverflowNode->JSNode()->GetCData(XFA_Attribute::Trailer);
+ pLeaderTemplate = ResolveBreakTarget(pContainer, true, wsLeader);
+ pTrailerTemplate = ResolveBreakTarget(pContainer, true, wsTrailer);
}
return pOverflowNode;
}
@@ -1086,27 +1078,24 @@ bool CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
CXFA_Node* pBookendNode,
bool bLeader,
CXFA_Node*& pBookendAppendTemplate) {
- WideString wsBookendLeader;
CXFA_Node* pContainer =
pBookendNode
->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
->GetTemplateNode();
if (pBookendNode->GetElementType() == XFA_Element::Break) {
- pBookendNode->JSNode()->TryCData(
- bLeader ? XFA_Attribute::BookendLeader : XFA_Attribute::BookendTrailer,
- wsBookendLeader, true);
- if (!wsBookendLeader.IsEmpty()) {
- pBookendAppendTemplate =
- ResolveBreakTarget(pContainer, false, wsBookendLeader);
+ WideString leader = pBookendNode->JSNode()->GetCData(
+ bLeader ? XFA_Attribute::BookendLeader : XFA_Attribute::BookendTrailer);
+ if (!leader.IsEmpty()) {
+ pBookendAppendTemplate = ResolveBreakTarget(pContainer, false, leader);
return true;
}
return false;
- } else if (pBookendNode->GetElementType() == XFA_Element::Bookend) {
- pBookendNode->JSNode()->TryCData(
- bLeader ? XFA_Attribute::Leader : XFA_Attribute::Trailer,
- wsBookendLeader, true);
- pBookendAppendTemplate =
- ResolveBreakTarget(pContainer, true, wsBookendLeader);
+ }
+
+ if (pBookendNode->GetElementType() == XFA_Element::Bookend) {
+ WideString leader = pBookendNode->JSNode()->GetCData(
+ bLeader ? XFA_Attribute::Leader : XFA_Attribute::Trailer);
+ pBookendAppendTemplate = ResolveBreakTarget(pContainer, true, leader);
return true;
}
return false;
@@ -1666,15 +1655,13 @@ CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow(CXFA_Node* pFormNode) {
for (CXFA_Node* pCurNode = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild);
pCurNode; pCurNode = pCurNode->GetNodeItem((XFA_NODEITEM_NextSibling))) {
if (pCurNode->GetElementType() == XFA_Element::Break) {
- WideString wsOverflowLeader;
- WideString wsOverflowTarget;
- WideString wsOverflowTrailer;
- pCurNode->JSNode()->TryCData(XFA_Attribute::OverflowLeader,
- wsOverflowLeader, true);
- pCurNode->JSNode()->TryCData(XFA_Attribute::OverflowTrailer,
- wsOverflowTrailer, true);
- pCurNode->JSNode()->TryCData(XFA_Attribute::OverflowTarget,
- wsOverflowTarget, true);
+ WideString wsOverflowLeader =
+ pCurNode->JSNode()->GetCData(XFA_Attribute::OverflowLeader);
+ WideString wsOverflowTarget =
+ pCurNode->JSNode()->GetCData(XFA_Attribute::OverflowTarget);
+ WideString wsOverflowTrailer =
+ pCurNode->JSNode()->GetCData(XFA_Attribute::OverflowTrailer);
+
if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() ||
!wsOverflowTarget.IsEmpty()) {
return pCurNode;
diff --git a/xfa/fxfa/parser/cxfa_localemgr.cpp b/xfa/fxfa/parser/cxfa_localemgr.cpp
index ad11e28c6f..a4c041e95e 100644
--- a/xfa/fxfa/parser/cxfa_localemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_localemgr.cpp
@@ -1237,8 +1237,9 @@ WideStringView CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) {
pCommon ? pCommon->GetFirstChildByClass(XFA_Element::Locale)
: nullptr;
if (pLocale) {
- pLocale->JSNode()->TryCData(XFA_Attribute::Value, m_wsConfigLocale,
- false);
+ m_wsConfigLocale = pLocale->JSNode()
+ ->TryCData(XFA_Attribute::Value, false)
+ .value_or(WideString());
}
}
m_dwLocaleFlags |= 0x01;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 07d9f84916..5a375c7f2a 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -530,31 +530,38 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) {
CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode();
CXFA_Node* pTopSubform = pForm->GetFirstChildByClass(XFA_Element::Subform);
ASSERT(pTopSubform);
+
CXFA_Node* pLocaleNode = this;
- bool bLocale = false;
do {
- bLocale = pLocaleNode->JSNode()->TryCData(XFA_Attribute::Locale,
- wsLocaleName, false);
- if (!bLocale) {
- pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent);
+ pdfium::Optional<WideString> ret =
+ pLocaleNode->JSNode()->TryCData(XFA_Attribute::Locale, false);
+ if (ret) {
+ wsLocaleName = *ret;
+ return true;
}
- } while (pLocaleNode && pLocaleNode != pTopSubform && !bLocale);
- if (bLocale)
- return true;
+ 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;
- if (pTopSubform && pTopSubform->JSNode()->TryCData(XFA_Attribute::Locale,
- wsLocaleName, false)) {
- return true;
+
+ if (pTopSubform) {
+ pdfium::Optional<WideString> ret =
+ pTopSubform->JSNode()->TryCData(XFA_Attribute::Locale, false);
+ if (ret) {
+ wsLocaleName = *ret;
+ return true;
+ }
}
+
IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale();
- if (pLocale) {
- wsLocaleName = pLocale->GetName();
- return true;
- }
- return false;
+ if (!pLocale)
+ return false;
+
+ wsLocaleName = pLocale->GetName();
+ return true;
}
XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
diff --git a/xfa/fxfa/parser/cxfa_scriptdata.cpp b/xfa/fxfa/parser/cxfa_scriptdata.cpp
index f7352be79c..39d9a4b8c9 100644
--- a/xfa/fxfa/parser/cxfa_scriptdata.cpp
+++ b/xfa/fxfa/parser/cxfa_scriptdata.cpp
@@ -11,12 +11,13 @@
CXFA_ScriptData::CXFA_ScriptData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
XFA_ScriptDataType CXFA_ScriptData::GetContentType() {
- WideString cData;
- if (!m_pNode->JSNode()->TryCData(XFA_Attribute::ContentType, cData, false))
+ pdfium::Optional<WideString> cData =
+ m_pNode->JSNode()->TryCData(XFA_Attribute::ContentType, false);
+ if (!cData)
return XFA_ScriptDataType::Formcalc;
- if (cData == L"application/x-javascript")
+ if (*cData == L"application/x-javascript")
return XFA_ScriptDataType::Javascript;
- if (cData == L"application/x-formcalc")
+ if (*cData == L"application/x-formcalc")
return XFA_ScriptDataType::Formcalc;
return XFA_ScriptDataType::Unknown;
}
@@ -26,5 +27,5 @@ int32_t CXFA_ScriptData::GetRunAt() {
}
void CXFA_ScriptData::GetExpression(WideString& wsExpression) {
- m_pNode->JSNode()->TryContent(wsExpression, false, true);
+ wsExpression = m_pNode->JSNode()->GetContent(false);
}
diff --git a/xfa/fxfa/parser/cxfa_strokedata.cpp b/xfa/fxfa/parser/cxfa_strokedata.cpp
index 76798cb4bb..43354a38a4 100644
--- a/xfa/fxfa/parser/cxfa_strokedata.cpp
+++ b/xfa/fxfa/parser/cxfa_strokedata.cpp
@@ -50,9 +50,8 @@ FX_ARGB CXFA_StrokeData::GetColor() const {
if (!pNode)
return 0xFF000000;
- WideString wsColor;
- pNode->JSNode()->TryCData(XFA_Attribute::Value, wsColor, true);
- return CXFA_DataData::ToColor(wsColor.AsStringView());
+ return CXFA_DataData::ToColor(
+ pNode->JSNode()->GetCData(XFA_Attribute::Value).AsStringView());
}
void CXFA_StrokeData::SetColor(FX_ARGB argb) {
diff --git a/xfa/fxfa/parser/cxfa_submitdata.cpp b/xfa/fxfa/parser/cxfa_submitdata.cpp
index 1d4b91c5b6..c461ed2a09 100644
--- a/xfa/fxfa/parser/cxfa_submitdata.cpp
+++ b/xfa/fxfa/parser/cxfa_submitdata.cpp
@@ -19,9 +19,9 @@ int32_t CXFA_SubmitData::GetSubmitFormat() {
}
void CXFA_SubmitData::GetSubmitTarget(WideString& wsTarget) {
- m_pNode->JSNode()->TryCData(XFA_Attribute::Target, wsTarget, true);
+ wsTarget = m_pNode->JSNode()->GetCData(XFA_Attribute::Target);
}
void CXFA_SubmitData::GetSubmitXDPContent(WideString& wsContent) {
- m_pNode->JSNode()->TryCData(XFA_Attribute::XdpContent, wsContent, true);
+ wsContent = m_pNode->JSNode()->GetCData(XFA_Attribute::XdpContent);
}
diff --git a/xfa/fxfa/parser/cxfa_textdata.cpp b/xfa/fxfa/parser/cxfa_textdata.cpp
index ef804ab081..9fdc3006a8 100644
--- a/xfa/fxfa/parser/cxfa_textdata.cpp
+++ b/xfa/fxfa/parser/cxfa_textdata.cpp
@@ -11,5 +11,5 @@
CXFA_TextData::CXFA_TextData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
void CXFA_TextData::GetContent(WideString& wsText) {
- m_pNode->JSNode()->TryContent(wsText, false, true);
+ wsText = m_pNode->JSNode()->GetContent(false);
}
diff --git a/xfa/fxfa/parser/cxfa_validatedata.cpp b/xfa/fxfa/parser/cxfa_validatedata.cpp
index c7cfbabe6e..94c5829288 100644
--- a/xfa/fxfa/parser/cxfa_validatedata.cpp
+++ b/xfa/fxfa/parser/cxfa_validatedata.cpp
@@ -39,16 +39,15 @@ void CXFA_ValidateData::GetMessageText(WideString& wsMessage,
if (!pNode)
return;
- CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pItemNode;
+ for (CXFA_Node* pItemNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ pItemNode;
pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pItemNode->GetElementType() != XFA_Element::Text)
continue;
- WideString wsName;
- pItemNode->JSNode()->TryCData(XFA_Attribute::Name, wsName, true);
+ WideString wsName = pItemNode->JSNode()->GetCData(XFA_Attribute::Name);
if (wsName.IsEmpty() || wsName == wsMessageType) {
- pItemNode->JSNode()->TryContent(wsMessage, false, true);
+ wsMessage = pItemNode->JSNode()->GetContent(false);
return;
}
}
@@ -83,8 +82,7 @@ void CXFA_ValidateData::SetMessageText(WideString& wsMessage,
if (pItemNode->GetElementType() != XFA_Element::Text)
continue;
- WideString wsName;
- pItemNode->JSNode()->TryCData(XFA_Attribute::Name, wsName, true);
+ WideString wsName = pItemNode->JSNode()->GetCData(XFA_Attribute::Name);
if (wsName.IsEmpty() || wsName == wsMessageType) {
pItemNode->JSNode()->SetContent(wsMessage, wsMessage, false, false, true);
return;
@@ -107,7 +105,7 @@ void CXFA_ValidateData::SetScriptMessageText(WideString wsMessage) {
void CXFA_ValidateData::GetPicture(WideString& wsPicture) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Picture, false))
- pNode->JSNode()->TryContent(wsPicture, false, true);
+ wsPicture = pNode->JSNode()->GetContent(false);
}
CXFA_ScriptData CXFA_ValidateData::GetScriptData() {
diff --git a/xfa/fxfa/parser/cxfa_valuedata.cpp b/xfa/fxfa/parser/cxfa_valuedata.cpp
index a967b3b217..e44a76dbcc 100644
--- a/xfa/fxfa/parser/cxfa_valuedata.cpp
+++ b/xfa/fxfa/parser/cxfa_valuedata.cpp
@@ -19,9 +19,18 @@ XFA_Element CXFA_ValueData::GetChildValueClassID() {
bool CXFA_ValueData::GetChildValueContent(WideString& wsContent) {
if (!m_pNode)
return false;
- if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
- return pNode->JSNode()->TryContent(wsContent, false, true);
- return false;
+
+ CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ if (!pNode)
+ return false;
+
+ pdfium::Optional<WideString> content =
+ pNode->JSNode()->TryContent(false, true);
+ if (!content)
+ return false;
+
+ wsContent = *content;
+ return true;
}
CXFA_ArcData CXFA_ValueData::GetArcData() {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 2e9eda8b8c..1a39e2a525 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -406,10 +406,8 @@ bool CXFA_WidgetData::GetButtonRollover(WideString& wsRollover,
if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false)) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pText) {
- WideString wsName;
- pText->JSNode()->TryCData(XFA_Attribute::Name, wsName, true);
- if (wsName == L"rollover") {
- pText->JSNode()->TryContent(wsRollover, false, true);
+ if (pText->JSNode()->GetCData(XFA_Attribute::Name) == L"rollover") {
+ wsRollover = pText->JSNode()->GetContent(false);
bRichText = pText->GetElementType() == XFA_Element::ExData;
return !wsRollover.IsEmpty();
}
@@ -423,10 +421,8 @@ bool CXFA_WidgetData::GetButtonDown(WideString& wsDown, bool& bRichText) {
if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false)) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pText) {
- WideString wsName;
- pText->JSNode()->TryCData(XFA_Attribute::Name, wsName, true);
- if (wsName == L"down") {
- pText->JSNode()->TryContent(wsDown, false, true);
+ if (pText->JSNode()->GetCData(XFA_Attribute::Name) == L"down") {
+ wsDown = pText->JSNode()->GetContent(false);
bRichText = pText->GetElementType() == XFA_Element::ExData;
return !wsDown.IsEmpty();
}
@@ -480,11 +476,10 @@ XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
int32_t i = 0;
while (pText) {
- WideString wsContent;
- if (pText->JSNode()->TryContent(wsContent, false, true) &&
- (wsContent == wsValue)) {
- return (XFA_CHECKSTATE)i;
- }
+ pdfium::Optional<WideString> wsContent =
+ pText->JSNode()->TryContent(false, true);
+ if (wsContent && *wsContent == wsValue)
+ return static_cast<XFA_CHECKSTATE>(i);
i++;
pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling);
@@ -501,7 +496,7 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items, false)) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
if (pText)
- pText->JSNode()->TryContent(wsValue, false, true);
+ wsValue = pText->JSNode()->GetContent(false);
}
}
CXFA_Node* pChild =
@@ -542,7 +537,7 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
while (pText) {
i++;
if (i == eCheckState) {
- pText->JSNode()->TryContent(wsContent, false, true);
+ wsContent = pText->JSNode()->GetContent(false);
break;
}
pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling);
@@ -735,7 +730,7 @@ bool CXFA_WidgetData::GetChoiceListItem(WideString& wsText,
if (pItems) {
CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_Element::Unknown, false);
if (pItem) {
- pItem->JSNode()->TryContent(wsText, false, true);
+ wsText = pItem->JSNode()->GetContent(false);
return true;
}
}
@@ -764,8 +759,7 @@ std::vector<WideString> CXFA_WidgetData::GetChoiceListItems(bool bSaveValue) {
std::vector<WideString> wsTextArray;
for (CXFA_Node* pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- wsTextArray.emplace_back();
- pNode->JSNode()->TryContent(wsTextArray.back(), false, true);
+ wsTextArray.emplace_back(pNode->JSNode()->GetContent(false));
}
return wsTextArray;
}
@@ -967,10 +961,9 @@ void CXFA_WidgetData::InsertItem(const WideString& wsLabel,
CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
int32_t i = 0;
while (pListNode) {
- WideString wsOldValue;
- pListNode->JSNode()->TryContent(wsOldValue, false, true);
- InsertListTextItem(pSaveItems, wsOldValue, i);
- i++;
+ InsertListTextItem(pSaveItems, pListNode->JSNode()->GetContent(false), i);
+ ++i;
+
pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
InsertListTextItem(pNode, wsLabel, nIndex);
@@ -994,38 +987,40 @@ void CXFA_WidgetData::GetItemLabel(const WideStringView& wsValue,
iCount++;
listitems.push_back(pItems);
}
+
if (iCount <= 1) {
wsLabel = wsValue;
+ return;
+ }
+
+ CXFA_Node* pLabelItems = listitems[0];
+ bool bSave = pLabelItems->JSNode()->GetBoolean(XFA_Attribute::Save);
+ CXFA_Node* pSaveItems = nullptr;
+ if (bSave) {
+ pSaveItems = pLabelItems;
+ pLabelItems = listitems[1];
} else {
- CXFA_Node* pLabelItems = listitems[0];
- bool bSave = pLabelItems->JSNode()->GetBoolean(XFA_Attribute::Save);
- CXFA_Node* pSaveItems = nullptr;
- if (bSave) {
- pSaveItems = pLabelItems;
- pLabelItems = listitems[1];
- } else {
- pSaveItems = listitems[1];
- }
- iCount = 0;
- int32_t iSearch = -1;
- WideString wsContent;
- CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pChildItem;
- pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- pChildItem->JSNode()->TryContent(wsContent, false, true);
- if (wsContent == wsValue) {
- iSearch = iCount;
- break;
- }
- iCount++;
- }
- if (iSearch < 0)
- return;
- if (CXFA_Node* pText =
- pLabelItems->GetChild(iSearch, XFA_Element::Unknown, false)) {
- pText->JSNode()->TryContent(wsLabel, false, true);
+ pSaveItems = listitems[1];
+ }
+ iCount = 0;
+
+ int32_t iSearch = -1;
+ for (CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild);
+ pChildItem;
+ pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ if (pChildItem->JSNode()->GetContent(false) == wsValue) {
+ iSearch = iCount;
+ break;
}
+ iCount++;
}
+ if (iSearch < 0)
+ return;
+
+ CXFA_Node* pText =
+ pLabelItems->GetChild(iSearch, XFA_Element::Unknown, false);
+ if (pText)
+ wsLabel = pText->JSNode()->GetContent(false);
}
void CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel,
@@ -1041,36 +1036,37 @@ void CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel,
}
if (iCount <= 1) {
wsValue = wsLabel;
+ return;
+ }
+
+ CXFA_Node* pLabelItems = listitems[0];
+ bool bSave = pLabelItems->JSNode()->GetBoolean(XFA_Attribute::Save);
+ CXFA_Node* pSaveItems = nullptr;
+ if (bSave) {
+ pSaveItems = pLabelItems;
+ pLabelItems = listitems[1];
} else {
- CXFA_Node* pLabelItems = listitems[0];
- bool bSave = pLabelItems->JSNode()->GetBoolean(XFA_Attribute::Save);
- CXFA_Node* pSaveItems = nullptr;
- if (bSave) {
- pSaveItems = pLabelItems;
- pLabelItems = listitems[1];
- } else {
- pSaveItems = listitems[1];
- }
- iCount = 0;
- int32_t iSearch = -1;
- WideString wsContent;
- CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pChildItem;
- pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- pChildItem->JSNode()->TryContent(wsContent, false, true);
- if (wsContent == wsLabel) {
- iSearch = iCount;
- break;
- }
- iCount++;
- }
- if (iSearch < 0)
- return;
- if (CXFA_Node* pText =
- pSaveItems->GetChild(iSearch, XFA_Element::Unknown, false)) {
- pText->JSNode()->TryContent(wsValue, false, true);
+ pSaveItems = listitems[1];
+ }
+ iCount = 0;
+
+ int32_t iSearch = -1;
+ WideString wsContent;
+ CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild);
+ for (; pChildItem;
+ pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ if (pChildItem->JSNode()->GetContent(false) == wsLabel) {
+ iSearch = iCount;
+ break;
}
+ iCount++;
}
+ if (iSearch < 0)
+ return;
+
+ CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_Element::Unknown, false);
+ if (pText)
+ wsValue = pText->JSNode()->GetContent(false);
}
bool CXFA_WidgetData::DeleteItem(int32_t nIndex,
@@ -1132,18 +1128,17 @@ WideString CXFA_WidgetData::GetBarcodeType() {
}
bool CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t* val) {
- CXFA_Node* pUIChild = GetUIChild();
- WideString wsCharEncoding;
- if (pUIChild->JSNode()->TryCData(XFA_Attribute::CharEncoding, wsCharEncoding,
- true)) {
- if (wsCharEncoding.CompareNoCase(L"UTF-16")) {
- *val = CHAR_ENCODING_UNICODE;
- return true;
- }
- if (wsCharEncoding.CompareNoCase(L"UTF-8")) {
- *val = CHAR_ENCODING_UTF8;
- return true;
- }
+ pdfium::Optional<WideString> wsCharEncoding =
+ GetUIChild()->JSNode()->TryCData(XFA_Attribute::CharEncoding, true);
+ if (!wsCharEncoding)
+ return false;
+ if (wsCharEncoding->CompareNoCase(L"UTF-16")) {
+ *val = CHAR_ENCODING_UNICODE;
+ return true;
+ }
+ if (wsCharEncoding->CompareNoCase(L"UTF-8")) {
+ *val = CHAR_ENCODING_UTF8;
+ return true;
}
return false;
}
@@ -1173,58 +1168,49 @@ bool CXFA_WidgetData::GetBarcodeAttribute_Checksum(bool* val) {
}
bool CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t* val) {
- CXFA_Node* pUIChild = GetUIChild();
- WideString wsDataLength;
- if (pUIChild->JSNode()->TryCData(XFA_Attribute::DataLength, wsDataLength,
- true)) {
- *val = FXSYS_wtoi(wsDataLength.c_str());
- return true;
- }
- return false;
+ pdfium::Optional<WideString> wsDataLength =
+ GetUIChild()->JSNode()->TryCData(XFA_Attribute::DataLength, true);
+ if (!wsDataLength)
+ return false;
+
+ *val = FXSYS_wtoi(wsDataLength->c_str());
+ return true;
}
bool CXFA_WidgetData::GetBarcodeAttribute_StartChar(char* val) {
- CXFA_Node* pUIChild = GetUIChild();
- WideString wsStartEndChar;
- if (pUIChild->JSNode()->TryCData(XFA_Attribute::StartChar, wsStartEndChar,
- true)) {
- if (wsStartEndChar.GetLength()) {
- *val = static_cast<char>(wsStartEndChar[0]);
- return true;
- }
- }
- return false;
+ pdfium::Optional<WideString> wsStartEndChar =
+ GetUIChild()->JSNode()->TryCData(XFA_Attribute::StartChar, true);
+ if (!wsStartEndChar || wsStartEndChar->IsEmpty())
+ return false;
+
+ *val = static_cast<char>((*wsStartEndChar)[0]);
+ return true;
}
bool CXFA_WidgetData::GetBarcodeAttribute_EndChar(char* val) {
- CXFA_Node* pUIChild = GetUIChild();
- WideString wsStartEndChar;
- if (pUIChild->JSNode()->TryCData(XFA_Attribute::EndChar, wsStartEndChar,
- true)) {
- if (wsStartEndChar.GetLength()) {
- *val = static_cast<char>(wsStartEndChar[0]);
- return true;
- }
- }
- return false;
+ pdfium::Optional<WideString> wsStartEndChar =
+ GetUIChild()->JSNode()->TryCData(XFA_Attribute::EndChar, true);
+ if (!wsStartEndChar || wsStartEndChar->IsEmpty())
+ return false;
+
+ *val = static_cast<char>((*wsStartEndChar)[0]);
+ return true;
}
bool CXFA_WidgetData::GetBarcodeAttribute_ECLevel(int32_t* val) {
- CXFA_Node* pUIChild = GetUIChild();
- WideString wsECLevel;
- if (pUIChild->JSNode()->TryCData(XFA_Attribute::ErrorCorrectionLevel,
- wsECLevel, true)) {
- *val = FXSYS_wtoi(wsECLevel.c_str());
- return true;
- }
- return false;
+ pdfium::Optional<WideString> wsECLevel = GetUIChild()->JSNode()->TryCData(
+ XFA_Attribute::ErrorCorrectionLevel, true);
+ if (!wsECLevel)
+ return false;
+
+ *val = FXSYS_wtoi(wsECLevel->c_str());
+ return true;
}
bool CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t* val) {
- CXFA_Node* pUIChild = GetUIChild();
CXFA_Measurement mModuleWidthHeight;
- if (pUIChild->JSNode()->TryMeasure(XFA_Attribute::ModuleWidth,
- mModuleWidthHeight, true)) {
+ if (GetUIChild()->JSNode()->TryMeasure(XFA_Attribute::ModuleWidth,
+ mModuleWidthHeight, true)) {
*val = static_cast<int32_t>(mModuleWidthHeight.ToUnit(XFA_Unit::Pt));
return true;
}
@@ -1232,10 +1218,9 @@ bool CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t* val) {
}
bool CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t* val) {
- CXFA_Node* pUIChild = GetUIChild();
CXFA_Measurement mModuleWidthHeight;
- if (pUIChild->JSNode()->TryMeasure(XFA_Attribute::ModuleHeight,
- mModuleWidthHeight, true)) {
+ if (GetUIChild()->JSNode()->TryMeasure(XFA_Attribute::ModuleHeight,
+ mModuleWidthHeight, true)) {
*val = static_cast<int32_t>(mModuleWidthHeight.ToUnit(XFA_Unit::Pt));
return true;
}
@@ -1243,10 +1228,9 @@ bool CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t* val) {
}
bool CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(bool* val) {
- CXFA_Node* pUIChild = GetUIChild();
bool bPrintCheckDigit;
- if (pUIChild->JSNode()->TryBoolean(XFA_Attribute::PrintCheckDigit,
- bPrintCheckDigit, true)) {
+ if (GetUIChild()->JSNode()->TryBoolean(XFA_Attribute::PrintCheckDigit,
+ bPrintCheckDigit, true)) {
*val = bPrintCheckDigit;
return true;
}
@@ -1254,10 +1238,9 @@ bool CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(bool* val) {
}
bool CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t* val) {
- CXFA_Node* pUIChild = GetUIChild();
XFA_ATTRIBUTEENUM eTextLocation;
- if (pUIChild->JSNode()->TryEnum(XFA_Attribute::TextLocation, eTextLocation,
- true)) {
+ if (GetUIChild()->JSNode()->TryEnum(XFA_Attribute::TextLocation,
+ eTextLocation, true)) {
switch (eTextLocation) {
case XFA_ATTRIBUTEENUM_None:
*val = BC_TEXT_LOC_NONE;
@@ -1282,9 +1265,9 @@ bool CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t* val) {
}
bool CXFA_WidgetData::GetBarcodeAttribute_Truncate(bool* val) {
- CXFA_Node* pUIChild = GetUIChild();
bool bTruncate;
- if (!pUIChild->JSNode()->TryBoolean(XFA_Attribute::Truncate, bTruncate, true))
+ if (!GetUIChild()->JSNode()->TryBoolean(XFA_Attribute::Truncate, bTruncate,
+ true))
return false;
*val = bTruncate;
@@ -1292,36 +1275,36 @@ bool CXFA_WidgetData::GetBarcodeAttribute_Truncate(bool* val) {
}
bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(float* val) {
- CXFA_Node* pUIChild = GetUIChild();
- WideString wsWideNarrowRatio;
- if (pUIChild->JSNode()->TryCData(XFA_Attribute::WideNarrowRatio,
- wsWideNarrowRatio, true)) {
- auto ptPos = wsWideNarrowRatio.Find(':');
- float fRatio = 0;
- if (!ptPos.has_value()) {
- fRatio = (float)FXSYS_wtoi(wsWideNarrowRatio.c_str());
- } else {
- int32_t fA, fB;
- fA = FXSYS_wtoi(wsWideNarrowRatio.Left(ptPos.value()).c_str());
- fB = FXSYS_wtoi(
- wsWideNarrowRatio
- .Right(wsWideNarrowRatio.GetLength() - (ptPos.value() + 1))
- .c_str());
- if (fB)
- fRatio = (float)fA / fB;
- }
- *val = fRatio;
+ pdfium::Optional<WideString> wsWideNarrowRatio =
+ GetUIChild()->JSNode()->TryCData(XFA_Attribute::WideNarrowRatio, true);
+ if (!wsWideNarrowRatio)
+ return false;
+
+ pdfium::Optional<size_t> ptPos = wsWideNarrowRatio->Find(':');
+ if (!ptPos) {
+ *val = static_cast<float>(FXSYS_wtoi(wsWideNarrowRatio->c_str()));
return true;
}
- return false;
+
+ *val = 0.0f;
+ int32_t fB = FXSYS_wtoi(
+ wsWideNarrowRatio->Right(wsWideNarrowRatio->GetLength() - (*ptPos + 1))
+ .c_str());
+ if (!fB)
+ return true;
+
+ int32_t fA = FXSYS_wtoi(wsWideNarrowRatio->Left(*ptPos).c_str());
+ *val = static_cast<float>(fA) / static_cast<float>(fB);
+ return true;
}
void CXFA_WidgetData::GetPasswordChar(WideString& wsPassWord) {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild)
- pUIChild->JSNode()->TryCData(XFA_Attribute::PasswordChar, wsPassWord, true);
- else
+ if (!pUIChild) {
wsPassWord = L"*";
+ return;
+ }
+ wsPassWord = pUIChild->JSNode()->GetCData(XFA_Attribute::PasswordChar);
}
bool CXFA_WidgetData::IsMultiLine() {
@@ -1453,8 +1436,12 @@ bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture,
m_pNode->GetChild(0, XFA_Element::Format, false)) {
if (CXFA_Node* pPicture =
pFormat->GetChild(0, XFA_Element::Picture, false)) {
- if (pPicture->JSNode()->TryContent(wsPicture, false, true))
+ pdfium::Optional<WideString> picture =
+ pPicture->JSNode()->TryContent(false, true);
+ if (picture) {
+ wsPicture = *picture;
return true;
+ }
}
}
@@ -1491,8 +1478,12 @@ bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture,
if (pUI) {
if (CXFA_Node* pPicture =
pUI->GetChild(0, XFA_Element::Picture, false)) {
- if (pPicture->JSNode()->TryContent(wsPicture, false, true))
+ pdfium::Optional<WideString> picture =
+ pPicture->JSNode()->TryContent(false, true);
+ if (picture) {
+ wsPicture = *picture;
return true;
+ }
}
}
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 94c82f85e8..29bcd5f3b9 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -218,9 +218,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (!pText)
continue;
- WideString wsContent;
- if (pText->JSNode()->TryContent(wsContent, false, true) &&
- (wsContent == wsValue)) {
+ WideString wsContent = pText->JSNode()->GetContent(false);
+ if (wsContent == wsValue) {
pChecked = pChild;
wsFormattedValue = wsValue;
pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue,
@@ -250,7 +249,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
WideString wsContent;
if (pText)
- pText->JSNode()->TryContent(wsContent, false, true);
+ wsContent = pText->JSNode()->GetContent(false);
FormValueNode_SetChildContent(pValue, wsContent, XFA_Element::Text);
}
@@ -285,10 +284,11 @@ void CreateDataBinding(CXFA_Node* pFormNode,
return;
}
- WideString wsXMLValue;
- pDataNode->JSNode()->TryContent(wsXMLValue, false, true);
+ WideString wsXMLValue = pDataNode->JSNode()->GetContent(false);
+
WideString wsNormalizeValue;
pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormalizeValue);
+
pDataNode->JSNode()->SetAttributeValue(wsNormalizeValue, wsXMLValue, false,
false);
switch (eUIType) {
@@ -323,10 +323,12 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (!items.empty()) {
bool single = items.size() == 1;
wsNormalizeValue.clear();
- WideString wsItem;
+
for (CXFA_Node* pNode : items) {
- pNode->JSNode()->TryContent(wsItem, false, true);
- wsItem = single ? wsItem : wsItem + L"\n";
+ WideString wsItem = pNode->JSNode()->GetContent(false);
+ if (single)
+ wsItem += L"\n";
+
wsNormalizeValue += wsItem;
}
CXFA_ExDataData exData = defValueData.GetExData();