summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-14 21:19:44 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-14 21:19:44 +0000
commitaee28693976cc246eea8230a999906802e52cab7 (patch)
tree612e6dbc9b79c978208a623138f70f881acb539f /xfa/fxfa/parser
parent5a423ef8708e61d43f1556ab09c2e09f496d700d (diff)
downloadpdfium-aee28693976cc246eea8230a999906802e52cab7.tar.xz
Cleanup XFA default value code
This CL adds helper methods to CXFA_Node to retrieve the default values for attributes with the correct data types. Change-Id: I644435b4b430819f1060a95fa4fffe4ba2826cfe Reviewed-on: https://pdfium-review.googlesource.com/18450 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_binditemsdata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_binditemsdata.h6
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_eventdata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_eventdata.h2
-rw-r--r--xfa/fxfa/parser/cxfa_filldata.cpp20
-rw-r--r--xfa/fxfa/parser/cxfa_fontdata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_fontdata.h2
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp35
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp90
-rw-r--r--xfa/fxfa/parser/cxfa_node.h7
-rw-r--r--xfa/fxfa/parser/cxfa_scriptdata.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp33
-rw-r--r--xfa/fxfa/parser/cxfa_strokedata.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_submitdata.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_submitdata.h4
-rw-r--r--xfa/fxfa/parser/cxfa_validatedata.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp111
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h12
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp24
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp11
-rw-r--r--xfa/fxfa/parser/xfa_utils.h10
24 files changed, 203 insertions, 220 deletions
diff --git a/xfa/fxfa/parser/cxfa_binditemsdata.cpp b/xfa/fxfa/parser/cxfa_binditemsdata.cpp
index 644b532839..ac6b765faa 100644
--- a/xfa/fxfa/parser/cxfa_binditemsdata.cpp
+++ b/xfa/fxfa/parser/cxfa_binditemsdata.cpp
@@ -11,15 +11,15 @@
CXFA_BindItemsData::CXFA_BindItemsData(CXFA_Node* pNode)
: CXFA_DataData(pNode) {}
-void CXFA_BindItemsData::GetLabelRef(WideStringView& wsLabelRef) {
+void CXFA_BindItemsData::GetLabelRef(WideString& wsLabelRef) {
m_pNode->JSNode()->TryCData(XFA_Attribute::LabelRef, wsLabelRef, true);
}
-void CXFA_BindItemsData::GetValueRef(WideStringView& wsValueRef) {
+void CXFA_BindItemsData::GetValueRef(WideString& wsValueRef) {
m_pNode->JSNode()->TryCData(XFA_Attribute::ValueRef, wsValueRef, true);
}
-void CXFA_BindItemsData::GetRef(WideStringView& wsRef) {
+void CXFA_BindItemsData::GetRef(WideString& wsRef) {
m_pNode->JSNode()->TryCData(XFA_Attribute::Ref, wsRef, true);
}
diff --git a/xfa/fxfa/parser/cxfa_binditemsdata.h b/xfa/fxfa/parser/cxfa_binditemsdata.h
index 7c7eefa233..f9b506a993 100644
--- a/xfa/fxfa/parser/cxfa_binditemsdata.h
+++ b/xfa/fxfa/parser/cxfa_binditemsdata.h
@@ -16,9 +16,9 @@ class CXFA_BindItemsData : public CXFA_DataData {
public:
explicit CXFA_BindItemsData(CXFA_Node* pNode);
- void GetLabelRef(WideStringView& wsLabelRef);
- void GetValueRef(WideStringView& wsValueRef);
- void GetRef(WideStringView& wsRef);
+ void GetLabelRef(WideString& wsLabelRef);
+ void GetValueRef(WideString& wsValueRef);
+ void GetRef(WideString& wsRef);
bool SetConnection(const WideString& wsConnection);
};
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 8b16ae745c..c8b518c114 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -54,7 +54,7 @@ bool IsXMLValidChar(wchar_t ch) {
(ch >= 0x20 && ch <= 0xD7FF) || (ch >= 0xE000 && ch <= 0xFFFD);
}
-WideString ExportEncodeContent(const WideStringView& str) {
+WideString ExportEncodeContent(const WideString& str) {
CFX_WideTextBuf textBuf;
int32_t iLen = str.GetLength();
for (int32_t i = 0; i < iLen; i++) {
@@ -253,7 +253,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
for (int32_t i = 0; i < pdfium::CollectionSize<int32_t>(wsSelTextArray);
i++) {
buf << L"<value\n>";
- buf << ExportEncodeContent(wsSelTextArray[i].AsStringView());
+ buf << ExportEncodeContent(wsSelTextArray[i]);
buf << L"</value\n>";
}
buf << L"</";
@@ -262,7 +262,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
wsChildren += buf.AsStringView();
buf.Clear();
} else {
- WideStringView wsValue =
+ WideString wsValue =
pRawValueNode->JSNode()->GetCData(XFA_Attribute::Value);
wsChildren += ExportEncodeContent(wsValue);
}
@@ -271,7 +271,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
case XFA_ObjectType::TextNode:
case XFA_ObjectType::NodeC:
case XFA_ObjectType::NodeV: {
- WideStringView wsValue = pNode->JSNode()->GetCData(XFA_Attribute::Value);
+ WideString wsValue = pNode->JSNode()->GetCData(XFA_Attribute::Value);
wsChildren += ExportEncodeContent(wsValue);
break;
}
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index c374b762ba..f5a72bde9a 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -333,7 +333,7 @@ CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot,
CXFA_NodeIterator sIterator(pRoot);
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
- WideStringView wsIDVal;
+ WideString wsIDVal;
if (pNode->JSNode()->TryCData(XFA_Attribute::Id, wsIDVal, true) &&
!wsIDVal.IsEmpty()) {
if (wsIDVal == wsID)
@@ -353,12 +353,12 @@ void CXFA_Document::DoProtoMerge() {
CXFA_NodeIterator sIterator(pTemplateRoot);
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
- WideStringView wsIDVal;
+ WideString wsIDVal;
if (pNode->JSNode()->TryCData(XFA_Attribute::Id, wsIDVal, true) &&
!wsIDVal.IsEmpty()) {
- mIDMap[FX_HashCode_GetW(wsIDVal, false)] = pNode;
+ mIDMap[FX_HashCode_GetW(wsIDVal.AsStringView(), false)] = pNode;
}
- WideStringView wsUseVal;
+ WideString wsUseVal;
if (pNode->JSNode()->TryCData(XFA_Attribute::Use, wsUseVal, true) &&
!wsUseVal.IsEmpty()) {
sUseNodes.insert(pNode);
diff --git a/xfa/fxfa/parser/cxfa_eventdata.cpp b/xfa/fxfa/parser/cxfa_eventdata.cpp
index 0210fdc5f4..387b7328f0 100644
--- a/xfa/fxfa/parser/cxfa_eventdata.cpp
+++ b/xfa/fxfa/parser/cxfa_eventdata.cpp
@@ -26,7 +26,7 @@ XFA_Element CXFA_EventData::GetEventType() const {
return XFA_Element::Unknown;
}
-void CXFA_EventData::GetRef(WideStringView& wsRef) {
+void CXFA_EventData::GetRef(WideString& wsRef) {
m_pNode->JSNode()->TryCData(XFA_Attribute::Ref, wsRef, true);
}
@@ -44,7 +44,5 @@ void CXFA_EventData::GetSignDataTarget(WideString& wsTarget) {
if (!pNode)
return;
- WideStringView wsCData;
- pNode->JSNode()->TryCData(XFA_Attribute::Target, wsCData, true);
- wsTarget = wsCData;
+ pNode->JSNode()->TryCData(XFA_Attribute::Target, wsTarget, true);
}
diff --git a/xfa/fxfa/parser/cxfa_eventdata.h b/xfa/fxfa/parser/cxfa_eventdata.h
index 90b1b87ff5..98b85e662e 100644
--- a/xfa/fxfa/parser/cxfa_eventdata.h
+++ b/xfa/fxfa/parser/cxfa_eventdata.h
@@ -24,7 +24,7 @@ class CXFA_EventData : public CXFA_DataData {
XFA_Element GetEventType() const;
CXFA_ScriptData GetScriptData() const;
CXFA_SubmitData GetSubmitData() const;
- void GetRef(WideStringView& wsRef);
+ void GetRef(WideString& wsRef);
void GetSignDataTarget(WideString& wsTarget);
};
diff --git a/xfa/fxfa/parser/cxfa_filldata.cpp b/xfa/fxfa/parser/cxfa_filldata.cpp
index 65ad3961c2..fbc79ad4d0 100644
--- a/xfa/fxfa/parser/cxfa_filldata.cpp
+++ b/xfa/fxfa/parser/cxfa_filldata.cpp
@@ -31,9 +31,9 @@ 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)) {
- WideStringView wsColor;
+ WideString wsColor;
if (pNode->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false))
- return CXFA_DataData::ToColor(wsColor);
+ return CXFA_DataData::ToColor(wsColor.AsStringView());
}
if (bText)
return 0xFF000000;
@@ -56,9 +56,9 @@ int32_t CXFA_FillData::GetPattern(FX_ARGB& foreColor) {
CXFA_Node* pNode =
m_pNode->JSNode()->GetProperty(0, XFA_Element::Pattern, true);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
- WideStringView wsColor;
+ WideString wsColor;
pColor->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false);
- foreColor = CXFA_DataData::ToColor(wsColor);
+ foreColor = CXFA_DataData::ToColor(wsColor.AsStringView());
} else {
foreColor = 0xFF000000;
}
@@ -71,9 +71,9 @@ int32_t CXFA_FillData::GetStipple(FX_ARGB& stippleColor) {
int32_t eAttr = 50;
pNode->JSNode()->TryInteger(XFA_Attribute::Rate, eAttr, true);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) {
- WideStringView wsColor;
+ WideString wsColor;
pColor->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false);
- stippleColor = CXFA_DataData::ToColor(wsColor);
+ stippleColor = CXFA_DataData::ToColor(wsColor.AsStringView());
} else {
stippleColor = 0xFF000000;
}
@@ -86,9 +86,9 @@ int32_t CXFA_FillData::GetLinear(FX_ARGB& endColor) {
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)) {
- WideStringView wsColor;
+ WideString wsColor;
pColor->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false);
- endColor = CXFA_DataData::ToColor(wsColor);
+ endColor = CXFA_DataData::ToColor(wsColor.AsStringView());
} else {
endColor = 0xFF000000;
}
@@ -101,9 +101,9 @@ int32_t CXFA_FillData::GetRadial(FX_ARGB& endColor) {
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)) {
- WideStringView wsColor;
+ WideString wsColor;
pColor->JSNode()->TryCData(XFA_Attribute::Value, wsColor, false);
- endColor = CXFA_DataData::ToColor(wsColor);
+ endColor = CXFA_DataData::ToColor(wsColor.AsStringView());
} else {
endColor = 0xFF000000;
}
diff --git a/xfa/fxfa/parser/cxfa_fontdata.cpp b/xfa/fxfa/parser/cxfa_fontdata.cpp
index f5fe270f18..87bea1714f 100644
--- a/xfa/fxfa/parser/cxfa_fontdata.cpp
+++ b/xfa/fxfa/parser/cxfa_fontdata.cpp
@@ -35,11 +35,11 @@ float CXFA_FontData::GetVerticalScale() {
}
float CXFA_FontData::GetLetterSpacing() {
- WideStringView wsValue;
+ WideString wsValue;
if (!m_pNode->JSNode()->TryCData(XFA_Attribute::LetterSpacing, wsValue, true))
return 0;
- CXFA_Measurement ms(wsValue);
+ CXFA_Measurement ms(wsValue.AsStringView());
if (ms.GetUnit() == XFA_Unit::Em)
return ms.GetValue() * GetFontSize();
return ms.ToUnit(XFA_Unit::Pt);
@@ -69,7 +69,7 @@ float CXFA_FontData::GetFontSize() {
return ms.ToUnit(XFA_Unit::Pt);
}
-void CXFA_FontData::GetTypeface(WideStringView& wsTypeFace) {
+void CXFA_FontData::GetTypeface(WideString& wsTypeFace) {
m_pNode->JSNode()->TryCData(XFA_Attribute::Typeface, wsTypeFace, true);
}
diff --git a/xfa/fxfa/parser/cxfa_fontdata.h b/xfa/fxfa/parser/cxfa_fontdata.h
index d926fd3e46..ae5e4ac961 100644
--- a/xfa/fxfa/parser/cxfa_fontdata.h
+++ b/xfa/fxfa/parser/cxfa_fontdata.h
@@ -24,7 +24,7 @@ class CXFA_FontData : public CXFA_DataData {
int32_t GetUnderline();
int32_t GetUnderlinePeriod();
float GetFontSize();
- void GetTypeface(WideStringView& wsTypeFace);
+ void GetTypeface(WideString& wsTypeFace);
bool IsBold();
bool IsItalic();
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index 752d37473b..189a466e4f 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -1779,10 +1779,10 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
float fContentWidthLimit =
bContainerWidthAutoSize ? FLT_MAX
: containerSize.width - fLeftInset - fRightInset;
- WideStringView wsColumnWidths;
+ WideString wsColumnWidths;
if (pLayoutNode->JSNode()->TryCData(XFA_Attribute::ColumnWidths,
wsColumnWidths, true)) {
- auto widths = SeparateStringW(wsColumnWidths.unterminated_c_str(),
+ auto widths = SeparateStringW(wsColumnWidths.c_str(),
wsColumnWidths.GetLength(), L' ');
for (auto& width : widths) {
width.TrimLeft(L' ');
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index a24cce4979..57d71ffd89 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -65,7 +65,7 @@ class PageSetContainerLayoutItem {
uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) {
uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable;
- WideStringView wsRelevant;
+ WideString wsRelevant;
if (pFormItem->JSNode()->TryCData(XFA_Attribute::Relevant, wsRelevant,
true)) {
if (wsRelevant == L"+print" || wsRelevant == L"print")
@@ -137,12 +137,11 @@ void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) {
CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
bool bNewExprStyle,
- WideStringView& wsTargetExpr) {
+ WideString& wsTargetAll) {
CXFA_Document* pDocument = pPageSetRoot->GetDocument();
- if (wsTargetExpr.IsEmpty())
+ if (wsTargetAll.IsEmpty())
return nullptr;
- WideString wsTargetAll(wsTargetExpr);
wsTargetAll.TrimLeft();
wsTargetAll.TrimRight();
int32_t iSplitIndex = 0;
@@ -811,7 +810,8 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
switch (eType) {
case XFA_Element::BreakBefore:
case XFA_Element::BreakAfter: {
- WideStringView wsBreakLeader, wsBreakTrailer;
+ WideString wsBreakLeader;
+ WideString wsBreakTrailer;
CXFA_Node* pFormNode = pCurNode->GetNodeItem(
XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
CXFA_Node* pContainer = pFormNode->GetTemplateNode();
@@ -821,8 +821,7 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript))
return false;
- WideStringView wsTarget =
- pCurNode->JSNode()->GetCData(XFA_Attribute::Target);
+ WideString wsTarget = pCurNode->JSNode()->GetCData(XFA_Attribute::Target);
CXFA_Node* pTarget =
ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsTarget);
wsBreakTrailer = pCurNode->JSNode()->GetCData(XFA_Attribute::Trailer);
@@ -859,7 +858,7 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
case XFA_Element::Break: {
bool bStartNew =
pCurNode->JSNode()->GetInteger(XFA_Attribute::StartNew) != 0;
- WideStringView wsTarget = pCurNode->JSNode()->GetCData(
+ WideString wsTarget = pCurNode->JSNode()->GetCData(
bBefore ? XFA_Attribute::BeforeTarget : XFA_Attribute::AfterTarget);
CXFA_Node* pTarget =
ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsTarget);
@@ -950,9 +949,9 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
->GetTemplateNode();
if (pOverflowNode->GetElementType() == XFA_Element::Break) {
- WideStringView wsOverflowLeader;
- WideStringView wsOverflowTarget;
- WideStringView wsOverflowTrailer;
+ WideString wsOverflowLeader;
+ WideString wsOverflowTarget;
+ WideString wsOverflowTrailer;
pOverflowNode->JSNode()->TryCData(XFA_Attribute::OverflowLeader,
wsOverflowLeader, true);
pOverflowNode->JSNode()->TryCData(XFA_Attribute::OverflowTrailer,
@@ -995,9 +994,9 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
if (pOverflowNode->GetElementType() != XFA_Element::Overflow)
return nullptr;
- WideStringView wsOverflowLeader;
- WideStringView wsOverflowTrailer;
- WideStringView wsOverflowTarget;
+ WideString wsOverflowLeader;
+ WideString wsOverflowTrailer;
+ WideString wsOverflowTarget;
pOverflowNode->JSNode()->TryCData(XFA_Attribute::Leader, wsOverflowLeader,
true);
pOverflowNode->JSNode()->TryCData(XFA_Attribute::Trailer, wsOverflowTrailer,
@@ -1087,7 +1086,7 @@ bool CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
CXFA_Node* pBookendNode,
bool bLeader,
CXFA_Node*& pBookendAppendTemplate) {
- WideStringView wsBookendLeader;
+ WideString wsBookendLeader;
CXFA_Node* pContainer =
pBookendNode
->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
@@ -1667,9 +1666,9 @@ 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) {
- WideStringView wsOverflowLeader;
- WideStringView wsOverflowTarget;
- WideStringView wsOverflowTrailer;
+ WideString wsOverflowLeader;
+ WideString wsOverflowTarget;
+ WideString wsOverflowTrailer;
pCurNode->JSNode()->TryCData(XFA_Attribute::OverflowLeader,
wsOverflowLeader, true);
pCurNode->JSNode()->TryCData(XFA_Attribute::OverflowTrailer,
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 2ab0b18cf5..c906d26bda 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -199,10 +199,10 @@ CXFA_Node* CXFA_Node::Clone(bool bRecursive) {
WideString wsName;
JSNode()->GetAttribute(XFA_Attribute::Name, wsName, false);
auto pCloneXMLElement = pdfium::MakeUnique<CFX_XMLElement>(wsName);
- WideStringView wsValue = JSNode()->GetCData(XFA_Attribute::Value);
- if (!wsValue.IsEmpty()) {
+ WideString wsValue = JSNode()->GetCData(XFA_Attribute::Value);
+ if (!wsValue.IsEmpty())
pCloneXMLElement->SetTextData(WideString(wsValue));
- }
+
pCloneXML.reset(pCloneXMLElement.release());
pClone->JSNode()->SetEnum(XFA_Attribute::Contains,
XFA_ATTRIBUTEENUM_Unknown, false);
@@ -852,18 +852,17 @@ bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) {
if (pNode->m_pXMLNode->GetType() == FX_XMLNODE_Element) {
CFX_XMLElement* pXMLElement =
static_cast<CFX_XMLElement*>(pNode->m_pXMLNode);
- WideStringView wsAttributeName =
+ WideString wsAttributeName =
pNode->JSNode()->GetCData(XFA_Attribute::QualifiedName);
- // TODO(tsepez): check usage of c_str() below.
- pXMLElement->RemoveAttribute(wsAttributeName.unterminated_c_str());
+ pXMLElement->RemoveAttribute(wsAttributeName.c_str());
}
WideString wsName;
pNode->JSNode()->GetAttribute(XFA_Attribute::Name, wsName, false);
CFX_XMLElement* pNewXMLElement = new CFX_XMLElement(wsName);
- WideStringView wsValue = JSNode()->GetCData(XFA_Attribute::Value);
- if (!wsValue.IsEmpty()) {
+ WideString wsValue = JSNode()->GetCData(XFA_Attribute::Value);
+ if (!wsValue.IsEmpty())
pNewXMLElement->SetTextData(WideString(wsValue));
- }
+
pNode->m_pXMLNode = pNewXMLElement;
pNode->JSNode()->SetEnum(XFA_Attribute::Contains,
XFA_ATTRIBUTEENUM_Unknown, false);
@@ -963,9 +962,8 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() {
break;
}
if (eType == XFA_Element::InstanceManager) {
- WideStringView wsName = JSNode()->GetCData(XFA_Attribute::Name);
- WideStringView wsInstName =
- pNode->JSNode()->GetCData(XFA_Attribute::Name);
+ WideString wsName = JSNode()->GetCData(XFA_Attribute::Name);
+ WideString wsInstName = pNode->JSNode()->GetCData(XFA_Attribute::Name);
if (wsInstName.GetLength() > 0 && wsInstName[0] == '_' &&
wsInstName.Right(wsInstName.GetLength() - 1) == wsName) {
pInstanceMgr = pNode;
@@ -1020,14 +1018,14 @@ void CXFA_Node::OnRemoved(bool bNotify) {
void CXFA_Node::UpdateNameHash() {
const XFA_NOTSUREATTRIBUTE* pNotsure =
XFA_GetNotsureAttribute(GetElementType(), XFA_Attribute::Name);
- WideStringView wsName;
+ WideString wsName;
if (!pNotsure || pNotsure->eType == XFA_AttributeType::CData) {
wsName = JSNode()->GetCData(XFA_Attribute::Name);
- m_dwNameHash = FX_HashCode_GetW(wsName, false);
+ m_dwNameHash = FX_HashCode_GetW(wsName.AsStringView(), false);
} else if (pNotsure->eType == XFA_AttributeType::Enum) {
wsName =
GetAttributeEnumByID(JSNode()->GetEnum(XFA_Attribute::Name))->pName;
- m_dwNameHash = FX_HashCode_GetW(wsName, false);
+ m_dwNameHash = FX_HashCode_GetW(wsName.AsStringView(), false);
}
}
@@ -1058,8 +1056,8 @@ CXFA_Node* CXFA_Node::GetItem(int32_t iIndex) {
continue;
}
if (iCount == 0) {
- WideStringView wsName = pNode->JSNode()->GetCData(XFA_Attribute::Name);
- WideStringView wsInstName = JSNode()->GetCData(XFA_Attribute::Name);
+ WideString wsName = pNode->JSNode()->GetCData(XFA_Attribute::Name);
+ WideString wsInstName = JSNode()->GetCData(XFA_Attribute::Name);
if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' ||
wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
return nullptr;
@@ -1089,8 +1087,8 @@ int32_t CXFA_Node::GetCount() {
continue;
}
if (iCount == 0) {
- WideStringView wsName = pNode->JSNode()->GetCData(XFA_Attribute::Name);
- WideStringView wsInstName = JSNode()->GetCData(XFA_Attribute::Name);
+ WideString wsName = pNode->JSNode()->GetCData(XFA_Attribute::Name);
+ WideString wsInstName = JSNode()->GetCData(XFA_Attribute::Name);
if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' ||
wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
return iCount;
@@ -1229,3 +1227,57 @@ CXFA_Node* CXFA_Node::CreateInstance(bool bDataMerge) {
return pInstance;
}
+pdfium::Optional<bool> CXFA_Node::GetDefaultBoolean(XFA_Attribute attr) const {
+ void* pValue = nullptr;
+ if (!XFA_GetAttributeDefaultValue(pValue, GetElementType(), attr,
+ XFA_AttributeType::Boolean,
+ GetPacketID())) {
+ return {};
+ }
+ return {!!pValue};
+}
+
+pdfium::Optional<int32_t> CXFA_Node::GetDefaultInteger(
+ XFA_Attribute attr) const {
+ void* pValue = nullptr;
+ if (!XFA_GetAttributeDefaultValue(pValue, GetElementType(), attr,
+ XFA_AttributeType::Integer,
+ GetPacketID())) {
+ return {};
+ }
+ return {static_cast<int32_t>(reinterpret_cast<uintptr_t>(pValue))};
+}
+
+pdfium::Optional<CXFA_Measurement> CXFA_Node::GetDefaultMeasurement(
+ XFA_Attribute attr) const {
+ void* pValue = nullptr;
+ if (!XFA_GetAttributeDefaultValue(pValue, GetElementType(), attr,
+ XFA_AttributeType::Measure,
+ GetPacketID())) {
+ return {};
+ }
+ CXFA_Measurement measure;
+ memcpy(&measure, pValue, sizeof(measure));
+ return {measure};
+}
+
+pdfium::Optional<WideString> CXFA_Node::GetDefaultCData(
+ XFA_Attribute attr) const {
+ void* pValue = nullptr;
+ if (!XFA_GetAttributeDefaultValue(pValue, GetElementType(), attr,
+ XFA_AttributeType::CData, GetPacketID())) {
+ return {};
+ }
+ WideStringView view((const wchar_t*)pValue);
+ return {WideString(view)};
+}
+
+pdfium::Optional<XFA_ATTRIBUTEENUM> CXFA_Node::GetDefaultEnum(
+ XFA_Attribute attr) const {
+ void* pValue = nullptr;
+ if (!XFA_GetAttributeDefaultValue(pValue, GetElementType(), attr,
+ XFA_AttributeType::Enum, GetPacketID())) {
+ return {};
+ }
+ return {static_cast<XFA_ATTRIBUTEENUM>(reinterpret_cast<uintptr_t>(pValue))};
+}
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 073fd5261f..66a3174901 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -140,6 +140,13 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node* GetOccurNode();
+ pdfium::Optional<bool> GetDefaultBoolean(XFA_Attribute attr) const;
+ pdfium::Optional<int32_t> GetDefaultInteger(XFA_Attribute attr) const;
+ pdfium::Optional<CXFA_Measurement> GetDefaultMeasurement(
+ XFA_Attribute attr) const;
+ pdfium::Optional<WideString> GetDefaultCData(XFA_Attribute attr) const;
+ pdfium::Optional<XFA_ATTRIBUTEENUM> GetDefaultEnum(XFA_Attribute attr) const;
+
private:
CXFA_Node(CXFA_Document* pDoc,
uint16_t ePacket,
diff --git a/xfa/fxfa/parser/cxfa_scriptdata.cpp b/xfa/fxfa/parser/cxfa_scriptdata.cpp
index ea957f94c5..f7352be79c 100644
--- a/xfa/fxfa/parser/cxfa_scriptdata.cpp
+++ b/xfa/fxfa/parser/cxfa_scriptdata.cpp
@@ -11,7 +11,7 @@
CXFA_ScriptData::CXFA_ScriptData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
XFA_ScriptDataType CXFA_ScriptData::GetContentType() {
- WideStringView cData;
+ WideString cData;
if (!m_pNode->JSNode()->TryCData(XFA_Attribute::ContentType, cData, false))
return XFA_ScriptDataType::Formcalc;
if (cData == L"application/x-javascript")
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 79214356fe..579ca9e832 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -60,8 +60,8 @@ CFX_XMLNode* GetDocumentNode(CFX_XMLDoc* pXMLDoc,
WideString GetElementTagNamespaceURI(CFX_XMLElement* pElement) {
WideString wsNodeStr = pElement->GetNamespacePrefix();
WideString wsNamespaceURI;
- if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNodeStr.AsStringView(), &wsNamespaceURI)) {
+ if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNodeStr,
+ &wsNamespaceURI)) {
return WideString();
}
return wsNamespaceURI;
@@ -103,21 +103,20 @@ bool GetAttributeLocalName(const WideStringView& wsAttributeName,
}
bool ResolveAttribute(CFX_XMLElement* pElement,
- const WideStringView& wsAttributeName,
+ const WideString& wsAttrName,
WideString& wsLocalAttrName,
WideString& wsNamespaceURI) {
- WideString wsAttrName(wsAttributeName);
WideString wsNSPrefix;
- if (GetAttributeLocalName(wsAttributeName, wsLocalAttrName)) {
- wsNSPrefix = wsAttrName.Left(wsAttributeName.GetLength() -
+ if (GetAttributeLocalName(wsAttrName.AsStringView(), wsLocalAttrName)) {
+ wsNSPrefix = wsAttrName.Left(wsAttrName.GetLength() -
wsLocalAttrName.GetLength() - 1);
}
if (wsLocalAttrName == L"xmlns" || wsNSPrefix == L"xmlns" ||
wsNSPrefix == L"xml") {
return false;
}
- if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNSPrefix.AsStringView(), &wsNamespaceURI)) {
+ if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNSPrefix,
+ &wsNamespaceURI)) {
wsNamespaceURI.clear();
return false;
}
@@ -147,8 +146,8 @@ bool FindAttributeWithNS(CFX_XMLElement* pElement,
wsNSPrefix = it.first.Left(pos.value());
}
- if (!XFA_FDEExtension_ResolveNamespaceQualifier(
- pElement, wsNSPrefix.AsStringView(), &wsAttrNS)) {
+ if (!XFA_FDEExtension_ResolveNamespaceQualifier(pElement, wsNSPrefix,
+ &wsAttrNS)) {
continue;
}
if (bMatchNSAsPrefix) {
@@ -388,10 +387,9 @@ CFX_XMLDoc* CXFA_SimpleParser::GetXMLDoc() const {
return m_pXMLDoc.get();
}
-bool XFA_FDEExtension_ResolveNamespaceQualifier(
- CFX_XMLElement* pNode,
- const WideStringView& wsQualifier,
- WideString* wsNamespaceURI) {
+bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode,
+ const WideString& wsQualifier,
+ WideString* wsNamespaceURI) {
if (!pNode)
return false;
@@ -952,7 +950,7 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode,
XFA_XDPPACKET ePacketID) {
XFA_Element element = XFA_Element::Sharptext;
if (pXFANode->GetElementType() == XFA_Element::ExData) {
- WideStringView wsContentType =
+ WideString wsContentType =
pXFANode->JSNode()->GetCData(XFA_Attribute::ContentType);
if (wsContentType == L"text/html")
element = XFA_Element::SharpxHTML;
@@ -1072,8 +1070,7 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
for (auto it : pXMLElement->GetAttributes()) {
WideString wsName;
WideString wsNS;
- if (!ResolveAttribute(pXMLElement, it.first.AsStringView(), wsName,
- wsNS)) {
+ if (!ResolveAttribute(pXMLElement, it.first, wsName, wsNS)) {
continue;
}
if (wsName == L"nil" && it.second == L"true") {
@@ -1205,7 +1202,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
pXFANode->InsertChild(pXFAChild, nullptr);
pXFAChild->SetXMLMappingNode(pXMLChild);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
- WideStringView wsCurValue =
+ WideString wsCurValue =
pXFAChild->JSNode()->GetCData(XFA_Attribute::Value);
wsValueTextBuf << wsCurValue;
}
diff --git a/xfa/fxfa/parser/cxfa_strokedata.cpp b/xfa/fxfa/parser/cxfa_strokedata.cpp
index 93247e3537..76798cb4bb 100644
--- a/xfa/fxfa/parser/cxfa_strokedata.cpp
+++ b/xfa/fxfa/parser/cxfa_strokedata.cpp
@@ -32,9 +32,7 @@ float CXFA_StrokeData::GetThickness() const {
CXFA_Measurement CXFA_StrokeData::GetMSThickness() const {
return m_pNode ? m_pNode->JSNode()->GetMeasure(XFA_Attribute::Thickness)
- : XFA_GetAttributeDefaultValue_Measure(
- XFA_Element::Edge, XFA_Attribute::Thickness,
- XFA_XDPPACKET_Form);
+ : CXFA_Measurement(0.5, XFA_Unit::Pt);
}
void CXFA_StrokeData::SetMSThickness(CXFA_Measurement msThinkness) {
@@ -52,9 +50,9 @@ FX_ARGB CXFA_StrokeData::GetColor() const {
if (!pNode)
return 0xFF000000;
- WideStringView wsColor;
+ WideString wsColor;
pNode->JSNode()->TryCData(XFA_Attribute::Value, wsColor, true);
- return CXFA_DataData::ToColor(wsColor);
+ return CXFA_DataData::ToColor(wsColor.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 629cb9ea61..1d4b91c5b6 100644
--- a/xfa/fxfa/parser/cxfa_submitdata.cpp
+++ b/xfa/fxfa/parser/cxfa_submitdata.cpp
@@ -18,10 +18,10 @@ int32_t CXFA_SubmitData::GetSubmitFormat() {
return m_pNode->JSNode()->GetEnum(XFA_Attribute::Format);
}
-void CXFA_SubmitData::GetSubmitTarget(WideStringView& wsTarget) {
+void CXFA_SubmitData::GetSubmitTarget(WideString& wsTarget) {
m_pNode->JSNode()->TryCData(XFA_Attribute::Target, wsTarget, true);
}
-void CXFA_SubmitData::GetSubmitXDPContent(WideStringView& wsContent) {
+void CXFA_SubmitData::GetSubmitXDPContent(WideString& wsContent) {
m_pNode->JSNode()->TryCData(XFA_Attribute::XdpContent, wsContent, true);
}
diff --git a/xfa/fxfa/parser/cxfa_submitdata.h b/xfa/fxfa/parser/cxfa_submitdata.h
index 28cb3c29f2..e90848d9f1 100644
--- a/xfa/fxfa/parser/cxfa_submitdata.h
+++ b/xfa/fxfa/parser/cxfa_submitdata.h
@@ -19,8 +19,8 @@ class CXFA_SubmitData : public CXFA_DataData {
bool IsSubmitEmbedPDF();
int32_t GetSubmitFormat();
- void GetSubmitTarget(WideStringView& wsTarget);
- void GetSubmitXDPContent(WideStringView& wsContent);
+ void GetSubmitTarget(WideString& wsTarget);
+ void GetSubmitXDPContent(WideString& wsContent);
};
#endif // XFA_FXFA_PARSER_CXFA_SUBMITDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_validatedata.cpp b/xfa/fxfa/parser/cxfa_validatedata.cpp
index c332b12c7b..c7cfbabe6e 100644
--- a/xfa/fxfa/parser/cxfa_validatedata.cpp
+++ b/xfa/fxfa/parser/cxfa_validatedata.cpp
@@ -45,7 +45,7 @@ void CXFA_ValidateData::GetMessageText(WideString& wsMessage,
if (pItemNode->GetElementType() != XFA_Element::Text)
continue;
- WideStringView wsName;
+ WideString wsName;
pItemNode->JSNode()->TryCData(XFA_Attribute::Name, wsName, true);
if (wsName.IsEmpty() || wsName == wsMessageType) {
pItemNode->JSNode()->TryContent(wsMessage, false, true);
@@ -83,7 +83,7 @@ void CXFA_ValidateData::SetMessageText(WideString& wsMessage,
if (pItemNode->GetElementType() != XFA_Element::Text)
continue;
- WideStringView wsName;
+ WideString wsName;
pItemNode->JSNode()->TryCData(XFA_Attribute::Name, wsName, true);
if (wsName.IsEmpty() || wsName == wsMessageType) {
pItemNode->JSNode()->SetContent(wsMessage, wsMessage, false, false, true);
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 48832eb5e9..2e9eda8b8c 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -198,39 +198,6 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
return pUIChild;
}
-XFA_ATTRIBUTEENUM GetAttributeDefaultValue_Enum(XFA_Element eElement,
- XFA_Attribute eAttribute,
- uint32_t dwPacket) {
- void* pValue;
- if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
- XFA_AttributeType::Enum, dwPacket)) {
- return (XFA_ATTRIBUTEENUM)(uintptr_t)pValue;
- }
- return XFA_ATTRIBUTEENUM_Unknown;
-}
-
-WideStringView GetAttributeDefaultValue_Cdata(XFA_Element eElement,
- XFA_Attribute eAttribute,
- uint32_t dwPacket) {
- void* pValue;
- if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
- XFA_AttributeType::CData, dwPacket)) {
- return (const wchar_t*)pValue;
- }
- return nullptr;
-}
-
-bool GetAttributeDefaultValue_Boolean(XFA_Element eElement,
- XFA_Attribute eAttribute,
- uint32_t dwPacket) {
- void* pValue;
- if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
- XFA_AttributeType::Boolean, dwPacket)) {
- return !!pValue;
- }
- return false;
-}
-
} // namespace
CXFA_WidgetData::CXFA_WidgetData(CXFA_Node* pNode)
@@ -315,7 +282,7 @@ std::vector<CXFA_Node*> CXFA_WidgetData::GetEventByActivity(int32_t iActivity,
CXFA_EventData eventData(pNode);
if (eventData.GetActivity() == iActivity) {
if (iActivity == XFA_ATTRIBUTEENUM_Ready) {
- WideStringView wsRef;
+ WideString wsRef;
eventData.GetRef(wsRef);
if (bIsFormReady) {
if (wsRef == WideStringView(L"$form"))
@@ -427,12 +394,11 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() {
return CFX_RectF(fLeftInset, fTopInset, fRightInset, fBottomInset);
}
-int32_t CXFA_WidgetData::GetButtonHighlight() {
+XFA_ATTRIBUTEENUM CXFA_WidgetData::GetButtonHighlight() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
return pUIChild->JSNode()->GetEnum(XFA_Attribute::Highlight);
- return GetAttributeDefaultValue_Enum(
- XFA_Element::Button, XFA_Attribute::Highlight, XFA_XDPPACKET_Form);
+ return XFA_ATTRIBUTEENUM_Inverted;
}
bool CXFA_WidgetData::GetButtonRollover(WideString& wsRollover,
@@ -440,7 +406,7 @@ 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) {
- WideStringView wsName;
+ WideString wsName;
pText->JSNode()->TryCData(XFA_Attribute::Name, wsName, true);
if (wsName == L"rollover") {
pText->JSNode()->TryContent(wsRollover, false, true);
@@ -457,7 +423,7 @@ 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) {
- WideStringView wsName;
+ WideString wsName;
pText->JSNode()->TryCData(XFA_Attribute::Name, wsName, true);
if (wsName == L"down") {
pText->JSNode()->TryContent(wsDown, false, true);
@@ -470,46 +436,39 @@ bool CXFA_WidgetData::GetButtonDown(WideString& wsDown, bool& bRichText) {
return false;
}
-int32_t CXFA_WidgetData::GetCheckButtonShape() {
+XFA_ATTRIBUTEENUM CXFA_WidgetData::GetCheckButtonShape() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
return pUIChild->JSNode()->GetEnum(XFA_Attribute::Shape);
- return GetAttributeDefaultValue_Enum(
- XFA_Element::CheckButton, XFA_Attribute::Shape, XFA_XDPPACKET_Form);
+ return XFA_ATTRIBUTEENUM_Square;
}
-int32_t CXFA_WidgetData::GetCheckButtonMark() {
+XFA_ATTRIBUTEENUM CXFA_WidgetData::GetCheckButtonMark() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
return pUIChild->JSNode()->GetEnum(XFA_Attribute::Mark);
- return GetAttributeDefaultValue_Enum(XFA_Element::CheckButton,
- XFA_Attribute::Mark, XFA_XDPPACKET_Form);
+ return XFA_ATTRIBUTEENUM_Default;
}
bool CXFA_WidgetData::IsRadioButton() {
- if (CXFA_Node* pParent = m_pNode->GetNodeItem(XFA_NODEITEM_Parent))
- return pParent->GetElementType() == XFA_Element::ExclGroup;
- return false;
+ CXFA_Node* pParent = m_pNode->GetNodeItem(XFA_NODEITEM_Parent);
+ return pParent && pParent->GetElementType() == XFA_Element::ExclGroup;
}
float CXFA_WidgetData::GetCheckButtonSize() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild)
+ if (pUIChild) {
return pUIChild->JSNode()
->GetMeasure(XFA_Attribute::Size)
.ToUnit(XFA_Unit::Pt);
- return XFA_GetAttributeDefaultValue_Measure(
- XFA_Element::CheckButton, XFA_Attribute::Size, XFA_XDPPACKET_Form)
- .ToUnit(XFA_Unit::Pt);
+ }
+ return CXFA_Measurement(10, XFA_Unit::Pt).ToUnit(XFA_Unit::Pt);
}
bool CXFA_WidgetData::IsAllowNeutral() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild)
- return pUIChild->JSNode()->GetBoolean(XFA_Attribute::AllowNeutral);
- return GetAttributeDefaultValue_Boolean(XFA_Element::CheckButton,
- XFA_Attribute::AllowNeutral,
- XFA_XDPPACKET_Form);
+ return pUIChild &&
+ pUIChild->JSNode()->GetBoolean(XFA_Attribute::AllowNeutral);
}
XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() {
@@ -695,28 +654,23 @@ CXFA_Node* CXFA_WidgetData::GetExclGroupNextMember(CXFA_Node* pNode) {
return nullptr;
}
-int32_t CXFA_WidgetData::GetChoiceListCommitOn() {
+XFA_ATTRIBUTEENUM CXFA_WidgetData::GetChoiceListCommitOn() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
return pUIChild->JSNode()->GetEnum(XFA_Attribute::CommitOn);
- return GetAttributeDefaultValue_Enum(
- XFA_Element::ChoiceList, XFA_Attribute::CommitOn, XFA_XDPPACKET_Form);
+ return XFA_ATTRIBUTEENUM_Select;
}
bool CXFA_WidgetData::IsChoiceListAllowTextEntry() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild)
- return pUIChild->JSNode()->GetBoolean(XFA_Attribute::TextEntry);
- return GetAttributeDefaultValue_Boolean(
- XFA_Element::ChoiceList, XFA_Attribute::TextEntry, XFA_XDPPACKET_Form);
+ return pUIChild && pUIChild->JSNode()->GetBoolean(XFA_Attribute::TextEntry);
}
-int32_t CXFA_WidgetData::GetChoiceListOpen() {
+XFA_ATTRIBUTEENUM CXFA_WidgetData::GetChoiceListOpen() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
return pUIChild->JSNode()->GetEnum(XFA_Attribute::Open);
- return GetAttributeDefaultValue_Enum(XFA_Element::ChoiceList,
- XFA_Attribute::Open, XFA_XDPPACKET_Form);
+ return XFA_ATTRIBUTEENUM_UserControl;
}
bool CXFA_WidgetData::IsListBox() {
@@ -1231,7 +1185,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_StartChar(char* val) {
CXFA_Node* pUIChild = GetUIChild();
- WideStringView wsStartEndChar;
+ WideString wsStartEndChar;
if (pUIChild->JSNode()->TryCData(XFA_Attribute::StartChar, wsStartEndChar,
true)) {
if (wsStartEndChar.GetLength()) {
@@ -1244,7 +1198,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_StartChar(char* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_EndChar(char* val) {
CXFA_Node* pUIChild = GetUIChild();
- WideStringView wsStartEndChar;
+ WideString wsStartEndChar;
if (pUIChild->JSNode()->TryCData(XFA_Attribute::EndChar, wsStartEndChar,
true)) {
if (wsStartEndChar.GetLength()) {
@@ -1364,29 +1318,22 @@ bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(float* val) {
void CXFA_WidgetData::GetPasswordChar(WideString& wsPassWord) {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild) {
+ if (pUIChild)
pUIChild->JSNode()->TryCData(XFA_Attribute::PasswordChar, wsPassWord, true);
- } else {
- wsPassWord = GetAttributeDefaultValue_Cdata(XFA_Element::PasswordEdit,
- XFA_Attribute::PasswordChar,
- XFA_XDPPACKET_Form);
- }
+ else
+ wsPassWord = L"*";
}
bool CXFA_WidgetData::IsMultiLine() {
CXFA_Node* pUIChild = GetUIChild();
- if (pUIChild)
- return pUIChild->JSNode()->GetBoolean(XFA_Attribute::MultiLine);
- return GetAttributeDefaultValue_Boolean(
- XFA_Element::TextEdit, XFA_Attribute::MultiLine, XFA_XDPPACKET_Form);
+ return pUIChild && pUIChild->JSNode()->GetBoolean(XFA_Attribute::MultiLine);
}
-int32_t CXFA_WidgetData::GetVerticalScrollPolicy() {
+XFA_ATTRIBUTEENUM CXFA_WidgetData::GetVerticalScrollPolicy() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
return pUIChild->JSNode()->GetEnum(XFA_Attribute::VScrollPolicy);
- return GetAttributeDefaultValue_Enum(
- XFA_Element::TextEdit, XFA_Attribute::VScrollPolicy, XFA_XDPPACKET_Form);
+ return XFA_ATTRIBUTEENUM_Auto;
}
int32_t CXFA_WidgetData::GetMaxChars(XFA_Element& eType) {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 3f1b4dc399..12e811361b 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -70,11 +70,11 @@ class CXFA_WidgetData : public CXFA_DataData {
CXFA_BorderData GetUIBorderData();
CFX_RectF GetUIMargin();
- int32_t GetButtonHighlight();
+ XFA_ATTRIBUTEENUM GetButtonHighlight();
bool GetButtonRollover(WideString& wsRollover, bool& bRichText);
bool GetButtonDown(WideString& wsDown, bool& bRichText);
- int32_t GetCheckButtonShape();
- int32_t GetCheckButtonMark();
+ XFA_ATTRIBUTEENUM GetCheckButtonShape();
+ XFA_ATTRIBUTEENUM GetCheckButtonMark();
float GetCheckButtonSize();
bool IsAllowNeutral();
bool IsRadioButton();
@@ -89,9 +89,9 @@ class CXFA_WidgetData : public CXFA_DataData {
bool bSyncData);
CXFA_Node* GetExclGroupFirstMember();
CXFA_Node* GetExclGroupNextMember(CXFA_Node* pNode);
- int32_t GetChoiceListCommitOn();
+ XFA_ATTRIBUTEENUM GetChoiceListCommitOn();
bool IsChoiceListAllowTextEntry();
- int32_t GetChoiceListOpen();
+ XFA_ATTRIBUTEENUM GetChoiceListOpen();
bool IsListBox();
int32_t CountChoiceListItems(bool bSaveValue);
bool GetChoiceListItem(WideString& wsText, int32_t nIndex, bool bSaveValue);
@@ -145,7 +145,7 @@ class CXFA_WidgetData : public CXFA_DataData {
void GetPasswordChar(WideString& wsPassWord);
bool IsMultiLine();
- int32_t GetVerticalScrollPolicy();
+ XFA_ATTRIBUTEENUM GetVerticalScrollPolicy();
int32_t GetMaxChars(XFA_Element& eType);
bool GetFracDigits(int32_t& iFracDigits);
bool GetLeadDigits(int32_t& iLeadDigits);
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 67256f2385..128ad7b2ad 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -424,13 +424,13 @@ CXFA_Node* ScopeMatchGlobalBinding(CXFA_Node* pDataScope,
}
CXFA_Node* FindGlobalDataNode(CXFA_Document* pDocument,
- WideStringView wsName,
+ const WideString& wsName,
CXFA_Node* pDataScope,
XFA_Element eMatchNodeType) {
if (wsName.IsEmpty())
return nullptr;
- uint32_t dwNameHash = FX_HashCode_GetW(wsName, false);
+ uint32_t dwNameHash = FX_HashCode_GetW(wsName.AsStringView(), false);
CXFA_Node* pBounded = GetGlobalBinding(pDocument, dwNameHash);
if (!pBounded) {
pBounded =
@@ -442,13 +442,13 @@ CXFA_Node* FindGlobalDataNode(CXFA_Document* pDocument,
}
CXFA_Node* FindOnceDataNode(CXFA_Document* pDocument,
- WideStringView wsName,
+ const WideString& wsName,
CXFA_Node* pDataScope,
XFA_Element eMatchNodeType) {
if (wsName.IsEmpty())
return nullptr;
- uint32_t dwNameHash = FX_HashCode_GetW(wsName, false);
+ uint32_t dwNameHash = FX_HashCode_GetW(wsName.AsStringView(), false);
CXFA_Node* pLastDataScope = nullptr;
for (CXFA_Node* pCurDataScope = pDataScope;
pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets;
@@ -469,7 +469,7 @@ CXFA_Node* FindOnceDataNode(CXFA_Document* pDocument,
}
CXFA_Node* FindDataRefDataNode(CXFA_Document* pDocument,
- WideStringView wsRef,
+ const WideString& wsRef,
CXFA_Node* pDataScope,
XFA_Element eMatchNodeType,
CXFA_Node* pTemplateNode,
@@ -480,8 +480,8 @@ CXFA_Node* FindDataRefDataNode(CXFA_Document* pDocument,
dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings);
XFA_RESOLVENODE_RS rs;
- pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags,
- pTemplateNode);
+ pDocument->GetScriptContext()->ResolveObjects(
+ pDataScope, wsRef.AsStringView(), rs, dFlags, pTemplateNode);
if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll ||
rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll ||
rs.objects.size() > 1) {
@@ -513,7 +513,7 @@ CXFA_Node* CloneOrMergeInstanceManager(CXFA_Document* pDocument,
CXFA_Node* pFormParent,
CXFA_Node* pTemplateNode,
std::vector<CXFA_Node*>* subforms) {
- WideStringView wsSubformName =
+ WideString wsSubformName =
pTemplateNode->JSNode()->GetCData(XFA_Attribute::Name);
WideString wsInstMgrNodeName = L"_" + wsSubformName;
uint32_t dwInstNameHash =
@@ -1165,13 +1165,13 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
bMatchRef = bDataRef;
bParentDataRef = true;
if (!pDataNode && bDataRef) {
- WideStringView wsRef =
+ WideString wsRef =
pTemplateNodeBind->JSNode()->GetCData(XFA_Attribute::Ref);
uint32_t dFlags =
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode;
XFA_RESOLVENODE_RS rs;
- pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs,
- dFlags, pTemplateNode);
+ pDocument->GetScriptContext()->ResolveObjects(
+ pDataScope, wsRef.AsStringView(), rs, dFlags, pTemplateNode);
CXFA_Object* pObject =
!rs.objects.empty() ? rs.objects.front() : nullptr;
pDataNode = ToNode(pObject);
@@ -1465,7 +1465,7 @@ void CXFA_Document::DoDataMerge() {
this, pFormRoot, pTemplateChosen, false, nullptr);
ASSERT(pSubformSetNode);
if (!pDataTopLevel) {
- WideStringView wsFormName =
+ WideString wsFormName =
pSubformSetNode->JSNode()->GetCData(XFA_Attribute::Name);
WideString wsDataTopLevelName(wsFormName.IsEmpty() ? L"form" : wsFormName);
CFX_XMLElement* pDataTopLevelXMLNode =
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 122cfb0a1a..5bdfe5853b 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -393,17 +393,6 @@ XFA_Element XFA_GetElementTypeForName(const WideStringView& wsName) {
return XFA_Element::Unknown;
}
-CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_Element eElement,
- XFA_Attribute eAttribute,
- uint32_t dwPacket) {
- void* pValue;
- if (XFA_GetAttributeDefaultValue(pValue, eElement, eAttribute,
- XFA_AttributeType::Measure, dwPacket)) {
- return *(CXFA_Measurement*)pValue;
- }
- return CXFA_Measurement();
-}
-
bool XFA_GetAttributeDefaultValue(void*& pValue,
XFA_Element eElement,
XFA_Attribute eAttribute,
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index a7498561e1..cfa27bbccd 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -19,10 +19,9 @@ class CXFA_WidgetData;
double XFA_GetFractionalScale(uint32_t idx);
int XFA_GetMaxFractionalScale();
-bool XFA_FDEExtension_ResolveNamespaceQualifier(
- CFX_XMLElement* pNode,
- const WideStringView& wsQualifier,
- WideString* wsNamespaceURI);
+bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode,
+ const WideString& wsQualifier,
+ WideString* wsNamespaceURI);
template <class NodeType, class TraverseStrategy>
class CXFA_NodeIteratorTemplate {
@@ -177,9 +176,6 @@ const XFA_Attribute* XFA_GetElementAttributes(XFA_Element eElement,
int32_t& iCount);
const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_Element eName);
XFA_Element XFA_GetElementTypeForName(const WideStringView& wsName);
-CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_Element eElement,
- XFA_Attribute eAttribute,
- uint32_t dwPacket);
bool XFA_GetAttributeDefaultValue(void*& pValue,
XFA_Element eElement,
XFA_Attribute eAttribute,