summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-01 16:04:36 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-01 16:04:36 +0000
commite5434b5531f2c081c1d69f67125b6665070ea969 (patch)
tree1fa141f20597c62e9f2e2738d438bfaaecc772a3 /xfa
parent3fff90a670d860a7b0319aa0edf8628917d0a122 (diff)
downloadpdfium-e5434b5531f2c081c1d69f67125b6665070ea969.tar.xz
Split JS code out of CXFA_Node.
This CL moves JS code out of CXFA_Node and places it into fxjs/cjx_node. The CXFA_Node then has a CJX_Node as a member and, currently, proxies JS calls to the CJX_Node member. Change-Id: Ic5b95184c8fd2347f0bdcfbccfa89bb6b52835b6 Reviewed-on: https://pdfium-review.googlesource.com/17290 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffdochandler.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp25
-rw-r--r--xfa/fxfa/cxfa_ffnotify.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffpageview.cpp3
-rw-r--r--xfa/fxfa/cxfa_ffwidgethandler.cpp48
-rw-r--r--xfa/fxfa/cxfa_textlayout.cpp4
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp8
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp24
-rw-r--r--xfa/fxfa/parser/cscript_layoutpseudomodel.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_bind.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_binditems.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_box.cpp27
-rw-r--r--xfa/fxfa/parser/cxfa_calculate.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_caption.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_containerlayoutitem.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_contentlayoutitem.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_data.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp24
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp22
-rw-r--r--xfa/fxfa/parser/cxfa_event.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_exdata.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_fill.cpp32
-rw-r--r--xfa/fxfa/parser/cxfa_font.cpp26
-rw-r--r--xfa/fxfa/parser/cxfa_image.cpp23
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp219
-rw-r--r--xfa/fxfa/parser/cxfa_layoutitem.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp173
-rw-r--r--xfa/fxfa/parser/cxfa_layoutprocessor.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_line.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_localemgr.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp3967
-rw-r--r--xfa/fxfa/parser/cxfa_node.h218
-rw-r--r--xfa/fxfa/parser/cxfa_nodehelper.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_nodelocale.cpp14
-rw-r--r--xfa/fxfa/parser/cxfa_occur.cpp20
-rw-r--r--xfa/fxfa/parser/cxfa_para.cpp16
-rw-r--r--xfa/fxfa/parser/cxfa_resolveprocessor.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_script.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp100
-rw-r--r--xfa/fxfa/parser/cxfa_stroke.cpp25
-rw-r--r--xfa/fxfa/parser/cxfa_submit.cpp8
-rw-r--r--xfa/fxfa/parser/cxfa_text.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_tooltip.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_validate.cpp28
-rw-r--r--xfa/fxfa/parser/cxfa_value.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp229
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp124
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp2
49 files changed, 1259 insertions, 4254 deletions
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index fed20caaa4..5b00d5a579 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -264,7 +264,7 @@ void CXFA_FFDoc::StopLoad() {
return;
WideString wsType;
- if (pDynamicRender->TryContent(wsType) && wsType == L"required")
+ if (pDynamicRender->JSNode()->TryContent(wsType) && wsType == L"required")
m_FormType = FormType::kXFAFull;
}
diff --git a/xfa/fxfa/cxfa_ffdochandler.cpp b/xfa/fxfa/cxfa_ffdochandler.cpp
index 11e5b47e7c..86e493084b 100644
--- a/xfa/fxfa/cxfa_ffdochandler.cpp
+++ b/xfa/fxfa/cxfa_ffdochandler.cpp
@@ -39,7 +39,7 @@ XFA_ATTRIBUTEENUM CXFA_FFDocHandler::GetRestoreState(CXFA_FFDoc* hDoc) {
CXFA_Node* pSubForm = pForm->GetFirstChildByClass(XFA_Element::Subform);
if (!pSubForm)
return XFA_ATTRIBUTEENUM_Unknown;
- return pSubForm->GetEnum(XFA_ATTRIBUTE_RestoreState);
+ return pSubForm->JSNode()->GetEnum(XFA_ATTRIBUTE_RestoreState);
}
bool CXFA_FFDocHandler::RunDocScript(CXFA_FFDoc* hDoc,
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 603b752d25..a23c7e2958 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -281,7 +281,7 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
: nullptr;
}
if (pValidateNode)
- wsValidateStr = pValidateNode->GetContent();
+ wsValidateStr = pValidateNode->JSNode()->GetContent();
}
if (!wsValidateStr.Contains(L"preSubmit"))
@@ -618,8 +618,8 @@ void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) {
}
void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) {
- auto* pGlobalData =
- static_cast<CXFA_CalcData*>(pNodeChange->GetUserData(XFA_CalcData));
+ auto* pGlobalData = static_cast<CXFA_CalcData*>(
+ pNodeChange->JSNode()->GetUserData(XFA_CalcData));
if (!pGlobalData)
return;
@@ -634,10 +634,11 @@ size_t CXFA_FFDocView::RunCalculateRecursive(size_t index) {
CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[index];
AddCalculateNodeNotify(pCurAcc->GetNode());
int32_t iRefCount =
- (int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount);
+ (int32_t)(uintptr_t)pCurAcc->GetNode()->JSNode()->GetUserData(
+ XFA_CalcRefCount);
iRefCount++;
- pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount,
- (void*)(uintptr_t)iRefCount);
+ pCurAcc->GetNode()->JSNode()->SetUserData(XFA_CalcRefCount,
+ (void*)(uintptr_t)iRefCount);
if (iRefCount > 11)
break;
if (pCurAcc->ProcessCalculate() == XFA_EVENTERROR_Success)
@@ -655,7 +656,8 @@ int32_t CXFA_FFDocView::RunCalculateWidgets() {
RunCalculateRecursive(0);
for (CXFA_WidgetAcc* pCurAcc : m_CalculateAccs)
- pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0);
+ pCurAcc->GetNode()->JSNode()->SetUserData(XFA_CalcRefCount,
+ (void*)(uintptr_t)0);
m_CalculateAccs.clear();
return XFA_EVENTERROR_Success;
@@ -744,19 +746,20 @@ void CXFA_FFDocView::RunBindItems() {
continue;
if (bValueUseContent) {
- wsValue = refNode->GetContent();
+ wsValue = refNode->JSNode()->GetContent();
} else {
CXFA_Node* nodeValue = refNode->GetFirstChildByName(uValueHash);
- wsValue = nodeValue ? nodeValue->GetContent() : refNode->GetContent();
+ wsValue = nodeValue ? nodeValue->JSNode()->GetContent()
+ : refNode->JSNode()->GetContent();
}
if (!bUseValue) {
if (bLabelUseContent) {
- wsLabel = refNode->GetContent();
+ wsLabel = refNode->JSNode()->GetContent();
} else {
CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef);
if (nodeLabel)
- wsLabel = nodeLabel->GetContent();
+ wsLabel = nodeLabel->JSNode()->GetContent();
}
} else {
wsLabel = wsValue;
diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp
index 9aac64ab6d..df28aac0c1 100644
--- a/xfa/fxfa/cxfa_ffnotify.cpp
+++ b/xfa/fxfa/cxfa_ffnotify.cpp
@@ -353,7 +353,8 @@ void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) {
XFA_Element eType = pNode->GetElementType();
if (XFA_IsCreateWidget(eType)) {
CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode);
- pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc);
+ pNode->JSNode()->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc,
+ &gs_XFADeleteWidgetAcc);
return;
}
switch (eType) {
diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp
index 0e0db8dae0..39115c7f5b 100644
--- a/xfa/fxfa/cxfa_ffpageview.cpp
+++ b/xfa/fxfa/cxfa_ffpageview.cpp
@@ -313,7 +313,8 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget(
CXFA_Node* pTraverse = pTraversal->GetChild(0, XFA_Element::Traverse);
if (pTraverse) {
WideString wsTraverseWidgetName;
- if (pTraverse->GetAttribute(XFA_ATTRIBUTE_Ref, wsTraverseWidgetName)) {
+ if (pTraverse->JSNode()->GetAttribute(XFA_ATTRIBUTE_Ref,
+ wsTraverseWidgetName)) {
return FindWidgetByName(wsTraverseWidgetName, pWidget);
}
}
diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp
index 8f916d804b..0a4033d6c7 100644
--- a/xfa/fxfa/cxfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp
@@ -313,25 +313,29 @@ CXFA_Node* CXFA_FFWidgetHandler::CreatePushButton(CXFA_Node* pParent,
CXFA_Node* pCaption = CreateCopyNode(XFA_Element::Caption, pField);
CXFA_Node* pValue = CreateCopyNode(XFA_Element::Value, pCaption);
CXFA_Node* pText = CreateCopyNode(XFA_Element::Text, pValue);
- pText->SetContent(L"Button", L"Button", false);
+ pText->JSNode()->SetContent(L"Button", L"Button", false);
CXFA_Node* pPara = CreateCopyNode(XFA_Element::Para, pCaption);
- pPara->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle, false);
- pPara->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center, false);
+ pPara->JSNode()->SetEnum(XFA_ATTRIBUTE_VAlign, XFA_ATTRIBUTEENUM_Middle,
+ false);
+ pPara->JSNode()->SetEnum(XFA_ATTRIBUTE_HAlign, XFA_ATTRIBUTEENUM_Center,
+ false);
CreateFontNode(pCaption);
CXFA_Node* pBorder = CreateCopyNode(XFA_Element::Border, pField);
- pBorder->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right, false);
+ pBorder->JSNode()->SetEnum(XFA_ATTRIBUTE_Hand, XFA_ATTRIBUTEENUM_Right,
+ false);
CXFA_Node* pEdge = CreateCopyNode(XFA_Element::Edge, pBorder);
- pEdge->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised, false);
+ pEdge->JSNode()->SetEnum(XFA_ATTRIBUTE_Stroke, XFA_ATTRIBUTEENUM_Raised,
+ false);
CXFA_Node* pFill = CreateCopyNode(XFA_Element::Fill, pBorder);
CXFA_Node* pColor = CreateCopyNode(XFA_Element::Color, pFill);
- pColor->SetCData(XFA_ATTRIBUTE_Value, L"212, 208, 200", false);
+ pColor->JSNode()->SetCData(XFA_ATTRIBUTE_Value, L"212, 208, 200", false);
CXFA_Node* pBind = CreateCopyNode(XFA_Element::Bind, pField);
- pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None);
+ pBind->JSNode()->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None);
return pField;
}
@@ -351,7 +355,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateRadioButton(CXFA_Node* pParent,
CXFA_Node* pField = CreateField(XFA_Element::CheckButton, pParent, pBefore);
CXFA_Node* pUi = pField->GetFirstChildByClass(XFA_Element::Ui);
CXFA_Node* pWidget = pUi->GetFirstChildByClass(XFA_Element::CheckButton);
- pWidget->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round);
+ pWidget->JSNode()->SetEnum(XFA_ATTRIBUTE_Shape, XFA_ATTRIBUTEENUM_Round);
return pField;
}
@@ -394,8 +398,8 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateListBox(CXFA_Node* pParent,
CXFA_Node* pField = CreateDropdownList(pParent, pBefore);
CXFA_Node* pUi = pField->GetNodeItem(XFA_NODEITEM_FirstChild);
CXFA_Node* pListBox = pUi->GetNodeItem(XFA_NODEITEM_FirstChild);
- pListBox->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always);
- pListBox->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit);
+ pListBox->JSNode()->SetEnum(XFA_ATTRIBUTE_Open, XFA_ATTRIBUTEENUM_Always);
+ pListBox->JSNode()->SetEnum(XFA_ATTRIBUTE_CommitOn, XFA_ATTRIBUTEENUM_Exit);
return pField;
}
@@ -408,7 +412,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreatePasswordEdit(CXFA_Node* pParent,
CXFA_Node* pBefore) const {
CXFA_Node* pField = CreateField(XFA_Element::PasswordEdit, pParent, pBefore);
CXFA_Node* pBind = CreateCopyNode(XFA_Element::Bind, pField);
- pBind->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, false);
+ pBind->JSNode()->SetEnum(XFA_ATTRIBUTE_Match, XFA_ATTRIBUTEENUM_None, false);
return pField;
}
@@ -502,7 +506,7 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateTemplateNode(XFA_Element eElement,
CXFA_Node* CXFA_FFWidgetHandler::CreateFontNode(CXFA_Node* pParent) const {
CXFA_Node* pFont = CreateCopyNode(XFA_Element::Font, pParent);
- pFont->SetCData(XFA_ATTRIBUTE_Typeface, L"Myriad Pro", false);
+ pFont->JSNode()->SetCData(XFA_ATTRIBUTE_Typeface, L"Myriad Pro", false);
return pFont;
}
@@ -511,17 +515,21 @@ CXFA_Node* CXFA_FFWidgetHandler::CreateMarginNode(CXFA_Node* pParent,
float fInsets[4]) const {
CXFA_Node* pMargin = CreateCopyNode(XFA_Element::Margin, pParent);
if (dwFlags & 0x01)
- pMargin->SetMeasure(XFA_ATTRIBUTE_LeftInset,
- CXFA_Measurement(fInsets[0], XFA_UNIT_Pt), false);
+ pMargin->JSNode()->SetMeasure(XFA_ATTRIBUTE_LeftInset,
+ CXFA_Measurement(fInsets[0], XFA_UNIT_Pt),
+ false);
if (dwFlags & 0x02)
- pMargin->SetMeasure(XFA_ATTRIBUTE_TopInset,
- CXFA_Measurement(fInsets[1], XFA_UNIT_Pt), false);
+ pMargin->JSNode()->SetMeasure(XFA_ATTRIBUTE_TopInset,
+ CXFA_Measurement(fInsets[1], XFA_UNIT_Pt),
+ false);
if (dwFlags & 0x04)
- pMargin->SetMeasure(XFA_ATTRIBUTE_RightInset,
- CXFA_Measurement(fInsets[2], XFA_UNIT_Pt), false);
+ pMargin->JSNode()->SetMeasure(XFA_ATTRIBUTE_RightInset,
+ CXFA_Measurement(fInsets[2], XFA_UNIT_Pt),
+ false);
if (dwFlags & 0x08)
- pMargin->SetMeasure(XFA_ATTRIBUTE_BottomInset,
- CXFA_Measurement(fInsets[3], XFA_UNIT_Pt), false);
+ pMargin->JSNode()->SetMeasure(XFA_ATTRIBUTE_BottomInset,
+ CXFA_Measurement(fInsets[3], XFA_UNIT_Pt),
+ false);
return pMargin;
}
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 038f451ad9..5d4d262999 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -241,7 +241,7 @@ int32_t CXFA_TextLayout::GetText(WideString& wsText) {
GetTextDataNode();
wsText.clear();
if (!m_bRichText)
- wsText = m_pTextDataNode->GetContent();
+ wsText = m_pTextDataNode->JSNode()->GetContent();
return wsText.GetLength();
}
@@ -676,7 +676,7 @@ void CXFA_TextLayout::LoadText(CXFA_Node* pNode,
}
}
- WideString wsText = pNode->GetContent();
+ WideString wsText = pNode->JSNode()->GetContent();
wsText.TrimRight(L" ");
bool bRet = AppendChar(wsText, fLinePos, fSpaceAbove, bSavePieces);
if (bRet && m_pLoader)
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index 78decf8f06..fa564290ee 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -44,7 +44,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild);
if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) {
WideString wsContentType;
- pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false);
+ pChildNode->JSNode()->GetAttribute(XFA_ATTRIBUTE_ContentType,
+ wsContentType, false);
if (wsContentType == L"text/html")
bRichText = true;
}
@@ -81,7 +82,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild);
if (pChildNode && pChildNode->GetElementType() == XFA_Element::ExData) {
WideString wsContentType;
- pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false);
+ pChildNode->JSNode()->GetAttribute(XFA_ATTRIBUTE_ContentType,
+ wsContentType, false);
if (wsContentType == L"text/html")
bRichText = true;
}
@@ -96,7 +98,7 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
CXFA_Node* pNode = pItemNode->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pNode) {
WideStringView wsName;
- pNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName);
if (m_eType == XFA_TEXTPROVIDERTYPE_Rollover && wsName == L"rollover")
return pNode;
if (m_eType == XFA_TEXTPROVIDERTYPE_Down && wsName == L"down")
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index ddada38722..e9946a57d9 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -162,7 +162,7 @@ CXFA_WidgetAcc::~CXFA_WidgetAcc() {}
bool CXFA_WidgetAcc::GetName(WideString& wsName, int32_t iNameType) {
if (iNameType == 0) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName);
return !wsName.IsEmpty();
}
m_pNode->GetSOMExpression(wsName);
@@ -223,8 +223,11 @@ void CXFA_WidgetAcc::ResetData() {
continue;
WideString itemText;
- if (pItems->CountChildren(XFA_Element::Unknown) > 1)
- itemText = pItems->GetChild(1, XFA_Element::Unknown)->GetContent();
+ if (pItems->CountChildren(XFA_Element::Unknown) > 1) {
+ itemText = pItems->GetChild(1, XFA_Element::Unknown)
+ ->JSNode()
+ ->GetContent();
+ }
pAcc->SetValue(itemText, XFA_VALUEPICTURE_Raw);
}
@@ -254,16 +257,16 @@ void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType,
}
WideString wsFormatValue(wsData);
GetFormatDataValue(wsData, wsFormatValue);
- m_pNode->SetContent(wsData, wsFormatValue, true);
+ m_pNode->JSNode()->SetContent(wsData, wsFormatValue, true);
CXFA_Node* pBind = GetDatasets();
if (!pBind) {
image.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64);
return;
}
- pBind->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+ pBind->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
CXFA_Node* pHrefNode = pBind->GetNodeItem(XFA_NODEITEM_FirstChild);
if (pHrefNode) {
- pHrefNode->SetCData(XFA_ATTRIBUTE_Value, wsHref);
+ pHrefNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsHref);
} else {
CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode();
ASSERT(pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element);
@@ -656,12 +659,12 @@ int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
if (static_cast<CXFA_WidgetAcc*>(pRefNode->GetWidgetData()) == this)
continue;
- auto* pGlobalData =
- static_cast<CXFA_CalcData*>(pRefNode->GetUserData(XFA_CalcData));
+ auto* pGlobalData = static_cast<CXFA_CalcData*>(
+ pRefNode->JSNode()->GetUserData(XFA_CalcData));
if (!pGlobalData) {
pGlobalData = new CXFA_CalcData;
- pRefNode->SetUserData(XFA_CalcData, pGlobalData,
- &gs_XFADeleteCalcData);
+ pRefNode->JSNode()->SetUserData(XFA_CalcData, pGlobalData,
+ &gs_XFADeleteCalcData);
}
if (!pdfium::ContainsValue(pGlobalData->m_Globals, this))
pGlobalData->m_Globals.push_back(this);
@@ -1280,6 +1283,7 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) {
XFA_ATTRIBUTEENUM eLayoutMode;
GetNode()
->GetNodeItem(XFA_NODEITEM_Parent)
+ ->JSNode()
->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, true);
if ((eLayoutMode == XFA_ATTRIBUTEENUM_Position ||
eLayoutMode == XFA_ATTRIBUTEENUM_Tb ||
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
index 3195b8448d..574b62644a 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
@@ -153,7 +153,7 @@ void CScript_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments,
continue;
}
CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage();
- if (pMasterPage->GetInteger(XFA_ATTRIBUTE_Numbered)) {
+ if (pMasterPage->JSNode()->GetInteger(XFA_ATTRIBUTE_Numbered)) {
iPageCount++;
}
}
diff --git a/xfa/fxfa/parser/cxfa_bind.cpp b/xfa/fxfa/parser/cxfa_bind.cpp
index 72373ae571..3c16661364 100644
--- a/xfa/fxfa/parser/cxfa_bind.cpp
+++ b/xfa/fxfa/parser/cxfa_bind.cpp
@@ -12,5 +12,5 @@ CXFA_Bind::CXFA_Bind(CXFA_Node* pNode) : CXFA_Data(pNode) {}
void CXFA_Bind::GetPicture(WideString& wsPicture) {
if (CXFA_Node* pPicture = m_pNode->GetChild(0, XFA_Element::Picture))
- pPicture->TryContent(wsPicture);
+ pPicture->JSNode()->TryContent(wsPicture);
}
diff --git a/xfa/fxfa/parser/cxfa_binditems.cpp b/xfa/fxfa/parser/cxfa_binditems.cpp
index c6dbdb3b02..bfa4c30de2 100644
--- a/xfa/fxfa/parser/cxfa_binditems.cpp
+++ b/xfa/fxfa/parser/cxfa_binditems.cpp
@@ -11,17 +11,17 @@
CXFA_BindItems::CXFA_BindItems(CXFA_Node* pNode) : CXFA_Data(pNode) {}
void CXFA_BindItems::GetLabelRef(WideStringView& wsLabelRef) {
- m_pNode->TryCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_LabelRef, wsLabelRef);
}
void CXFA_BindItems::GetValueRef(WideStringView& wsValueRef) {
- m_pNode->TryCData(XFA_ATTRIBUTE_ValueRef, wsValueRef);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_ValueRef, wsValueRef);
}
void CXFA_BindItems::GetRef(WideStringView& wsRef) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
}
bool CXFA_BindItems::SetConnection(const WideString& wsConnection) {
- return m_pNode->SetCData(XFA_ATTRIBUTE_Connection, wsConnection);
+ return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Connection, wsConnection);
}
diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp
index 300edd01ad..3753108243 100644
--- a/xfa/fxfa/parser/cxfa_box.cpp
+++ b/xfa/fxfa/parser/cxfa_box.cpp
@@ -22,8 +22,8 @@ void GetStrokesInternal(CXFA_Node* pNode,
strokes->resize(8);
int32_t i, j;
for (i = 0, j = 0; i < 4; i++) {
- CXFA_Corner corner =
- CXFA_Corner(pNode->GetProperty(i, XFA_Element::Corner, i == 0));
+ CXFA_Corner corner = CXFA_Corner(
+ pNode->JSNode()->GetProperty(i, XFA_Element::Corner, i == 0));
if (corner || i == 0) {
(*strokes)[j] = corner;
} else if (!bNull) {
@@ -34,7 +34,7 @@ void GetStrokesInternal(CXFA_Node* pNode,
}
j++;
CXFA_Edge edge =
- CXFA_Edge(pNode->GetProperty(i, XFA_Element::Edge, i == 0));
+ CXFA_Edge(pNode->JSNode()->GetProperty(i, XFA_Element::Edge, i == 0));
if (edge || i == 0) {
(*strokes)[j] = edge;
} else if (!bNull) {
@@ -78,13 +78,13 @@ static int32_t Style3D(const std::vector<CXFA_Stroke>& strokes,
int32_t CXFA_Box::GetHand() const {
if (!m_pNode)
return XFA_ATTRIBUTEENUM_Even;
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Hand);
}
int32_t CXFA_Box::GetPresence() const {
if (!m_pNode)
return XFA_ATTRIBUTEENUM_Hidden;
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Presence);
}
int32_t CXFA_Box::CountEdges() const {
@@ -94,9 +94,9 @@ int32_t CXFA_Box::CountEdges() const {
}
CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const {
- return CXFA_Edge(
- m_pNode ? m_pNode->GetProperty(nIndex, XFA_Element::Edge, nIndex == 0)
- : nullptr);
+ return CXFA_Edge(m_pNode ? m_pNode->JSNode()->GetProperty(
+ nIndex, XFA_Element::Edge, nIndex == 0)
+ : nullptr);
}
void CXFA_Box::GetStrokes(std::vector<CXFA_Stroke>* strokes) const {
@@ -106,7 +106,7 @@ void CXFA_Box::GetStrokes(std::vector<CXFA_Stroke>* strokes) const {
bool CXFA_Box::IsCircular() const {
if (!m_pNode)
return false;
- return m_pNode->GetBoolean(XFA_ATTRIBUTE_Circular);
+ return m_pNode->JSNode()->GetBoolean(XFA_ATTRIBUTE_Circular);
}
bool CXFA_Box::GetStartAngle(float& fStartAngle) const {
@@ -115,7 +115,8 @@ bool CXFA_Box::GetStartAngle(float& fStartAngle) const {
return false;
CXFA_Measurement ms;
- bool bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, false);
+ bool bRet =
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_StartAngle, ms, false);
if (bRet)
fStartAngle = ms.GetValue();
@@ -128,7 +129,8 @@ bool CXFA_Box::GetSweepAngle(float& fSweepAngle) const {
return false;
CXFA_Measurement ms;
- bool bRet = m_pNode->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, false);
+ bool bRet =
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_SweepAngle, ms, false);
if (bRet)
fSweepAngle = ms.GetValue();
@@ -139,7 +141,8 @@ CXFA_Fill CXFA_Box::GetFill(bool bModified) const {
if (!m_pNode)
return CXFA_Fill(nullptr);
- CXFA_Node* pFillNode = m_pNode->GetProperty(0, XFA_Element::Fill, bModified);
+ CXFA_Node* pFillNode =
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Fill, bModified);
return CXFA_Fill(pFillNode);
}
diff --git a/xfa/fxfa/parser/cxfa_calculate.cpp b/xfa/fxfa/parser/cxfa_calculate.cpp
index 3b0f038f6a..4a51b2d4ef 100644
--- a/xfa/fxfa/parser/cxfa_calculate.cpp
+++ b/xfa/fxfa/parser/cxfa_calculate.cpp
@@ -13,7 +13,7 @@ CXFA_Calculate::CXFA_Calculate(CXFA_Node* pNode) : CXFA_Data(pNode) {}
int32_t CXFA_Calculate::GetOverride() {
XFA_ATTRIBUTEENUM eAtt = XFA_ATTRIBUTEENUM_Error;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Override, eAtt, false);
+ m_pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Override, eAtt, false);
return eAtt;
}
diff --git a/xfa/fxfa/parser/cxfa_caption.cpp b/xfa/fxfa/parser/cxfa_caption.cpp
index 1be4a206e7..6e28609a37 100644
--- a/xfa/fxfa/parser/cxfa_caption.cpp
+++ b/xfa/fxfa/parser/cxfa_caption.cpp
@@ -13,19 +13,19 @@ CXFA_Caption::CXFA_Caption(CXFA_Node* pNode) : CXFA_Data(pNode) {}
int32_t CXFA_Caption::GetPresence() {
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Visible;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Presence, eAttr);
+ m_pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Presence, eAttr);
return eAttr;
}
int32_t CXFA_Caption::GetPlacementType() {
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Placement, eAttr);
+ m_pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Placement, eAttr);
return eAttr;
}
float CXFA_Caption::GetReserve() {
CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_Reserve, ms);
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_Reserve, ms);
return ms.ToUnit(XFA_UNIT_Pt);
}
diff --git a/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp b/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp
index cf4e1ce3f3..a97d46d310 100644
--- a/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp
+++ b/xfa/fxfa/parser/cxfa_containerlayoutitem.cpp
@@ -31,9 +31,10 @@ CFX_SizeF CXFA_ContainerLayoutItem::GetPageSize() const {
if (!pMedium)
return size;
- size = CFX_SizeF(pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt),
- pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt));
- if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) ==
+ size = CFX_SizeF(
+ pMedium->JSNode()->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt),
+ pMedium->JSNode()->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt));
+ if (pMedium->JSNode()->GetEnum(XFA_ATTRIBUTE_Orientation) ==
XFA_ATTRIBUTEENUM_Landscape) {
size = CFX_SizeF(size.height, size.width);
}
diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
index c8acff2b1c..03c3ebcc84 100644
--- a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
+++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
@@ -15,6 +15,6 @@ CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode)
m_dwStatus(0) {}
CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() {
- if (m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY) == this)
- m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY, nullptr);
+ if (m_pFormNode->JSNode()->GetUserData(XFA_LAYOUTITEMKEY) == this)
+ m_pFormNode->JSNode()->SetUserData(XFA_LAYOUTITEMKEY, nullptr);
}
diff --git a/xfa/fxfa/parser/cxfa_data.cpp b/xfa/fxfa/parser/cxfa_data.cpp
index 5a82ce36cb..37817c3ce2 100644
--- a/xfa/fxfa/parser/cxfa_data.cpp
+++ b/xfa/fxfa/parser/cxfa_data.cpp
@@ -69,7 +69,7 @@ bool CXFA_Data::TryMeasure(XFA_ATTRIBUTE eAttr,
float& fValue,
bool bUseDefault) const {
CXFA_Measurement ms;
- if (m_pNode->TryMeasure(eAttr, ms, bUseDefault)) {
+ if (m_pNode->JSNode()->TryMeasure(eAttr, ms, bUseDefault)) {
fValue = ms.ToUnit(XFA_UNIT_Pt);
return true;
}
@@ -78,5 +78,5 @@ bool CXFA_Data::TryMeasure(XFA_ATTRIBUTE eAttr,
bool CXFA_Data::SetMeasure(XFA_ATTRIBUTE eAttr, float fValue) {
CXFA_Measurement ms(fValue, XFA_UNIT_Pt);
- return m_pNode->SetMeasure(eAttr, ms);
+ return m_pNode->JSNode()->SetMeasure(eAttr, ms);
}
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 44b0dca98c..aeee2c196a 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -91,8 +91,9 @@ void SaveAttribute(CXFA_Node* pNode,
bool bProto,
WideString& wsOutput) {
WideString wsValue;
- if ((!bProto && !pNode->HasAttribute((XFA_ATTRIBUTE)eName, bProto)) ||
- !pNode->GetAttribute((XFA_ATTRIBUTE)eName, wsValue, false)) {
+ if ((!bProto &&
+ !pNode->JSNode()->HasAttribute((XFA_ATTRIBUTE)eName, bProto)) ||
+ !pNode->JSNode()->GetAttribute((XFA_ATTRIBUTE)eName, wsValue, false)) {
return;
}
wsValue = ExportEncodeAttribute(wsValue);
@@ -122,7 +123,7 @@ bool AttributeSaveInDataModel(CXFA_Node* pNode, XFA_ATTRIBUTE eAttribute) {
bool ContentNodeNeedtoExport(CXFA_Node* pContentNode) {
WideString wsContent;
- if (!pContentNode->TryContent(wsContent, false, false))
+ if (!pContentNode->JSNode()->TryContent(wsContent, false, false))
return false;
ASSERT(pContentNode->IsContentNode());
@@ -150,7 +151,7 @@ void RecognizeXFAVersionNumber(CXFA_Node* pTemplateRoot,
return;
WideString wsTemplateNS;
- if (!pTemplateRoot->TryNamespace(wsTemplateNS))
+ if (!pTemplateRoot->JSNode()->TryNamespace(wsTemplateNS))
return;
XFA_VERSION eVersion =
@@ -197,7 +198,8 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
break;
WideString wsContentType;
- pNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false);
+ pNode->JSNode()->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType,
+ false);
if (pRawValueNode->GetElementType() == XFA_Element::SharpxHTML &&
wsContentType == L"text/html") {
CFX_XMLNode* pExDataXML = pNode->GetXMLMappingNode();
@@ -220,7 +222,8 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
} else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml &&
wsContentType == L"text/xml") {
WideString wsRawValue;
- pRawValueNode->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue, false);
+ pRawValueNode->JSNode()->GetAttribute(XFA_ATTRIBUTE_Value, wsRawValue,
+ false);
if (wsRawValue.IsEmpty())
break;
@@ -242,7 +245,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
pParentNode->GetNodeItem(XFA_NODEITEM_Parent);
ASSERT(pGrandparentNode);
WideString bodyTagName;
- bodyTagName = pGrandparentNode->GetCData(XFA_ATTRIBUTE_Name);
+ bodyTagName = pGrandparentNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
if (bodyTagName.IsEmpty())
bodyTagName = L"ListBox1";
@@ -261,7 +264,8 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
wsChildren += buf.AsStringView();
buf.Clear();
} else {
- WideStringView wsValue = pRawValueNode->GetCData(XFA_ATTRIBUTE_Value);
+ WideStringView wsValue =
+ pRawValueNode->JSNode()->GetCData(XFA_ATTRIBUTE_Value);
wsChildren += ExportEncodeContent(wsValue);
}
break;
@@ -269,7 +273,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
case XFA_ObjectType::TextNode:
case XFA_ObjectType::NodeC:
case XFA_ObjectType::NodeV: {
- WideStringView wsValue = pNode->GetCData(XFA_ATTRIBUTE_Value);
+ WideStringView wsValue = pNode->JSNode()->GetCData(XFA_ATTRIBUTE_Value);
wsChildren += ExportEncodeContent(wsValue);
break;
}
@@ -306,7 +310,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
}
if (!wsChildren.IsEmpty() || !wsAttrs.IsEmpty() ||
- pNode->HasAttribute(XFA_ATTRIBUTE_Name)) {
+ pNode->JSNode()->HasAttribute(XFA_ATTRIBUTE_Name)) {
WideStringView wsElement = pNode->GetClassName();
WideString wsName;
SaveAttribute(pNode, XFA_ATTRIBUTE_Name, L"name", true, wsName);
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 3ab1a988b5..7723d0b5a7 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -152,11 +152,11 @@ CXFA_Object* CXFA_Document::GetXFAObject(XFA_HashCode dwNodeNameHash) {
continue;
WideString wsNamespaceURI;
- if (!pDatasetsChild->TryNamespace(wsNamespaceURI))
+ if (!pDatasetsChild->JSNode()->TryNamespace(wsNamespaceURI))
continue;
WideString wsDatasetsURI;
- if (!pDatasetsNode->TryNamespace(wsDatasetsURI))
+ if (!pDatasetsNode->JSNode()->TryNamespace(wsDatasetsURI))
continue;
if (wsNamespaceURI == wsDatasetsURI)
return pDatasetsChild;
@@ -267,7 +267,8 @@ bool CXFA_Document::IsInteractive() {
CXFA_Node* pFormFiller = pPDF->GetChild(0, XFA_Element::Interactive);
if (pFormFiller) {
m_dwDocFlags |= XFA_DOCFLAG_HasInteractive;
- if (pFormFiller->TryContent(wsInteractive) && wsInteractive == L"1") {
+ if (pFormFiller->JSNode()->TryContent(wsInteractive) &&
+ wsInteractive == L"1") {
m_dwDocFlags |= XFA_DOCFLAG_Interactive;
return true;
}
@@ -333,7 +334,8 @@ CXFA_Node* CXFA_Document::GetNodeByID(CXFA_Node* pRoot,
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
WideStringView wsIDVal;
- if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) {
+ if (pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) &&
+ !wsIDVal.IsEmpty()) {
if (wsIDVal == wsID)
return pNode;
}
@@ -352,13 +354,15 @@ void CXFA_Document::DoProtoMerge() {
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
WideStringView wsIDVal;
- if (pNode->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) && !wsIDVal.IsEmpty()) {
+ if (pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Id, wsIDVal) &&
+ !wsIDVal.IsEmpty()) {
mIDMap[FX_HashCode_GetW(wsIDVal, false)] = pNode;
}
WideStringView wsUseVal;
- if (pNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) && !wsUseVal.IsEmpty()) {
+ if (pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) &&
+ !wsUseVal.IsEmpty()) {
sUseNodes.insert(pNode);
- } else if (pNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
+ } else if (pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
!wsUseVal.IsEmpty()) {
sUseNodes.insert(pNode);
}
@@ -367,7 +371,7 @@ void CXFA_Document::DoProtoMerge() {
for (CXFA_Node* pUseHrefNode : sUseNodes) {
WideString wsUseVal;
WideStringView wsURI, wsID, wsSOM;
- if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
+ if (pUseHrefNode->JSNode()->TryCData(XFA_ATTRIBUTE_Usehref, wsUseVal) &&
!wsUseVal.IsEmpty()) {
auto uSharpPos = wsUseVal.Find('#');
if (!uSharpPos.has_value()) {
@@ -386,7 +390,7 @@ void CXFA_Document::DoProtoMerge() {
uLen - uSharpPos.value() - 1);
}
}
- } else if (pUseHrefNode->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) &&
+ } else if (pUseHrefNode->JSNode()->TryCData(XFA_ATTRIBUTE_Use, wsUseVal) &&
!wsUseVal.IsEmpty()) {
if (wsUseVal[0] == '#')
wsID = WideStringView(wsUseVal.c_str() + 1, wsUseVal.GetLength() - 1);
diff --git a/xfa/fxfa/parser/cxfa_event.cpp b/xfa/fxfa/parser/cxfa_event.cpp
index d541ea0f14..4d7c27d80f 100644
--- a/xfa/fxfa/parser/cxfa_event.cpp
+++ b/xfa/fxfa/parser/cxfa_event.cpp
@@ -11,7 +11,7 @@
CXFA_Event::CXFA_Event(CXFA_Node* pNode) : CXFA_Data(pNode) {}
int32_t CXFA_Event::GetActivity() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Activity);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Activity);
}
XFA_Element CXFA_Event::GetEventType() const {
@@ -27,7 +27,7 @@ XFA_Element CXFA_Event::GetEventType() const {
}
void CXFA_Event::GetRef(WideStringView& wsRef) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
}
CXFA_Script CXFA_Event::GetScript() const {
@@ -39,11 +39,11 @@ CXFA_Submit CXFA_Event::GetSubmit() const {
}
void CXFA_Event::GetSignDataTarget(WideString& wsTarget) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::SignData);
+ CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::SignData);
if (!pNode)
return;
WideStringView wsCData;
- pNode->TryCData(XFA_ATTRIBUTE_Target, wsCData);
+ pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Target, wsCData);
wsTarget = wsCData;
}
diff --git a/xfa/fxfa/parser/cxfa_exdata.cpp b/xfa/fxfa/parser/cxfa_exdata.cpp
index 8ba9d0218b..89a6c34f5f 100644
--- a/xfa/fxfa/parser/cxfa_exdata.cpp
+++ b/xfa/fxfa/parser/cxfa_exdata.cpp
@@ -11,5 +11,5 @@
CXFA_ExData::CXFA_ExData(CXFA_Node* pNode) : CXFA_Data(pNode) {}
bool CXFA_ExData::SetContentType(const WideString& wsContentType) {
- return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+ return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
}
diff --git a/xfa/fxfa/parser/cxfa_fill.cpp b/xfa/fxfa/parser/cxfa_fill.cpp
index 6b39134126..f3d045ad30 100644
--- a/xfa/fxfa/parser/cxfa_fill.cpp
+++ b/xfa/fxfa/parser/cxfa_fill.cpp
@@ -13,11 +13,11 @@ CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {}
CXFA_Fill::~CXFA_Fill() {}
int32_t CXFA_Fill::GetPresence() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Presence);
}
void CXFA_Fill::SetColor(FX_ARGB color) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Color);
+ CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Color);
WideString wsColor;
int a;
int r;
@@ -25,13 +25,13 @@ void CXFA_Fill::SetColor(FX_ARGB color) {
int b;
std::tie(a, r, g, b) = ArgbDecode(color);
wsColor.Format(L"%d,%d,%d", r, g, b);
- pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
+ pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsColor);
}
FX_ARGB CXFA_Fill::GetColor(bool bText) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color)) {
WideStringView wsColor;
- if (pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor, false))
+ if (pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false))
return CXFA_Data::ToColor(wsColor);
}
if (bText)
@@ -52,24 +52,24 @@ XFA_Element CXFA_Fill::GetFillType() {
}
int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Pattern);
+ CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Pattern);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) {
WideStringView wsColor;
- pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
+ pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
foreColor = CXFA_Data::ToColor(wsColor);
} else {
foreColor = 0xFF000000;
}
- return pNode->GetEnum(XFA_ATTRIBUTE_Type);
+ return pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Type);
}
int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Stipple);
+ CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Stipple);
int32_t eAttr = 50;
- pNode->TryInteger(XFA_ATTRIBUTE_Rate, eAttr);
+ pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Rate, eAttr);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) {
WideStringView wsColor;
- pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
+ pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
stippleColor = CXFA_Data::ToColor(wsColor);
} else {
stippleColor = 0xFF000000;
@@ -78,12 +78,12 @@ int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) {
}
int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Linear);
+ CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Linear);
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight;
- pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
+ pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) {
WideStringView wsColor;
- pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
+ pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
endColor = CXFA_Data::ToColor(wsColor);
} else {
endColor = 0xFF000000;
@@ -92,12 +92,12 @@ int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) {
}
int32_t CXFA_Fill::GetRadial(FX_ARGB& endColor) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Radial);
+ CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Radial);
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge;
- pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
+ pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Type, eAttr);
if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) {
WideStringView wsColor;
- pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
+ pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false);
endColor = CXFA_Data::ToColor(wsColor);
} else {
endColor = 0xFF000000;
diff --git a/xfa/fxfa/parser/cxfa_font.cpp b/xfa/fxfa/parser/cxfa_font.cpp
index 71aa61700f..023a34b387 100644
--- a/xfa/fxfa/parser/cxfa_font.cpp
+++ b/xfa/fxfa/parser/cxfa_font.cpp
@@ -14,26 +14,28 @@
CXFA_Font::CXFA_Font(CXFA_Node* pNode) : CXFA_Data(pNode) {}
float CXFA_Font::GetBaselineShift() {
- return m_pNode->GetMeasure(XFA_ATTRIBUTE_BaselineShift).ToUnit(XFA_UNIT_Pt);
+ return m_pNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_BaselineShift)
+ .ToUnit(XFA_UNIT_Pt);
}
float CXFA_Font::GetHorizontalScale() {
WideString wsValue;
- m_pNode->TryCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue);
int32_t iScale = FXSYS_wtoi(wsValue.c_str());
return iScale > 0 ? (float)iScale : 100.0f;
}
float CXFA_Font::GetVerticalScale() {
WideString wsValue;
- m_pNode->TryCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue);
int32_t iScale = FXSYS_wtoi(wsValue.c_str());
return iScale > 0 ? (float)iScale : 100.0f;
}
float CXFA_Font::GetLetterSpacing() {
WideStringView wsValue;
- if (!m_pNode->TryCData(XFA_ATTRIBUTE_LetterSpacing, wsValue))
+ if (!m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_LetterSpacing, wsValue))
return 0;
CXFA_Measurement ms(wsValue);
@@ -44,46 +46,46 @@ float CXFA_Font::GetLetterSpacing() {
int32_t CXFA_Font::GetLineThrough() {
int32_t iValue = 0;
- m_pNode->TryInteger(XFA_ATTRIBUTE_LineThrough, iValue);
+ m_pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_LineThrough, iValue);
return iValue;
}
int32_t CXFA_Font::GetUnderline() {
int32_t iValue = 0;
- m_pNode->TryInteger(XFA_ATTRIBUTE_Underline, iValue);
+ m_pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Underline, iValue);
return iValue;
}
int32_t CXFA_Font::GetUnderlinePeriod() {
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All;
- m_pNode->TryEnum(XFA_ATTRIBUTE_UnderlinePeriod, eAttr);
+ m_pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_UnderlinePeriod, eAttr);
return eAttr;
}
float CXFA_Font::GetFontSize() {
CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_Size, ms);
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_Size, ms);
return ms.ToUnit(XFA_UNIT_Pt);
}
void CXFA_Font::GetTypeface(WideStringView& wsTypeFace) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Typeface, wsTypeFace);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Typeface, wsTypeFace);
}
bool CXFA_Font::IsBold() {
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Weight, eAttr);
+ m_pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Weight, eAttr);
return eAttr == XFA_ATTRIBUTEENUM_Bold;
}
bool CXFA_Font::IsItalic() {
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
- m_pNode->TryEnum(XFA_ATTRIBUTE_Posture, eAttr);
+ m_pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Posture, eAttr);
return eAttr == XFA_ATTRIBUTEENUM_Italic;
}
void CXFA_Font::SetColor(FX_ARGB color) {
- CXFA_Fill fill(m_pNode->GetProperty(0, XFA_Element::Fill));
+ CXFA_Fill fill(m_pNode->JSNode()->GetProperty(0, XFA_Element::Fill));
fill.SetColor(color);
}
diff --git a/xfa/fxfa/parser/cxfa_image.cpp b/xfa/fxfa/parser/cxfa_image.cpp
index b6d78d9eda..cfa3db76f1 100644
--- a/xfa/fxfa/parser/cxfa_image.cpp
+++ b/xfa/fxfa/parser/cxfa_image.cpp
@@ -12,43 +12,44 @@ CXFA_Image::CXFA_Image(CXFA_Node* pNode, bool bDefValue)
: CXFA_Data(pNode), m_bDefValue(bDefValue) {}
int32_t CXFA_Image::GetAspect() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Aspect);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Aspect);
}
bool CXFA_Image::GetContentType(WideString& wsContentType) {
- return m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+ return m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType);
}
bool CXFA_Image::GetHref(WideString& wsHref) {
if (m_bDefValue)
- return m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref);
- return m_pNode->GetAttribute(L"href", wsHref);
+ return m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Href, wsHref);
+ return m_pNode->JSNode()->GetAttribute(L"href", wsHref);
}
int32_t CXFA_Image::GetTransferEncoding() {
if (m_bDefValue)
- return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_TransferEncoding);
return XFA_ATTRIBUTEENUM_Base64;
}
bool CXFA_Image::GetContent(WideString& wsText) {
- return m_pNode->TryContent(wsText);
+ return m_pNode->JSNode()->TryContent(wsText);
}
bool CXFA_Image::SetContentType(const WideString& wsContentType) {
- return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+ return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
}
bool CXFA_Image::SetHref(const WideString& wsHref) {
if (m_bDefValue)
- return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref);
- return m_pNode->SetAttribute(XFA_ATTRIBUTE_Href, wsHref.AsStringView());
+ return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Href, wsHref);
+ return m_pNode->JSNode()->SetAttribute(XFA_ATTRIBUTE_Href,
+ wsHref.AsStringView());
}
bool CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) {
if (m_bDefValue) {
- return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding,
- (XFA_ATTRIBUTEENUM)iTransferEncoding);
+ return m_pNode->JSNode()->SetEnum(XFA_ATTRIBUTE_TransferEncoding,
+ (XFA_ATTRIBUTEENUM)iTransferEncoding);
}
return true;
}
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index 8bc71f11d3..688990b2fd 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -88,25 +88,25 @@ CFX_SizeF CalculateContainerSpecifiedSize(CXFA_Node* pFormNode,
CXFA_Measurement mTmpValue;
CFX_SizeF containerSize;
if ((eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup) &&
- pFormNode->TryMeasure(XFA_ATTRIBUTE_W, mTmpValue, false) &&
+ pFormNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_W, mTmpValue, false) &&
mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) {
containerSize.width = mTmpValue.ToUnit(XFA_UNIT_Pt);
*bContainerWidthAutoSize = false;
}
if ((eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup) &&
- pFormNode->TryMeasure(XFA_ATTRIBUTE_H, mTmpValue, false) &&
+ pFormNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_H, mTmpValue, false) &&
mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) {
containerSize.height = mTmpValue.ToUnit(XFA_UNIT_Pt);
*bContainerHeightAutoSize = false;
}
if (*bContainerWidthAutoSize && eType == XFA_Element::Subform &&
- pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxW, mTmpValue, false) &&
+ pFormNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_MaxW, mTmpValue, false) &&
mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) {
containerSize.width = mTmpValue.ToUnit(XFA_UNIT_Pt);
*bContainerWidthAutoSize = false;
}
if (*bContainerHeightAutoSize && eType == XFA_Element::Subform &&
- pFormNode->TryMeasure(XFA_ATTRIBUTE_MaxH, mTmpValue, false) &&
+ pFormNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_MaxH, mTmpValue, false) &&
mTmpValue.GetValue() > XFA_LAYOUT_FLOAT_PERCISION) {
containerSize.height = mTmpValue.ToUnit(XFA_UNIT_Pt);
*bContainerHeightAutoSize = false;
@@ -127,9 +127,11 @@ CFX_SizeF CalculateContainerComponentSizeFromContentSize(
if (bContainerWidthAutoSize) {
componentSize.width = fContentCalculatedWidth;
if (pMarginNode) {
- if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_LeftInset, mTmpValue, false))
+ if (pMarginNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_LeftInset, mTmpValue,
+ false))
componentSize.width += mTmpValue.ToUnit(XFA_UNIT_Pt);
- if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_RightInset, mTmpValue, false))
+ if (pMarginNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_RightInset, mTmpValue,
+ false))
componentSize.width += mTmpValue.ToUnit(XFA_UNIT_Pt);
}
}
@@ -137,10 +139,11 @@ CFX_SizeF CalculateContainerComponentSizeFromContentSize(
if (bContainerHeightAutoSize) {
componentSize.height = fContentCalculatedHeight;
if (pMarginNode) {
- if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_TopInset, mTmpValue, false))
+ if (pMarginNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_TopInset, mTmpValue,
+ false))
componentSize.height += mTmpValue.ToUnit(XFA_UNIT_Pt);
- if (pMarginNode->TryMeasure(XFA_ATTRIBUTE_BottomInset, mTmpValue,
- false)) {
+ if (pMarginNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_BottomInset,
+ mTmpValue, false)) {
componentSize.height += mTmpValue.ToUnit(XFA_UNIT_Pt);
}
}
@@ -163,14 +166,18 @@ void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
float fRightInset = 0;
float fBottomInset = 0;
if (pMarginNode) {
- fLeftInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt);
- fTopInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt);
- fRightInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt);
- fBottomInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt);
+ fLeftInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_LeftInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fTopInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_TopInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fRightInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_RightInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fBottomInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_BottomInset)
+ .ToUnit(XFA_UNIT_Pt);
}
float fContentWidthLimit =
@@ -189,7 +196,7 @@ void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
pLayoutChild; pLayoutChild = static_cast<CXFA_ContentLayoutItem*>(
pLayoutChild->m_pNextSibling)) {
int32_t nOriginalColSpan =
- pLayoutChild->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan);
+ pLayoutChild->m_pFormNode->JSNode()->GetInteger(XFA_ATTRIBUTE_ColSpan);
int32_t nColSpan = nOriginalColSpan;
float fColSpanWidth = 0;
if (nColSpan == -1 ||
@@ -238,7 +245,8 @@ void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
pLayoutChild->m_pFormNode->GetFirstChildByClass(XFA_Element::Para);
if (pParaNode && pLayoutChild->m_pFirstChild) {
float fOffHeight = fContentCalculatedHeight - fOldChildHeight;
- XFA_ATTRIBUTEENUM eVType = pParaNode->GetEnum(XFA_ATTRIBUTE_VAlign);
+ XFA_ATTRIBUTEENUM eVType =
+ pParaNode->JSNode()->GetEnum(XFA_ATTRIBUTE_VAlign);
switch (eVType) {
case XFA_ATTRIBUTEENUM_Middle:
fOffHeight = fOffHeight / 2;
@@ -275,7 +283,7 @@ void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
fContentCalculatedWidth = containerSize.width - fLeftInset - fRightInset;
}
- if (pLayoutRow->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout) ==
+ if (pLayoutRow->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout) ==
XFA_ATTRIBUTEENUM_Rl_row) {
for (CXFA_ContentLayoutItem* pLayoutChild =
(CXFA_ContentLayoutItem*)pLayoutRow->m_pFirstChild;
@@ -294,7 +302,7 @@ void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
void UpdatePendingItemLayout(CXFA_ItemLayoutProcessor* pProcessor,
CXFA_ContentLayoutItem* pLayoutItem) {
XFA_ATTRIBUTEENUM eLayout =
- pLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ pLayoutItem->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
switch (eLayout) {
case XFA_ATTRIBUTEENUM_Row:
case XFA_ATTRIBUTEENUM_Rl_row:
@@ -331,14 +339,18 @@ void AddTrailerBeforeSplit(CXFA_ItemLayoutProcessor* pProcessor,
float fRightInset = 0;
float fBottomInset = 0;
if (pMarginNode) {
- fLeftInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt);
- fTopInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt);
- fRightInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt);
- fBottomInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt);
+ fLeftInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_LeftInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fTopInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_TopInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fRightInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_RightInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fBottomInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_BottomInset)
+ .ToUnit(XFA_UNIT_Pt);
}
if (!pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem)) {
@@ -361,7 +373,8 @@ void AddTrailerBeforeSplit(CXFA_ItemLayoutProcessor* pProcessor,
pTrailerLayoutItem->m_sPos.y = fSplitPos - fTopInset - fBottomInset;
}
- switch (pTrailerLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) {
+ switch (pTrailerLayoutItem->m_pFormNode->JSNode()->GetEnum(
+ XFA_ATTRIBUTE_HAlign)) {
case XFA_ATTRIBUTEENUM_Right:
pTrailerLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.width -
fRightInset -
@@ -391,10 +404,12 @@ void AddLeaderAfterSplit(CXFA_ItemLayoutProcessor* pProcessor,
float fLeftInset = 0;
float fRightInset = 0;
if (pMarginNode) {
- fLeftInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt);
- fRightInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt);
+ fLeftInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_LeftInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fRightInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_RightInset)
+ .ToUnit(XFA_UNIT_Pt);
}
float fHeight = pLeaderLayoutItem->m_sSize.height;
@@ -406,7 +421,8 @@ void AddLeaderAfterSplit(CXFA_ItemLayoutProcessor* pProcessor,
}
pLeaderLayoutItem->m_sPos.y = 0;
- switch (pLeaderLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) {
+ switch (
+ pLeaderLayoutItem->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_HAlign)) {
case XFA_ATTRIBUTEENUM_Right:
pLeaderLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.width -
fRightInset -
@@ -467,7 +483,7 @@ float InsertPendingItems(CXFA_ItemLayoutProcessor* pProcessor,
XFA_ATTRIBUTEENUM GetLayout(CXFA_Node* pFormNode, bool* bRootForceTb) {
*bRootForceTb = false;
XFA_ATTRIBUTEENUM eLayoutMode;
- if (pFormNode->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, false))
+ if (pFormNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Layout, eLayoutMode, false))
return eLayoutMode;
CXFA_Node* pParentNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent);
@@ -498,7 +514,7 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
if (!bPreFind)
eKeepType = XFA_ATTRIBUTE_Next;
- if (pKeep->TryEnum(eKeepType, ePrevious, false)) {
+ if (pKeep->JSNode()->TryEnum(eKeepType, ePrevious, false)) {
if (ePrevious == XFA_ATTRIBUTEENUM_ContentArea ||
ePrevious == XFA_ATTRIBUTEENUM_PageArea) {
return true;
@@ -515,7 +531,7 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
eKeepType = XFA_ATTRIBUTE_Previous;
XFA_ATTRIBUTEENUM eNext;
- if (!pKeep->TryEnum(eKeepType, eNext, false))
+ if (!pKeep->JSNode()->TryEnum(eKeepType, eNext, false))
return false;
if (eNext == XFA_ATTRIBUTEENUM_ContentArea ||
eNext == XFA_ATTRIBUTEENUM_PageArea) {
@@ -553,7 +569,8 @@ bool FindBreakNode(CXFA_Node* pContainerNode,
break;
}
case XFA_Element::Break:
- if (pBreakNode->GetEnum(eAttributeType) != XFA_ATTRIBUTEENUM_Auto) {
+ if (pBreakNode->JSNode()->GetEnum(eAttributeType) !=
+ XFA_ATTRIBUTEENUM_Auto) {
pCurActionNode = pBreakNode;
*nCurStage = XFA_ItemLayoutProcessorStages::BreakBefore;
if (!bBreakBefore)
@@ -580,7 +597,8 @@ void DeleteLayoutGeneratedNode(CXFA_Node* pGenerateNode) {
for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
pNode = sIterator.MoveToNext()) {
CXFA_ContentLayoutItem* pCurLayoutItem =
- (CXFA_ContentLayoutItem*)pNode->GetUserData(XFA_LAYOUTITEMKEY);
+ (CXFA_ContentLayoutItem*)pNode->JSNode()->GetUserData(
+ XFA_LAYOUTITEMKEY);
CXFA_ContentLayoutItem* pNextLayoutItem = nullptr;
while (pCurLayoutItem) {
pNextLayoutItem = pCurLayoutItem->m_pNext;
@@ -626,8 +644,8 @@ XFA_ItemLayoutProcessorResult InsertFlowedItem(
bool bNewRow) {
bool bTakeSpace =
XFA_ItemLayoutProcessor_IsTakingSpace(pProcessor->m_pFormNode);
- uint8_t uHAlign =
- HAlignEnumToInt(pThis->m_pCurChildNode->GetEnum(XFA_ATTRIBUTE_HAlign));
+ uint8_t uHAlign = HAlignEnumToInt(
+ pThis->m_pCurChildNode->JSNode()->GetEnum(XFA_ATTRIBUTE_HAlign));
if (bContainerWidthAutoSize)
uHAlign = 0;
@@ -815,7 +833,7 @@ XFA_ItemLayoutProcessorResult InsertFlowedItem(
float fSplitPos = pProcessor->FindSplitPos(fAvailHeight - *fContentCurRowY);
if (fSplitPos > XFA_LAYOUT_FLOAT_PERCISION) {
XFA_ATTRIBUTEENUM eLayout =
- pProcessor->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ pProcessor->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
if (eLayout == XFA_ATTRIBUTEENUM_Tb &&
eRetValue == XFA_ItemLayoutProcessorResult::Done) {
pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
@@ -910,7 +928,7 @@ XFA_ItemLayoutProcessorResult InsertFlowedItem(
}
XFA_ATTRIBUTEENUM eLayout =
- pProcessor->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ pProcessor->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
if (pProcessor->m_pFormNode->GetIntact() == XFA_ATTRIBUTEENUM_None &&
eLayout == XFA_ATTRIBUTEENUM_Tb) {
if (pThis->m_pPageMgr) {
@@ -963,9 +981,11 @@ bool FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem,
CXFA_Node* pMarginNode =
pFormNode->GetFirstChildByClass(XFA_Element::Margin);
if (pMarginNode && bCalculateMargin) {
- fCurTopMargin =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt);
- fCurBottomMargin = pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset)
+ fCurTopMargin = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_TopInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fCurBottomMargin = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_BottomInset)
.ToUnit(XFA_UNIT_Pt);
}
bool bChanged = true;
@@ -1026,7 +1046,8 @@ bool FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem,
CFX_PointF CalculatePositionedContainerPos(CXFA_Node* pNode,
const CFX_SizeF& size) {
- XFA_ATTRIBUTEENUM eAnchorType = pNode->GetEnum(XFA_ATTRIBUTE_AnchorType);
+ XFA_ATTRIBUTEENUM eAnchorType =
+ pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_AnchorType);
int32_t nAnchorType = 0;
switch (eAnchorType) {
case XFA_ATTRIBUTEENUM_TopLeft:
@@ -1064,10 +1085,11 @@ CFX_PointF CalculatePositionedContainerPos(CXFA_Node* pNode,
{8, 7, 6, 5, 4, 3, 2, 1, 0},
{2, 5, 8, 1, 4, 7, 0, 3, 6}};
- CFX_PointF pos(pNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt),
- pNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt));
+ CFX_PointF pos(
+ pNode->JSNode()->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt),
+ pNode->JSNode()->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt));
int32_t nRotate =
- FXSYS_round(pNode->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue());
+ FXSYS_round(pNode->JSNode()->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue());
nRotate = XFA_MapRotation(nRotate) / 90;
int32_t nAbsoluteAnchorType = nNextPos[nRotate][nAnchorType];
switch (nAbsoluteAnchorType / 3) {
@@ -1119,7 +1141,8 @@ CXFA_ItemLayoutProcessor::CXFA_ItemLayoutProcessor(CXFA_Node* pNode,
ASSERT(m_pFormNode && (m_pFormNode->IsContainerNode() ||
m_pFormNode->GetElementType() == XFA_Element::Form));
m_pOldLayoutItem =
- (CXFA_ContentLayoutItem*)m_pFormNode->GetUserData(XFA_LAYOUTITEMKEY);
+ (CXFA_ContentLayoutItem*)m_pFormNode->JSNode()->GetUserData(
+ XFA_LAYOUTITEMKEY);
}
CXFA_ItemLayoutProcessor::~CXFA_ItemLayoutProcessor() {}
@@ -1139,7 +1162,8 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::CreateContentLayoutItem(
->GetNotify()
->OnCreateLayoutItem(pFormNode);
CXFA_ContentLayoutItem* pPrevLayoutItem =
- (CXFA_ContentLayoutItem*)pFormNode->GetUserData(XFA_LAYOUTITEMKEY);
+ (CXFA_ContentLayoutItem*)pFormNode->JSNode()->GetUserData(
+ XFA_LAYOUTITEMKEY);
if (pPrevLayoutItem) {
while (pPrevLayoutItem->m_pNext)
pPrevLayoutItem = pPrevLayoutItem->m_pNext;
@@ -1147,14 +1171,15 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::CreateContentLayoutItem(
pPrevLayoutItem->m_pNext = pLayoutItem;
pLayoutItem->m_pPrev = pPrevLayoutItem;
} else {
- pFormNode->SetUserData(XFA_LAYOUTITEMKEY, pLayoutItem);
+ pFormNode->JSNode()->SetUserData(XFA_LAYOUTITEMKEY, pLayoutItem);
}
return pLayoutItem;
}
float CXFA_ItemLayoutProcessor::FindSplitPos(float fProposedSplitPos) {
ASSERT(m_pLayoutItem);
- XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ XFA_ATTRIBUTEENUM eLayout =
+ m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
bool bCalculateMargin = eLayout != XFA_ATTRIBUTEENUM_Position;
while (fProposedSplitPos > XFA_LAYOUT_FLOAT_PERCISION) {
bool bAppChange = false;
@@ -1171,7 +1196,8 @@ void CXFA_ItemLayoutProcessor::SplitLayoutItem(
CXFA_ContentLayoutItem* pSecondParent,
float fSplitPos) {
float fCurTopMargin = 0, fCurBottomMargin = 0;
- XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ XFA_ATTRIBUTEENUM eLayout =
+ m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
bool bCalculateMargin = true;
if (eLayout == XFA_ATTRIBUTEENUM_Position)
bCalculateMargin = false;
@@ -1179,10 +1205,12 @@ void CXFA_ItemLayoutProcessor::SplitLayoutItem(
CXFA_Node* pMarginNode =
pLayoutItem->m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
if (pMarginNode && bCalculateMargin) {
- fCurTopMargin =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt);
- fCurBottomMargin =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt);
+ fCurTopMargin = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_TopInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fCurBottomMargin = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_BottomInset)
+ .ToUnit(XFA_UNIT_Pt);
}
CXFA_ContentLayoutItem* pSecondLayoutItem = nullptr;
@@ -1541,7 +1569,8 @@ bool CXFA_ItemLayoutProcessor::ProcessKeepNodesForBreakBefore(
}
bool XFA_ItemLayoutProcessor_IsTakingSpace(CXFA_Node* pNode) {
- XFA_ATTRIBUTEENUM ePresence = pNode->GetEnum(XFA_ATTRIBUTE_Presence);
+ XFA_ATTRIBUTEENUM ePresence =
+ pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Presence);
return ePresence == XFA_ATTRIBUTEENUM_Visible ||
ePresence == XFA_ATTRIBUTEENUM_Invisible;
}
@@ -1615,7 +1644,7 @@ void CXFA_ItemLayoutProcessor::DoLayoutPositionedContainer(
return;
m_pLayoutItem = CreateContentLayoutItem(m_pFormNode);
- bool bIgnoreXY = (m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout) !=
+ bool bIgnoreXY = (m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout) !=
XFA_ATTRIBUTEENUM_Position);
bool bContainerWidthAutoSize = true;
bool bContainerHeightAutoSize = true;
@@ -1642,7 +1671,8 @@ void CXFA_ItemLayoutProcessor::DoLayoutPositionedContainer(
auto pProcessor = pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(
m_pCurChildNode, m_pPageMgr);
if (pContext && pContext->m_prgSpecifiedColumnWidths) {
- int32_t iColSpan = m_pCurChildNode->GetInteger(XFA_ATTRIBUTE_ColSpan);
+ int32_t iColSpan =
+ m_pCurChildNode->JSNode()->GetInteger(XFA_ATTRIBUTE_ColSpan);
if (iColSpan <= pdfium::CollectionSize<int32_t>(
*pContext->m_prgSpecifiedColumnWidths) -
iColIndex) {
@@ -1737,17 +1767,20 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
float fLeftInset = 0;
float fRightInset = 0;
if (pMarginNode) {
- fLeftInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt);
- fRightInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt);
+ fLeftInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_LeftInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fRightInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_RightInset)
+ .ToUnit(XFA_UNIT_Pt);
}
float fContentWidthLimit =
bContainerWidthAutoSize ? FLT_MAX
: containerSize.width - fLeftInset - fRightInset;
WideStringView wsColumnWidths;
- if (pLayoutNode->TryCData(XFA_ATTRIBUTE_ColumnWidths, wsColumnWidths)) {
+ if (pLayoutNode->JSNode()->TryCData(XFA_ATTRIBUTE_ColumnWidths,
+ wsColumnWidths)) {
auto widths = SeparateStringW(wsColumnWidths.unterminated_c_str(),
wsColumnWidths.GetLength(), L' ');
for (auto& width : widths) {
@@ -1803,7 +1836,7 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
continue;
XFA_ATTRIBUTEENUM eLayout =
- pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ pLayoutChild->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
if (eLayout != XFA_ATTRIBUTEENUM_Row &&
eLayout != XFA_ATTRIBUTEENUM_Rl_row) {
continue;
@@ -1811,8 +1844,8 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
if (CXFA_ContentLayoutItem* pRowLayoutCell =
(CXFA_ContentLayoutItem*)pLayoutChild->m_pFirstChild) {
rgRowItems.push_back(pRowLayoutCell);
- int32_t iColSpan =
- pRowLayoutCell->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan);
+ int32_t iColSpan = pRowLayoutCell->m_pFormNode->JSNode()->GetInteger(
+ XFA_ATTRIBUTE_ColSpan);
rgRowItemsSpan.push_back(iColSpan);
rgRowItemsWidth.push_back(pRowLayoutCell->m_sSize.width);
}
@@ -1835,10 +1868,10 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
pNewCell = nullptr;
}
rgRowItems[i] = pNewCell;
- rgRowItemsSpan[i] =
- pNewCell
- ? pNewCell->m_pFormNode->GetInteger(XFA_ATTRIBUTE_ColSpan)
- : 0;
+ rgRowItemsSpan[i] = pNewCell
+ ? pNewCell->m_pFormNode->JSNode()->GetInteger(
+ XFA_ATTRIBUTE_ColSpan)
+ : 0;
rgRowItemsWidth[i] = pNewCell ? pNewCell->m_sSize.width : 0;
}
CXFA_ContentLayoutItem* pCell = rgRowItems[i];
@@ -1890,7 +1923,7 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
if (pLayoutChild->m_pFormNode->GetElementType() == XFA_Element::Subform) {
XFA_ATTRIBUTEENUM eSubformLayout =
- pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ pLayoutChild->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
if (eSubformLayout == XFA_ATTRIBUTEENUM_Row ||
eSubformLayout == XFA_ATTRIBUTEENUM_Rl_row) {
RelocateTableRowCells(pLayoutChild, m_rgSpecifiedColumnWidths,
@@ -1902,7 +1935,8 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
if (bContainerWidthAutoSize) {
pLayoutChild->m_sPos.x = 0;
} else {
- switch (pLayoutChild->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign)) {
+ switch (
+ pLayoutChild->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_HAlign)) {
case XFA_ATTRIBUTEENUM_Center:
pLayoutChild->m_sPos.x =
(fContentWidthLimit - pLayoutChild->m_sSize.width) / 2;
@@ -1946,7 +1980,8 @@ bool CXFA_ItemLayoutProcessor::IsAddNewRowForTrailer(
return false;
float fWidth = pTrailerItem->m_sSize.width;
- XFA_ATTRIBUTEENUM eLayout = m_pFormNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ XFA_ATTRIBUTEENUM eLayout =
+ m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
return eLayout == XFA_ATTRIBUTEENUM_Tb || m_fWidthLimite <= fWidth;
}
@@ -2055,7 +2090,7 @@ void CXFA_ItemLayoutProcessor::ProcessUnUseBinds(CXFA_Node* pFormNode) {
CXFA_Node* pBindNode = pNode->GetBindData();
if (pBindNode) {
pBindNode->RemoveBindItem(pNode);
- pNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
+ pNode->JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
}
}
pNode->SetFlag(XFA_NodeFlag_UnusedNode, true);
@@ -2134,14 +2169,18 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
float fRightInset = 0;
float fBottomInset = 0;
if (pMarginNode) {
- fLeftInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset).ToUnit(XFA_UNIT_Pt);
- fTopInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset).ToUnit(XFA_UNIT_Pt);
- fRightInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_RightInset).ToUnit(XFA_UNIT_Pt);
- fBottomInset =
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_BottomInset).ToUnit(XFA_UNIT_Pt);
+ fLeftInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_LeftInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fTopInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_TopInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fRightInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_RightInset)
+ .ToUnit(XFA_UNIT_Pt);
+ fBottomInset = pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_BottomInset)
+ .ToUnit(XFA_UNIT_Pt);
}
float fContentWidthLimit =
bContainerWidthAutoSize ? FLT_MAX
@@ -2221,7 +2260,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
break;
}
uint8_t uHAlign = HAlignEnumToInt(
- pLayoutNext->m_pFormNode->GetEnum(XFA_ATTRIBUTE_HAlign));
+ pLayoutNext->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_HAlign));
rgCurLineLayoutItems[uHAlign].push_back(pLayoutNext);
if (eFlowStrategy == XFA_ATTRIBUTEENUM_Lr_tb) {
if (uHAlign > uCurHAlignState)
@@ -2705,8 +2744,8 @@ void CXFA_ItemLayoutProcessor::DoLayoutField() {
CFX_SizeF size(-1, -1);
pNotify->StartFieldDrawLayout(m_pFormNode, size.width, size.height);
- int32_t nRotate =
- FXSYS_round(m_pFormNode->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue());
+ int32_t nRotate = FXSYS_round(
+ m_pFormNode->JSNode()->GetMeasure(XFA_ATTRIBUTE_Rotate).GetValue());
nRotate = XFA_MapRotation(nRotate);
if (nRotate == 90 || nRotate == 270)
std::swap(size.width, size.height);
diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp
index a670d30ae0..e23c5f04a8 100644
--- a/xfa/fxfa/parser/cxfa_layoutitem.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp
@@ -76,9 +76,11 @@ CFX_RectF CXFA_LayoutItem::GetRect(bool bRelative) const {
CXFA_Node* pMarginNode =
pLayoutItem->m_pFormNode->GetFirstChildByClass(XFA_Element::Margin);
if (pMarginNode) {
- sPos += CFX_PointF(pMarginNode->GetMeasure(XFA_ATTRIBUTE_LeftInset)
+ sPos += CFX_PointF(pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_LeftInset)
.ToUnit(XFA_UNIT_Pt),
- pMarginNode->GetMeasure(XFA_ATTRIBUTE_TopInset)
+ pMarginNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_TopInset)
.ToUnit(XFA_UNIT_Pt));
}
continue;
@@ -86,9 +88,11 @@ CFX_RectF CXFA_LayoutItem::GetRect(bool bRelative) const {
if (pLayoutItem->m_pFormNode->GetElementType() ==
XFA_Element::ContentArea) {
- sPos += CFX_PointF(pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_X)
+ sPos += CFX_PointF(pLayoutItem->m_pFormNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_X)
.ToUnit(XFA_UNIT_Pt),
- pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_Y)
+ pLayoutItem->m_pFormNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_Y)
.ToUnit(XFA_UNIT_Pt));
break;
}
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 759d19de79..f7b2910db2 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -66,7 +66,7 @@ class PageSetContainerLayoutItem {
uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) {
uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable;
WideStringView wsRelevant;
- if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) {
+ if (pFormItem->JSNode()->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) {
if (wsRelevant == L"+print" || wsRelevant == L"print")
dwRelevant &= ~XFA_WidgetStatus_Viewable;
else if (wsRelevant == L"-print")
@@ -96,7 +96,7 @@ void SyncContainer(CXFA_FFNotify* pNotify,
uint32_t dwRelevantContainer = 0;
if (bVisible) {
XFA_ATTRIBUTEENUM eAttributeValue =
- pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence);
+ pContainerItem->m_pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Presence);
if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible ||
eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) {
bVisibleItem = true;
@@ -272,7 +272,8 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
if (!pTemplateNode)
return false;
- m_pTemplatePageSetRoot = pTemplateNode->GetProperty(0, XFA_Element::PageSet);
+ m_pTemplatePageSetRoot =
+ pTemplateNode->JSNode()->GetProperty(0, XFA_Element::PageSet);
ASSERT(m_pTemplatePageSetRoot);
if (m_pPageSetLayoutItemRoot) {
m_pPageSetLayoutItemRoot->m_pParent = nullptr;
@@ -284,10 +285,10 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
new CXFA_ContainerLayoutItem(m_pTemplatePageSetRoot);
}
m_pPageSetCurRoot = m_pPageSetLayoutItemRoot;
- m_pTemplatePageSetRoot->SetUserData(XFA_LAYOUTITEMKEY,
- (void*)m_pPageSetLayoutItemRoot);
+ m_pTemplatePageSetRoot->JSNode()->SetUserData(
+ XFA_LAYOUTITEMKEY, (void*)m_pPageSetLayoutItemRoot);
XFA_ATTRIBUTEENUM eRelation =
- m_pTemplatePageSetRoot->GetEnum(XFA_ATTRIBUTE_Relation);
+ m_pTemplatePageSetRoot->JSNode()->GetEnum(XFA_ATTRIBUTE_Relation);
if (eRelation != XFA_ATTRIBUTEENUM_Unknown)
m_ePageSetMode = eRelation;
@@ -326,14 +327,14 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
pPageArea->InsertChild(pContentArea, nullptr);
pContentArea->SetFlag(XFA_NodeFlag_Initialized, true);
- pContentArea->SetMeasure(XFA_ATTRIBUTE_X,
- CXFA_Measurement(0.25f, XFA_UNIT_In));
- pContentArea->SetMeasure(XFA_ATTRIBUTE_Y,
- CXFA_Measurement(0.25f, XFA_UNIT_In));
- pContentArea->SetMeasure(XFA_ATTRIBUTE_W,
- CXFA_Measurement(8.0f, XFA_UNIT_In));
- pContentArea->SetMeasure(XFA_ATTRIBUTE_H,
- CXFA_Measurement(10.5f, XFA_UNIT_In));
+ pContentArea->JSNode()->SetMeasure(XFA_ATTRIBUTE_X,
+ CXFA_Measurement(0.25f, XFA_UNIT_In));
+ pContentArea->JSNode()->SetMeasure(XFA_ATTRIBUTE_Y,
+ CXFA_Measurement(0.25f, XFA_UNIT_In));
+ pContentArea->JSNode()->SetMeasure(XFA_ATTRIBUTE_W,
+ CXFA_Measurement(8.0f, XFA_UNIT_In));
+ pContentArea->JSNode()->SetMeasure(XFA_ATTRIBUTE_H,
+ CXFA_Measurement(10.5f, XFA_UNIT_In));
}
CXFA_Node* pMedium = pPageArea->GetChild(0, XFA_Element::Medium);
if (!pMedium) {
@@ -344,10 +345,10 @@ bool CXFA_LayoutPageMgr::InitLayoutPage(CXFA_Node* pFormNode) {
pPageArea->InsertChild(pMedium, nullptr);
pMedium->SetFlag(XFA_NodeFlag_Initialized, true);
- pMedium->SetMeasure(XFA_ATTRIBUTE_Short,
- CXFA_Measurement(8.5f, XFA_UNIT_In));
- pMedium->SetMeasure(XFA_ATTRIBUTE_Long,
- CXFA_Measurement(11.0f, XFA_UNIT_In));
+ pMedium->JSNode()->SetMeasure(XFA_ATTRIBUTE_Short,
+ CXFA_Measurement(8.5f, XFA_UNIT_In));
+ pMedium->JSNode()->SetMeasure(XFA_ATTRIBUTE_Long,
+ CXFA_Measurement(11.0f, XFA_UNIT_In));
}
return true;
}
@@ -363,7 +364,7 @@ bool CXFA_LayoutPageMgr::PrepareFirstPage(CXFA_Node* pRootSubform) {
XFA_Element eType = pBreakNode->GetElementType();
if (eType == XFA_Element::BreakBefore ||
(eType == XFA_Element::Break &&
- pBreakNode->GetEnum(XFA_ATTRIBUTE_Before) !=
+ pBreakNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Before) !=
XFA_ATTRIBUTEENUM_Auto)) {
bProBreakBefore = true;
pBreakBeforeNode = pBreakNode;
@@ -467,8 +468,9 @@ float CXFA_LayoutPageMgr::GetAvailHeight() {
if (!pLayoutItem || !pLayoutItem->m_pFormNode)
return 0.0f;
- float fAvailHeight =
- pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
+ float fAvailHeight = pLayoutItem->m_pFormNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_H)
+ .ToUnit(XFA_UNIT_Pt);
if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION)
return fAvailHeight;
if (m_CurrentContainerRecordIter == m_ProposedContainerRecords.begin())
@@ -478,7 +480,7 @@ float CXFA_LayoutPageMgr::GetAvailHeight() {
bool XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) {
WideString wsExpression;
- pTestScript->TryContent(wsExpression);
+ pTestScript->JSNode()->TryContent(wsExpression);
if (wsExpression.IsEmpty())
return true;
return pTestScript->GetDocument()->GetNotify()->RunScript(
@@ -503,7 +505,7 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord(
} else {
CXFA_ContainerLayoutItem* pParentLayoutItem =
static_cast<CXFA_ContainerLayoutItem*>(
- pPageSet->GetUserData(XFA_LAYOUTITEMKEY));
+ pPageSet->JSNode()->GetUserData(XFA_LAYOUTITEMKEY));
if (!pParentLayoutItem)
pParentLayoutItem = m_pPageSetCurRoot;
@@ -517,11 +519,13 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord(
} else {
pParentPageSetLayout = static_cast<CXFA_ContainerLayoutItem*>(
pPageSet->GetNodeItem(XFA_NODEITEM_Parent)
+ ->JSNode()
->GetUserData(XFA_LAYOUTITEMKEY));
}
CXFA_ContainerLayoutItem* pPageSetLayoutItem =
new CXFA_ContainerLayoutItem(pPageSet);
- pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem);
+ pPageSet->JSNode()->SetUserData(XFA_LAYOUTITEMKEY,
+ (void*)pPageSetLayoutItem);
if (!pParentPageSetLayout) {
CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot;
while (pPrePageSet->m_pNextSibling) {
@@ -544,7 +548,8 @@ CXFA_ContainerRecord* CXFA_LayoutPageMgr::CreateContainerRecord(
} else {
CXFA_ContainerLayoutItem* pPageSetLayoutItem =
new CXFA_ContainerLayoutItem(pPageSet);
- pPageSet->SetUserData(XFA_LAYOUTITEMKEY, (void*)pPageSetLayoutItem);
+ pPageSet->JSNode()->SetUserData(XFA_LAYOUTITEMKEY,
+ (void*)pPageSetLayoutItem);
m_pPageSetLayoutItemRoot->AddChild(pPageSetLayoutItem);
pNewRecord->pCurPageSet = pPageSetLayoutItem;
}
@@ -603,7 +608,8 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent();
pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) {
XFA_ATTRIBUTEENUM ePageRelation =
- pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation);
+ pPageSetLayoutItem->m_pFormNode->JSNode()->GetEnum(
+ XFA_ATTRIBUTE_Relation);
switch (ePageRelation) {
case XFA_ATTRIBUTEENUM_OrderedOccurrence:
default: { ProcessLastPageSet(); } break;
@@ -637,12 +643,12 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
}
CXFA_Node* pNode = m_pCurPageArea;
XFA_ATTRIBUTEENUM eCurChoice =
- pNode->GetEnum(XFA_ATTRIBUTE_PagePosition);
+ pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_PagePosition);
if (eCurChoice == XFA_ATTRIBUTEENUM_Last) {
XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any;
- pNode->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven);
+ pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven);
XFA_ATTRIBUTEENUM eLastChoice =
- pLastPageAreaLayoutItem->m_pFormNode->GetEnum(
+ pLastPageAreaLayoutItem->m_pFormNode->JSNode()->GetEnum(
XFA_ATTRIBUTE_PagePosition);
if (eLastChoice == XFA_ATTRIBUTEENUM_First &&
(ePageRelation == XFA_ATTRIBUTEENUM_SimplexPaginated ||
@@ -687,7 +693,8 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
}
iCurContentAreaIndex++;
if (rgUsedHeights[iCurContentAreaIndex] >
- pContentAreaNode->GetMeasure(XFA_ATTRIBUTE_H)
+ pContentAreaNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_H)
.ToUnit(XFA_UNIT_Pt) +
XFA_LAYOUT_FLOAT_PERCISION) {
bUsable = false;
@@ -717,7 +724,7 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
pContentAreaNode =
pContentAreaNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
- } else if (pNode->GetEnum(XFA_ATTRIBUTE_PagePosition) ==
+ } else if (pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_PagePosition) ==
XFA_ATTRIBUTEENUM_Last) {
CXFA_ContainerRecord* pRecord = CreateContainerRecord();
AddPageAreaLayoutItem(pRecord, pNode);
@@ -805,22 +812,24 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
CXFA_Node* pFormNode = pCurNode->GetNodeItem(
XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
CXFA_Node* pContainer = pFormNode->GetTemplateNode();
- bool bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0;
+ bool bStartNew =
+ pCurNode->JSNode()->GetInteger(XFA_ATTRIBUTE_StartNew) != 0;
CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_Element::Script);
if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript))
return false;
- WideStringView wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target);
+ WideStringView wsTarget =
+ pCurNode->JSNode()->GetCData(XFA_ATTRIBUTE_Target);
CXFA_Node* pTarget =
ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsTarget);
- wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer);
- wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader);
+ wsBreakTrailer = pCurNode->JSNode()->GetCData(XFA_ATTRIBUTE_Trailer);
+ wsBreakLeader = pCurNode->JSNode()->GetCData(XFA_ATTRIBUTE_Leader);
pBreakLeaderTemplate =
ResolveBreakTarget(pContainer, true, wsBreakLeader);
pBreakTrailerTemplate =
ResolveBreakTarget(pContainer, true, wsBreakTrailer);
- if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget,
- bStartNew)) {
+ if (RunBreak(eType, pCurNode->JSNode()->GetEnum(XFA_ATTRIBUTE_TargetType),
+ pTarget, bStartNew)) {
return true;
}
if (!m_ProposedContainerRecords.empty() &&
@@ -844,14 +853,15 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
break;
}
case XFA_Element::Break: {
- bool bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0;
- WideStringView wsTarget = pCurNode->GetCData(
+ bool bStartNew =
+ pCurNode->JSNode()->GetInteger(XFA_ATTRIBUTE_StartNew) != 0;
+ WideStringView wsTarget = pCurNode->JSNode()->GetCData(
bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget);
CXFA_Node* pTarget =
ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsTarget);
if (RunBreak(bBefore ? XFA_Element::BreakBefore : XFA_Element::BreakAfter,
- pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before
- : XFA_ATTRIBUTE_After),
+ pCurNode->JSNode()->GetEnum(bBefore ? XFA_ATTRIBUTE_Before
+ : XFA_ATTRIBUTE_After),
pTarget, bStartNew)) {
return true;
}
@@ -939,9 +949,12 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
WideStringView wsOverflowLeader;
WideStringView wsOverflowTarget;
WideStringView wsOverflowTrailer;
- pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader);
- pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer);
- pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget);
+ pOverflowNode->JSNode()->TryCData(XFA_ATTRIBUTE_OverflowLeader,
+ wsOverflowLeader);
+ pOverflowNode->JSNode()->TryCData(XFA_ATTRIBUTE_OverflowTrailer,
+ wsOverflowTrailer);
+ pOverflowNode->JSNode()->TryCData(XFA_ATTRIBUTE_OverflowTarget,
+ wsOverflowTarget);
if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() ||
!wsOverflowTarget.IsEmpty()) {
if (!wsOverflowTarget.IsEmpty() && bCreatePage &&
@@ -981,9 +994,9 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
WideStringView wsOverflowLeader;
WideStringView wsOverflowTrailer;
WideStringView wsOverflowTarget;
- pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader);
- pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer);
- pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget);
+ pOverflowNode->JSNode()->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader);
+ pOverflowNode->JSNode()->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer);
+ pOverflowNode->JSNode()->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget);
if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) {
CXFA_Node* pTarget =
ResolveBreakTarget(m_pTemplatePageSetRoot, true, wsOverflowTarget);
@@ -1073,7 +1086,7 @@ bool CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
->GetTemplateNode();
if (pBookendNode->GetElementType() == XFA_Element::Break) {
- pBookendNode->TryCData(
+ pBookendNode->JSNode()->TryCData(
bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer,
wsBookendLeader);
if (!wsBookendLeader.IsEmpty()) {
@@ -1083,7 +1096,7 @@ bool CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
}
return false;
} else if (pBookendNode->GetElementType() == XFA_Element::Bookend) {
- pBookendNode->TryCData(
+ pBookendNode->JSNode()->TryCData(
bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer,
wsBookendLeader);
pBookendAppendTemplate =
@@ -1131,7 +1144,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered(
int32_t iMax = -1;
CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur);
if (pOccurNode)
- pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false);
+ pOccurNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Max, iMax, false);
if (iMax >= 0 && iMax <= iPageSetCount)
return false;
}
@@ -1207,12 +1220,12 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
continue;
XFA_ATTRIBUTEENUM eCurPagePosition =
- pCurrentNode->GetEnum(XFA_ATTRIBUTE_PagePosition);
+ pCurrentNode->JSNode()->GetEnum(XFA_ATTRIBUTE_PagePosition);
if (ePreferredPosition == XFA_ATTRIBUTEENUM_Last) {
if (eCurPagePosition != ePreferredPosition)
continue;
if (m_ePageSetMode == XFA_ATTRIBUTEENUM_SimplexPaginated ||
- pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) ==
+ pCurrentNode->JSNode()->GetEnum(XFA_ATTRIBUTE_OddOrEven) ==
XFA_ATTRIBUTEENUM_Any) {
pPreferredPageArea = pCurrentNode;
break;
@@ -1228,7 +1241,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
if (eCurPagePosition != ePreferredPosition)
continue;
if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated ||
- pCurrentNode->GetEnum(XFA_ATTRIBUTE_OddOrEven) ==
+ pCurrentNode->JSNode()->GetEnum(XFA_ATTRIBUTE_OddOrEven) ==
XFA_ATTRIBUTEENUM_Any) {
pPreferredPageArea = pCurrentNode;
break;
@@ -1297,7 +1310,7 @@ bool CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea,
return true;
XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any;
- pPageArea->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven);
+ pPageArea->JSNode()->TryEnum(XFA_ATTRIBUTE_OddOrEven, eOddOrEven);
if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) {
int32_t iPageCount = GetPageCount();
if (bLastMatch) {
@@ -1331,7 +1344,7 @@ CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea(
CXFA_Node* pOccurNode =
m_pCurPageArea->GetFirstChildByClass(XFA_Element::Occur);
if (pOccurNode)
- pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false);
+ pOccurNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Max, iMax, false);
if ((iMax < 0 || m_nCurPageCount < iMax)) {
if (!bQuery) {
CXFA_ContainerRecord* pNewRecord =
@@ -1418,7 +1431,7 @@ void CXFA_LayoutPageMgr::InitPageSetMap() {
pPageSetNode = sIterator.MoveToNext()) {
if (pPageSetNode->GetElementType() == XFA_Element::PageSet) {
XFA_ATTRIBUTEENUM eRelation =
- pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation);
+ pPageSetNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Relation);
if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence)
m_pPageSetMap[pPageSetNode] = 0;
}
@@ -1433,7 +1446,8 @@ int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea,
CXFA_Node* pOccurNode = pPageArea->GetFirstChildByClass(XFA_Element::Occur);
int32_t iMin = 0;
- if ((pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, false)) ||
+ if ((pOccurNode &&
+ pOccurNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Min, iMin, false)) ||
bTargetPageArea) {
CXFA_Node* pContentArea =
pPageArea->GetFirstChildByClass(XFA_Element::ContentArea);
@@ -1468,7 +1482,8 @@ void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet,
CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur);
int32_t iMin = 0;
- if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, false)) {
+ if (pOccurNode &&
+ pOccurNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Min, iMin, false)) {
if (iCurSetCount < iMin) {
for (int32_t i = 0; i < iMin - iCurSetCount; i++) {
for (CXFA_Node* pCurrentPageNode =
@@ -1526,15 +1541,17 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(float fChildHeight) {
pCurContentNode =
pCurContentNode->GetNextSameClassSibling(XFA_Element::ContentArea);
if (pCurContentNode) {
- float fNextContentHeight =
- pCurContentNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
+ float fNextContentHeight = pCurContentNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_H)
+ .ToUnit(XFA_UNIT_Pt);
return fNextContentHeight > fChildHeight;
}
CXFA_Node* pPageNode = GetCurrentContainerRecord()->pCurPageArea->m_pFormNode;
CXFA_Node* pOccurNode = pPageNode->GetFirstChildByClass(XFA_Element::Occur);
int32_t iMax = 0;
- if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false)) {
+ if (pOccurNode &&
+ pOccurNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Max, iMax, false)) {
if (m_nCurPageCount == iMax) {
CXFA_Node* pSrcPage = m_pCurPageArea;
int32_t nSrcPageCount = m_nCurPageCount;
@@ -1555,8 +1572,9 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(float fChildHeight) {
CXFA_Node* pContentArea =
pNextPage->GetFirstChildByClass(XFA_Element::ContentArea);
if (pContentArea) {
- float fNextContentHeight =
- pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
+ float fNextContentHeight = pContentArea->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_H)
+ .ToUnit(XFA_UNIT_Pt);
if (fNextContentHeight > fChildHeight)
return true;
}
@@ -1568,7 +1586,7 @@ bool CXFA_LayoutPageMgr::GetNextAvailContentHeight(float fChildHeight) {
CXFA_Node* pContentArea =
pPageNode->GetFirstChildByClass(XFA_Element::ContentArea);
float fNextContentHeight =
- pContentArea->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
+ pContentArea->JSNode()->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt);
if (fNextContentHeight < XFA_LAYOUT_FLOAT_PERCISION)
return true;
if (fNextContentHeight > fChildHeight)
@@ -1645,9 +1663,12 @@ CXFA_Node* CXFA_LayoutPageMgr::QueryOverflow(CXFA_Node* pFormNode) {
WideStringView wsOverflowLeader;
WideStringView wsOverflowTarget;
WideStringView wsOverflowTrailer;
- pCurNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader);
- pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer);
- pCurNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget);
+ pCurNode->JSNode()->TryCData(XFA_ATTRIBUTE_OverflowLeader,
+ wsOverflowLeader);
+ pCurNode->JSNode()->TryCData(XFA_ATTRIBUTE_OverflowTrailer,
+ wsOverflowTrailer);
+ pCurNode->JSNode()->TryCData(XFA_ATTRIBUTE_OverflowTarget,
+ wsOverflowTarget);
if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() ||
!wsOverflowTarget.IsEmpty()) {
return pCurNode;
@@ -1674,7 +1695,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_Node* pBindNode = pNode->GetBindData();
if (pBindNode) {
pBindNode->RemoveBindItem(pNode);
- pNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
+ pNode->JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
}
}
pNode->SetFlag(XFA_NodeFlag_UnusedNode, true);
@@ -1706,10 +1727,10 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
pPendingPageSet = pRootPageSetContainerItem->m_pFormNode;
}
}
- if (pRootPageSetContainerItem->m_pFormNode->GetUserData(
+ if (pRootPageSetContainerItem->m_pFormNode->JSNode()->GetUserData(
XFA_LAYOUTITEMKEY) == pRootPageSetContainerItem) {
- pRootPageSetContainerItem->m_pFormNode->SetUserData(XFA_LAYOUTITEMKEY,
- nullptr);
+ pRootPageSetContainerItem->m_pFormNode->JSNode()->SetUserData(
+ XFA_LAYOUTITEMKEY, nullptr);
}
pRootPageSetContainerItem->m_pFormNode = pPendingPageSet;
pPendingPageSet->ClearFlag(XFA_NodeFlag_UnusedNode);
@@ -1757,7 +1778,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
pIter = sIterator.MoveToNext()) {
if (pIter->GetElementType() != XFA_Element::ContentArea) {
CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
- pIter->GetUserData(XFA_LAYOUTITEMKEY));
+ pIter->JSNode()->GetUserData(XFA_LAYOUTITEMKEY));
if (pLayoutItem) {
pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
delete pLayoutItem;
@@ -1821,7 +1842,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_Node* pChildNode = iteChild.MoveToNext();
for (; pChildNode; pChildNode = iteChild.MoveToNext()) {
CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
- pChildNode->GetUserData(XFA_LAYOUTITEMKEY));
+ pChildNode->JSNode()->GetUserData(XFA_LAYOUTITEMKEY));
if (pLayoutItem) {
pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
delete pLayoutItem;
@@ -1829,7 +1850,7 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
}
} else if (eType != XFA_Element::ContentArea) {
CXFA_LayoutItem* pLayoutItem = static_cast<CXFA_LayoutItem*>(
- pNode->GetUserData(XFA_LAYOUTITEMKEY));
+ pNode->JSNode()->GetUserData(XFA_LAYOUTITEMKEY));
if (pLayoutItem) {
pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
delete pLayoutItem;
@@ -1908,8 +1929,8 @@ void CXFA_LayoutPageMgr::SyncLayoutData() {
continue;
}
bool bVisible =
- (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) ==
- XFA_ATTRIBUTEENUM_Visible);
+ (pContentItem->m_pFormNode->JSNode()->GetEnum(
+ XFA_ATTRIBUTE_Presence) == XFA_ATTRIBUTEENUM_Visible);
uint32_t dwRelevantChild =
GetRelevant(pContentItem->m_pFormNode, dwRelevant);
SyncContainer(pNotify, m_pLayoutProcessor, pContentItem,
diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
index 765f8b2fe7..53a28f394a 100644
--- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
@@ -63,8 +63,10 @@ int32_t CXFA_LayoutProcessor::DoLayout() {
XFA_ItemLayoutProcessorResult eStatus;
CXFA_Node* pFormNode = m_pRootItemLayoutProcessor->GetFormNode();
- float fPosX = pFormNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt);
- float fPosY = pFormNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt);
+ float fPosX =
+ pFormNode->JSNode()->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt);
+ float fPosY =
+ pFormNode->JSNode()->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt);
do {
float fAvailHeight = m_pLayoutPageMgr->GetAvailHeight();
eStatus = m_pRootItemLayoutProcessor->DoLayout(true, fAvailHeight,
@@ -121,7 +123,7 @@ CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetPage(int32_t index) const {
CXFA_LayoutItem* CXFA_LayoutProcessor::GetLayoutItem(CXFA_Node* pFormItem) {
return static_cast<CXFA_LayoutItem*>(
- pFormItem->GetUserData(XFA_LAYOUTITEMKEY));
+ pFormItem->JSNode()->GetUserData(XFA_LAYOUTITEMKEY));
}
void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) {
diff --git a/xfa/fxfa/parser/cxfa_line.cpp b/xfa/fxfa/parser/cxfa_line.cpp
index 8be1d25a46..0de7bcd8a2 100644
--- a/xfa/fxfa/parser/cxfa_line.cpp
+++ b/xfa/fxfa/parser/cxfa_line.cpp
@@ -9,11 +9,12 @@
#include "xfa/fxfa/parser/cxfa_node.h"
int32_t CXFA_Line::GetHand() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Hand);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Hand);
}
bool CXFA_Line::GetSlope() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Slope) == XFA_ATTRIBUTEENUM_Slash;
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Slope) ==
+ XFA_ATTRIBUTEENUM_Slash;
}
CXFA_Edge CXFA_Line::GetEdge() {
diff --git a/xfa/fxfa/parser/cxfa_localemgr.cpp b/xfa/fxfa/parser/cxfa_localemgr.cpp
index d05750a4df..631030da28 100644
--- a/xfa/fxfa/parser/cxfa_localemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_localemgr.cpp
@@ -1237,7 +1237,8 @@ WideStringView CXFA_LocaleMgr::GetConfigLocaleName(CXFA_Node* pConfig) {
pCommon ? pCommon->GetFirstChildByClass(XFA_Element::Locale)
: nullptr;
if (pLocale) {
- pLocale->TryCData(XFA_ATTRIBUTE_Value, m_wsConfigLocale, false);
+ pLocale->JSNode()->TryCData(XFA_ATTRIBUTE_Value, m_wsConfigLocale,
+ false);
}
}
m_dwLocaleFlags |= 0x01;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index f9333187a2..a33a5c21ac 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -39,20 +39,6 @@
namespace {
-void XFA_DeleteWideString(void* pData) {
- delete static_cast<WideString*>(pData);
-}
-
-void XFA_CopyWideString(void*& pData) {
- if (pData) {
- WideString* pNewData = new WideString(*(WideString*)pData);
- pData = pNewData;
- }
-}
-
-XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = {XFA_DeleteWideString,
- XFA_CopyWideString};
-
void XFA_DataNodeDeleteBindItem(void* pData) {
delete static_cast<std::vector<CXFA_Node*>*>(pData);
}
@@ -60,36 +46,6 @@ void XFA_DataNodeDeleteBindItem(void* pData) {
XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = {
XFA_DataNodeDeleteBindItem, nullptr};
-int32_t GetCount(CXFA_Node* pInstMgrNode) {
- ASSERT(pInstMgrNode);
- int32_t iCount = 0;
- uint32_t dwNameHash = 0;
- for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling);
- pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- XFA_Element eCurType = pNode->GetElementType();
- if (eCurType == XFA_Element::InstanceManager)
- break;
- if ((eCurType != XFA_Element::Subform) &&
- (eCurType != XFA_Element::SubformSet)) {
- continue;
- }
- if (iCount == 0) {
- WideStringView wsName = pNode->GetCData(XFA_ATTRIBUTE_Name);
- WideStringView wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name);
- if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' ||
- wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
- return iCount;
- }
- dwNameHash = pNode->GetNameHash();
- }
- if (dwNameHash != pNode->GetNameHash())
- break;
-
- iCount++;
- }
- return iCount;
-}
-
std::vector<CXFA_Node*> NodesSortedByDocumentIdx(
const std::set<CXFA_Node*>& rgNodeSet) {
if (rgNodeSet.empty())
@@ -181,299 +137,12 @@ void ReorderDataNodes(const std::set<CXFA_Node*>& sSet1,
}
}
-CXFA_Node* GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex) {
- ASSERT(pInstMgrNode);
- int32_t iCount = 0;
- uint32_t dwNameHash = 0;
- for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling);
- pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- XFA_Element eCurType = pNode->GetElementType();
- if (eCurType == XFA_Element::InstanceManager)
- break;
- if ((eCurType != XFA_Element::Subform) &&
- (eCurType != XFA_Element::SubformSet)) {
- continue;
- }
- if (iCount == 0) {
- WideStringView wsName = pNode->GetCData(XFA_ATTRIBUTE_Name);
- WideStringView wsInstName = pInstMgrNode->GetCData(XFA_ATTRIBUTE_Name);
- if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' ||
- wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
- return nullptr;
- }
- dwNameHash = pNode->GetNameHash();
- }
- if (dwNameHash != pNode->GetNameHash())
- break;
-
- iCount++;
- if (iCount > iIndex)
- return pNode;
- }
- return nullptr;
-}
-
-void InsertItem(CXFA_Node* pInstMgrNode,
- CXFA_Node* pNewInstance,
- int32_t iPos,
- int32_t iCount = -1,
- bool bMoveDataBindingNodes = true) {
- if (iCount < 0)
- iCount = GetCount(pInstMgrNode);
- if (iPos < 0)
- iPos = iCount;
- if (iPos == iCount) {
- CXFA_Node* pNextSibling =
- iCount > 0
- ? GetItem(pInstMgrNode, iCount - 1)
- ->GetNodeItem(XFA_NODEITEM_NextSibling)
- : pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling);
- pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)
- ->InsertChild(pNewInstance, pNextSibling);
- if (bMoveDataBindingNodes) {
- std::set<CXFA_Node*> sNew;
- std::set<CXFA_Node*> sAfter;
- CXFA_NodeIteratorTemplate<CXFA_Node,
- CXFA_TraverseStrategy_XFAContainerNode>
- sIteratorNew(pNewInstance);
- for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode;
- pNode = sIteratorNew.MoveToNext()) {
- CXFA_Node* pDataNode = pNode->GetBindData();
- if (!pDataNode)
- continue;
-
- sNew.insert(pDataNode);
- }
- CXFA_NodeIteratorTemplate<CXFA_Node,
- CXFA_TraverseStrategy_XFAContainerNode>
- sIteratorAfter(pNextSibling);
- for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode;
- pNode = sIteratorAfter.MoveToNext()) {
- CXFA_Node* pDataNode = pNode->GetBindData();
- if (!pDataNode)
- continue;
-
- sAfter.insert(pDataNode);
- }
- ReorderDataNodes(sNew, sAfter, false);
- }
- } else {
- CXFA_Node* pBeforeInstance = GetItem(pInstMgrNode, iPos);
- pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)
- ->InsertChild(pNewInstance, pBeforeInstance);
- if (bMoveDataBindingNodes) {
- std::set<CXFA_Node*> sNew;
- std::set<CXFA_Node*> sBefore;
- CXFA_NodeIteratorTemplate<CXFA_Node,
- CXFA_TraverseStrategy_XFAContainerNode>
- sIteratorNew(pNewInstance);
- for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode;
- pNode = sIteratorNew.MoveToNext()) {
- CXFA_Node* pDataNode = pNode->GetBindData();
- if (!pDataNode)
- continue;
-
- sNew.insert(pDataNode);
- }
- CXFA_NodeIteratorTemplate<CXFA_Node,
- CXFA_TraverseStrategy_XFAContainerNode>
- sIteratorBefore(pBeforeInstance);
- for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode;
- pNode = sIteratorBefore.MoveToNext()) {
- CXFA_Node* pDataNode = pNode->GetBindData();
- if (!pDataNode)
- continue;
-
- sBefore.insert(pDataNode);
- }
- ReorderDataNodes(sNew, sBefore, true);
- }
- }
-}
-
-void RemoveItem(CXFA_Node* pInstMgrNode,
- CXFA_Node* pRemoveInstance,
- bool bRemoveDataBinding = true) {
- pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pRemoveInstance);
- if (!bRemoveDataBinding)
- return;
-
- CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>
- sIterator(pRemoveInstance);
- for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode;
- pFormNode = sIterator.MoveToNext()) {
- CXFA_Node* pDataNode = pFormNode->GetBindData();
- if (!pDataNode)
- continue;
-
- if (pDataNode->RemoveBindItem(pFormNode) == 0) {
- if (CXFA_Node* pDataParent =
- pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) {
- pDataParent->RemoveChild(pDataNode);
- }
- }
- pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
- }
-}
-
-CXFA_Node* CreateInstance(CXFA_Node* pInstMgrNode, bool bDataMerge) {
- CXFA_Document* pDocument = pInstMgrNode->GetDocument();
- CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode();
- CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent);
- CXFA_Node* pDataScope = nullptr;
- for (CXFA_Node* pRootBoundNode = pFormParent;
- pRootBoundNode && pRootBoundNode->IsContainerNode();
- pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) {
- pDataScope = pRootBoundNode->GetBindData();
- if (pDataScope)
- break;
- }
- if (!pDataScope) {
- pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
- ASSERT(pDataScope);
- }
- CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer(
- pTemplateNode, pFormParent, pDataScope, true, bDataMerge, true);
- if (pInstance) {
- pDocument->DataMerge_UpdateBindingRelations(pInstance);
- pFormParent->RemoveChild(pInstance);
- }
- return pInstance;
-}
-
-struct XFA_ExecEventParaInfo {
- public:
- uint32_t m_uHash;
- const wchar_t* m_lpcEventName;
- XFA_EVENTTYPE m_eventType;
- uint32_t m_validFlags;
-};
-static const XFA_ExecEventParaInfo gs_eventParaInfos[] = {
- {0x02a6c55a, L"postSubmit", XFA_EVENT_PostSubmit, 0},
- {0x0ab466bb, L"preSubmit", XFA_EVENT_PreSubmit, 0},
- {0x109d7ce7, L"mouseEnter", XFA_EVENT_MouseEnter, 5},
- {0x17fad373, L"postPrint", XFA_EVENT_PostPrint, 0},
- {0x1bfc72d9, L"preOpen", XFA_EVENT_PreOpen, 7},
- {0x2196a452, L"initialize", XFA_EVENT_Initialize, 1},
- {0x27410f03, L"mouseExit", XFA_EVENT_MouseExit, 5},
- {0x33c43dec, L"docClose", XFA_EVENT_DocClose, 0},
- {0x361fa1b6, L"preSave", XFA_EVENT_PreSave, 0},
- {0x36f1c6d8, L"preSign", XFA_EVENT_PreSign, 6},
- {0x4731d6ba, L"exit", XFA_EVENT_Exit, 2},
- {0x56bf456b, L"docReady", XFA_EVENT_DocReady, 0},
- {0x7233018a, L"validate", XFA_EVENT_Validate, 1},
- {0x8808385e, L"indexChange", XFA_EVENT_IndexChange, 3},
- {0x891f4606, L"change", XFA_EVENT_Change, 4},
- {0x9528a7b4, L"prePrint", XFA_EVENT_PrePrint, 0},
- {0x9f693b21, L"mouseDown", XFA_EVENT_MouseDown, 5},
- {0xcdce56b3, L"full", XFA_EVENT_Full, 4},
- {0xd576d08e, L"mouseUp", XFA_EVENT_MouseUp, 5},
- {0xd95657a6, L"click", XFA_EVENT_Click, 4},
- {0xdbfbe02e, L"calculate", XFA_EVENT_Calculate, 1},
- {0xe25fa7b8, L"postOpen", XFA_EVENT_PostOpen, 7},
- {0xe28dce7e, L"enter", XFA_EVENT_Enter, 2},
- {0xfc82d695, L"postSave", XFA_EVENT_PostSave, 0},
- {0xfd54fbb7, L"postSign", XFA_EVENT_PostSign, 6},
-};
-
-const XFA_ExecEventParaInfo* GetEventParaInfoByName(
- const WideStringView& wsEventName) {
- uint32_t uHash = FX_HashCode_GetW(wsEventName, false);
- int32_t iStart = 0;
- int32_t iEnd = (sizeof(gs_eventParaInfos) / sizeof(gs_eventParaInfos[0])) - 1;
- do {
- int32_t iMid = (iStart + iEnd) / 2;
- const XFA_ExecEventParaInfo* eventParaInfo = &gs_eventParaInfos[iMid];
- if (uHash == eventParaInfo->m_uHash)
- return eventParaInfo;
- if (uHash < eventParaInfo->m_uHash)
- iEnd = iMid - 1;
- else
- iStart = iMid + 1;
- } while (iStart <= iEnd);
- return nullptr;
-}
-
-void StrToRGB(const WideString& strRGB, int32_t& r, int32_t& g, int32_t& b) {
- r = 0;
- g = 0;
- b = 0;
-
- wchar_t zero = '0';
- int32_t iIndex = 0;
- int32_t iLen = strRGB.GetLength();
- for (int32_t i = 0; i < iLen; ++i) {
- wchar_t ch = strRGB[i];
- if (ch == L',')
- ++iIndex;
- if (iIndex > 2)
- break;
-
- int32_t iValue = ch - zero;
- if (iValue >= 0 && iValue <= 9) {
- switch (iIndex) {
- case 0:
- r = r * 10 + iValue;
- break;
- case 1:
- g = g * 10 + iValue;
- break;
- default:
- b = b * 10 + iValue;
- break;
- }
- }
- }
-}
-
-enum XFA_KEYTYPE {
- XFA_KEYTYPE_Custom,
- XFA_KEYTYPE_Element,
-};
-
-void* GetMapKey_Custom(const WideStringView& wsKey) {
- uint32_t dwKey = FX_HashCode_GetW(wsKey, false);
- return (void*)(uintptr_t)((dwKey << 1) | XFA_KEYTYPE_Custom);
-}
-
-void* GetMapKey_Element(XFA_Element eType, XFA_ATTRIBUTE eAttribute) {
- return (void*)(uintptr_t)((static_cast<int32_t>(eType) << 16) |
- (eAttribute << 8) | XFA_KEYTYPE_Element);
-}
-
-const XFA_ATTRIBUTEINFO* GetAttributeOfElement(XFA_Element eElement,
- XFA_ATTRIBUTE eAttribute,
- uint32_t dwPacket) {
- int32_t iCount = 0;
- const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount);
- if (!pAttr || iCount < 1)
- return nullptr;
-
- if (!std::binary_search(pAttr, pAttr + iCount, eAttribute))
- return nullptr;
-
- const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute);
- ASSERT(pInfo);
- if (dwPacket == XFA_XDPPACKET_UNKNOWN)
- return pInfo;
- return (dwPacket & pInfo->dwPackets) ? pInfo : nullptr;
-}
+} // namespace
const XFA_ATTRIBUTEENUMINFO* GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName) {
return g_XFAEnumData + eName;
}
-} // namespace
-
-static void XFA_DefaultFreeData(void* pData) {}
-
-static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADefaultFreeData = {
- XFA_DefaultFreeData, nullptr};
-
-XFA_MAPMODULEDATA::XFA_MAPMODULEDATA() {}
-
-XFA_MAPMODULEDATA::~XFA_MAPMODULEDATA() {}
-
CXFA_Node::CXFA_Node(CXFA_Document* pDoc,
uint16_t ePacket,
XFA_ObjectType oType,
@@ -489,13 +158,12 @@ CXFA_Node::CXFA_Node(CXFA_Document* pDoc,
m_uNodeFlags(XFA_NodeFlag_None),
m_dwNameHash(0),
m_pAuxNode(nullptr),
- m_pMapModuleData(nullptr) {
+ m_JSNode(this) {
ASSERT(m_pDocument);
}
CXFA_Node::~CXFA_Node() {
ASSERT(!m_pParent);
- RemoveMapModuleKey();
CXFA_Node* pNode = m_pChild;
while (pNode) {
CXFA_Node* pNext = pNode->m_pNext;
@@ -512,20 +180,21 @@ CXFA_Node* CXFA_Node::Clone(bool bRecursive) {
if (!pClone)
return nullptr;
- MergeAllData(pClone);
+ m_JSNode.MergeAllData(pClone);
pClone->UpdateNameHash();
if (IsNeedSavingXMLNode()) {
std::unique_ptr<CFX_XMLNode> pCloneXML;
if (IsAttributeInXML()) {
WideString wsName;
- GetAttribute(XFA_ATTRIBUTE_Name, wsName, false);
+ m_JSNode.GetAttribute(XFA_ATTRIBUTE_Name, wsName, false);
auto pCloneXMLElement = pdfium::MakeUnique<CFX_XMLElement>(wsName);
- WideStringView wsValue = GetCData(XFA_ATTRIBUTE_Value);
+ WideStringView wsValue = m_JSNode.GetCData(XFA_ATTRIBUTE_Value);
if (!wsValue.IsEmpty()) {
pCloneXMLElement->SetTextData(WideString(wsValue));
}
pCloneXML.reset(pCloneXMLElement.release());
- pClone->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown);
+ pClone->JSNode()->SetEnum(XFA_ATTRIBUTE_Contains,
+ XFA_ATTRIBUTEENUM_Unknown);
} else {
pCloneXML = m_pXMLNode->Clone();
}
@@ -539,7 +208,7 @@ CXFA_Node* CXFA_Node::Clone(bool bRecursive) {
}
}
pClone->SetFlag(XFA_NodeFlag_Initialized, true);
- pClone->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
+ pClone->JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
return pClone;
}
@@ -702,18 +371,18 @@ void CXFA_Node::SetTemplateNode(CXFA_Node* pTemplateNode) {
CXFA_Node* CXFA_Node::GetBindData() {
ASSERT(GetPacketID() == XFA_XDPPACKET_Form);
- return static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
+ return static_cast<CXFA_Node*>(m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode));
}
std::vector<CXFA_Node*> CXFA_Node::GetBindItems() {
if (BindsFormItems()) {
void* pBinding = nullptr;
- TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
+ m_JSNode.TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
return *static_cast<std::vector<CXFA_Node*>*>(pBinding);
}
std::vector<CXFA_Node*> result;
CXFA_Node* pFormNode =
- static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
+ static_cast<CXFA_Node*>(m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode));
if (pFormNode)
result.push_back(pFormNode);
return result;
@@ -723,23 +392,24 @@ int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) {
ASSERT(pFormNode);
if (BindsFormItems()) {
void* pBinding = nullptr;
- TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
+ m_JSNode.TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
auto* pItems = static_cast<std::vector<CXFA_Node*>*>(pBinding);
if (!pdfium::ContainsValue(*pItems, pFormNode))
pItems->push_back(pFormNode);
return pdfium::CollectionSize<int32_t>(*pItems);
}
CXFA_Node* pOldFormItem =
- static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
+ static_cast<CXFA_Node*>(m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode));
if (!pOldFormItem) {
- SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode);
+ m_JSNode.SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode);
return 1;
}
if (pOldFormItem == pFormNode)
return 1;
std::vector<CXFA_Node*>* pItems = new std::vector<CXFA_Node*>;
- SetObject(XFA_ATTRIBUTE_BindingNode, pItems, &deleteBindItemCallBack);
+ m_JSNode.SetObject(XFA_ATTRIBUTE_BindingNode, pItems,
+ &deleteBindItemCallBack);
pItems->push_back(pOldFormItem);
pItems->push_back(pFormNode);
m_uNodeFlags |= XFA_NodeFlag_BindFormItems;
@@ -749,15 +419,15 @@ int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) {
int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) {
if (BindsFormItems()) {
void* pBinding = nullptr;
- TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
+ m_JSNode.TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
auto* pItems = static_cast<std::vector<CXFA_Node*>*>(pBinding);
auto iter = std::find(pItems->begin(), pItems->end(), pFormNode);
if (iter != pItems->end()) {
*iter = pItems->back();
pItems->pop_back();
if (pItems->size() == 1) {
- SetObject(XFA_ATTRIBUTE_BindingNode,
- (*pItems)[0]); // Invalidates pItems.
+ m_JSNode.SetObject(XFA_ATTRIBUTE_BindingNode,
+ (*pItems)[0]); // Invalidates pItems.
m_uNodeFlags &= ~XFA_NodeFlag_BindFormItems;
return 1;
}
@@ -765,21 +435,21 @@ int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) {
return pdfium::CollectionSize<int32_t>(*pItems);
}
CXFA_Node* pOldFormItem =
- static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
+ static_cast<CXFA_Node*>(m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode));
if (pOldFormItem != pFormNode)
return pOldFormItem ? 1 : 0;
- SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
+ m_JSNode.SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
return 0;
}
bool CXFA_Node::HasBindItem() {
return GetPacketID() == XFA_XDPPACKET_Datasets &&
- GetObject(XFA_ATTRIBUTE_BindingNode);
+ m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode);
}
CXFA_WidgetData* CXFA_Node::GetWidgetData() {
- return (CXFA_WidgetData*)GetObject(XFA_ATTRIBUTE_WidgetData);
+ return (CXFA_WidgetData*)m_JSNode.GetObject(XFA_ATTRIBUTE_WidgetData);
}
CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() {
@@ -850,7 +520,8 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) {
CXFA_Node* pLocaleNode = this;
bool bLocale = false;
do {
- bLocale = pLocaleNode->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, false);
+ bLocale = pLocaleNode->JSNode()->TryCData(XFA_ATTRIBUTE_Locale,
+ wsLocaleName, false);
if (!bLocale) {
pLocaleNode = pLocaleNode->GetNodeItem(XFA_NODEITEM_Parent);
}
@@ -861,8 +532,8 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) {
wsLocaleName = GetDocument()->GetLocalMgr()->GetConfigLocaleName(pConfig);
if (!wsLocaleName.IsEmpty())
return true;
- if (pTopSubform &&
- pTopSubform->TryCData(XFA_ATTRIBUTE_Locale, wsLocaleName, false)) {
+ if (pTopSubform && pTopSubform->JSNode()->TryCData(XFA_ATTRIBUTE_Locale,
+ wsLocaleName, false)) {
return true;
}
IFX_Locale* pLocale = GetDocument()->GetLocalMgr()->GetDefLocale();
@@ -875,27 +546,27 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) {
XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
CXFA_Node* pKeep = GetFirstChildByClass(XFA_Element::Keep);
- XFA_ATTRIBUTEENUM eLayoutType = GetEnum(XFA_ATTRIBUTE_Layout);
+ XFA_ATTRIBUTEENUM eLayoutType = m_JSNode.GetEnum(XFA_ATTRIBUTE_Layout);
if (pKeep) {
XFA_ATTRIBUTEENUM eIntact;
- if (pKeep->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, false)) {
+ if (pKeep->JSNode()->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, false)) {
if (eIntact == XFA_ATTRIBUTEENUM_None &&
eLayoutType == XFA_ATTRIBUTEENUM_Row &&
m_pDocument->GetCurVersionMode() < XFA_VERSION_208) {
CXFA_Node* pPreviewRow = GetNodeItem(XFA_NODEITEM_PrevSibling,
XFA_ObjectType::ContainerNode);
- if (pPreviewRow &&
- pPreviewRow->GetEnum(XFA_ATTRIBUTE_Layout) ==
- XFA_ATTRIBUTEENUM_Row) {
+ if (pPreviewRow && pPreviewRow->JSNode()->GetEnum(
+ XFA_ATTRIBUTE_Layout) == XFA_ATTRIBUTEENUM_Row) {
XFA_ATTRIBUTEENUM eValue;
- if (pKeep->TryEnum(XFA_ATTRIBUTE_Previous, eValue, false) &&
+ if (pKeep->JSNode()->TryEnum(XFA_ATTRIBUTE_Previous, eValue, false) &&
(eValue == XFA_ATTRIBUTEENUM_ContentArea ||
eValue == XFA_ATTRIBUTEENUM_PageArea)) {
return XFA_ATTRIBUTEENUM_ContentArea;
}
CXFA_Node* pNode =
pPreviewRow->GetFirstChildByClass(XFA_Element::Keep);
- if (pNode && pNode->TryEnum(XFA_ATTRIBUTE_Next, eValue, false) &&
+ if (pNode &&
+ pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Next, eValue, false) &&
(eValue == XFA_ATTRIBUTEENUM_ContentArea ||
eValue == XFA_ATTRIBUTEENUM_PageArea)) {
return XFA_ATTRIBUTEENUM_ContentArea;
@@ -927,7 +598,7 @@ XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
return XFA_ATTRIBUTEENUM_ContentArea;
if (pParentNode->GetIntact() == XFA_ATTRIBUTEENUM_None) {
XFA_ATTRIBUTEENUM eParLayout =
- pParentNode->GetEnum(XFA_ATTRIBUTE_Layout);
+ pParentNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Layout);
if (eParLayout == XFA_ATTRIBUTEENUM_Position ||
eParLayout == XFA_ATTRIBUTEENUM_Row ||
eParLayout == XFA_ATTRIBUTEENUM_Table) {
@@ -936,7 +607,7 @@ XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
XFA_VERSION version = m_pDocument->GetCurVersionMode();
if (eParLayout == XFA_ATTRIBUTEENUM_Tb && version < XFA_VERSION_208) {
CXFA_Measurement measureH;
- if (TryMeasure(XFA_ATTRIBUTE_H, measureH, false))
+ if (m_JSNode.TryMeasure(XFA_ATTRIBUTE_H, measureH, false))
return XFA_ATTRIBUTEENUM_ContentArea;
}
return XFA_ATTRIBUTEENUM_None;
@@ -962,3311 +633,830 @@ void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) {
m_pAuxNode = pDataDescriptionNode;
}
-void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"resolveNode");
- return;
+int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() {
+ int32_t index = 0;
+ for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
+ pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
+ if ((pNode->GetElementType() == XFA_Element::Subform) ||
+ (pNode->GetElementType() == XFA_Element::SubformSet)) {
+ index++;
+ } else {
+ break;
+ }
}
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext();
- if (!pScriptContext)
- return;
- CXFA_Node* refNode = this;
- if (refNode->GetElementType() == XFA_Element::Xfa)
- refNode = ToNode(pScriptContext->GetThisObject());
- uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
- XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings;
- XFA_RESOLVENODE_RS resoveNodeRS;
- int32_t iRet = pScriptContext->ResolveObjects(
- refNode, wsExpression.AsStringView(), resoveNodeRS, dwFlag);
- if (iRet < 1) {
- pArguments->GetReturnValue()->SetNull();
- return;
+ return index;
+}
+
+int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
+ CXFA_Occur nodeOccur(GetOccurNode());
+ int32_t iMax = nodeOccur.GetMax();
+ int32_t iMin = nodeOccur.GetMin();
+ if (iDesired < iMin) {
+ ThrowTooManyOccurancesException(L"min");
+ return 1;
}
- if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
- CXFA_Object* pObject = resoveNodeRS.objects.front();
- pArguments->GetReturnValue()->Assign(
- pScriptContext->GetJSValueFromMap(pObject));
- } else {
- const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
- resoveNodeRS.pScriptAttribute;
- if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) {
- auto pValue =
- pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetRuntime());
- (resoveNodeRS.objects.front()->*(lpAttributeInfo->lpfnCallback))(
- pValue.get(), false, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
- pArguments->GetReturnValue()->Assign(pValue.get());
- } else {
- pArguments->GetReturnValue()->SetNull();
+ if ((iMax >= 0) && (iDesired > iMax)) {
+ ThrowTooManyOccurancesException(L"max");
+ return 2;
+ }
+ int32_t iCount = GetCount(this);
+ if (iDesired == iCount) {
+ return 0;
+ }
+ if (iDesired < iCount) {
+ WideStringView wsInstManagerName = m_JSNode.GetCData(XFA_ATTRIBUTE_Name);
+ WideString wsInstanceName = WideString(
+ wsInstManagerName.IsEmpty()
+ ? wsInstManagerName
+ : wsInstManagerName.Right(wsInstManagerName.GetLength() - 1));
+ uint32_t dInstanceNameHash =
+ FX_HashCode_GetW(wsInstanceName.AsStringView(), false);
+ CXFA_Node* pPrevSibling =
+ (iDesired == 0) ? this : GetItem(this, iDesired - 1);
+ while (iCount > iDesired) {
+ CXFA_Node* pRemoveInstance =
+ pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling);
+ if (pRemoveInstance->GetElementType() != XFA_Element::Subform &&
+ pRemoveInstance->GetElementType() != XFA_Element::SubformSet) {
+ continue;
+ }
+ if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) {
+ NOTREACHED();
+ break;
+ }
+ if (pRemoveInstance->GetNameHash() == dInstanceNameHash) {
+ RemoveItem(this, pRemoveInstance);
+ iCount--;
+ }
+ }
+ } else if (iDesired > iCount) {
+ while (iCount < iDesired) {
+ CXFA_Node* pNewInstance = CreateInstance(this, true);
+ InsertItem(this, pNewInstance, iCount, iCount, false);
+ iCount++;
+ CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
+ if (!pNotify) {
+ return 0;
+ }
+ pNotify->RunNodeInitialize(pNewInstance);
}
}
+ CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
+ if (pLayoutPro) {
+ pLayoutPro->AddChangedContainer(
+ ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
+ }
+ return 0;
}
-void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"resolveNodes");
- return;
+int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) {
+ int32_t iCount = GetCount(this);
+ if (iFrom > iCount || iTo > iCount - 1) {
+ ThrowIndexOutOfBoundsException();
+ return 1;
}
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pValue)
- return;
- uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
- XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings;
- CXFA_Node* refNode = this;
- if (refNode->GetElementType() == XFA_Element::Xfa)
- refNode = ToNode(m_pDocument->GetScriptContext()->GetThisObject());
- Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag, refNode);
+ if (iFrom < 0 || iTo < 0 || iFrom == iTo) {
+ return 0;
+ }
+ CXFA_Node* pMoveInstance = GetItem(this, iFrom);
+ RemoveItem(this, pMoveInstance, false);
+ InsertItem(this, pMoveInstance, iTo, iCount - 1, true);
+ CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
+ if (pLayoutPro) {
+ pLayoutPro->AddChangedContainer(
+ ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
+ }
+ return 0;
+}
+
+void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
+ m_JSNode.Script_TreeClass_ResolveNode(pArguments);
+}
+
+void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) {
+ m_JSNode.Script_TreeClass_ResolveNodes(pArguments);
}
void CXFA_Node::Script_Som_ResolveNodeList(CFXJSE_Value* pValue,
WideString wsExpression,
uint32_t dwFlag,
CXFA_Node* refNode) {
- CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext();
- if (!pScriptContext)
- return;
- XFA_RESOLVENODE_RS resoveNodeRS;
- if (!refNode)
- refNode = this;
- pScriptContext->ResolveObjects(refNode, wsExpression.AsStringView(),
- resoveNodeRS, dwFlag);
- CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(m_pDocument.Get());
- if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
- for (CXFA_Object* pObject : resoveNodeRS.objects) {
- if (pObject->IsNode())
- pNodeList->Append(pObject->AsNode());
- }
- } else {
- CXFA_ValueArray valueArray(pScriptContext->GetRuntime());
- if (resoveNodeRS.GetAttributeResult(&valueArray) > 0) {
- for (CXFA_Object* pObject : valueArray.GetAttributeObject()) {
- if (pObject->IsNode())
- pNodeList->Append(pObject->AsNode());
- }
- }
- }
- pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass());
+ m_JSNode.Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag, refNode);
}
void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
-
- uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
- WideString wsName;
- GetAttribute(XFA_ATTRIBUTE_Name, wsName);
- WideString wsExpression = wsName + L"[*]";
- Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag);
+ m_JSNode.Script_TreeClass_All(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext();
- if (!pScriptContext)
- return;
- if (bSetting) {
- WideString wsMessage = L"Unable to set ";
- FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView());
- } else {
- CXFA_AttachNodeList* pNodeList =
- new CXFA_AttachNodeList(m_pDocument.Get(), this);
- pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass());
- }
+ m_JSNode.Script_TreeClass_Nodes(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
- WideString wsExpression = L"#" + GetClassName() + L"[*]";
- Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag);
+ m_JSNode.Script_TreeClass_ClassAll(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent);
- if (pParent) {
- pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent));
- } else {
- pValue->SetNull();
- }
+ m_JSNode.Script_TreeClass_Parent(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- pValue->SetInteger(GetNodeSameNameIndex());
+ m_JSNode.Script_TreeClass_Index(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- pValue->SetInteger(GetNodeSameClassIndex());
+ m_JSNode.Script_TreeClass_ClassIndex(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- WideString wsSOMExpression;
- GetSOMExpression(wsSOMExpression);
- pValue->SetString(wsSOMExpression.UTF8Encode().AsStringView());
+ m_JSNode.Script_TreeClass_SomExpression(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"applyXSL");
- return;
- }
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- // TODO(weili): check whether we need to implement this, pdfium:501.
- // For now, just put the variables here to avoid unused variable warning.
- (void)wsExpression;
+ m_JSNode.Script_NodeClass_ApplyXSL(pArguments);
}
void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 3) {
- ThrowParamCountMismatchException(L"assignNode");
- return;
- }
- WideString wsExpression;
- WideString wsValue;
- int32_t iAction = 0;
- wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- if (iLength >= 2) {
- wsValue = WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringView());
- }
- if (iLength >= 3)
- iAction = pArguments->GetInt32(2);
- // TODO(weili): check whether we need to implement this, pdfium:501.
- // For now, just put the variables here to avoid unused variable warning.
- (void)wsExpression;
- (void)wsValue;
- (void)iAction;
+ m_JSNode.Script_NodeClass_AssignNode(pArguments);
}
void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"clone");
- return;
- }
- bool bClone = !!pArguments->GetInt32(0);
- CXFA_Node* pCloneNode = Clone(bClone);
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pCloneNode));
+ m_JSNode.Script_NodeClass_Clone(pArguments);
}
void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getAttribute");
- return;
- }
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- WideString wsValue;
- GetAttribute(wsExpression.AsStringView(), wsValue);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetString(wsValue.UTF8Encode().AsStringView());
+ m_JSNode.Script_NodeClass_GetAttribute(pArguments);
}
void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 2) {
- ThrowParamCountMismatchException(L"getElement");
- return;
- }
- WideString wsExpression;
- int32_t iValue = 0;
- wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- if (iLength >= 2)
- iValue = pArguments->GetInt32(1);
- CXFA_Node* pNode = GetProperty(
- iValue, XFA_GetElementTypeForName(wsExpression.AsStringView()));
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode));
+ m_JSNode.Script_NodeClass_GetElement(pArguments);
}
void CXFA_Node::Script_NodeClass_IsPropertySpecified(
CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 3) {
- ThrowParamCountMismatchException(L"isPropertySpecified");
- return;
- }
-
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (!pValue)
- return;
-
- WideString wsExpression =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- const XFA_ATTRIBUTEINFO* pAttributeInfo =
- XFA_GetAttributeByName(wsExpression.AsStringView());
- bool bHas = pAttributeInfo ? HasAttribute(pAttributeInfo->eName) : false;
- if (!bHas) {
- bool bParent = iLength < 2 || pArguments->GetInt32(1);
- int32_t iIndex = iLength == 3 ? pArguments->GetInt32(2) : 0;
- XFA_Element eType = XFA_GetElementTypeForName(wsExpression.AsStringView());
- bHas = !!GetProperty(iIndex, eType);
- if (!bHas && bParent && m_pParent) {
- // Also check on the parent.
- bHas = m_pParent->HasAttribute(pAttributeInfo->eName);
- if (!bHas)
- bHas = !!m_pParent->GetProperty(iIndex, eType);
- }
- }
- pValue->SetBoolean(bHas);
+ m_JSNode.Script_NodeClass_IsPropertySpecified(pArguments);
}
void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 3) {
- ThrowParamCountMismatchException(L"loadXML");
- return;
- }
-
- bool bIgnoreRoot = true;
- bool bOverwrite = 0;
- ByteString wsExpression = pArguments->GetUTF8String(0);
- if (wsExpression.IsEmpty())
- return;
- if (iLength >= 2)
- bIgnoreRoot = !!pArguments->GetInt32(1);
- if (iLength >= 3)
- bOverwrite = !!pArguments->GetInt32(2);
- auto pParser =
- pdfium::MakeUnique<CXFA_SimpleParser>(m_pDocument.Get(), false);
- if (!pParser)
- return;
- CFX_XMLNode* pXMLNode = pParser->ParseXMLData(wsExpression);
- if (!pXMLNode)
- return;
- if (bIgnoreRoot &&
- (pXMLNode->GetType() != FX_XMLNODE_Element ||
- XFA_RecognizeRichText(static_cast<CFX_XMLElement*>(pXMLNode)))) {
- bIgnoreRoot = false;
- }
- CXFA_Node* pFakeRoot = Clone(false);
- WideStringView wsContentType = GetCData(XFA_ATTRIBUTE_ContentType);
- if (!wsContentType.IsEmpty()) {
- pFakeRoot->SetCData(XFA_ATTRIBUTE_ContentType, WideString(wsContentType));
- }
-
- std::unique_ptr<CFX_XMLNode> pFakeXMLRoot(pFakeRoot->GetXMLMappingNode());
- if (!pFakeXMLRoot) {
- CFX_XMLNode* pThisXMLRoot = GetXMLMappingNode();
- pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone() : nullptr;
- }
- if (!pFakeXMLRoot) {
- pFakeXMLRoot =
- pdfium::MakeUnique<CFX_XMLElement>(WideString(GetClassName()));
- }
-
- if (bIgnoreRoot) {
- CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- while (pXMLChild) {
- CFX_XMLNode* pXMLSibling =
- pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling);
- pXMLNode->RemoveChildNode(pXMLChild);
- pFakeXMLRoot->InsertChildNode(pXMLChild);
- pXMLChild = pXMLSibling;
- }
- } else {
- CFX_XMLNode* pXMLParent = pXMLNode->GetNodeItem(CFX_XMLNode::Parent);
- if (pXMLParent) {
- pXMLParent->RemoveChildNode(pXMLNode);
- }
- pFakeXMLRoot->InsertChildNode(pXMLNode);
- }
- pParser->ConstructXFANode(pFakeRoot, pFakeXMLRoot.get());
- pFakeRoot = pParser->GetRootNode();
- if (!pFakeRoot)
- return;
-
- if (bOverwrite) {
- CXFA_Node* pChild = GetNodeItem(XFA_NODEITEM_FirstChild);
- CXFA_Node* pNewChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
- int32_t index = 0;
- while (pNewChild) {
- CXFA_Node* pItem = pNewChild->GetNodeItem(XFA_NODEITEM_NextSibling);
- pFakeRoot->RemoveChild(pNewChild);
- InsertChild(index++, pNewChild);
- pNewChild->SetFlag(XFA_NodeFlag_Initialized, true);
- pNewChild = pItem;
- }
- while (pChild) {
- CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
- RemoveChild(pChild);
- pFakeRoot->InsertChild(pChild);
- pChild = pItem;
- }
- if (GetPacketID() == XFA_XDPPACKET_Form &&
- GetElementType() == XFA_Element::ExData) {
- CFX_XMLNode* pTempXMLNode = GetXMLMappingNode();
- SetXMLMappingNode(pFakeXMLRoot.release());
- SetFlag(XFA_NodeFlag_OwnXMLNode, false);
- if (pTempXMLNode && !pTempXMLNode->GetNodeItem(CFX_XMLNode::Parent))
- pFakeXMLRoot.reset(pTempXMLNode);
- else
- pFakeXMLRoot = nullptr;
- }
- MoveBufferMapData(pFakeRoot, this, XFA_CalcData, true);
- } else {
- CXFA_Node* pChild = pFakeRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
- while (pChild) {
- CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
- pFakeRoot->RemoveChild(pChild);
- InsertChild(pChild);
- pChild->SetFlag(XFA_NodeFlag_Initialized, true);
- pChild = pItem;
- }
- }
- if (pFakeXMLRoot) {
- pFakeRoot->SetXMLMappingNode(pFakeXMLRoot.release());
- pFakeRoot->SetFlag(XFA_NodeFlag_OwnXMLNode, false);
- }
- pFakeRoot->SetFlag(XFA_NodeFlag_HasRemovedChildren, false);
+ m_JSNode.Script_NodeClass_LoadXML(pArguments);
}
void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) {
- // TODO(weili): Check whether we need to implement this, pdfium:501.
+ m_JSNode.Script_NodeClass_SaveFilteredXML(pArguments);
}
void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 0 || iLength > 1) {
- ThrowParamCountMismatchException(L"saveXML");
- return;
- }
- bool bPrettyMode = false;
- if (iLength == 1) {
- if (pArguments->GetUTF8String(0) != "pretty") {
- ThrowArgumentMismatchException();
- return;
- }
- bPrettyMode = true;
- }
- WideString bsXMLHeader = L"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- if (GetPacketID() == XFA_XDPPACKET_Form ||
- GetPacketID() == XFA_XDPPACKET_Datasets) {
- CFX_XMLNode* pElement = nullptr;
- if (GetPacketID() == XFA_XDPPACKET_Datasets) {
- pElement = GetXMLMappingNode();
- if (!pElement || pElement->GetType() != FX_XMLNODE_Element) {
- pArguments->GetReturnValue()->SetString(
- bsXMLHeader.UTF8Encode().AsStringView());
- return;
- }
- XFA_DataExporter_DealWithDataGroupNode(this);
- }
- auto pMemoryStream = pdfium::MakeRetain<CFX_MemoryStream>(true);
- auto pStream =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(pMemoryStream, true);
- pStream->SetCodePage(FX_CODEPAGE_UTF8);
- pStream->WriteString(bsXMLHeader.AsStringView());
-
- if (GetPacketID() == XFA_XDPPACKET_Form)
- XFA_DataExporter_RegenerateFormFile(this, pStream, nullptr, true);
- else
- pElement->SaveXMLNode(pStream);
- // TODO(weili): Check whether we need to save pretty print XML, pdfium:501.
- // For now, just put it here to avoid unused variable warning.
- (void)bPrettyMode;
- pArguments->GetReturnValue()->SetString(
- ByteStringView(pMemoryStream->GetBuffer(), pMemoryStream->GetSize()));
- return;
- }
- pArguments->GetReturnValue()->SetString("");
+ m_JSNode.Script_NodeClass_SaveXML(pArguments);
}
void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 2) {
- ThrowParamCountMismatchException(L"setAttribute");
- return;
- }
- WideString wsAttributeValue =
- WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
- WideString wsAttribute =
- WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringView());
- SetAttribute(wsAttribute.AsStringView(), wsAttributeValue.AsStringView(),
- true);
+ m_JSNode.Script_NodeClass_SetAttribute(pArguments);
}
void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1 && iLength != 2) {
- ThrowParamCountMismatchException(L"setElement");
- return;
- }
- CXFA_Node* pNode = nullptr;
- WideString wsName;
- pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (iLength == 2)
- wsName = WideString::FromUTF8(pArguments->GetUTF8String(1).AsStringView());
- // TODO(weili): check whether we need to implement this, pdfium:501.
- // For now, just put the variables here to avoid unused variable warning.
- (void)pNode;
- (void)wsName;
+ m_JSNode.Script_NodeClass_SetElement(pArguments);
}
void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
-
- WideString wsNameSpace;
- TryNamespace(wsNameSpace);
- pValue->SetString(wsNameSpace.UTF8Encode().AsStringView());
+ m_JSNode.Script_NodeClass_Ns(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(GetModelNode()));
+ m_JSNode.Script_NodeClass_Model(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- pValue->SetBoolean(IsContainerNode());
+ m_JSNode.Script_NodeClass_IsContainer(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- if (GetElementType() == XFA_Element::Subform) {
- pValue->SetBoolean(false);
- return;
- }
- WideString strValue;
- pValue->SetBoolean(!TryContent(strValue) || strValue.IsEmpty());
+ m_JSNode.Script_NodeClass_IsNull(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- std::vector<CXFA_Node*> properties =
- GetNodeList(XFA_NODEFILTER_OneOfProperty);
- if (!properties.empty()) {
- pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(properties.front()));
- }
+ m_JSNode.Script_NodeClass_OneOfChild(pValue, bSetting, eAttribute);
}
-void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {}
+void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {
+ m_JSNode.Script_ContainerClass_GetDelta(pArguments);
+}
void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) {
- CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument.Get());
- pArguments->GetReturnValue()->SetObject(
- pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass());
+ m_JSNode.Script_ContainerClass_GetDeltas(pArguments);
}
+
void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) {
+ m_JSNode.Script_ModelClass_ClearErrorList(pArguments);
}
void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) {
- Script_Template_CreateNode(pArguments);
+ m_JSNode.Script_ModelClass_CreateNode(pArguments);
}
void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1) {
- ThrowParamCountMismatchException(L"isCompatibleNS");
- return;
- }
- WideString wsNameSpace;
- if (iLength >= 1) {
- ByteString bsNameSpace = pArguments->GetUTF8String(0);
- wsNameSpace = WideString::FromUTF8(bsNameSpace.AsStringView());
- }
- WideString wsNodeNameSpace;
- TryNamespace(wsNodeNameSpace);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(wsNodeNameSpace == wsNameSpace);
+ m_JSNode.Script_ModelClass_IsCompatibleNS(pArguments);
}
void CXFA_Node::Script_ModelClass_Context(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_ModelClass_Context(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_ModelClass_AliasNode(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- SetInteger(eAttribute, pValue->ToInteger(), true);
- } else {
- pValue->SetInteger(GetInteger(eAttribute));
- }
+ m_JSNode.Script_Attribute_Integer(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- pValue->SetInteger(GetInteger(eAttribute));
+ m_JSNode.Script_Attribute_IntegerRead(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- SetBoolean(eAttribute, pValue->ToBoolean(), true);
- } else {
- pValue->SetString(GetBoolean(eAttribute) ? "1" : "0");
- }
+ m_JSNode.Script_Attribute_BOOL(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- pValue->SetString(GetBoolean(eAttribute) ? "1" : "0");
+ m_JSNode.Script_Attribute_BOOLRead(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Attribute_SendAttributeChangeMessage(
XFA_ATTRIBUTE eAttribute,
bool bScriptModify) {
- CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
- if (!pLayoutPro)
- return;
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- uint32_t dwPacket = GetPacketID();
- if (!(dwPacket & XFA_XDPPACKET_Form)) {
- pNotify->OnValueChanged(this, eAttribute, this, this);
- return;
- }
-
- bool bNeedFindContainer = false;
- switch (GetElementType()) {
- case XFA_Element::Caption:
- bNeedFindContainer = true;
- pNotify->OnValueChanged(this, eAttribute, this,
- GetNodeItem(XFA_NODEITEM_Parent));
- break;
- case XFA_Element::Font:
- case XFA_Element::Para: {
- bNeedFindContainer = true;
- CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent);
- if (pParentNode->GetElementType() == XFA_Element::Caption) {
- pNotify->OnValueChanged(this, eAttribute, pParentNode,
- pParentNode->GetNodeItem(XFA_NODEITEM_Parent));
- } else {
- pNotify->OnValueChanged(this, eAttribute, this, pParentNode);
- }
- } break;
- case XFA_Element::Margin: {
- bNeedFindContainer = true;
- CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent);
- XFA_Element eParentType = pParentNode->GetElementType();
- if (pParentNode->IsContainerNode()) {
- pNotify->OnValueChanged(this, eAttribute, this, pParentNode);
- } else if (eParentType == XFA_Element::Caption) {
- pNotify->OnValueChanged(this, eAttribute, pParentNode,
- pParentNode->GetNodeItem(XFA_NODEITEM_Parent));
- } else {
- CXFA_Node* pNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (pNode && pNode->GetElementType() == XFA_Element::Ui) {
- pNotify->OnValueChanged(this, eAttribute, pNode,
- pNode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- }
- } break;
- case XFA_Element::Comb: {
- CXFA_Node* pEditNode = GetNodeItem(XFA_NODEITEM_Parent);
- XFA_Element eUIType = pEditNode->GetElementType();
- if (pEditNode && (eUIType == XFA_Element::DateTimeEdit ||
- eUIType == XFA_Element::NumericEdit ||
- eUIType == XFA_Element::TextEdit)) {
- CXFA_Node* pUINode = pEditNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (pUINode) {
- pNotify->OnValueChanged(this, eAttribute, pUINode,
- pUINode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- }
- } break;
- case XFA_Element::Button:
- case XFA_Element::Barcode:
- case XFA_Element::ChoiceList:
- case XFA_Element::DateTimeEdit:
- case XFA_Element::NumericEdit:
- case XFA_Element::PasswordEdit:
- case XFA_Element::TextEdit: {
- CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent);
- if (pUINode) {
- pNotify->OnValueChanged(this, eAttribute, pUINode,
- pUINode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- } break;
- case XFA_Element::CheckButton: {
- bNeedFindContainer = true;
- CXFA_Node* pUINode = GetNodeItem(XFA_NODEITEM_Parent);
- if (pUINode) {
- pNotify->OnValueChanged(this, eAttribute, pUINode,
- pUINode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- } break;
- case XFA_Element::Keep:
- case XFA_Element::Bookend:
- case XFA_Element::Break:
- case XFA_Element::BreakAfter:
- case XFA_Element::BreakBefore:
- case XFA_Element::Overflow:
- bNeedFindContainer = true;
- break;
- case XFA_Element::Area:
- case XFA_Element::Draw:
- case XFA_Element::ExclGroup:
- case XFA_Element::Field:
- case XFA_Element::Subform:
- case XFA_Element::SubformSet:
- pLayoutPro->AddChangedContainer(this);
- pNotify->OnValueChanged(this, eAttribute, this, this);
- break;
- case XFA_Element::Sharptext:
- case XFA_Element::Sharpxml:
- case XFA_Element::SharpxHTML: {
- CXFA_Node* pTextNode = GetNodeItem(XFA_NODEITEM_Parent);
- if (!pTextNode) {
- return;
- }
- CXFA_Node* pValueNode = pTextNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (!pValueNode) {
- return;
- }
- XFA_Element eType = pValueNode->GetElementType();
- if (eType == XFA_Element::Value) {
- bNeedFindContainer = true;
- CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (pNode && pNode->IsContainerNode()) {
- if (bScriptModify) {
- pValueNode = pNode;
- }
- pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode);
- } else {
- pNotify->OnValueChanged(this, eAttribute, pNode,
- pNode->GetNodeItem(XFA_NODEITEM_Parent));
- }
- } else {
- if (eType == XFA_Element::Items) {
- CXFA_Node* pNode = pValueNode->GetNodeItem(XFA_NODEITEM_Parent);
- if (pNode && pNode->IsContainerNode()) {
- pNotify->OnValueChanged(this, eAttribute, pValueNode, pNode);
- }
- }
- }
- } break;
- default:
- break;
- }
- if (bNeedFindContainer) {
- CXFA_Node* pParent = this;
- while (pParent) {
- if (pParent->IsContainerNode())
- break;
-
- pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
- }
- if (pParent) {
- pLayoutPro->AddChangedContainer(pParent);
- }
- }
+ m_JSNode.Script_Attribute_SendAttributeChangeMessage(eAttribute,
+ bScriptModify);
}
void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- WideString wsValue = pValue->ToWideString();
- SetAttribute(eAttribute, wsValue.AsStringView(), true);
- if (eAttribute == XFA_ATTRIBUTE_Use &&
- GetElementType() == XFA_Element::Desc) {
- CXFA_Node* pTemplateNode =
- ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template));
- CXFA_Node* pProtoRoot =
- pTemplateNode->GetFirstChildByClass(XFA_Element::Subform)
- ->GetFirstChildByClass(XFA_Element::Proto);
-
- WideString wsID;
- WideString wsSOM;
- if (!wsValue.IsEmpty()) {
- if (wsValue[0] == '#') {
- wsID = WideString(wsValue.c_str() + 1, wsValue.GetLength() - 1);
- } else {
- wsSOM = wsValue;
- }
- }
- CXFA_Node* pProtoNode = nullptr;
- if (!wsSOM.IsEmpty()) {
- uint32_t dwFlag = XFA_RESOLVENODE_Children |
- XFA_RESOLVENODE_Attributes |
- XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
- XFA_RESOLVENODE_Siblings;
- XFA_RESOLVENODE_RS resoveNodeRS;
- int32_t iRet = m_pDocument->GetScriptContext()->ResolveObjects(
- pProtoRoot, wsSOM.AsStringView(), resoveNodeRS, dwFlag);
- if (iRet > 0 && resoveNodeRS.objects.front()->IsNode()) {
- pProtoNode = resoveNodeRS.objects.front()->AsNode();
- }
- } else if (!wsID.IsEmpty()) {
- pProtoNode = m_pDocument->GetNodeByID(pProtoRoot, wsID.AsStringView());
- }
- if (pProtoNode) {
- CXFA_Node* pHeadChild = GetNodeItem(XFA_NODEITEM_FirstChild);
- while (pHeadChild) {
- CXFA_Node* pSibling =
- pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling);
- RemoveChild(pHeadChild);
- pHeadChild = pSibling;
- }
- CXFA_Node* pProtoForm = pProtoNode->CloneTemplateToForm(true);
- pHeadChild = pProtoForm->GetNodeItem(XFA_NODEITEM_FirstChild);
- while (pHeadChild) {
- CXFA_Node* pSibling =
- pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling);
- pProtoForm->RemoveChild(pHeadChild);
- InsertChild(pHeadChild);
- pHeadChild = pSibling;
- }
- m_pDocument->RemovePurgeNode(pProtoForm);
- delete pProtoForm;
- }
- }
- } else {
- WideString wsValue;
- GetAttribute(eAttribute, wsValue);
- pValue->SetString(wsValue.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Attribute_String(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
-
- WideString wsValue;
- GetAttribute(eAttribute, wsValue);
- pValue->SetString(wsValue.UTF8Encode().AsStringView());
+ m_JSNode.Script_Attribute_StringRead(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"execute");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(false);
+ m_JSNode.Script_WsdlConnection_Execute(pArguments);
}
void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"restore");
+ m_JSNode.Script_Delta_Restore(pArguments);
}
void CXFA_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_Delta_CurrentValue(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_Delta_SavedValue(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_Delta_SavedValue(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_Delta_Target(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_Delta_Target(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue,
bool bSetting,
XFA_SOM_MESSAGETYPE iMessageType) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- bool bNew = false;
- CXFA_Validate validate = pWidgetData->GetValidate(false);
- if (!validate) {
- validate = pWidgetData->GetValidate(true);
- bNew = true;
- }
- if (bSetting) {
- switch (iMessageType) {
- case XFA_SOM_ValidationMessage:
- validate.SetScriptMessageText(pValue->ToWideString());
- break;
- case XFA_SOM_FormatMessage:
- validate.SetFormatMessageText(pValue->ToWideString());
- break;
- case XFA_SOM_MandatoryMessage:
- validate.SetNullMessageText(pValue->ToWideString());
- break;
- default:
- break;
- }
- if (!bNew) {
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->AddCalcValidate(this);
- }
- } else {
- WideString wsMessage;
- switch (iMessageType) {
- case XFA_SOM_ValidationMessage:
- validate.GetScriptMessageText(wsMessage);
- break;
- case XFA_SOM_FormatMessage:
- validate.GetFormatMessageText(wsMessage);
- break;
- case XFA_SOM_MandatoryMessage:
- validate.GetNullMessageText(wsMessage);
- break;
- default:
- break;
- }
- pValue->SetString(wsMessage.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Som_Message(pValue, bSetting, iMessageType);
}
void CXFA_Node::Script_Som_ValidationMessage(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_Som_Message(pValue, bSetting, XFA_SOM_ValidationMessage);
+ m_JSNode.Script_Som_ValidationMessage(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
-
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pValue->SetInteger(0);
- return;
- }
- pValue->SetInteger(pWidgetData->CountChoiceListItems(true));
+ m_JSNode.Script_Field_Length(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- XFA_Element eType = GetElementType();
- if (eType == XFA_Element::Field) {
- Script_Field_DefaultValue(pValue, bSetting, eAttribute);
- return;
- }
- if (eType == XFA_Element::Draw) {
- Script_Draw_DefaultValue(pValue, bSetting, eAttribute);
- return;
- }
- if (eType == XFA_Element::Boolean) {
- Script_Boolean_Value(pValue, bSetting, eAttribute);
- return;
- }
- if (bSetting) {
- WideString wsNewValue;
- if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
- wsNewValue = pValue->ToWideString();
-
- WideString wsFormatValue(wsNewValue);
- CXFA_WidgetData* pContainerWidgetData = nullptr;
- if (GetPacketID() == XFA_XDPPACKET_Datasets) {
- WideString wsPicture;
- for (CXFA_Node* pFormNode : GetBindItems()) {
- if (!pFormNode || pFormNode->HasRemovedChildren())
- continue;
- pContainerWidgetData = pFormNode->GetContainerWidgetData();
- if (pContainerWidgetData) {
- pContainerWidgetData->GetPictureContent(wsPicture,
- XFA_VALUEPICTURE_DataBind);
- }
- if (!wsPicture.IsEmpty())
- break;
- pContainerWidgetData = nullptr;
- }
- } else if (GetPacketID() == XFA_XDPPACKET_Form) {
- pContainerWidgetData = GetContainerWidgetData();
- }
- if (pContainerWidgetData) {
- pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue);
- }
- SetScriptContent(wsNewValue, wsFormatValue, true, true);
- } else {
- WideString content = GetScriptContent(true);
- if (content.IsEmpty() && eType != XFA_Element::Text &&
- eType != XFA_Element::SubmitUrl) {
- pValue->SetNull();
- } else if (eType == XFA_Element::Integer) {
- pValue->SetInteger(FXSYS_wtoi(content.c_str()));
- } else if (eType == XFA_Element::Float || eType == XFA_Element::Decimal) {
- CFX_Decimal decimal(content.AsStringView());
- pValue->SetFloat((float)(double)decimal);
- } else {
- pValue->SetString(content.UTF8Encode().AsStringView());
- }
- }
+ m_JSNode.Script_Som_DefaultValue(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
-
- WideString content = GetScriptContent(true);
- if (content.IsEmpty()) {
- pValue->SetNull();
- return;
- }
- pValue->SetString(content.UTF8Encode().AsStringView());
+ m_JSNode.Script_Som_DefaultValue_Read(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ByteString newValue;
- if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
- newValue = pValue->ToString();
-
- int32_t iValue = FXSYS_atoi(newValue.c_str());
- WideString wsNewValue(iValue == 0 ? L"0" : L"1");
- WideString wsFormatValue(wsNewValue);
- CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData();
- if (pContainerWidgetData) {
- pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue);
- }
- SetScriptContent(wsNewValue, wsFormatValue, true, true);
- } else {
- WideString wsValue = GetScriptContent(true);
- pValue->SetBoolean(wsValue == L"1");
- }
+ m_JSNode.Script_Boolean_Value(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- CXFA_Border border = pWidgetData->GetBorder(true);
- int32_t iSize = border.CountEdges();
- if (bSetting) {
- int32_t r = 0;
- int32_t g = 0;
- int32_t b = 0;
- StrToRGB(pValue->ToWideString(), r, g, b);
- FX_ARGB rgb = ArgbEncode(100, r, g, b);
- for (int32_t i = 0; i < iSize; ++i) {
- CXFA_Edge edge = border.GetEdge(i);
- edge.SetColor(rgb);
- }
- } else {
- CXFA_Edge edge = border.GetEdge(0);
- FX_ARGB color = edge.GetColor();
- int32_t a;
- int32_t r;
- int32_t g;
- int32_t b;
- std::tie(a, r, g, b) = ArgbDecode(color);
- WideString strColor;
- strColor.Format(L"%d,%d,%d", r, g, b);
- pValue->SetString(strColor.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Som_BorderColor(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- CXFA_Border border = pWidgetData->GetBorder(true);
- int32_t iSize = border.CountEdges();
- WideString wsThickness;
- if (bSetting) {
- wsThickness = pValue->ToWideString();
- for (int32_t i = 0; i < iSize; ++i) {
- CXFA_Edge edge = border.GetEdge(i);
- CXFA_Measurement thickness(wsThickness.AsStringView());
- edge.SetMSThickness(thickness);
- }
- } else {
- CXFA_Edge edge = border.GetEdge(0);
- CXFA_Measurement thickness = edge.GetMSThickness();
- thickness.ToString(&wsThickness);
- pValue->SetString(wsThickness.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Som_BorderWidth(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- CXFA_Border border = pWidgetData->GetBorder(true);
- CXFA_Fill borderfill = border.GetFill(true);
- CXFA_Node* pNode = borderfill.GetNode();
- if (!pNode) {
- return;
- }
- if (bSetting) {
- int32_t r;
- int32_t g;
- int32_t b;
- StrToRGB(pValue->ToWideString(), r, g, b);
- FX_ARGB color = ArgbEncode(0xff, r, g, b);
- borderfill.SetColor(color);
- } else {
- FX_ARGB color = borderfill.GetColor();
- int32_t a;
- int32_t r;
- int32_t g;
- int32_t b;
- std::tie(a, r, g, b) = ArgbDecode(color);
- WideString wsColor;
- wsColor.Format(L"%d,%d,%d", r, g, b);
- pValue->SetString(wsColor.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Som_FillColor(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
-
- CXFA_Node* pDataNode = GetBindData();
- if (!pDataNode) {
- pValue->SetNull();
- return;
- }
-
- pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode));
+ m_JSNode.Script_Som_DataNode(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- if (pValue && pValue->IsString()) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- ASSERT(pWidgetData);
- XFA_Element uiType = pWidgetData->GetUIType();
- if (uiType == XFA_Element::Text) {
- WideString wsNewValue = pValue->ToWideString();
- WideString wsFormatValue(wsNewValue);
- SetScriptContent(wsNewValue, wsFormatValue, true, true);
- }
- }
- } else {
- WideString content = GetScriptContent(true);
- if (content.IsEmpty())
- pValue->SetNull();
- else
- pValue->SetString(content.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Draw_DefaultValue(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- if (bSetting) {
- if (pValue && pValue->IsNull()) {
- pWidgetData->m_bPreNull = pWidgetData->m_bIsNull;
- pWidgetData->m_bIsNull = true;
- } else {
- pWidgetData->m_bPreNull = pWidgetData->m_bIsNull;
- pWidgetData->m_bIsNull = false;
- }
- WideString wsNewText;
- if (!(pValue && (pValue->IsNull() || pValue->IsUndefined())))
- wsNewText = pValue->ToWideString();
-
- CXFA_Node* pUIChild = pWidgetData->GetUIChild();
- if (pUIChild->GetElementType() == XFA_Element::NumericEdit) {
- int32_t iLeadDigits = 0;
- int32_t iFracDigits = 0;
- pWidgetData->GetLeadDigits(iLeadDigits);
- pWidgetData->GetFracDigits(iFracDigits);
- wsNewText =
- pWidgetData->NumericLimit(wsNewText, iLeadDigits, iFracDigits);
- }
- CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData();
- WideString wsFormatText(wsNewText);
- if (pContainerWidgetData) {
- pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText);
- }
- SetScriptContent(wsNewText, wsFormatText, true, true);
- } else {
- WideString content = GetScriptContent(true);
- if (content.IsEmpty()) {
- pValue->SetNull();
- } else {
- CXFA_Node* pUIChild = pWidgetData->GetUIChild();
- CXFA_Value defVal = pWidgetData->GetFormValue();
- CXFA_Node* pNode = defVal.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (pNode && pNode->GetElementType() == XFA_Element::Decimal) {
- if (pUIChild->GetElementType() == XFA_Element::NumericEdit &&
- (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) {
- pValue->SetString(content.UTF8Encode().AsStringView());
- } else {
- CFX_Decimal decimal(content.AsStringView());
- pValue->SetFloat((float)(double)decimal);
- }
- } else if (pNode && pNode->GetElementType() == XFA_Element::Integer) {
- pValue->SetInteger(FXSYS_wtoi(content.c_str()));
- } else if (pNode && pNode->GetElementType() == XFA_Element::Boolean) {
- pValue->SetBoolean(FXSYS_wtoi(content.c_str()) == 0 ? false : true);
- } else if (pNode && pNode->GetElementType() == XFA_Element::Float) {
- CFX_Decimal decimal(content.AsStringView());
- pValue->SetFloat((float)(double)decimal);
- } else {
- pValue->SetString(content.UTF8Encode().AsStringView());
- }
- }
- }
+ m_JSNode.Script_Field_DefaultValue(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- if (bSetting) {
- pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Edit);
- } else {
- WideString wsValue;
- pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit);
- pValue->SetString(wsValue.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Field_EditValue(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- CXFA_Font font = pWidgetData->GetFont(true);
- CXFA_Node* pNode = font.GetNode();
- if (!pNode) {
- return;
- }
- if (bSetting) {
- int32_t r;
- int32_t g;
- int32_t b;
- StrToRGB(pValue->ToWideString(), r, g, b);
- FX_ARGB color = ArgbEncode(0xff, r, g, b);
- font.SetColor(color);
- } else {
- FX_ARGB color = font.GetColor();
- int32_t a;
- int32_t r;
- int32_t g;
- int32_t b;
- std::tie(a, r, g, b) = ArgbDecode(color);
- WideString wsColor;
- wsColor.Format(L"%d,%d,%d", r, g, b);
- pValue->SetString(wsColor.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Som_FontColor(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_Som_Message(pValue, bSetting, XFA_SOM_FormatMessage);
+ m_JSNode.Script_Field_FormatMessage(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- if (bSetting) {
- pWidgetData->SetValue(pValue->ToWideString(), XFA_VALUEPICTURE_Display);
- } else {
- WideString wsValue;
- pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display);
- pValue->SetString(wsValue.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Field_FormattedValue(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- CXFA_Validate validate = pWidgetData->GetValidate(true);
- if (bSetting) {
- validate.SetNullTest(pValue->ToWideString());
- } else {
- int32_t iValue = validate.GetNullTest();
- const XFA_ATTRIBUTEENUMINFO* pInfo =
- GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue);
- WideString wsValue;
- if (pInfo)
- wsValue = pInfo->pName;
- pValue->SetString(wsValue.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Som_Mandatory(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Som_MandatoryMessage(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- Script_Som_Message(pValue, bSetting, XFA_SOM_MandatoryMessage);
+ m_JSNode.Script_Som_MandatoryMessage(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- pValue->SetNull();
+ m_JSNode.Script_Field_ParentSubform(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- if (bSetting) {
- int32_t iIndex = pValue->ToInteger();
- if (iIndex == -1) {
- pWidgetData->ClearAllSelections();
- return;
- }
- pWidgetData->SetItemState(iIndex, true, true, true, true);
- } else {
- pValue->SetInteger(pWidgetData->GetSelectedItem(0));
- }
+ m_JSNode.Script_Field_SelectedIndex(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- pWidgetData->DeleteItem(-1, true, false);
+ m_JSNode.Script_Field_ClearItems(pArguments);
}
void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
-
- ByteString eventString = pArguments->GetUTF8String(0);
- int32_t iRet = execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::Field);
- if (eventString != "validate")
- return;
-
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ m_JSNode.Script_Field_ExecEvent(pArguments);
}
void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize, false, false);
+ m_JSNode.Script_Field_ExecInitialize(pArguments);
}
void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"deleteItem");
- return;
- }
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- int32_t iIndex = pArguments->GetInt32(0);
- bool bValue = pWidgetData->DeleteItem(iIndex, true, true);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(bValue);
+ m_JSNode.Script_Field_DeleteItem(pArguments);
}
void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getSaveItem");
- return;
- }
- int32_t iIndex = pArguments->GetInt32(0);
- if (iIndex < 0) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- WideString wsValue;
- if (!pWidgetData->GetChoiceListItem(wsValue, iIndex, true)) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- pArguments->GetReturnValue()->SetString(wsValue.UTF8Encode().AsStringView());
+ m_JSNode.Script_Field_GetSaveItem(pArguments);
}
void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"boundItem");
- return;
- }
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- ByteString bsValue = pArguments->GetUTF8String(0);
- WideString wsValue = WideString::FromUTF8(bsValue.AsStringView());
- WideString wsBoundValue;
- pWidgetData->GetItemValue(wsValue.AsStringView(), wsBoundValue);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetString(wsBoundValue.UTF8Encode().AsStringView());
+ m_JSNode.Script_Field_BoundItem(pArguments);
}
void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getItemState");
- return;
- }
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- int32_t iIndex = pArguments->GetInt32(0);
- bool bValue = pWidgetData->GetItemState(iIndex);
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(bValue);
+ m_JSNode.Script_Field_GetItemState(pArguments);
}
void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, false, false);
+ m_JSNode.Script_Field_ExecCalculate(pArguments);
}
-void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {}
+void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {
+ m_JSNode.Script_Field_SetItems(pArguments);
+}
void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 1) {
- ThrowParamCountMismatchException(L"getDisplayItem");
- return;
- }
- int32_t iIndex = pArguments->GetInt32(0);
- if (iIndex < 0) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- WideString wsValue;
- if (!pWidgetData->GetChoiceListItem(wsValue, iIndex, false)) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- pArguments->GetReturnValue()->SetString(wsValue.UTF8Encode().AsStringView());
+ m_JSNode.Script_Field_GetDisplayItem(pArguments);
}
void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength != 2) {
- ThrowParamCountMismatchException(L"setItemState");
- return;
- }
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData)
- return;
-
- int32_t iIndex = pArguments->GetInt32(0);
- if (pArguments->GetInt32(1) != 0) {
- pWidgetData->SetItemState(iIndex, true, true, true, true);
- } else {
- if (pWidgetData->GetItemState(iIndex))
- pWidgetData->SetItemState(iIndex, false, true, true, true);
- }
+ m_JSNode.Script_Field_SetItemState(pArguments);
}
void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) {
- int32_t iLength = pArguments->GetLength();
- if (iLength < 1 || iLength > 2) {
- ThrowParamCountMismatchException(L"addItem");
- return;
- }
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- WideString wsLabel;
- WideString wsValue;
- if (iLength >= 1) {
- ByteString bsLabel = pArguments->GetUTF8String(0);
- wsLabel = WideString::FromUTF8(bsLabel.AsStringView());
- }
- if (iLength >= 2) {
- ByteString bsValue = pArguments->GetUTF8String(1);
- wsValue = WideString::FromUTF8(bsValue.AsStringView());
- }
- pWidgetData->InsertItem(wsLabel, wsValue, true);
+ m_JSNode.Script_Field_AddItem(pArguments);
}
void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
-
- int32_t iRet =
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, false, false);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ m_JSNode.Script_Field_ExecValidate(pArguments);
}
void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting)
- ThrowInvalidPropertyException();
+ m_JSNode.Script_ExclGroup_ErrorText(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- return;
- }
- if (bSetting) {
- pWidgetData->SetSelectedMemberByValue(pValue->ToWideString().AsStringView(),
- true, true, true);
- } else {
- WideString wsValue = GetScriptContent(true);
- XFA_VERSION curVersion = GetDocument()->GetCurVersionMode();
- if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) {
- pValue->SetNull();
- } else {
- pValue->SetString(wsValue.UTF8Encode().AsStringView());
- }
- }
+ m_JSNode.Script_ExclGroup_DefaultAndRawValue(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_ExclGroup_Transient(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
-
- ByteString eventString = pArguments->GetUTF8String(0);
- execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::ExclGroup);
+ m_JSNode.Script_ExclGroup_ExecEvent(pArguments);
}
void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc < 0 || argc > 1) {
- ThrowParamCountMismatchException(L"selectedMember");
- return;
- }
-
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
-
- CXFA_Node* pReturnNode = nullptr;
- if (argc == 0) {
- pReturnNode = pWidgetData->GetSelectedMember();
- } else {
- ByteString szName;
- szName = pArguments->GetUTF8String(0);
- pReturnNode = pWidgetData->SetSelectedMember(
- WideString::FromUTF8(szName.AsStringView()).AsStringView(), true);
- }
- if (!pReturnNode) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode));
+ m_JSNode.Script_ExclGroup_SelectedMember(pArguments);
}
void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
+ m_JSNode.Script_ExclGroup_ExecInitialize(pArguments);
}
void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
+ m_JSNode.Script_ExclGroup_ExecCalculate(pArguments);
}
void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
-
- int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ m_JSNode.Script_ExclGroup_ExecValidate(pArguments);
}
void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- int32_t iTo = pValue->ToInteger();
- int32_t iFrom = Subform_and_SubformSet_InstanceIndex();
- CXFA_Node* pManagerNode = nullptr;
- for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
- pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
- if (pNode->GetElementType() == XFA_Element::InstanceManager) {
- pManagerNode = pNode;
- break;
- }
- }
- if (pManagerNode) {
- pManagerNode->InstanceManager_MoveInstance(iTo, iFrom);
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- CXFA_Node* pToInstance = GetItem(pManagerNode, iTo);
- if (pToInstance &&
- pToInstance->GetElementType() == XFA_Element::Subform) {
- pNotify->RunSubformIndexChange(pToInstance);
- }
- CXFA_Node* pFromInstance = GetItem(pManagerNode, iFrom);
- if (pFromInstance &&
- pFromInstance->GetElementType() == XFA_Element::Subform) {
- pNotify->RunSubformIndexChange(pFromInstance);
- }
- }
- } else {
- pValue->SetInteger(Subform_and_SubformSet_InstanceIndex());
- }
+ m_JSNode.Script_Som_InstanceIndex(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
-
- WideStringView wsName = GetCData(XFA_ATTRIBUTE_Name);
- CXFA_Node* pInstanceMgr = nullptr;
- for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
- pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
- if (pNode->GetElementType() == XFA_Element::InstanceManager) {
- WideStringView wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name);
- if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName[0] == '_' &&
- wsInstMgrName.Right(wsInstMgrName.GetLength() - 1) == wsName) {
- pInstanceMgr = pNode;
- }
- break;
- }
- }
- if (!pInstanceMgr) {
- pValue->SetNull();
- return;
- }
-
- pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr));
+ m_JSNode.Script_Subform_InstanceManager(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- SetCData(XFA_ATTRIBUTE_Locale, pValue->ToWideString(), true, true);
- } else {
- WideString wsLocaleName;
- GetLocaleName(wsLocaleName);
- pValue->SetString(wsLocaleName.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Subform_Locale(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"execEvent");
- return;
- }
-
- ByteString eventString = pArguments->GetUTF8String(0);
- execSingleEventByName(
- WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
- XFA_Element::Subform);
+ m_JSNode.Script_Subform_ExecEvent(pArguments);
}
void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
+ m_JSNode.Script_Subform_ExecInitialize(pArguments);
}
void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
+ m_JSNode.Script_Subform_ExecInitialize(pArguments);
}
void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
-
- int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ m_JSNode.Script_Subform_ExecValidate(pArguments);
}
void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"getInvalidObjects");
-}
-
-int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() {
- int32_t index = 0;
- for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode;
- pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) {
- if ((pNode->GetElementType() == XFA_Element::Subform) ||
- (pNode->GetElementType() == XFA_Element::SubformSet)) {
- index++;
- } else {
- break;
- }
- }
- return index;
+ m_JSNode.Script_Subform_GetInvalidObjects(pArguments);
}
void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"formNodes");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ m_JSNode.Script_Template_FormNodes(pArguments);
}
void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"remerge");
- return;
- }
- m_pDocument->DoDataRemerge(true);
+ m_JSNode.Script_Template_Remerge(pArguments);
}
void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
-
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ m_JSNode.Script_Template_ExecInitialize(pArguments);
}
void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc <= 0 || argc >= 4) {
- ThrowParamCountMismatchException(L"createNode");
- return;
- }
-
- WideString strName;
- WideString strNameSpace;
- ByteString bsTagName = pArguments->GetUTF8String(0);
- WideString strTagName = WideString::FromUTF8(bsTagName.AsStringView());
- if (argc > 1) {
- ByteString bsName = pArguments->GetUTF8String(1);
- strName = WideString::FromUTF8(bsName.AsStringView());
- if (argc == 3) {
- ByteString bsNameSpace = pArguments->GetUTF8String(2);
- strNameSpace = WideString::FromUTF8(bsNameSpace.AsStringView());
- }
- }
-
- XFA_Element eType = XFA_GetElementTypeForName(strTagName.AsStringView());
- CXFA_Node* pNewNode = CreateSamePacketNode(eType);
- if (!pNewNode) {
- pArguments->GetReturnValue()->SetNull();
- return;
- }
-
- if (strName.IsEmpty()) {
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode));
- return;
- }
-
- if (!GetAttributeOfElement(eType, XFA_ATTRIBUTE_Name,
- XFA_XDPPACKET_UNKNOWN)) {
- ThrowMissingPropertyException(strTagName, L"name");
- return;
- }
-
- pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName.AsStringView(), true);
- if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets)
- pNewNode->CreateXMLMappingNode();
-
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode));
+ m_JSNode.Script_Template_CreateNode(pArguments);
}
void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"recalculate");
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ m_JSNode.Script_Template_Recalculate(pArguments);
}
void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
-
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ m_JSNode.Script_Template_ExecCalculate(pArguments);
}
void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ m_JSNode.Script_Template_ExecValidate(pArguments);
}
void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"evaluate");
- return;
- }
-
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (!pWidgetData) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
- pArguments->GetReturnValue()->SetBoolean(true);
+ m_JSNode.Script_Manifest_Evaluate(pArguments);
}
void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- CXFA_Occur nodeOccur(GetOccurNode());
- pValue->SetInteger(nodeOccur.GetMax());
+ m_JSNode.Script_InstanceManager_Max(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- CXFA_Occur nodeOccur(GetOccurNode());
- pValue->SetInteger(nodeOccur.GetMin());
+ m_JSNode.Script_InstanceManager_Min(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- int32_t iDesired = pValue->ToInteger();
- InstanceManager_SetInstances(iDesired);
- } else {
- pValue->SetInteger(GetCount(this));
- }
+ m_JSNode.Script_InstanceManager_Count(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_InstanceManager_MoveInstance(
CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
- int32_t iFrom = pArguments->GetInt32(0);
- int32_t iTo = pArguments->GetInt32(1);
- InstanceManager_MoveInstance(iTo, iFrom);
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- CXFA_Node* pToInstance = GetItem(this, iTo);
- if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) {
- pNotify->RunSubformIndexChange(pToInstance);
- }
- CXFA_Node* pFromInstance = GetItem(this, iFrom);
- if (pFromInstance &&
- pFromInstance->GetElementType() == XFA_Element::Subform) {
- pNotify->RunSubformIndexChange(pFromInstance);
- }
+ m_JSNode.Script_InstanceManager_MoveInstance(pArguments);
}
void CXFA_Node::Script_InstanceManager_RemoveInstance(
CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
- int32_t iIndex = pArguments->GetInt32(0);
- int32_t iCount = GetCount(this);
- if (iIndex < 0 || iIndex >= iCount) {
- ThrowIndexOutOfBoundsException();
- return;
- }
- CXFA_Occur nodeOccur(GetOccurNode());
- int32_t iMin = nodeOccur.GetMin();
- if (iCount - 1 < iMin) {
- ThrowTooManyOccurancesException(L"min");
- return;
- }
- CXFA_Node* pRemoveInstance = GetItem(this, iIndex);
- RemoveItem(this, pRemoveInstance);
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (pNotify) {
- for (int32_t i = iIndex; i < iCount - 1; i++) {
- CXFA_Node* pSubformInstance = GetItem(this, i);
- if (pSubformInstance &&
- pSubformInstance->GetElementType() == XFA_Element::Subform) {
- pNotify->RunSubformIndexChange(pSubformInstance);
- }
- }
- }
- CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
- if (!pLayoutPro) {
- return;
- }
- pLayoutPro->AddChangedContainer(
- ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
+ m_JSNode.Script_InstanceManager_RemoveInstance(pArguments);
}
void CXFA_Node::Script_InstanceManager_SetInstances(
CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- pArguments->GetReturnValue()->SetUndefined();
- return;
- }
- int32_t iDesired = pArguments->GetInt32(0);
- InstanceManager_SetInstances(iDesired);
+ m_JSNode.Script_InstanceManager_SetInstances(pArguments);
}
void CXFA_Node::Script_InstanceManager_AddInstance(
CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"addInstance");
- return;
- }
- bool fFlags = true;
- if (argc == 1) {
- fFlags = pArguments->GetInt32(0) == 0 ? false : true;
- }
- int32_t iCount = GetCount(this);
- CXFA_Occur nodeOccur(GetOccurNode());
- int32_t iMax = nodeOccur.GetMax();
- if (iMax >= 0 && iCount >= iMax) {
- ThrowTooManyOccurancesException(L"max");
- return;
- }
- CXFA_Node* pNewInstance = CreateInstance(this, fFlags);
- InsertItem(this, pNewInstance, iCount, iCount, false);
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance));
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->RunNodeInitialize(pNewInstance);
- CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
- if (!pLayoutPro) {
- return;
- }
- pLayoutPro->AddChangedContainer(
- ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
+ m_JSNode.Script_InstanceManager_AddInstance(pArguments);
}
void CXFA_Node::Script_InstanceManager_InsertInstance(
CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 1 && argc != 2) {
- ThrowParamCountMismatchException(L"insertInstance");
- return;
- }
- int32_t iIndex = pArguments->GetInt32(0);
- bool bBind = false;
- if (argc == 2) {
- bBind = pArguments->GetInt32(1) == 0 ? false : true;
- }
- CXFA_Occur nodeOccur(GetOccurNode());
- int32_t iCount = GetCount(this);
- if (iIndex < 0 || iIndex > iCount) {
- ThrowIndexOutOfBoundsException();
- return;
- }
- int32_t iMax = nodeOccur.GetMax();
- if (iMax >= 0 && iCount >= iMax) {
- ThrowTooManyOccurancesException(L"max");
- return;
- }
- CXFA_Node* pNewInstance = CreateInstance(this, bBind);
- InsertItem(this, pNewInstance, iIndex, iCount, true);
- pArguments->GetReturnValue()->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance));
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return;
- }
- pNotify->RunNodeInitialize(pNewInstance);
- CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
- if (!pLayoutPro) {
- return;
- }
- pLayoutPro->AddChangedContainer(
- ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
-}
-
-int32_t CXFA_Node::InstanceManager_SetInstances(int32_t iDesired) {
- CXFA_Occur nodeOccur(GetOccurNode());
- int32_t iMax = nodeOccur.GetMax();
- int32_t iMin = nodeOccur.GetMin();
- if (iDesired < iMin) {
- ThrowTooManyOccurancesException(L"min");
- return 1;
- }
- if ((iMax >= 0) && (iDesired > iMax)) {
- ThrowTooManyOccurancesException(L"max");
- return 2;
- }
- int32_t iCount = GetCount(this);
- if (iDesired == iCount) {
- return 0;
- }
- if (iDesired < iCount) {
- WideStringView wsInstManagerName = GetCData(XFA_ATTRIBUTE_Name);
- WideString wsInstanceName = WideString(
- wsInstManagerName.IsEmpty()
- ? wsInstManagerName
- : wsInstManagerName.Right(wsInstManagerName.GetLength() - 1));
- uint32_t dInstanceNameHash =
- FX_HashCode_GetW(wsInstanceName.AsStringView(), false);
- CXFA_Node* pPrevSibling =
- (iDesired == 0) ? this : GetItem(this, iDesired - 1);
- while (iCount > iDesired) {
- CXFA_Node* pRemoveInstance =
- pPrevSibling->GetNodeItem(XFA_NODEITEM_NextSibling);
- if (pRemoveInstance->GetElementType() != XFA_Element::Subform &&
- pRemoveInstance->GetElementType() != XFA_Element::SubformSet) {
- continue;
- }
- if (pRemoveInstance->GetElementType() == XFA_Element::InstanceManager) {
- NOTREACHED();
- break;
- }
- if (pRemoveInstance->GetNameHash() == dInstanceNameHash) {
- RemoveItem(this, pRemoveInstance);
- iCount--;
- }
- }
- } else if (iDesired > iCount) {
- while (iCount < iDesired) {
- CXFA_Node* pNewInstance = CreateInstance(this, true);
- InsertItem(this, pNewInstance, iCount, iCount, false);
- iCount++;
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return 0;
- }
- pNotify->RunNodeInitialize(pNewInstance);
- }
- }
- CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
- if (pLayoutPro) {
- pLayoutPro->AddChangedContainer(
- ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
- }
- return 0;
-}
-
-int32_t CXFA_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) {
- int32_t iCount = GetCount(this);
- if (iFrom > iCount || iTo > iCount - 1) {
- ThrowIndexOutOfBoundsException();
- return 1;
- }
- if (iFrom < 0 || iTo < 0 || iFrom == iTo) {
- return 0;
- }
- CXFA_Node* pMoveInstance = GetItem(this, iFrom);
- RemoveItem(this, pMoveInstance, false);
- InsertItem(this, pMoveInstance, iTo, iCount - 1, true);
- CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor();
- if (pLayoutPro) {
- pLayoutPro->AddChangedContainer(
- ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)));
- }
- return 0;
+ m_JSNode.Script_InstanceManager_InsertInstance(pArguments);
}
void CXFA_Node::Script_Occur_Max(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_Occur occur(this);
- if (bSetting) {
- int32_t iMax = pValue->ToInteger();
- occur.SetMax(iMax);
- } else {
- pValue->SetInteger(occur.GetMax());
- }
+ m_JSNode.Script_Occur_Max(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- CXFA_Occur occur(this);
- if (bSetting) {
- int32_t iMin = pValue->ToInteger();
- occur.SetMin(iMin);
- } else {
- pValue->SetInteger(occur.GetMin());
- }
+ m_JSNode.Script_Occur_Min(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) {
- int32_t argc = pArguments->GetLength();
- if (argc != 0 && argc != 1) {
- ThrowParamCountMismatchException(L"metadata");
- return;
- }
- pArguments->GetReturnValue()->SetString("");
+ m_JSNode.Script_Desc_Metadata(pArguments);
}
void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"formNodes");
- return;
- }
-
- CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
- if (!pDataNode) {
- ThrowArgumentMismatchException();
- return;
- }
-
- std::vector<CXFA_Node*> formItems;
- CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument.Get());
- pFormNodes->SetArrayNodeList(formItems);
- pArguments->GetReturnValue()->SetObject(
- pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass());
+ m_JSNode.Script_Form_FormNodes(pArguments);
}
void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"remerge");
- return;
- }
-
- m_pDocument->DoDataRemerge(true);
+ m_JSNode.Script_Form_Remerge(pArguments);
}
void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execInitialize");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Initialize);
+ m_JSNode.Script_Form_ExecInitialize(pArguments);
}
void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) {
- CXFA_EventParam* pEventParam =
- m_pDocument->GetScriptContext()->GetEventParam();
- if (pEventParam->m_eType == XFA_EVENT_Calculate ||
- pEventParam->m_eType == XFA_EVENT_InitCalculate) {
- return;
- }
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"recalculate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
- if (pArguments->GetInt32(0) != 0)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Ready, true);
+ m_JSNode.Script_Form_Recalculate(pArguments);
}
void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execCalculate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify)
- return;
-
- pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate);
+ m_JSNode.Script_Form_ExecCalculate(pArguments);
}
void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0) {
- ThrowParamCountMismatchException(L"execValidate");
- return;
- }
-
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- pArguments->GetReturnValue()->SetBoolean(false);
- return;
- }
-
- int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate);
- pArguments->GetReturnValue()->SetBoolean(
- (iRet == XFA_EVENTERROR_Error) ? false : true);
+ m_JSNode.Script_Form_ExecValidate(pArguments);
}
void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- SetAttribute(XFA_ATTRIBUTE_Checksum, pValue->ToWideString().AsStringView());
- return;
- }
- WideString wsChecksum;
- GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, false);
- pValue->SetString(wsChecksum.UTF8Encode().AsStringView());
+ m_JSNode.Script_Form_Checksum(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"getAttribute");
- return;
- }
- ByteString bsAttributeName = pArguments->GetUTF8String(0);
- WideString wsAttributeValue;
- CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- wsAttributeValue = static_cast<CFX_XMLElement*>(pXMLNode)->GetString(
- WideString::FromUTF8(bsAttributeName.AsStringView()).c_str());
- }
- pArguments->GetReturnValue()->SetString(
- wsAttributeValue.UTF8Encode().AsStringView());
+ m_JSNode.Script_Packet_GetAttribute(pArguments);
}
void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 2) {
- ThrowParamCountMismatchException(L"setAttribute");
- return;
- }
- ByteString bsValue = pArguments->GetUTF8String(0);
- ByteString bsName = pArguments->GetUTF8String(1);
- CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- static_cast<CFX_XMLElement*>(pXMLNode)->SetString(
- WideString::FromUTF8(bsName.AsStringView()),
- WideString::FromUTF8(bsValue.AsStringView()));
- }
- pArguments->GetReturnValue()->SetNull();
+ m_JSNode.Script_Packet_SetAttribute(pArguments);
}
void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 1) {
- ThrowParamCountMismatchException(L"removeAttribute");
- return;
- }
-
- ByteString bsName = pArguments->GetUTF8String(0);
- WideString wsName = WideString::FromUTF8(bsName.AsStringView());
- CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
- if (pXMLElement->HasAttribute(wsName.c_str())) {
- pXMLElement->RemoveAttribute(wsName.c_str());
- }
- }
- pArguments->GetReturnValue()->SetNull();
+ m_JSNode.Script_Packet_RemoveAttribute(pArguments);
}
void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
- pXMLElement->SetTextData(pValue->ToWideString());
- }
- } else {
- WideString wsTextData;
- CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
- CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
- wsTextData = pXMLElement->GetTextData();
- }
- pValue->SetString(wsTextData.UTF8Encode().AsStringView());
- }
+ m_JSNode.Script_Packet_Content(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"next");
+ m_JSNode.Script_Source_Next(pArguments);
}
void CXFA_Node::Script_Source_CancelBatch(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"cancelBatch");
+ m_JSNode.Script_Source_CancelBatch(pArguments);
}
void CXFA_Node::Script_Source_First(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"first");
+ m_JSNode.Script_Source_First(pArguments);
}
void CXFA_Node::Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"updateBatch");
+ m_JSNode.Script_Source_UpdateBatch(pArguments);
}
void CXFA_Node::Script_Source_Previous(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"previous");
+ m_JSNode.Script_Source_Previous(pArguments);
}
void CXFA_Node::Script_Source_IsBOF(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"isBOF");
+ m_JSNode.Script_Source_IsBOF(pArguments);
}
void CXFA_Node::Script_Source_IsEOF(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"isEOF");
+ m_JSNode.Script_Source_IsEOF(pArguments);
}
void CXFA_Node::Script_Source_Cancel(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"cancel");
+ m_JSNode.Script_Source_Cancel(pArguments);
}
void CXFA_Node::Script_Source_Update(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"update");
+ m_JSNode.Script_Source_Update(pArguments);
}
void CXFA_Node::Script_Source_Open(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"open");
+ m_JSNode.Script_Source_Open(pArguments);
}
void CXFA_Node::Script_Source_Delete(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"delete");
+ m_JSNode.Script_Source_Delete(pArguments);
}
void CXFA_Node::Script_Source_AddNew(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"addNew");
+ m_JSNode.Script_Source_AddNew(pArguments);
}
void CXFA_Node::Script_Source_Requery(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"requery");
+ m_JSNode.Script_Source_Requery(pArguments);
}
void CXFA_Node::Script_Source_Resync(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"resync");
+ m_JSNode.Script_Source_Resync(pArguments);
}
void CXFA_Node::Script_Source_Close(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"close");
+ m_JSNode.Script_Source_Close(pArguments);
}
void CXFA_Node::Script_Source_Last(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"last");
+ m_JSNode.Script_Source_Last(pArguments);
}
void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) {
- if (pArguments->GetLength() != 0)
- ThrowParamCountMismatchException(L"hasDataChanged");
+ m_JSNode.Script_Source_HasDataChanged(pArguments);
}
void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_Source_Db(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_Xfa_This(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (!bSetting) {
- CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject();
- ASSERT(pThis);
- pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis));
- }
+ m_JSNode.Script_Xfa_This(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Handler_Version(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_Handler_Version(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_SubmitFormat_Mode(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_Extras_Type(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_Extras_Type(pValue, bSetting, eAttribute);
+}
void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute) {
- if (bSetting) {
- ThrowInvalidPropertyException();
- return;
- }
- pValue->SetString(FX_UTF8Encode(WideStringView(L"0", 1)).AsStringView());
+ m_JSNode.Script_Script_Stateless(pValue, bSetting, eAttribute);
}
void CXFA_Node::Script_Encrypt_Format(CFXJSE_Value* pValue,
bool bSetting,
- XFA_ATTRIBUTE eAttribute) {}
-
-bool CXFA_Node::HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- return HasMapModuleKey(pKey, bCanInherit);
-}
-
-bool CXFA_Node::SetAttribute(XFA_ATTRIBUTE eAttr,
- const WideStringView& wsValue,
- bool bNotify) {
- const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr);
- if (!pAttr)
- return false;
-
- XFA_ATTRIBUTETYPE eType = pAttr->eType;
- if (eType == XFA_ATTRIBUTETYPE_NOTSURE) {
- const XFA_NOTSUREATTRIBUTE* pNotsure =
- XFA_GetNotsureAttribute(GetElementType(), pAttr->eName);
- eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata;
- }
- switch (eType) {
- case XFA_ATTRIBUTETYPE_Enum: {
- const XFA_ATTRIBUTEENUMINFO* pEnum = XFA_GetAttributeEnumByName(wsValue);
- return SetEnum(pAttr->eName,
- pEnum ? pEnum->eName
- : (XFA_ATTRIBUTEENUM)(intptr_t)(pAttr->pDefValue),
- bNotify);
- } break;
- case XFA_ATTRIBUTETYPE_Cdata:
- return SetCData(pAttr->eName, WideString(wsValue), bNotify);
- case XFA_ATTRIBUTETYPE_Boolean:
- return SetBoolean(pAttr->eName, wsValue != L"0", bNotify);
- case XFA_ATTRIBUTETYPE_Integer:
- return SetInteger(pAttr->eName,
- FXSYS_round(FXSYS_wcstof(wsValue.unterminated_c_str(),
- wsValue.GetLength(), nullptr)),
- bNotify);
- case XFA_ATTRIBUTETYPE_Measure:
- return SetMeasure(pAttr->eName, CXFA_Measurement(wsValue), bNotify);
- default:
- break;
- }
- return false;
-}
-
-bool CXFA_Node::GetAttribute(XFA_ATTRIBUTE eAttr,
- WideString& wsValue,
- bool bUseDefault) {
- const XFA_ATTRIBUTEINFO* pAttr = XFA_GetAttributeByID(eAttr);
- if (!pAttr)
- return false;
-
- XFA_ATTRIBUTETYPE eType = pAttr->eType;
- if (eType == XFA_ATTRIBUTETYPE_NOTSURE) {
- const XFA_NOTSUREATTRIBUTE* pNotsure =
- XFA_GetNotsureAttribute(GetElementType(), pAttr->eName);
- eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata;
- }
- switch (eType) {
- case XFA_ATTRIBUTETYPE_Enum: {
- XFA_ATTRIBUTEENUM eValue;
- if (!TryEnum(pAttr->eName, eValue, bUseDefault))
- return false;
-
- wsValue = GetAttributeEnumByID(eValue)->pName;
- return true;
- }
- case XFA_ATTRIBUTETYPE_Cdata: {
- WideStringView wsValueC;
- if (!TryCData(pAttr->eName, wsValueC, bUseDefault))
- return false;
-
- wsValue = wsValueC;
- return true;
- }
- case XFA_ATTRIBUTETYPE_Boolean: {
- bool bValue;
- if (!TryBoolean(pAttr->eName, bValue, bUseDefault))
- return false;
-
- wsValue = bValue ? L"1" : L"0";
- return true;
- }
- case XFA_ATTRIBUTETYPE_Integer: {
- int32_t iValue;
- if (!TryInteger(pAttr->eName, iValue, bUseDefault))
- return false;
-
- wsValue.Format(L"%d", iValue);
- return true;
- }
- case XFA_ATTRIBUTETYPE_Measure: {
- CXFA_Measurement mValue;
- if (!TryMeasure(pAttr->eName, mValue, bUseDefault))
- return false;
-
- mValue.ToString(&wsValue);
- return true;
- }
- default:
- return false;
- }
-}
-
-bool CXFA_Node::SetAttribute(const WideStringView& wsAttr,
- const WideStringView& wsValue,
- bool bNotify) {
- const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsValue);
- if (pAttributeInfo) {
- return SetAttribute(pAttributeInfo->eName, wsValue, bNotify);
- }
- void* pKey = GetMapKey_Custom(wsAttr);
- SetMapModuleString(pKey, wsValue);
- return true;
-}
-
-bool CXFA_Node::GetAttribute(const WideStringView& wsAttr,
- WideString& wsValue,
- bool bUseDefault) {
- const XFA_ATTRIBUTEINFO* pAttributeInfo = XFA_GetAttributeByName(wsAttr);
- if (pAttributeInfo) {
- return GetAttribute(pAttributeInfo->eName, wsValue, bUseDefault);
- }
- void* pKey = GetMapKey_Custom(wsAttr);
- WideStringView wsValueC;
- if (GetMapModuleString(pKey, wsValueC)) {
- wsValue = wsValueC;
- }
- return true;
-}
-
-bool CXFA_Node::RemoveAttribute(const WideStringView& wsAttr) {
- void* pKey = GetMapKey_Custom(wsAttr);
- RemoveMapModuleKey(pKey);
- return true;
-}
-
-bool CXFA_Node::TryBoolean(XFA_ATTRIBUTE eAttr,
- bool& bValue,
- bool bUseDefault) {
- void* pValue = nullptr;
- if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, bUseDefault, pValue))
- return false;
- bValue = !!pValue;
- return true;
-}
-
-bool CXFA_Node::TryInteger(XFA_ATTRIBUTE eAttr,
- int32_t& iValue,
- bool bUseDefault) {
- void* pValue = nullptr;
- if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, bUseDefault, pValue))
- return false;
- iValue = (int32_t)(uintptr_t)pValue;
- return true;
-}
-
-bool CXFA_Node::TryEnum(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTEENUM& eValue,
- bool bUseDefault) {
- void* pValue = nullptr;
- if (!GetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, bUseDefault, pValue))
- return false;
- eValue = (XFA_ATTRIBUTEENUM)(uintptr_t)pValue;
- return true;
-}
-
-bool CXFA_Node::SetMeasure(XFA_ATTRIBUTE eAttr,
- CXFA_Measurement mValue,
- bool bNotify) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- OnChanging(eAttr, bNotify);
- SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement));
- OnChanged(eAttr, bNotify, false);
- return true;
-}
-
-bool CXFA_Node::TryMeasure(XFA_ATTRIBUTE eAttr,
- CXFA_Measurement& mValue,
- bool bUseDefault) const {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- void* pValue;
- int32_t iBytes;
- if (GetMapModuleBuffer(pKey, pValue, iBytes) && iBytes == sizeof(mValue)) {
- memcpy(&mValue, pValue, sizeof(mValue));
- return true;
- }
- if (bUseDefault &&
- XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr,
- XFA_ATTRIBUTETYPE_Measure, m_ePacket)) {
- memcpy(&mValue, pValue, sizeof(mValue));
- return true;
- }
- return false;
-}
-
-CXFA_Measurement CXFA_Node::GetMeasure(XFA_ATTRIBUTE eAttr) const {
- CXFA_Measurement mValue;
- return TryMeasure(eAttr, mValue, true) ? mValue : CXFA_Measurement();
-}
-
-bool CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr,
- const WideString& wsValue,
- bool bNotify,
- bool bScriptModify) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- OnChanging(eAttr, bNotify);
- if (eAttr == XFA_ATTRIBUTE_Value) {
- WideString* pClone = new WideString(wsValue);
- SetUserData(pKey, pClone, &deleteWideStringCallBack);
- } else {
- SetMapModuleString(pKey, wsValue.AsStringView());
- if (eAttr == XFA_ATTRIBUTE_Name)
- UpdateNameHash();
- }
- OnChanged(eAttr, bNotify, bScriptModify);
-
- if (!IsNeedSavingXMLNode() || eAttr == XFA_ATTRIBUTE_QualifiedName ||
- eAttr == XFA_ATTRIBUTE_BindingNode) {
- return true;
- }
-
- if (eAttr == XFA_ATTRIBUTE_Name &&
- (m_elementType == XFA_Element::DataValue ||
- m_elementType == XFA_Element::DataGroup)) {
- return true;
- }
-
- if (eAttr == XFA_ATTRIBUTE_Value) {
- FX_XMLNODETYPE eXMLType = m_pXMLNode->GetType();
- switch (eXMLType) {
- case FX_XMLNODE_Element:
- if (IsAttributeInXML()) {
- static_cast<CFX_XMLElement*>(m_pXMLNode)
- ->SetString(WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)),
- wsValue);
- } else {
- bool bDeleteChildren = true;
- if (GetPacketID() == XFA_XDPPACKET_Datasets) {
- for (CXFA_Node* pChildDataNode =
- GetNodeItem(XFA_NODEITEM_FirstChild);
- pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
- XFA_NODEITEM_NextSibling)) {
- if (!pChildDataNode->GetBindItems().empty()) {
- bDeleteChildren = false;
- break;
- }
- }
- }
- if (bDeleteChildren) {
- static_cast<CFX_XMLElement*>(m_pXMLNode)->DeleteChildren();
- }
- static_cast<CFX_XMLElement*>(m_pXMLNode)->SetTextData(wsValue);
- }
- break;
- case FX_XMLNODE_Text:
- static_cast<CFX_XMLText*>(m_pXMLNode)->SetText(wsValue);
- break;
- default:
- ASSERT(0);
- }
- return true;
- }
-
- const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr);
- if (pInfo) {
- ASSERT(m_pXMLNode->GetType() == FX_XMLNODE_Element);
- WideString wsAttrName = pInfo->pName;
- if (pInfo->eName == XFA_ATTRIBUTE_ContentType) {
- wsAttrName = L"xfa:" + wsAttrName;
- }
- static_cast<CFX_XMLElement*>(m_pXMLNode)->SetString(wsAttrName, wsValue);
- }
- return true;
-}
-
-bool CXFA_Node::SetAttributeValue(const WideString& wsValue,
- const WideString& wsXMLValue,
- bool bNotify,
- bool bScriptModify) {
- void* pKey = GetMapKey_Element(GetElementType(), XFA_ATTRIBUTE_Value);
- OnChanging(XFA_ATTRIBUTE_Value, bNotify);
- WideString* pClone = new WideString(wsValue);
- SetUserData(pKey, pClone, &deleteWideStringCallBack);
- OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify);
- if (IsNeedSavingXMLNode()) {
- FX_XMLNODETYPE eXMLType = m_pXMLNode->GetType();
- switch (eXMLType) {
- case FX_XMLNODE_Element:
- if (IsAttributeInXML()) {
- static_cast<CFX_XMLElement*>(m_pXMLNode)
- ->SetString(WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)),
- wsXMLValue);
- } else {
- bool bDeleteChildren = true;
- if (GetPacketID() == XFA_XDPPACKET_Datasets) {
- for (CXFA_Node* pChildDataNode =
- GetNodeItem(XFA_NODEITEM_FirstChild);
- pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
- XFA_NODEITEM_NextSibling)) {
- if (!pChildDataNode->GetBindItems().empty()) {
- bDeleteChildren = false;
- break;
- }
- }
- }
- if (bDeleteChildren) {
- static_cast<CFX_XMLElement*>(m_pXMLNode)->DeleteChildren();
- }
- static_cast<CFX_XMLElement*>(m_pXMLNode)->SetTextData(wsXMLValue);
- }
- break;
- case FX_XMLNODE_Text:
- static_cast<CFX_XMLText*>(m_pXMLNode)->SetText(wsXMLValue);
- break;
- default:
- ASSERT(0);
- }
- }
- return true;
-}
-
-bool CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr,
- WideString& wsValue,
- bool bUseDefault,
- bool bProto) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- if (eAttr == XFA_ATTRIBUTE_Value) {
- WideString* pStr = (WideString*)GetUserData(pKey, bProto);
- if (pStr) {
- wsValue = *pStr;
- return true;
- }
- } else {
- WideStringView wsValueC;
- if (GetMapModuleString(pKey, wsValueC)) {
- wsValue = wsValueC;
- return true;
- }
- }
- if (!bUseDefault) {
- return false;
- }
- void* pValue = nullptr;
- if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr,
- XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) {
- wsValue = (const wchar_t*)pValue;
- return true;
- }
- return false;
-}
-
-bool CXFA_Node::TryCData(XFA_ATTRIBUTE eAttr,
- WideStringView& wsValue,
- bool bUseDefault,
- bool bProto) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- if (eAttr == XFA_ATTRIBUTE_Value) {
- WideString* pStr = (WideString*)GetUserData(pKey, bProto);
- if (pStr) {
- wsValue = pStr->AsStringView();
- return true;
- }
- } else {
- if (GetMapModuleString(pKey, wsValue)) {
- return true;
- }
- }
- if (!bUseDefault) {
- return false;
- }
- void* pValue = nullptr;
- if (XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr,
- XFA_ATTRIBUTETYPE_Cdata, m_ePacket)) {
- wsValue = (WideStringView)(const wchar_t*)pValue;
- return true;
- }
- return false;
-}
-
-bool CXFA_Node::SetObject(XFA_ATTRIBUTE eAttr,
- void* pData,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- return SetUserData(pKey, pData, pCallbackInfo);
-}
-
-bool CXFA_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- pData = GetUserData(pKey);
- return !!pData;
-}
-
-bool CXFA_Node::SetValue(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTETYPE eType,
- void* pValue,
- bool bNotify) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- OnChanging(eAttr, bNotify);
- SetMapModuleValue(pKey, pValue);
- OnChanged(eAttr, bNotify, false);
- if (IsNeedSavingXMLNode()) {
- ASSERT(m_pXMLNode->GetType() == FX_XMLNODE_Element);
- const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr);
- if (pInfo) {
- switch (eType) {
- case XFA_ATTRIBUTETYPE_Enum:
- static_cast<CFX_XMLElement*>(m_pXMLNode)
- ->SetString(
- pInfo->pName,
- GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue)
- ->pName);
- break;
- case XFA_ATTRIBUTETYPE_Boolean:
- static_cast<CFX_XMLElement*>(m_pXMLNode)
- ->SetString(pInfo->pName, pValue ? L"1" : L"0");
- break;
- case XFA_ATTRIBUTETYPE_Integer: {
- WideString wsValue;
- wsValue.Format(
- L"%d", static_cast<int32_t>(reinterpret_cast<uintptr_t>(pValue)));
- static_cast<CFX_XMLElement*>(m_pXMLNode)
- ->SetString(pInfo->pName, wsValue);
- break;
- }
- default:
- ASSERT(0);
- }
- }
- }
- return true;
-}
-
-bool CXFA_Node::GetValue(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTETYPE eType,
- bool bUseDefault,
- void*& pValue) {
- void* pKey = GetMapKey_Element(GetElementType(), eAttr);
- if (GetMapModuleValue(pKey, pValue)) {
- return true;
- }
- if (!bUseDefault) {
- return false;
- }
- return XFA_GetAttributeDefaultValue(pValue, GetElementType(), eAttr, eType,
- m_ePacket);
-}
-
-bool CXFA_Node::SetUserData(void* pKey,
- void* pData,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
- SetMapModuleBuffer(pKey, &pData, sizeof(void*),
- pCallbackInfo ? pCallbackInfo : &gs_XFADefaultFreeData);
- return true;
-}
-
-bool CXFA_Node::TryUserData(void* pKey, void*& pData, bool bProtoAlso) {
- int32_t iBytes = 0;
- if (!GetMapModuleBuffer(pKey, pData, iBytes, bProtoAlso)) {
- return false;
- }
- return iBytes == sizeof(void*) && memcpy(&pData, pData, iBytes);
-}
-
-bool CXFA_Node::SetScriptContent(const WideString& wsContent,
- const WideString& wsXMLValue,
- bool bNotify,
- bool bScriptModify,
- bool bSyncData) {
- CXFA_Node* pNode = nullptr;
- CXFA_Node* pBindNode = nullptr;
- switch (GetObjectType()) {
- case XFA_ObjectType::ContainerNode: {
- if (XFA_FieldIsMultiListBox(this)) {
- CXFA_Node* pValue = GetProperty(0, XFA_Element::Value);
- if (!pValue)
- break;
-
- CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild);
- ASSERT(pChildValue);
- pChildValue->SetCData(XFA_ATTRIBUTE_ContentType, L"text/xml");
- pChildValue->SetScriptContent(wsContent, wsContent, bNotify,
- bScriptModify, false);
- CXFA_Node* pBind = GetBindData();
- if (bSyncData && pBind) {
- std::vector<WideString> wsSaveTextArray;
- size_t iSize = 0;
- if (!wsContent.IsEmpty()) {
- size_t iStart = 0;
- size_t iLength = wsContent.GetLength();
- auto iEnd = wsContent.Find(L'\n', iStart);
- iEnd = !iEnd.has_value() ? iLength : iEnd;
- while (iEnd.value() >= iStart) {
- wsSaveTextArray.push_back(
- wsContent.Mid(iStart, iEnd.value() - iStart));
- iStart = iEnd.value() + 1;
- if (iStart >= iLength) {
- break;
- }
- iEnd = wsContent.Find(L'\n', iStart);
- if (!iEnd.has_value()) {
- wsSaveTextArray.push_back(
- wsContent.Mid(iStart, iLength - iStart));
- }
- }
- iSize = wsSaveTextArray.size();
- }
- if (iSize == 0) {
- while (CXFA_Node* pChildNode =
- pBind->GetNodeItem(XFA_NODEITEM_FirstChild)) {
- pBind->RemoveChild(pChildNode);
- }
- } else {
- std::vector<CXFA_Node*> valueNodes = pBind->GetNodeList(
- XFA_NODEFILTER_Children, XFA_Element::DataValue);
- size_t iDatas = valueNodes.size();
- if (iDatas < iSize) {
- size_t iAddNodes = iSize - iDatas;
- CXFA_Node* pValueNodes = nullptr;
- while (iAddNodes-- > 0) {
- pValueNodes =
- pBind->CreateSamePacketNode(XFA_Element::DataValue);
- pValueNodes->SetCData(XFA_ATTRIBUTE_Name, L"value");
- pValueNodes->CreateXMLMappingNode();
- pBind->InsertChild(pValueNodes);
- }
- pValueNodes = nullptr;
- } else if (iDatas > iSize) {
- size_t iDelNodes = iDatas - iSize;
- while (iDelNodes-- > 0) {
- pBind->RemoveChild(pBind->GetNodeItem(XFA_NODEITEM_FirstChild));
- }
- }
- int32_t i = 0;
- for (CXFA_Node* pValueNode =
- pBind->GetNodeItem(XFA_NODEITEM_FirstChild);
- pValueNode; pValueNode = pValueNode->GetNodeItem(
- XFA_NODEITEM_NextSibling)) {
- pValueNode->SetAttributeValue(wsSaveTextArray[i],
- wsSaveTextArray[i], false);
- i++;
- }
- }
- for (CXFA_Node* pArrayNode : pBind->GetBindItems()) {
- if (pArrayNode != this) {
- pArrayNode->SetScriptContent(wsContent, wsContent, bNotify,
- bScriptModify, false);
- }
- }
- }
- break;
- }
- if (GetElementType() == XFA_Element::ExclGroup) {
- pNode = this;
- } else {
- CXFA_Node* pValue = GetProperty(0, XFA_Element::Value);
- if (!pValue)
- break;
-
- CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild);
- ASSERT(pChildValue);
- pChildValue->SetScriptContent(wsContent, wsContent, bNotify,
- bScriptModify, false);
- }
- pBindNode = GetBindData();
- if (pBindNode && bSyncData) {
- pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify,
- bScriptModify, false);
- for (CXFA_Node* pArrayNode : pBindNode->GetBindItems()) {
- if (pArrayNode != this) {
- pArrayNode->SetScriptContent(wsContent, wsContent, bNotify, true,
- false);
- }
- }
- }
- pBindNode = nullptr;
- break;
- }
- case XFA_ObjectType::ContentNode: {
- WideString wsContentType;
- if (GetElementType() == XFA_Element::ExData) {
- GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false);
- if (wsContentType == L"text/html") {
- wsContentType = L"";
- SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType.AsStringView());
- }
- }
- CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pContentRawDataNode) {
- pContentRawDataNode = CreateSamePacketNode(
- (wsContentType == L"text/xml") ? XFA_Element::Sharpxml
- : XFA_Element::Sharptext);
- InsertChild(pContentRawDataNode);
- }
- return pContentRawDataNode->SetScriptContent(
- wsContent, wsXMLValue, bNotify, bScriptModify, bSyncData);
- }
- case XFA_ObjectType::NodeC:
- case XFA_ObjectType::TextNode:
- pNode = this;
- break;
- case XFA_ObjectType::NodeV:
- pNode = this;
- if (bSyncData && GetPacketID() == XFA_XDPPACKET_Form) {
- CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent);
- if (pParent) {
- pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
- }
- if (pParent && pParent->GetElementType() == XFA_Element::Value) {
- pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent);
- if (pParent && pParent->IsContainerNode()) {
- pBindNode = pParent->GetBindData();
- if (pBindNode) {
- pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify,
- bScriptModify, false);
- }
- }
- }
- }
- break;
- default:
- if (GetElementType() == XFA_Element::DataValue) {
- pNode = this;
- pBindNode = this;
- }
- break;
- }
- if (!pNode)
- return false;
-
- SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify);
- if (pBindNode && bSyncData) {
- for (CXFA_Node* pArrayNode : pBindNode->GetBindItems()) {
- pArrayNode->SetScriptContent(wsContent, wsContent, bNotify, bScriptModify,
- false);
- }
- }
- return true;
-}
-
-bool CXFA_Node::SetContent(const WideString& wsContent,
- const WideString& wsXMLValue,
- bool bNotify,
- bool bScriptModify,
- bool bSyncData) {
- return SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify,
- bSyncData);
-}
-
-WideString CXFA_Node::GetScriptContent(bool bScriptModify) {
- WideString wsContent;
- return TryContent(wsContent, bScriptModify) ? wsContent : WideString();
-}
-
-WideString CXFA_Node::GetContent() {
- return GetScriptContent();
-}
-
-bool CXFA_Node::TryContent(WideString& wsContent,
- bool bScriptModify,
- bool bProto) {
- CXFA_Node* pNode = nullptr;
- switch (GetObjectType()) {
- case XFA_ObjectType::ContainerNode:
- if (GetElementType() == XFA_Element::ExclGroup) {
- pNode = this;
- } else {
- CXFA_Node* pValue = GetChild(0, XFA_Element::Value);
- if (!pValue) {
- return false;
- }
- CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild);
- if (pChildValue && XFA_FieldIsMultiListBox(this)) {
- pChildValue->SetAttribute(XFA_ATTRIBUTE_ContentType, L"text/xml");
- }
- return pChildValue
- ? pChildValue->TryContent(wsContent, bScriptModify, bProto)
- : false;
- }
- break;
- case XFA_ObjectType::ContentNode: {
- CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild);
- if (!pContentRawDataNode) {
- XFA_Element element = XFA_Element::Sharptext;
- if (GetElementType() == XFA_Element::ExData) {
- WideString wsContentType;
- GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false);
- if (wsContentType == L"text/html") {
- element = XFA_Element::SharpxHTML;
- } else if (wsContentType == L"text/xml") {
- element = XFA_Element::Sharpxml;
- }
- }
- pContentRawDataNode = CreateSamePacketNode(element);
- InsertChild(pContentRawDataNode);
- }
- return pContentRawDataNode->TryContent(wsContent, bScriptModify, bProto);
- }
- case XFA_ObjectType::NodeC:
- case XFA_ObjectType::NodeV:
- case XFA_ObjectType::TextNode:
- pNode = this;
- default:
- if (GetElementType() == XFA_Element::DataValue) {
- pNode = this;
- }
- break;
- }
- if (pNode) {
- if (bScriptModify) {
- CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext();
- if (pScriptContext) {
- m_pDocument->GetScriptContext()->AddNodesOfRunScript(this);
- }
- }
- return TryCData(XFA_ATTRIBUTE_Value, wsContent, false, bProto);
- }
- return false;
+ XFA_ATTRIBUTE eAttribute) {
+ m_JSNode.Script_Encrypt_Format(pValue, bSetting, eAttribute);
}
CXFA_Node* CXFA_Node::GetModelNode() {
@@ -4294,81 +1484,6 @@ CXFA_Node* CXFA_Node::GetModelNode() {
}
}
-bool CXFA_Node::TryNamespace(WideString& wsNamespace) {
- wsNamespace.clear();
- if (IsModelNode() || GetElementType() == XFA_Element::Packet) {
- CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element)
- return false;
-
- wsNamespace = static_cast<CFX_XMLElement*>(pXMLNode)->GetNamespaceURI();
- return true;
- }
-
- if (GetPacketID() != XFA_XDPPACKET_Datasets)
- return GetModelNode()->TryNamespace(wsNamespace);
-
- CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (!pXMLNode)
- return false;
- if (pXMLNode->GetType() != FX_XMLNODE_Element)
- return true;
-
- if (GetElementType() == XFA_Element::DataValue &&
- GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) {
- return XFA_FDEExtension_ResolveNamespaceQualifier(
- static_cast<CFX_XMLElement*>(pXMLNode),
- GetCData(XFA_ATTRIBUTE_QualifiedName), &wsNamespace);
- }
- wsNamespace = static_cast<CFX_XMLElement*>(pXMLNode)->GetNamespaceURI();
- return true;
-}
-
-CXFA_Node* CXFA_Node::GetProperty(int32_t index,
- XFA_Element eProperty,
- bool bCreateProperty) {
- XFA_Element eType = GetElementType();
- uint32_t dwPacket = GetPacketID();
- const XFA_PROPERTY* pProperty =
- XFA_GetPropertyOfElement(eType, eProperty, dwPacket);
- if (!pProperty || index >= pProperty->uOccur)
- return nullptr;
-
- CXFA_Node* pNode = m_pChild;
- int32_t iCount = 0;
- for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pNode->GetElementType() == eProperty) {
- iCount++;
- if (iCount > index) {
- return pNode;
- }
- }
- }
- if (!bCreateProperty)
- return nullptr;
-
- if (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf) {
- pNode = m_pChild;
- for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- const XFA_PROPERTY* pExistProperty =
- XFA_GetPropertyOfElement(eType, pNode->GetElementType(), dwPacket);
- if (pExistProperty && (pExistProperty->uFlags & XFA_PROPERTYFLAG_OneOf))
- return nullptr;
- }
- }
-
- const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket);
- CXFA_Node* pNewNode = nullptr;
- for (; iCount <= index; iCount++) {
- pNewNode = m_pDocument->CreateNode(pPacket, eProperty);
- if (!pNewNode)
- return nullptr;
- InsertChild(pNewNode, nullptr);
- pNewNode->SetFlag(XFA_NodeFlag_Initialized, true);
- }
- return pNewNode;
-}
-
int32_t CXFA_Node::CountChildren(XFA_Element eType, bool bOnlyChild) {
CXFA_Node* pNode = m_pChild;
int32_t iCount = 0;
@@ -4551,19 +1666,20 @@ bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) {
CFX_XMLElement* pXMLElement =
static_cast<CFX_XMLElement*>(pNode->m_pXMLNode);
WideStringView wsAttributeName =
- pNode->GetCData(XFA_ATTRIBUTE_QualifiedName);
+ pNode->JSNode()->GetCData(XFA_ATTRIBUTE_QualifiedName);
// TODO(tsepez): check usage of c_str() below.
pXMLElement->RemoveAttribute(wsAttributeName.unterminated_c_str());
}
WideString wsName;
- pNode->GetAttribute(XFA_ATTRIBUTE_Name, wsName, false);
+ pNode->JSNode()->GetAttribute(XFA_ATTRIBUTE_Name, wsName, false);
CFX_XMLElement* pNewXMLElement = new CFX_XMLElement(wsName);
- WideStringView wsValue = GetCData(XFA_ATTRIBUTE_Value);
+ WideStringView wsValue = m_JSNode.GetCData(XFA_ATTRIBUTE_Value);
if (!wsValue.IsEmpty()) {
pNewXMLElement->SetTextData(WideString(wsValue));
}
pNode->m_pXMLNode = pNewXMLElement;
- pNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_Unknown);
+ pNode->JSNode()->SetEnum(XFA_ATTRIBUTE_Contains,
+ XFA_ATTRIBUTEENUM_Unknown);
} else {
m_pXMLNode->RemoveChildNode(pNode->m_pXMLNode);
}
@@ -4660,8 +1776,9 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() {
break;
}
if (eType == XFA_Element::InstanceManager) {
- WideStringView wsName = GetCData(XFA_ATTRIBUTE_Name);
- WideStringView wsInstName = pNode->GetCData(XFA_ATTRIBUTE_Name);
+ WideStringView wsName = m_JSNode.GetCData(XFA_ATTRIBUTE_Name);
+ WideStringView wsInstName =
+ pNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
if (wsInstName.GetLength() > 0 && wsInstName[0] == '_' &&
wsInstName.Right(wsInstName.GetLength() - 1) == wsName) {
pInstanceMgr = pNode;
@@ -4700,7 +1817,7 @@ void CXFA_Node::ClearFlag(uint32_t dwFlag) {
}
bool CXFA_Node::IsAttributeInXML() {
- return GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData;
+ return m_JSNode.GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData;
}
void CXFA_Node::OnRemoved(bool bNotify) {
@@ -4729,83 +1846,22 @@ void CXFA_Node::OnChanged(XFA_ATTRIBUTE eAttr,
}
}
-int32_t CXFA_Node::execSingleEventByName(const WideStringView& wsEventName,
- XFA_Element eType) {
- int32_t iRet = XFA_EVENTERROR_NotExist;
- const XFA_ExecEventParaInfo* eventParaInfo =
- GetEventParaInfoByName(wsEventName);
- if (eventParaInfo) {
- uint32_t validFlags = eventParaInfo->m_validFlags;
- CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
- return iRet;
- }
- if (validFlags == 1) {
- iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType);
- } else if (validFlags == 2) {
- iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
- false, false);
- } else if (validFlags == 3) {
- if (eType == XFA_Element::Subform) {
- iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
- false, false);
- }
- } else if (validFlags == 4) {
- if (eType == XFA_Element::ExclGroup || eType == XFA_Element::Field) {
- CXFA_Node* pParentNode = GetNodeItem(XFA_NODEITEM_Parent);
- if (pParentNode &&
- pParentNode->GetElementType() == XFA_Element::ExclGroup) {
- iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
- false, false);
- }
- iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
- false, false);
- }
- } else if (validFlags == 5) {
- if (eType == XFA_Element::Field) {
- iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
- false, false);
- }
- } else if (validFlags == 6) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (pWidgetData) {
- CXFA_Node* pUINode = pWidgetData->GetUIChild();
- if (pUINode->m_elementType == XFA_Element::Signature) {
- iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
- false, false);
- }
- }
- } else if (validFlags == 7) {
- CXFA_WidgetData* pWidgetData = GetWidgetData();
- if (pWidgetData) {
- CXFA_Node* pUINode = pWidgetData->GetUIChild();
- if ((pUINode->m_elementType == XFA_Element::ChoiceList) &&
- (!pWidgetData->IsListBox())) {
- iRet = pNotify->ExecEventByDeepFirst(this, eventParaInfo->m_eventType,
- false, false);
- }
- }
- }
- }
- return iRet;
-}
-
void CXFA_Node::UpdateNameHash() {
const XFA_NOTSUREATTRIBUTE* pNotsure =
XFA_GetNotsureAttribute(GetElementType(), XFA_ATTRIBUTE_Name);
WideStringView wsName;
if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) {
- wsName = GetCData(XFA_ATTRIBUTE_Name);
+ wsName = m_JSNode.GetCData(XFA_ATTRIBUTE_Name);
m_dwNameHash = FX_HashCode_GetW(wsName, false);
} else if (pNotsure->eType == XFA_ATTRIBUTETYPE_Enum) {
- wsName = GetAttributeEnumByID(GetEnum(XFA_ATTRIBUTE_Name))->pName;
+ wsName = GetAttributeEnumByID(m_JSNode.GetEnum(XFA_ATTRIBUTE_Name))->pName;
m_dwNameHash = FX_HashCode_GetW(wsName, false);
}
}
CFX_XMLNode* CXFA_Node::CreateXMLMappingNode() {
if (!m_pXMLNode) {
- WideString wsTag(GetCData(XFA_ATTRIBUTE_Name));
+ WideString wsTag(m_JSNode.GetCData(XFA_ATTRIBUTE_Name));
m_pXMLNode = new CFX_XMLElement(wsTag);
SetFlag(XFA_NodeFlag_OwnXMLNode, false);
}
@@ -4817,269 +1873,206 @@ bool CXFA_Node::IsNeedSavingXMLNode() {
GetElementType() == XFA_Element::Xfa);
}
-XFA_MAPMODULEDATA* CXFA_Node::CreateMapModuleData() {
- if (!m_pMapModuleData)
- m_pMapModuleData = new XFA_MAPMODULEDATA;
- return m_pMapModuleData;
-}
-
-XFA_MAPMODULEDATA* CXFA_Node::GetMapModuleData() const {
- return m_pMapModuleData;
+void CXFA_Node::ThrowMissingPropertyException(const WideString& obj,
+ const WideString& prop) const {
+ ThrowException(L"'%s' doesn't have property '%s'.", obj.c_str(),
+ prop.c_str());
}
-void CXFA_Node::SetMapModuleValue(void* pKey, void* pValue) {
- XFA_MAPMODULEDATA* pModule = CreateMapModuleData();
- pModule->m_ValueMap[pKey] = pValue;
+void CXFA_Node::ThrowTooManyOccurancesException(const WideString& obj) const {
+ ThrowException(
+ L"The element [%s] has violated its allowable number of occurrences.",
+ obj.c_str());
}
-bool CXFA_Node::GetMapModuleValue(void* pKey, void*& pValue) {
- for (CXFA_Node* pNode = this; pNode; pNode = pNode->GetTemplateNode()) {
- XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData();
- if (pModule) {
- auto it = pModule->m_ValueMap.find(pKey);
- if (it != pModule->m_ValueMap.end()) {
- pValue = it->second;
- return true;
+CXFA_Node* CXFA_Node::GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex) {
+ ASSERT(pInstMgrNode);
+ int32_t iCount = 0;
+ uint32_t dwNameHash = 0;
+ for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling);
+ pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ XFA_Element eCurType = pNode->GetElementType();
+ if (eCurType == XFA_Element::InstanceManager)
+ break;
+ if ((eCurType != XFA_Element::Subform) &&
+ (eCurType != XFA_Element::SubformSet)) {
+ continue;
+ }
+ if (iCount == 0) {
+ WideStringView wsName = pNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
+ WideStringView wsInstName =
+ pInstMgrNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
+ if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' ||
+ wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
+ return nullptr;
}
+ dwNameHash = pNode->GetNameHash();
}
- if (pNode->GetPacketID() == XFA_XDPPACKET_Datasets)
+ if (dwNameHash != pNode->GetNameHash())
break;
- }
- return false;
-}
-
-void CXFA_Node::SetMapModuleString(void* pKey, const WideStringView& wsValue) {
- SetMapModuleBuffer(pKey, (void*)wsValue.unterminated_c_str(),
- wsValue.GetLength() * sizeof(wchar_t));
-}
-bool CXFA_Node::GetMapModuleString(void* pKey, WideStringView& wsValue) {
- void* pValue;
- int32_t iBytes;
- if (!GetMapModuleBuffer(pKey, pValue, iBytes))
- return false;
- // Defensive measure: no out-of-bounds pointers even if zero length.
- int32_t iChars = iBytes / sizeof(wchar_t);
- wsValue = WideStringView(iChars ? (const wchar_t*)pValue : nullptr, iChars);
- return true;
+ iCount++;
+ if (iCount > iIndex)
+ return pNode;
+ }
+ return nullptr;
}
-void CXFA_Node::SetMapModuleBuffer(
- void* pKey,
- void* pValue,
- int32_t iBytes,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) {
- XFA_MAPMODULEDATA* pModule = CreateMapModuleData();
- XFA_MAPDATABLOCK*& pBuffer = pModule->m_BufferMap[pKey];
- if (!pBuffer) {
- pBuffer =
- (XFA_MAPDATABLOCK*)FX_Alloc(uint8_t, sizeof(XFA_MAPDATABLOCK) + iBytes);
- } else if (pBuffer->iBytes != iBytes) {
- if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) {
- pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData());
+int32_t CXFA_Node::GetCount(CXFA_Node* pInstMgrNode) {
+ ASSERT(pInstMgrNode);
+ int32_t iCount = 0;
+ uint32_t dwNameHash = 0;
+ for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling);
+ pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ XFA_Element eCurType = pNode->GetElementType();
+ if (eCurType == XFA_Element::InstanceManager)
+ break;
+ if ((eCurType != XFA_Element::Subform) &&
+ (eCurType != XFA_Element::SubformSet)) {
+ continue;
}
- pBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(uint8_t, pBuffer,
- sizeof(XFA_MAPDATABLOCK) + iBytes);
- } else if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree) {
- pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData());
- }
- if (!pBuffer)
- return;
-
- pBuffer->pCallbackInfo = pCallbackInfo;
- pBuffer->iBytes = iBytes;
- memcpy(pBuffer->GetData(), pValue, iBytes);
-}
-
-bool CXFA_Node::GetMapModuleBuffer(void* pKey,
- void*& pValue,
- int32_t& iBytes,
- bool bProtoAlso) const {
- XFA_MAPDATABLOCK* pBuffer = nullptr;
- for (const CXFA_Node* pNode = this; pNode; pNode = pNode->GetTemplateNode()) {
- XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData();
- if (pModule) {
- auto it = pModule->m_BufferMap.find(pKey);
- if (it != pModule->m_BufferMap.end()) {
- pBuffer = it->second;
- break;
+ if (iCount == 0) {
+ WideStringView wsName = pNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
+ WideStringView wsInstName =
+ pInstMgrNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
+ if (wsInstName.GetLength() < 1 || wsInstName[0] != '_' ||
+ wsInstName.Right(wsInstName.GetLength() - 1) != wsName) {
+ return iCount;
}
+ dwNameHash = pNode->GetNameHash();
}
- if (!bProtoAlso || pNode->GetPacketID() == XFA_XDPPACKET_Datasets)
+ if (dwNameHash != pNode->GetNameHash())
break;
- }
- if (!pBuffer)
- return false;
-
- pValue = pBuffer->GetData();
- iBytes = pBuffer->iBytes;
- return true;
-}
-
-bool CXFA_Node::HasMapModuleKey(void* pKey, bool bProtoAlso) {
- for (CXFA_Node* pNode = this; pNode; pNode = pNode->GetTemplateNode()) {
- XFA_MAPMODULEDATA* pModule = pNode->GetMapModuleData();
- if (pModule) {
- auto it1 = pModule->m_ValueMap.find(pKey);
- if (it1 != pModule->m_ValueMap.end())
- return true;
- auto it2 = pModule->m_BufferMap.find(pKey);
- if (it2 != pModule->m_BufferMap.end())
- return true;
- }
- if (!bProtoAlso || pNode->GetPacketID() == XFA_XDPPACKET_Datasets)
- break;
+ iCount++;
}
- return false;
+ return iCount;
}
-void CXFA_Node::RemoveMapModuleKey(void* pKey) {
- XFA_MAPMODULEDATA* pModule = GetMapModuleData();
- if (!pModule)
- return;
+void CXFA_Node::InsertItem(CXFA_Node* pInstMgrNode,
+ CXFA_Node* pNewInstance,
+ int32_t iPos,
+ int32_t iCount,
+ bool bMoveDataBindingNodes) {
+ if (iCount < 0)
+ iCount = GetCount(pInstMgrNode);
+ if (iPos < 0)
+ iPos = iCount;
+ if (iPos == iCount) {
+ CXFA_Node* pNextSibling =
+ iCount > 0 ? pInstMgrNode->GetItem(pInstMgrNode, iCount - 1)
+ ->GetNodeItem(XFA_NODEITEM_NextSibling)
+ : pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling);
+ pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)
+ ->InsertChild(pNewInstance, pNextSibling);
+ if (bMoveDataBindingNodes) {
+ std::set<CXFA_Node*> sNew;
+ std::set<CXFA_Node*> sAfter;
+ CXFA_NodeIteratorTemplate<CXFA_Node,
+ CXFA_TraverseStrategy_XFAContainerNode>
+ sIteratorNew(pNewInstance);
+ for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode;
+ pNode = sIteratorNew.MoveToNext()) {
+ CXFA_Node* pDataNode = pNode->GetBindData();
+ if (!pDataNode)
+ continue;
- if (pKey) {
- auto it = pModule->m_BufferMap.find(pKey);
- if (it != pModule->m_BufferMap.end()) {
- XFA_MAPDATABLOCK* pBuffer = it->second;
- if (pBuffer) {
- if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree)
- pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData());
- FX_Free(pBuffer);
+ sNew.insert(pDataNode);
}
- pModule->m_BufferMap.erase(it);
- }
- pModule->m_ValueMap.erase(pKey);
- return;
- }
+ CXFA_NodeIteratorTemplate<CXFA_Node,
+ CXFA_TraverseStrategy_XFAContainerNode>
+ sIteratorAfter(pNextSibling);
+ for (CXFA_Node* pNode = sIteratorAfter.GetCurrent(); pNode;
+ pNode = sIteratorAfter.MoveToNext()) {
+ CXFA_Node* pDataNode = pNode->GetBindData();
+ if (!pDataNode)
+ continue;
- for (auto& pair : pModule->m_BufferMap) {
- XFA_MAPDATABLOCK* pBuffer = pair.second;
- if (pBuffer) {
- if (pBuffer->pCallbackInfo && pBuffer->pCallbackInfo->pFree)
- pBuffer->pCallbackInfo->pFree(*(void**)pBuffer->GetData());
- FX_Free(pBuffer);
+ sAfter.insert(pDataNode);
+ }
+ ReorderDataNodes(sNew, sAfter, false);
}
- }
- pModule->m_BufferMap.clear();
- pModule->m_ValueMap.clear();
- delete pModule;
-}
-
-void CXFA_Node::MergeAllData(void* pDstModule) {
- XFA_MAPMODULEDATA* pDstModuleData =
- static_cast<CXFA_Node*>(pDstModule)->CreateMapModuleData();
- XFA_MAPMODULEDATA* pSrcModuleData = GetMapModuleData();
- if (!pSrcModuleData)
- return;
+ } else {
+ CXFA_Node* pBeforeInstance = GetItem(pInstMgrNode, iPos);
+ pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)
+ ->InsertChild(pNewInstance, pBeforeInstance);
+ if (bMoveDataBindingNodes) {
+ std::set<CXFA_Node*> sNew;
+ std::set<CXFA_Node*> sBefore;
+ CXFA_NodeIteratorTemplate<CXFA_Node,
+ CXFA_TraverseStrategy_XFAContainerNode>
+ sIteratorNew(pNewInstance);
+ for (CXFA_Node* pNode = sIteratorNew.GetCurrent(); pNode;
+ pNode = sIteratorNew.MoveToNext()) {
+ CXFA_Node* pDataNode = pNode->GetBindData();
+ if (!pDataNode)
+ continue;
- for (const auto& pair : pSrcModuleData->m_ValueMap)
- pDstModuleData->m_ValueMap[pair.first] = pair.second;
-
- for (const auto& pair : pSrcModuleData->m_BufferMap) {
- XFA_MAPDATABLOCK* pSrcBuffer = pair.second;
- XFA_MAPDATABLOCK*& pDstBuffer = pDstModuleData->m_BufferMap[pair.first];
- if (pSrcBuffer->pCallbackInfo && pSrcBuffer->pCallbackInfo->pFree &&
- !pSrcBuffer->pCallbackInfo->pCopy) {
- if (pDstBuffer) {
- pDstBuffer->pCallbackInfo->pFree(*(void**)pDstBuffer->GetData());
- pDstModuleData->m_BufferMap.erase(pair.first);
+ sNew.insert(pDataNode);
}
- continue;
- }
- if (!pDstBuffer) {
- pDstBuffer = (XFA_MAPDATABLOCK*)FX_Alloc(
- uint8_t, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes);
- } else if (pDstBuffer->iBytes != pSrcBuffer->iBytes) {
- if (pDstBuffer->pCallbackInfo && pDstBuffer->pCallbackInfo->pFree) {
- pDstBuffer->pCallbackInfo->pFree(*(void**)pDstBuffer->GetData());
+ CXFA_NodeIteratorTemplate<CXFA_Node,
+ CXFA_TraverseStrategy_XFAContainerNode>
+ sIteratorBefore(pBeforeInstance);
+ for (CXFA_Node* pNode = sIteratorBefore.GetCurrent(); pNode;
+ pNode = sIteratorBefore.MoveToNext()) {
+ CXFA_Node* pDataNode = pNode->GetBindData();
+ if (!pDataNode)
+ continue;
+
+ sBefore.insert(pDataNode);
}
- pDstBuffer = (XFA_MAPDATABLOCK*)FX_Realloc(
- uint8_t, pDstBuffer, sizeof(XFA_MAPDATABLOCK) + pSrcBuffer->iBytes);
- } else if (pDstBuffer->pCallbackInfo && pDstBuffer->pCallbackInfo->pFree) {
- pDstBuffer->pCallbackInfo->pFree(*(void**)pDstBuffer->GetData());
- }
- if (!pDstBuffer) {
- continue;
- }
- pDstBuffer->pCallbackInfo = pSrcBuffer->pCallbackInfo;
- pDstBuffer->iBytes = pSrcBuffer->iBytes;
- memcpy(pDstBuffer->GetData(), pSrcBuffer->GetData(), pSrcBuffer->iBytes);
- if (pDstBuffer->pCallbackInfo && pDstBuffer->pCallbackInfo->pCopy) {
- pDstBuffer->pCallbackInfo->pCopy(*(void**)pDstBuffer->GetData());
+ ReorderDataNodes(sNew, sBefore, true);
}
}
}
-void CXFA_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) {
- if (!pDstModule) {
+void CXFA_Node::RemoveItem(CXFA_Node* pInstMgrNode,
+ CXFA_Node* pRemoveInstance,
+ bool bRemoveDataBinding) {
+ pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent)->RemoveChild(pRemoveInstance);
+ if (!bRemoveDataBinding)
return;
- }
- bool bNeedMove = true;
- if (!pKey) {
- bNeedMove = false;
- }
- if (pDstModule->GetElementType() != GetElementType()) {
- bNeedMove = false;
- }
- XFA_MAPMODULEDATA* pSrcModuleData = nullptr;
- XFA_MAPMODULEDATA* pDstModuleData = nullptr;
- if (bNeedMove) {
- pSrcModuleData = GetMapModuleData();
- if (!pSrcModuleData) {
- bNeedMove = false;
- }
- pDstModuleData = pDstModule->CreateMapModuleData();
- }
- if (bNeedMove) {
- auto it = pSrcModuleData->m_BufferMap.find(pKey);
- if (it != pSrcModuleData->m_BufferMap.end()) {
- XFA_MAPDATABLOCK* pBufferBlockData = it->second;
- if (pBufferBlockData) {
- pSrcModuleData->m_BufferMap.erase(pKey);
- pDstModuleData->m_BufferMap[pKey] = pBufferBlockData;
+
+ CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>
+ sIterator(pRemoveInstance);
+ for (CXFA_Node* pFormNode = sIterator.GetCurrent(); pFormNode;
+ pFormNode = sIterator.MoveToNext()) {
+ CXFA_Node* pDataNode = pFormNode->GetBindData();
+ if (!pDataNode)
+ continue;
+
+ if (pDataNode->RemoveBindItem(pFormNode) == 0) {
+ if (CXFA_Node* pDataParent =
+ pDataNode->GetNodeItem(XFA_NODEITEM_Parent)) {
+ pDataParent->RemoveChild(pDataNode);
}
}
- }
- if (pDstModule->IsNodeV()) {
- WideString wsValue = pDstModule->GetScriptContent(false);
- WideString wsFormatValue(wsValue);
- CXFA_WidgetData* pWidgetData = pDstModule->GetContainerWidgetData();
- if (pWidgetData) {
- pWidgetData->GetFormatDataValue(wsValue, wsFormatValue);
- }
- pDstModule->SetScriptContent(wsValue, wsFormatValue, true, true);
+ pFormNode->JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
}
}
-void CXFA_Node::MoveBufferMapData(CXFA_Node* pSrcModule,
- CXFA_Node* pDstModule,
- void* pKey,
- bool bRecursive) {
- if (!pSrcModule || !pDstModule || !pKey) {
- return;
+CXFA_Node* CXFA_Node::CreateInstance(CXFA_Node* pInstMgrNode, bool bDataMerge) {
+ CXFA_Document* pDocument = pInstMgrNode->GetDocument();
+ CXFA_Node* pTemplateNode = pInstMgrNode->GetTemplateNode();
+ CXFA_Node* pFormParent = pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent);
+ CXFA_Node* pDataScope = nullptr;
+ for (CXFA_Node* pRootBoundNode = pFormParent;
+ pRootBoundNode && pRootBoundNode->IsContainerNode();
+ pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) {
+ pDataScope = pRootBoundNode->GetBindData();
+ if (pDataScope)
+ break;
}
- if (bRecursive) {
- CXFA_Node* pSrcChild = pSrcModule->GetNodeItem(XFA_NODEITEM_FirstChild);
- CXFA_Node* pDstChild = pDstModule->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pSrcChild && pDstChild;
- pSrcChild = pSrcChild->GetNodeItem(XFA_NODEITEM_NextSibling),
- pDstChild = pDstChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- MoveBufferMapData(pSrcChild, pDstChild, pKey, true);
- }
+ if (!pDataScope) {
+ pDataScope = ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
+ ASSERT(pDataScope);
}
- pSrcModule->MoveBufferMapData(pDstModule, pKey);
-}
-
-void CXFA_Node::ThrowMissingPropertyException(const WideString& obj,
- const WideString& prop) const {
- ThrowException(L"'%s' doesn't have property '%s'.", obj.c_str(),
- prop.c_str());
+ CXFA_Node* pInstance = pDocument->DataMerge_CopyContainer(
+ pTemplateNode, pFormParent, pDataScope, true, bDataMerge, true);
+ if (pInstance) {
+ pDocument->DataMerge_UpdateBindingRelations(pInstance);
+ pFormParent->RemoveChild(pInstance);
+ }
+ return pInstance;
}
-void CXFA_Node::ThrowTooManyOccurancesException(const WideString& obj) const {
- ThrowException(
- L"The element [%s] has violated its allowable number of occurrences.",
- obj.c_str());
-}
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 7faed0e38f..6151d738a2 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -11,6 +11,7 @@
#include <vector>
#include "core/fxcrt/fx_string.h"
+#include "fxjs/cjx_node.h"
#include "xfa/fxfa/parser/cxfa_object.h"
class CFX_XMLNode;
@@ -34,12 +35,6 @@ enum XFA_NodeFlag {
XFA_NodeFlag_LayoutGeneratedNode = 1 << 8
};
-enum XFA_SOM_MESSAGETYPE {
- XFA_SOM_ValidationMessage,
- XFA_SOM_FormatMessage,
- XFA_SOM_MandatoryMessage
-};
-
enum XFA_NODEITEM {
XFA_NODEITEM_Parent,
XFA_NODEITEM_FirstChild,
@@ -47,35 +42,34 @@ enum XFA_NODEITEM {
XFA_NODEITEM_PrevSibling,
};
-typedef void (*PD_CALLBACK_FREEDATA)(void* pData);
-typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData);
-
-struct XFA_MAPDATABLOCKCALLBACKINFO {
- PD_CALLBACK_FREEDATA pFree;
- PD_CALLBACK_DUPLICATEDATA pCopy;
-};
-
-struct XFA_MAPDATABLOCK {
- uint8_t* GetData() const { return (uint8_t*)this + sizeof(XFA_MAPDATABLOCK); }
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo;
- int32_t iBytes;
-};
-
-struct XFA_MAPMODULEDATA {
- XFA_MAPMODULEDATA();
- ~XFA_MAPMODULEDATA();
-
- std::map<void*, void*> m_ValueMap;
- std::map<void*, XFA_MAPDATABLOCK*> m_BufferMap;
-};
+const XFA_ATTRIBUTEENUMINFO* GetAttributeEnumByID(XFA_ATTRIBUTEENUM eName);
class CXFA_Node : public CXFA_Object {
public:
+ ~CXFA_Node() override;
+
uint32_t GetPacketID() const { return m_ePacket; }
void SetFlag(uint32_t dwFlag, bool bNotify);
void ClearFlag(uint32_t dwFlag);
+ CJX_Node* JSNode() { return &m_JSNode; }
+ const CJX_Node* JSNode() const { return &m_JSNode; }
+ CXFA_Node* GetParent() { return m_pParent; }
+ CXFA_Node* GetChildNode() { return m_pChild; }
+
+ CXFA_Node* CreateInstance(CXFA_Node* pInstMgrNode, bool bDataMerge);
+ int32_t GetCount(CXFA_Node* pInstMgrNode);
+ CXFA_Node* GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex);
+ void RemoveItem(CXFA_Node* pInstMgrNode,
+ CXFA_Node* pRemoveInstance,
+ bool bRemoveDataBinding = true);
+ void InsertItem(CXFA_Node* pInstMgrNode,
+ CXFA_Node* pNewInstance,
+ int32_t iPos,
+ int32_t iCount = -1,
+ bool bMoveDataBindingNodes = true);
+
bool IsInitialized() const { return HasFlag(XFA_NodeFlag_Initialized); }
bool IsOwnXMLNode() const { return HasFlag(XFA_NodeFlag_OwnXMLNode); }
bool IsUserInteractive() const {
@@ -103,111 +97,7 @@ class CXFA_Node : public CXFA_Object {
bool IsUnnamed() const { return m_dwNameHash == 0; }
CXFA_Node* GetModelNode();
void UpdateNameHash();
- bool HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit = false);
- bool SetAttribute(XFA_ATTRIBUTE eAttr,
- const WideStringView& wsValue,
- bool bNotify = false);
- bool GetAttribute(XFA_ATTRIBUTE eAttr,
- WideString& wsValue,
- bool bUseDefault = true);
- bool SetAttribute(const WideStringView& wsAttr,
- const WideStringView& wsValue,
- bool bNotify = false);
- bool GetAttribute(const WideStringView& wsAttr,
- WideString& wsValue,
- bool bUseDefault = true);
- bool RemoveAttribute(const WideStringView& wsAttr);
- bool SetContent(const WideString& wsContent,
- const WideString& wsXMLValue,
- bool bNotify = false,
- bool bScriptModify = false,
- bool bSyncData = true);
- bool TryContent(WideString& wsContent,
- bool bScriptModify = false,
- bool bProto = true);
- WideString GetContent();
-
- bool TryNamespace(WideString& wsNamespace);
- bool SetBoolean(XFA_ATTRIBUTE eAttr, bool bValue, bool bNotify = false) {
- return SetValue(eAttr, XFA_ATTRIBUTETYPE_Boolean, (void*)(uintptr_t)bValue,
- bNotify);
- }
- bool TryBoolean(XFA_ATTRIBUTE eAttr, bool& bValue, bool bUseDefault = true);
- bool GetBoolean(XFA_ATTRIBUTE eAttr) {
- bool bValue;
- return TryBoolean(eAttr, bValue, true) ? bValue : false;
- }
- bool SetInteger(XFA_ATTRIBUTE eAttr, int32_t iValue, bool bNotify = false) {
- return SetValue(eAttr, XFA_ATTRIBUTETYPE_Integer, (void*)(uintptr_t)iValue,
- bNotify);
- }
- bool TryInteger(XFA_ATTRIBUTE eAttr,
- int32_t& iValue,
- bool bUseDefault = true);
- int32_t GetInteger(XFA_ATTRIBUTE eAttr) {
- int32_t iValue;
- return TryInteger(eAttr, iValue, true) ? iValue : 0;
- }
- bool SetEnum(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTEENUM eValue,
- bool bNotify = false) {
- return SetValue(eAttr, XFA_ATTRIBUTETYPE_Enum, (void*)(uintptr_t)eValue,
- bNotify);
- }
- bool TryEnum(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTEENUM& eValue,
- bool bUseDefault = true);
- XFA_ATTRIBUTEENUM GetEnum(XFA_ATTRIBUTE eAttr) {
- XFA_ATTRIBUTEENUM eValue;
- return TryEnum(eAttr, eValue, true) ? eValue : XFA_ATTRIBUTEENUM_Unknown;
- }
- bool SetCData(XFA_ATTRIBUTE eAttr,
- const WideString& wsValue,
- bool bNotify = false,
- bool bScriptModify = false);
- bool SetAttributeValue(const WideString& wsValue,
- const WideString& wsXMLValue,
- bool bNotify = false,
- bool bScriptModify = false);
- bool TryCData(XFA_ATTRIBUTE eAttr,
- WideString& wsValue,
- bool bUseDefault = true,
- bool bProto = true);
- bool TryCData(XFA_ATTRIBUTE eAttr,
- WideStringView& wsValue,
- bool bUseDefault = true,
- bool bProto = true);
- WideStringView GetCData(XFA_ATTRIBUTE eAttr) {
- WideStringView wsValue;
- return TryCData(eAttr, wsValue) ? wsValue : WideStringView();
- }
- bool SetMeasure(XFA_ATTRIBUTE eAttr,
- CXFA_Measurement mValue,
- bool bNotify = false);
- bool TryMeasure(XFA_ATTRIBUTE eAttr,
- CXFA_Measurement& mValue,
- bool bUseDefault = true) const;
- CXFA_Measurement GetMeasure(XFA_ATTRIBUTE eAttr) const;
- bool SetObject(XFA_ATTRIBUTE eAttr,
- void* pData,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr);
- bool TryObject(XFA_ATTRIBUTE eAttr, void*& pData);
- void* GetObject(XFA_ATTRIBUTE eAttr) {
- void* pData;
- return TryObject(eAttr, pData) ? pData : nullptr;
- }
- bool SetUserData(void* pKey,
- void* pData,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr);
- bool TryUserData(void* pKey, void*& pData, bool bProtoAlso = false);
- void* GetUserData(void* pKey, bool bProtoAlso = false) {
- void* pData;
- return TryUserData(pKey, pData, bProtoAlso) ? pData : nullptr;
- }
- CXFA_Node* GetProperty(int32_t index,
- XFA_Element eType,
- bool bCreateProperty = true);
int32_t CountChildren(XFA_Element eType, bool bOnlyChild = false);
CXFA_Node* GetChild(int32_t index,
XFA_Element eType,
@@ -250,6 +140,14 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node* GetInstanceMgrOfSubform();
CXFA_Node* GetOccurNode();
+
+ int32_t Subform_and_SubformSet_InstanceIndex();
+ int32_t InstanceManager_SetInstances(int32_t iCount);
+ int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom);
+
+ void OnChanged(XFA_ATTRIBUTE eAttr, bool bNotify, bool bScriptModify);
+ void OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify);
+
void Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments);
void Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments);
void Script_Som_ResolveNodeList(CFXJSE_Value* pValue,
@@ -447,7 +345,6 @@ class CXFA_Node : public CXFA_Object {
void Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments);
void Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments);
- int32_t Subform_and_SubformSet_InstanceIndex();
void Script_Template_FormNodes(CFXJSE_Arguments* pArguments);
void Script_Template_Remerge(CFXJSE_Arguments* pArguments);
void Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments);
@@ -470,8 +367,7 @@ class CXFA_Node : public CXFA_Object {
void Script_InstanceManager_SetInstances(CFXJSE_Arguments* pArguments);
void Script_InstanceManager_AddInstance(CFXJSE_Arguments* pArguments);
void Script_InstanceManager_InsertInstance(CFXJSE_Arguments* pArguments);
- int32_t InstanceManager_SetInstances(int32_t iCount);
- int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom);
+
void Script_Occur_Max(CFXJSE_Value* pValue,
bool bSetting,
XFA_ATTRIBUTE eAttribute);
@@ -533,6 +429,10 @@ class CXFA_Node : public CXFA_Object {
bool bSetting,
XFA_ATTRIBUTE eAttribute);
+ void ThrowMissingPropertyException(const WideString& obj,
+ const WideString& prop) const;
+ void ThrowTooManyOccurancesException(const WideString& obj) const;
+
private:
friend class CXFA_Document;
@@ -541,52 +441,11 @@ class CXFA_Node : public CXFA_Object {
XFA_ObjectType oType,
XFA_Element eType,
const WideStringView& elementName);
- ~CXFA_Node() override;
bool HasFlag(XFA_NodeFlag dwFlag) const;
CXFA_Node* Deprecated_GetPrevSibling();
- bool SetValue(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTETYPE eType,
- void* pValue,
- bool bNotify);
- bool GetValue(XFA_ATTRIBUTE eAttr,
- XFA_ATTRIBUTETYPE eType,
- bool bUseDefault,
- void*& pValue);
+
void OnRemoved(bool bNotify);
- void OnChanging(XFA_ATTRIBUTE eAttr, bool bNotify);
- void OnChanged(XFA_ATTRIBUTE eAttr, bool bNotify, bool bScriptModify);
- int32_t execSingleEventByName(const WideStringView& wsEventName,
- XFA_Element eType);
- bool SetScriptContent(const WideString& wsContent,
- const WideString& wsXMLValue,
- bool bNotify = true,
- bool bScriptModify = false,
- bool bSyncData = true);
- WideString GetScriptContent(bool bScriptModify = false);
- XFA_MAPMODULEDATA* CreateMapModuleData();
- XFA_MAPMODULEDATA* GetMapModuleData() const;
- void SetMapModuleValue(void* pKey, void* pValue);
- bool GetMapModuleValue(void* pKey, void*& pValue);
- void SetMapModuleString(void* pKey, const WideStringView& wsValue);
- bool GetMapModuleString(void* pKey, WideStringView& wsValue);
- void SetMapModuleBuffer(
- void* pKey,
- void* pValue,
- int32_t iBytes,
- XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo = nullptr);
- bool GetMapModuleBuffer(void* pKey,
- void*& pValue,
- int32_t& iBytes,
- bool bProtoAlso = true) const;
- bool HasMapModuleKey(void* pKey, bool bProtoAlso = false);
- void RemoveMapModuleKey(void* pKey = nullptr);
- void MergeAllData(void* pDstModule);
- void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey);
- void MoveBufferMapData(CXFA_Node* pSrcModule,
- CXFA_Node* pDstModule,
- void* pKey,
- bool bRecursive = false);
CXFA_Node* m_pNext;
CXFA_Node* m_pChild;
@@ -597,12 +456,7 @@ class CXFA_Node : public CXFA_Object {
uint16_t m_uNodeFlags;
uint32_t m_dwNameHash;
CXFA_Node* m_pAuxNode;
- XFA_MAPMODULEDATA* m_pMapModuleData;
-
- private:
- void ThrowMissingPropertyException(const WideString& obj,
- const WideString& prop) const;
- void ThrowTooManyOccurancesException(const WideString& obj) const;
+ CJX_Node m_JSNode;
};
#endif // XFA_FXFA_PARSER_CXFA_NODE_H_
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp
index 289149998e..6bf7cc20b6 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.cpp
+++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp
@@ -256,7 +256,7 @@ void CXFA_NodeHelper::GetNameExpression(CXFA_Node* refNode,
GetIndex(refNode, eLogicType, bIsProperty, true));
return;
}
- ws = refNode->GetCData(XFA_ATTRIBUTE_Name);
+ ws = refNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
ws.Replace(L".", L"\\.");
wsName.Format(L"%s[%d]", ws.c_str(),
GetIndex(refNode, eLogicType, bIsProperty, false));
@@ -357,7 +357,8 @@ bool CXFA_NodeHelper::ResolveNodes_CreateNode(WideString wsName,
for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) {
CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType);
if (pNewNode) {
- pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName.AsStringView());
+ pNewNode->JSNode()->SetAttribute(XFA_ATTRIBUTE_Name,
+ wsName.AsStringView());
pNewNode->CreateXMLMappingNode();
m_pCreateParent->InsertChild(pNewNode);
if (iIndex == m_iCreateCount - 1) {
diff --git a/xfa/fxfa/parser/cxfa_nodelocale.cpp b/xfa/fxfa/parser/cxfa_nodelocale.cpp
index d0d1fd34e4..7aaec5aa19 100644
--- a/xfa/fxfa/parser/cxfa_nodelocale.cpp
+++ b/xfa/fxfa/parser/cxfa_nodelocale.cpp
@@ -43,8 +43,8 @@ CXFA_NodeLocale::CXFA_NodeLocale(CXFA_Node* pLocale) : m_pLocale(pLocale) {}
CXFA_NodeLocale::~CXFA_NodeLocale() {}
WideString CXFA_NodeLocale::GetName() const {
- return WideString(m_pLocale ? m_pLocale->GetCData(XFA_ATTRIBUTE_Name)
- : nullptr);
+ return WideString(
+ m_pLocale ? m_pLocale->JSNode()->GetCData(XFA_ATTRIBUTE_Name) : nullptr);
}
WideString CXFA_NodeLocale::GetNumbericSymbol(FX_LOCALENUMSYMBOL eType) const {
@@ -71,7 +71,7 @@ WideString CXFA_NodeLocale::GetDateTimeSymbols() const {
CXFA_Node* pSymbols =
m_pLocale ? m_pLocale->GetChild(0, XFA_Element::DateTimeSymbols)
: nullptr;
- return pSymbols ? pSymbols->GetContent() : WideString();
+ return pSymbols ? pSymbols->JSNode()->GetContent() : WideString();
}
WideString CXFA_NodeLocale::GetMonthName(int32_t nMonth, bool bAbbr) const {
@@ -136,7 +136,7 @@ CXFA_Node* CXFA_NodeLocale::GetNodeByName(CXFA_Node* pParent,
pParent ? pParent->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr;
while (pChild) {
WideString wsChild;
- if (pChild->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) {
+ if (pChild->JSNode()->GetAttribute(XFA_ATTRIBUTE_Name, wsChild)) {
if (wsChild == wsName)
return pChild;
}
@@ -149,7 +149,7 @@ WideString CXFA_NodeLocale::GetSymbol(XFA_Element eElement,
const WideStringView& symbol_type) const {
CXFA_Node* pSymbols = m_pLocale ? m_pLocale->GetChild(0, eElement) : nullptr;
CXFA_Node* pSymbol = GetNodeByName(pSymbols, symbol_type);
- return pSymbol ? pSymbol->GetContent() : WideString();
+ return pSymbol ? pSymbol->JSNode()->GetContent() : WideString();
}
WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
@@ -163,9 +163,9 @@ WideString CXFA_NodeLocale::GetCalendarSymbol(XFA_Element eElement,
CXFA_Node* pNode = pCalendar->GetFirstChildByClass(eElement);
for (; pNode; pNode = pNode->GetNextSameClassSibling(eElement)) {
- if (pNode->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) {
+ if (pNode->JSNode()->GetBoolean(XFA_ATTRIBUTE_Abbr) == bAbbr) {
CXFA_Node* pSymbol = pNode->GetChild(index, XFA_Element::Unknown);
- return pSymbol ? pSymbol->GetContent() : WideString();
+ return pSymbol ? pSymbol->JSNode()->GetContent() : WideString();
}
}
return WideString();
diff --git a/xfa/fxfa/parser/cxfa_occur.cpp b/xfa/fxfa/parser/cxfa_occur.cpp
index ddce8d6422..6c770d2e72 100644
--- a/xfa/fxfa/parser/cxfa_occur.cpp
+++ b/xfa/fxfa/parser/cxfa_occur.cpp
@@ -13,7 +13,7 @@ CXFA_Occur::CXFA_Occur(CXFA_Node* pNode) : CXFA_Data(pNode) {}
int32_t CXFA_Occur::GetMax() {
int32_t iMax = 1;
if (m_pNode) {
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, true))
+ if (!m_pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Max, iMax, true))
iMax = GetMin();
}
return iMax;
@@ -22,7 +22,8 @@ int32_t CXFA_Occur::GetMax() {
int32_t CXFA_Occur::GetMin() {
int32_t iMin = 1;
if (m_pNode) {
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, true) || iMin < 0)
+ if (!m_pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Min, iMin, true) ||
+ iMin < 0)
iMin = 1;
}
return iMin;
@@ -31,15 +32,16 @@ int32_t CXFA_Occur::GetMin() {
bool CXFA_Occur::GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit) {
if (!m_pNode)
return false;
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, false) || iMin < 0)
+ if (!m_pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Min, iMin, false) ||
+ iMin < 0)
iMin = 1;
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false)) {
+ if (!m_pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Max, iMax, false)) {
if (iMin == 0)
iMax = 1;
else
iMax = iMin;
}
- if (!m_pNode->TryInteger(XFA_ATTRIBUTE_Initial, iInit, false) ||
+ if (!m_pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Initial, iInit, false) ||
iInit < iMin) {
iInit = iMin;
}
@@ -48,20 +50,20 @@ bool CXFA_Occur::GetOccurInfo(int32_t& iMin, int32_t& iMax, int32_t& iInit) {
void CXFA_Occur::SetMax(int32_t iMax) {
iMax = (iMax != -1 && iMax < 1) ? 1 : iMax;
- m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, false);
+ m_pNode->JSNode()->SetInteger(XFA_ATTRIBUTE_Max, iMax, false);
int32_t iMin = GetMin();
if (iMax != -1 && iMax < iMin) {
iMin = iMax;
- m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, false);
+ m_pNode->JSNode()->SetInteger(XFA_ATTRIBUTE_Min, iMin, false);
}
}
void CXFA_Occur::SetMin(int32_t iMin) {
iMin = (iMin < 0) ? 1 : iMin;
- m_pNode->SetInteger(XFA_ATTRIBUTE_Min, iMin, false);
+ m_pNode->JSNode()->SetInteger(XFA_ATTRIBUTE_Min, iMin, false);
int32_t iMax = GetMax();
if (iMax > 0 && iMax < iMin) {
iMax = iMin;
- m_pNode->SetInteger(XFA_ATTRIBUTE_Max, iMax, false);
+ m_pNode->JSNode()->SetInteger(XFA_ATTRIBUTE_Max, iMax, false);
}
}
diff --git a/xfa/fxfa/parser/cxfa_para.cpp b/xfa/fxfa/parser/cxfa_para.cpp
index c3d55f2164..174563bc64 100644
--- a/xfa/fxfa/parser/cxfa_para.cpp
+++ b/xfa/fxfa/parser/cxfa_para.cpp
@@ -13,48 +13,48 @@ CXFA_Para::CXFA_Para(CXFA_Node* pNode) : CXFA_Data(pNode) {}
int32_t CXFA_Para::GetHorizontalAlign() {
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Left;
- m_pNode->TryEnum(XFA_ATTRIBUTE_HAlign, eAttr);
+ m_pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_HAlign, eAttr);
return eAttr;
}
int32_t CXFA_Para::GetVerticalAlign() {
XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Top;
- m_pNode->TryEnum(XFA_ATTRIBUTE_VAlign, eAttr);
+ m_pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_VAlign, eAttr);
return eAttr;
}
float CXFA_Para::GetLineHeight() {
CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_LineHeight, ms);
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_LineHeight, ms);
return ms.ToUnit(XFA_UNIT_Pt);
}
float CXFA_Para::GetMarginLeft() {
CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginLeft, ms);
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_MarginLeft, ms);
return ms.ToUnit(XFA_UNIT_Pt);
}
float CXFA_Para::GetMarginRight() {
CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_MarginRight, ms);
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_MarginRight, ms);
return ms.ToUnit(XFA_UNIT_Pt);
}
float CXFA_Para::GetSpaceAbove() {
CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceAbove, ms);
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_SpaceAbove, ms);
return ms.ToUnit(XFA_UNIT_Pt);
}
float CXFA_Para::GetSpaceBelow() {
CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_SpaceBelow, ms);
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_SpaceBelow, ms);
return ms.ToUnit(XFA_UNIT_Pt);
}
float CXFA_Para::GetTextIndent() {
CXFA_Measurement ms;
- m_pNode->TryMeasure(XFA_ATTRIBUTE_TextIndent, ms);
+ m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_TextIndent, ms);
return ms.ToUnit(XFA_UNIT_Pt);
}
diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
index a72ad7b3f6..a09456a7a4 100644
--- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
@@ -343,13 +343,14 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
CXFA_Node* pInstanceManager =
curNode->AsNode()->GetInstanceMgrOfSubform();
if (pInstanceManager) {
- pProp = pInstanceManager->GetProperty(0, XFA_Element::Occur, true);
+ pProp = pInstanceManager->JSNode()->GetProperty(0, XFA_Element::Occur,
+ true);
}
} else {
XFA_Element eType = XFA_GetElementTypeForName(wsName.AsStringView());
if (eType != XFA_Element::Unknown) {
- pProp = curNode->AsNode()->GetProperty(0, eType,
- eType != XFA_Element::PageSet);
+ pProp = curNode->AsNode()->JSNode()->GetProperty(
+ 0, eType, eType != XFA_Element::PageSet);
}
}
if (pProp) {
diff --git a/xfa/fxfa/parser/cxfa_script.cpp b/xfa/fxfa/parser/cxfa_script.cpp
index 6b6f6ba1c8..c548dea394 100644
--- a/xfa/fxfa/parser/cxfa_script.cpp
+++ b/xfa/fxfa/parser/cxfa_script.cpp
@@ -12,7 +12,7 @@ CXFA_Script::CXFA_Script(CXFA_Node* pNode) : CXFA_Data(pNode) {}
XFA_SCRIPTTYPE CXFA_Script::GetContentType() {
WideStringView cData;
- if (m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, cData, false)) {
+ if (m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_ContentType, cData, false)) {
if (cData == L"application/x-javascript")
return XFA_SCRIPTTYPE_Javascript;
if (cData == L"application/x-formcalc")
@@ -23,9 +23,9 @@ XFA_SCRIPTTYPE CXFA_Script::GetContentType() {
}
int32_t CXFA_Script::GetRunAt() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_RunAt);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_RunAt);
}
void CXFA_Script::GetExpression(WideString& wsExpression) {
- m_pNode->TryContent(wsExpression);
+ m_pNode->JSNode()->TryContent(wsExpression);
}
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 4574ae48d7..9d3f2b0222 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -353,11 +353,11 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode,
CFX_XMLElement* child = static_cast<CFX_XMLElement*>(pXMLChild);
WideString wsNodeStr = child->GetLocalTagName();
- pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr);
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr);
WideString wsChildValue;
XFA_GetPlainTextFromRichText(child, wsChildValue);
if (!wsChildValue.IsEmpty())
- pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsChildValue);
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsChildValue);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLChild);
@@ -458,14 +458,14 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
return nullptr;
m_pRootNode = pXFARootNode;
- pXFARootNode->SetCData(XFA_ATTRIBUTE_Name, L"xfa");
+ pXFARootNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name, L"xfa");
CFX_XMLElement* pElement = static_cast<CFX_XMLElement*>(pXMLDocumentNode);
for (auto it : pElement->GetAttributes()) {
if (it.first == L"uuid")
- pXFARootNode->SetCData(XFA_ATTRIBUTE_Uuid, it.second);
+ pXFARootNode->JSNode()->SetCData(XFA_ATTRIBUTE_Uuid, it.second);
else if (it.first == L"timeStamp")
- pXFARootNode->SetCData(XFA_ATTRIBUTE_TimeStamp, it.second);
+ pXFARootNode->JSNode()->SetCData(XFA_ATTRIBUTE_TimeStamp, it.second);
}
CFX_XMLNode* pXMLConfigDOMRoot = nullptr;
@@ -583,8 +583,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Config(
if (!pNode)
return nullptr;
- pNode->SetCData(XFA_ATTRIBUTE_Name,
- XFA_GetPacketByIndex(XFA_PACKET_Config)->pName);
+ pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name,
+ XFA_GetPacketByIndex(XFA_PACKET_Config)->pName);
if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, true))
return nullptr;
@@ -606,8 +606,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm(
if (!pNode)
return nullptr;
- pNode->SetCData(XFA_ATTRIBUTE_Name,
- XFA_GetPacketByIndex(XFA_PACKET_Template)->pName);
+ pNode->JSNode()->SetCData(
+ XFA_ATTRIBUTE_Name, XFA_GetPacketByIndex(XFA_PACKET_Template)->pName);
if (m_bDocumentParser) {
CFX_XMLElement* pXMLDocumentElement =
static_cast<CFX_XMLElement*>(pXMLDocumentNode);
@@ -648,9 +648,10 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm(
if (!pNode)
return nullptr;
- pNode->SetCData(XFA_ATTRIBUTE_Name,
- XFA_GetPacketByIndex(XFA_PACKET_Form)->pName);
- pNode->SetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum.AsStringView());
+ pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name,
+ XFA_GetPacketByIndex(XFA_PACKET_Form)->pName);
+ pNode->JSNode()->SetAttribute(XFA_ATTRIBUTE_Checksum,
+ wsChecksum.AsStringView());
CXFA_Node* pTemplateRoot =
m_pRootNode->GetFirstChildByClass(XFA_Element::Template);
CXFA_Node* pTemplateChosen =
@@ -659,7 +660,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_TemplateForm(
: nullptr;
bool bUseAttribute = true;
if (pTemplateChosen &&
- pTemplateChosen->GetEnum(XFA_ATTRIBUTE_RestoreState) !=
+ pTemplateChosen->JSNode()->GetEnum(XFA_ATTRIBUTE_RestoreState) !=
XFA_ATTRIBUTEENUM_Auto) {
bUseAttribute = false;
}
@@ -683,8 +684,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
if (!pNode)
return nullptr;
- pNode->SetCData(XFA_ATTRIBUTE_Name,
- XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName);
+ pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name,
+ XFA_GetPacketByIndex(XFA_PACKET_Datasets)->pName);
if (!DataLoader(pNode, pDatasetsXMLNode, false))
return nullptr;
@@ -725,7 +726,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
}
WideString wsLocalName =
static_cast<CFX_XMLElement*>(pDataXMLNode)->GetLocalTagName();
- pNode->SetCData(XFA_ATTRIBUTE_Name, wsLocalName);
+ pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsLocalName);
if (!DataLoader(pNode, pDataXMLNode, true))
return nullptr;
@@ -751,8 +752,9 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet(
if (!pNode)
return nullptr;
- pNode->SetCData(XFA_ATTRIBUTE_Name,
- XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName);
+ pNode->JSNode()->SetCData(
+ XFA_ATTRIBUTE_Name,
+ XFA_GetPacketByIndex(XFA_PACKET_LocaleSet)->pName);
if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, true))
return nullptr;
}
@@ -766,8 +768,9 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet(
if (!pNode)
return nullptr;
- pNode->SetCData(XFA_ATTRIBUTE_Name,
- XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName);
+ pNode->JSNode()->SetCData(
+ XFA_ATTRIBUTE_Name,
+ XFA_GetPacketByIndex(XFA_PACKET_ConnectionSet)->pName);
if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, true))
return nullptr;
}
@@ -781,8 +784,9 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet(
if (!pNode)
return nullptr;
- pNode->SetCData(XFA_ATTRIBUTE_Name,
- XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName);
+ pNode->JSNode()->SetCData(
+ XFA_ATTRIBUTE_Name,
+ XFA_GetPacketByIndex(XFA_PACKET_SourceSet)->pName);
if (!NormalLoader(pNode, pXMLDocumentNode, ePacketID, true))
return nullptr;
}
@@ -806,8 +810,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Xdc(
if (!pNode)
return nullptr;
- pNode->SetCData(XFA_ATTRIBUTE_Name,
- XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName);
+ pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name,
+ XFA_GetPacketByIndex(XFA_PACKET_Xdc)->pName);
pNode->SetXMLMappingNode(pXMLDocumentNode);
return pNode;
}
@@ -822,7 +826,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_User(
WideString wsName =
static_cast<CFX_XMLElement*>(pXMLDocumentNode)->GetLocalTagName();
- pNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
+ pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsName);
if (!UserPacketLoader(pNode, pXMLDocumentNode))
return nullptr;
@@ -871,8 +875,10 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
CXFA_Node* pXFAChild = m_pFactory->CreateNode(ePacketID, eType);
if (!pXFAChild)
return nullptr;
- if (ePacketID == XFA_XDPPACKET_Config)
- pXFAChild->SetAttribute(XFA_ATTRIBUTE_Name, wsTagName.AsStringView());
+ if (ePacketID == XFA_XDPPACKET_Config) {
+ pXFAChild->JSNode()->SetAttribute(XFA_ATTRIBUTE_Name,
+ wsTagName.AsStringView());
+ }
bool IsNeedValue = true;
for (auto it : pXMLElement->GetAttributes()) {
@@ -890,7 +896,8 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
lpAttrInfo->eName != XFA_ATTRIBUTE_Save) {
continue;
}
- pXFAChild->SetAttribute(lpAttrInfo->eName, it.second.AsStringView());
+ pXFAChild->JSNode()->SetAttribute(lpAttrInfo->eName,
+ it.second.AsStringView());
}
pXFANode->InsertChild(pXFAChild);
if (eType == XFA_Element::Validate || eType == XFA_Element::Locale) {
@@ -931,7 +938,7 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode,
XFA_Element element = XFA_Element::Sharptext;
if (pXFANode->GetElementType() == XFA_Element::ExData) {
WideStringView wsContentType =
- pXFANode->GetCData(XFA_ATTRIBUTE_ContentType);
+ pXFANode->JSNode()->GetCData(XFA_ATTRIBUTE_ContentType);
if (wsContentType == L"text/html")
element = XFA_Element::SharpxHTML;
else if (wsContentType == L"text/xml")
@@ -973,10 +980,10 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode,
CXFA_Node* pContentRawDataNode =
m_pFactory->CreateNode(ePacketID, element);
ASSERT(pContentRawDataNode);
- pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsValue);
+ pContentRawDataNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsValue);
pXFANode->InsertChild(pContentRawDataNode);
} else {
- pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsValue);
+ pXFANode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsValue);
}
}
}
@@ -1042,7 +1049,8 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->SetCData(XFA_ATTRIBUTE_Name, pXMLElement->GetLocalTagName());
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Name,
+ pXMLElement->GetLocalTagName());
bool bNeedValue = true;
for (auto it : pXMLElement->GetAttributes()) {
@@ -1067,11 +1075,12 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
if (!pXFAMetaData)
return;
- pXFAMetaData->SetCData(XFA_ATTRIBUTE_Name, wsName);
- pXFAMetaData->SetCData(XFA_ATTRIBUTE_QualifiedName, it.first);
- pXFAMetaData->SetCData(XFA_ATTRIBUTE_Value, it.second);
- pXFAMetaData->SetEnum(XFA_ATTRIBUTE_Contains,
- XFA_ATTRIBUTEENUM_MetaData);
+ pXFAMetaData->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsName);
+ pXFAMetaData->JSNode()->SetCData(XFA_ATTRIBUTE_QualifiedName,
+ it.first);
+ pXFAMetaData->JSNode()->SetCData(XFA_ATTRIBUTE_Value, it.second);
+ pXFAMetaData->JSNode()->SetEnum(XFA_ATTRIBUTE_Contains,
+ XFA_ATTRIBUTEENUM_MetaData);
pXFAChild->InsertChild(pXFAMetaData);
pXFAMetaData->SetXMLMappingNode(pXMLElement);
pXFAMetaData->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1103,7 +1112,7 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsText);
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsText);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLText);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1153,8 +1162,8 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->SetCData(XFA_ATTRIBUTE_Name, L"");
- pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCurValue);
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Name, L"");
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsCurValue);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLCurValueNode);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1170,12 +1179,13 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
WideString wsNodeStr =
static_cast<CFX_XMLElement*>(pXMLChild)->GetLocalTagName();
- pXFAChild->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr);
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsNodeStr);
ParseDataValue(pXFAChild, pXMLChild, ePacketID);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLChild);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
- WideStringView wsCurValue = pXFAChild->GetCData(XFA_ATTRIBUTE_Value);
+ WideStringView wsCurValue =
+ pXFAChild->JSNode()->GetCData(XFA_ATTRIBUTE_Value);
wsValueTextBuf << wsCurValue;
}
}
@@ -1188,8 +1198,8 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
if (!pXFAChild)
return;
- pXFAChild->SetCData(XFA_ATTRIBUTE_Name, L"");
- pXFAChild->SetCData(XFA_ATTRIBUTE_Value, wsCurValue);
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Name, L"");
+ pXFAChild->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsCurValue);
pXFANode->InsertChild(pXFAChild);
pXFAChild->SetXMLMappingNode(pXMLCurValueNode);
pXFAChild->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1200,7 +1210,7 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
pXMLCurValueNode = nullptr;
}
WideString wsNodeValue = wsValueTextBuf.MakeString();
- pXFANode->SetCData(XFA_ATTRIBUTE_Value, wsNodeValue);
+ pXFANode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsNodeValue);
}
void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode,
diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp
index f1319340a0..7cf0b2c5fd 100644
--- a/xfa/fxfa/parser/cxfa_stroke.cpp
+++ b/xfa/fxfa/parser/cxfa_stroke.cpp
@@ -11,18 +11,18 @@
#include "xfa/fxfa/parser/xfa_utils.h"
int32_t CXFA_Stroke::GetPresence() const {
- return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence)
+ return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Presence)
: XFA_ATTRIBUTEENUM_Invisible;
}
int32_t CXFA_Stroke::GetCapType() const {
if (!m_pNode)
return XFA_ATTRIBUTEENUM_Square;
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Cap);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Cap);
}
int32_t CXFA_Stroke::GetStrokeType() const {
- return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Stroke)
+ return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Stroke)
: XFA_ATTRIBUTEENUM_Solid;
}
@@ -31,7 +31,7 @@ float CXFA_Stroke::GetThickness() const {
}
CXFA_Measurement CXFA_Stroke::GetMSThickness() const {
- return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Thickness)
+ return m_pNode ? m_pNode->JSNode()->GetMeasure(XFA_ATTRIBUTE_Thickness)
: XFA_GetAttributeDefaultValue_Measure(XFA_Element::Edge,
XFA_ATTRIBUTE_Thickness,
XFA_XDPPACKET_Form);
@@ -41,7 +41,7 @@ void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) {
if (!m_pNode)
return;
- m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness);
+ m_pNode->JSNode()->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness);
}
FX_ARGB CXFA_Stroke::GetColor() const {
@@ -53,7 +53,7 @@ FX_ARGB CXFA_Stroke::GetColor() const {
return 0xFF000000;
WideStringView wsColor;
- pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor);
+ pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor);
return CXFA_Data::ToColor(wsColor);
}
@@ -61,7 +61,7 @@ void CXFA_Stroke::SetColor(FX_ARGB argb) {
if (!m_pNode)
return;
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Color);
+ CXFA_Node* pNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Color);
WideString wsColor;
int a;
int r;
@@ -69,20 +69,23 @@ void CXFA_Stroke::SetColor(FX_ARGB argb) {
int b;
std::tie(a, r, g, b) = ArgbDecode(argb);
wsColor.Format(L"%d,%d,%d", r, g, b);
- pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
+ pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsColor);
}
int32_t CXFA_Stroke::GetJoinType() const {
- return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Join)
+ return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Join)
: XFA_ATTRIBUTEENUM_Square;
}
bool CXFA_Stroke::IsInverted() const {
- return m_pNode ? m_pNode->GetBoolean(XFA_ATTRIBUTE_Inverted) : false;
+ return m_pNode ? m_pNode->JSNode()->GetBoolean(XFA_ATTRIBUTE_Inverted)
+ : false;
}
float CXFA_Stroke::GetRadius() const {
- return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Radius).ToUnit(XFA_UNIT_Pt)
+ return m_pNode ? m_pNode->JSNode()
+ ->GetMeasure(XFA_ATTRIBUTE_Radius)
+ .ToUnit(XFA_UNIT_Pt)
: 0;
}
diff --git a/xfa/fxfa/parser/cxfa_submit.cpp b/xfa/fxfa/parser/cxfa_submit.cpp
index 7fb04a3c64..c4fb22582c 100644
--- a/xfa/fxfa/parser/cxfa_submit.cpp
+++ b/xfa/fxfa/parser/cxfa_submit.cpp
@@ -11,17 +11,17 @@
CXFA_Submit::CXFA_Submit(CXFA_Node* pNode) : CXFA_Data(pNode) {}
bool CXFA_Submit::IsSubmitEmbedPDF() {
- return m_pNode->GetBoolean(XFA_ATTRIBUTE_EmbedPDF);
+ return m_pNode->JSNode()->GetBoolean(XFA_ATTRIBUTE_EmbedPDF);
}
int32_t CXFA_Submit::GetSubmitFormat() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_Format);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Format);
}
void CXFA_Submit::GetSubmitTarget(WideStringView& wsTarget) {
- m_pNode->TryCData(XFA_ATTRIBUTE_Target, wsTarget);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Target, wsTarget);
}
void CXFA_Submit::GetSubmitXDPContent(WideStringView& wsContent) {
- m_pNode->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent);
+ m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_XdpContent, wsContent);
}
diff --git a/xfa/fxfa/parser/cxfa_text.cpp b/xfa/fxfa/parser/cxfa_text.cpp
index cab11a6892..9d743fa518 100644
--- a/xfa/fxfa/parser/cxfa_text.cpp
+++ b/xfa/fxfa/parser/cxfa_text.cpp
@@ -11,5 +11,5 @@
CXFA_Text::CXFA_Text(CXFA_Node* pNode) : CXFA_Data(pNode) {}
void CXFA_Text::GetContent(WideString& wsText) {
- m_pNode->TryContent(wsText);
+ m_pNode->JSNode()->TryContent(wsText);
}
diff --git a/xfa/fxfa/parser/cxfa_tooltip.cpp b/xfa/fxfa/parser/cxfa_tooltip.cpp
index 9561ef2ac5..fed28d0f32 100644
--- a/xfa/fxfa/parser/cxfa_tooltip.cpp
+++ b/xfa/fxfa/parser/cxfa_tooltip.cpp
@@ -11,5 +11,5 @@
CXFA_ToolTip::CXFA_ToolTip(CXFA_Node* pNode) : CXFA_Data(pNode) {}
bool CXFA_ToolTip::GetTip(WideString& wsTip) {
- return m_pNode->TryContent(wsTip);
+ return m_pNode->JSNode()->TryContent(wsTip);
}
diff --git a/xfa/fxfa/parser/cxfa_validate.cpp b/xfa/fxfa/parser/cxfa_validate.cpp
index fc472741a9..5f784259d2 100644
--- a/xfa/fxfa/parser/cxfa_validate.cpp
+++ b/xfa/fxfa/parser/cxfa_validate.cpp
@@ -12,7 +12,7 @@
CXFA_Validate::CXFA_Validate(CXFA_Node* pNode) : CXFA_Data(pNode) {}
int32_t CXFA_Validate::GetFormatTest() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_FormatTest);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_FormatTest);
}
bool CXFA_Validate::SetTestValue(int32_t iType,
@@ -23,7 +23,7 @@ bool CXFA_Validate::SetTestValue(int32_t iType,
if (pInfo)
eName = pInfo->eName;
- m_pNode->SetEnum((XFA_ATTRIBUTE)iType, eName, false);
+ m_pNode->JSNode()->SetEnum((XFA_ATTRIBUTE)iType, eName, false);
return true;
}
@@ -33,16 +33,17 @@ bool CXFA_Validate::SetNullTest(WideString wsValue) {
}
int32_t CXFA_Validate::GetNullTest() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_NullTest);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_NullTest);
}
int32_t CXFA_Validate::GetScriptTest() {
- return m_pNode->GetEnum(XFA_ATTRIBUTE_ScriptTest);
+ return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_ScriptTest);
}
void CXFA_Validate::GetMessageText(WideString& wsMessage,
const WideString& wsMessageType) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Message, false);
+ CXFA_Node* pNode =
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Message, false);
if (!pNode)
return;
@@ -53,9 +54,9 @@ void CXFA_Validate::GetMessageText(WideString& wsMessage,
continue;
WideStringView wsName;
- pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ pItemNode->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName);
if (wsName.IsEmpty() || wsName == wsMessageType) {
- pItemNode->TryContent(wsMessage);
+ pItemNode->JSNode()->TryContent(wsMessage);
return;
}
}
@@ -79,7 +80,8 @@ void CXFA_Validate::GetNullMessageText(WideString& wsMessage) {
void CXFA_Validate::SetMessageText(WideString& wsMessage,
const WideString& wsMessageType) {
- CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Message, true);
+ CXFA_Node* pNode =
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Message, true);
if (!pNode)
return;
@@ -90,16 +92,16 @@ void CXFA_Validate::SetMessageText(WideString& wsMessage,
continue;
WideStringView wsName;
- pItemNode->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ pItemNode->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName);
if (wsName.IsEmpty() || wsName == wsMessageType) {
- pItemNode->SetContent(wsMessage, wsMessage, false);
+ pItemNode->JSNode()->SetContent(wsMessage, wsMessage, false);
return;
}
}
CXFA_Node* pTextNode = pNode->CreateSamePacketNode(XFA_Element::Text);
pNode->InsertChild(pTextNode);
- pTextNode->SetCData(XFA_ATTRIBUTE_Name, wsMessageType, false);
- pTextNode->SetContent(wsMessage, wsMessage, false);
+ pTextNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsMessageType, false);
+ pTextNode->JSNode()->SetContent(wsMessage, wsMessage, false);
}
void CXFA_Validate::GetScriptMessageText(WideString& wsMessage) {
@@ -112,7 +114,7 @@ void CXFA_Validate::SetScriptMessageText(WideString wsMessage) {
void CXFA_Validate::GetPicture(WideString& wsPicture) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Picture))
- pNode->TryContent(wsPicture);
+ pNode->JSNode()->TryContent(wsPicture);
}
CXFA_Script CXFA_Validate::GetScript() {
diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp
index abf55da260..2b32e9d25e 100644
--- a/xfa/fxfa/parser/cxfa_value.cpp
+++ b/xfa/fxfa/parser/cxfa_value.cpp
@@ -20,7 +20,7 @@ bool CXFA_Value::GetChildValueContent(WideString& wsContent) {
if (!m_pNode)
return false;
if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild))
- return pNode->TryContent(wsContent);
+ return pNode->JSNode()->TryContent(wsContent);
return false;
}
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 13ccf2b824..2704189b22 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -69,7 +69,8 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
eWidgetType = XFA_Element::Unknown;
XFA_Element eUIType = XFA_Element::Unknown;
- CXFA_Value defValue(pNode->GetProperty(0, XFA_Element::Value, true));
+ CXFA_Value defValue(
+ pNode->JSNode()->GetProperty(0, XFA_Element::Value, true));
XFA_Element eValueType = defValue.GetChildValueClassID();
switch (eValueType) {
case XFA_Element::Boolean:
@@ -105,7 +106,7 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
}
CXFA_Node* pUIChild = nullptr;
- CXFA_Node* pUI = pNode->GetProperty(0, XFA_Element::Ui, true);
+ CXFA_Node* pUI = pNode->JSNode()->GetProperty(0, XFA_Element::Ui, true);
CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
XFA_Element eChildType = pChild->GetElementType();
@@ -150,9 +151,9 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
if (!pUIChild) {
if (eUIType == XFA_Element::Unknown) {
eUIType = XFA_Element::TextEdit;
- defValue.GetNode()->GetProperty(0, XFA_Element::Text, true);
+ defValue.GetNode()->JSNode()->GetProperty(0, XFA_Element::Text, true);
}
- return pUI->GetProperty(0, eUIType, true);
+ return pUI->JSNode()->GetProperty(0, eUIType, true);
}
if (eUIType != XFA_Element::Unknown)
@@ -177,7 +178,7 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
eValueType = XFA_Element::Float;
break;
case XFA_Element::ChoiceList: {
- eValueType = (pUIChild->GetEnum(XFA_ATTRIBUTE_Open) ==
+ eValueType = (pUIChild->JSNode()->GetEnum(XFA_ATTRIBUTE_Open) ==
XFA_ATTRIBUTEENUM_MultiSelect)
? XFA_Element::ExData
: XFA_Element::Text;
@@ -192,7 +193,7 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) {
eValueType = XFA_Element::Text;
break;
}
- defValue.GetNode()->GetProperty(0, eValueType, true);
+ defValue.GetNode()->JSNode()->GetProperty(0, eValueType, true);
return pUIChild;
}
@@ -252,13 +253,13 @@ XFA_Element CXFA_WidgetData::GetUIType() {
}
WideString CXFA_WidgetData::GetRawValue() {
- return m_pNode->GetContent();
+ return m_pNode->JSNode()->GetContent();
}
int32_t CXFA_WidgetData::GetAccess() {
CXFA_Node* pNode = m_pNode;
while (pNode) {
- int32_t iAcc = pNode->GetEnum(XFA_ATTRIBUTE_Access);
+ int32_t iAcc = pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Access);
if (iAcc != XFA_ATTRIBUTEENUM_Open)
return iAcc;
@@ -270,7 +271,7 @@ int32_t CXFA_WidgetData::GetAccess() {
int32_t CXFA_WidgetData::GetRotate() {
CXFA_Measurement ms;
- if (!m_pNode->TryMeasure(XFA_ATTRIBUTE_Rotate, ms, false))
+ if (!m_pNode->JSNode()->TryMeasure(XFA_ATTRIBUTE_Rotate, ms, false))
return 0;
int32_t iRotate = FXSYS_round(ms.GetValue());
@@ -279,23 +280,27 @@ int32_t CXFA_WidgetData::GetRotate() {
}
CXFA_Border CXFA_WidgetData::GetBorder(bool bModified) {
- return CXFA_Border(m_pNode->GetProperty(0, XFA_Element::Border, bModified));
+ return CXFA_Border(
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Border, bModified));
}
CXFA_Caption CXFA_WidgetData::GetCaption() {
- return CXFA_Caption(m_pNode->GetProperty(0, XFA_Element::Caption, false));
+ return CXFA_Caption(
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Caption, false));
}
CXFA_Font CXFA_WidgetData::GetFont(bool bModified) {
- return CXFA_Font(m_pNode->GetProperty(0, XFA_Element::Font, bModified));
+ return CXFA_Font(
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Font, bModified));
}
CXFA_Margin CXFA_WidgetData::GetMargin() {
- return CXFA_Margin(m_pNode->GetProperty(0, XFA_Element::Margin, false));
+ return CXFA_Margin(
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Margin, false));
}
CXFA_Para CXFA_WidgetData::GetPara() {
- return CXFA_Para(m_pNode->GetProperty(0, XFA_Element::Para, false));
+ return CXFA_Para(m_pNode->JSNode()->GetProperty(0, XFA_Element::Para, false));
}
std::vector<CXFA_Node*> CXFA_WidgetData::GetEventList() {
@@ -329,28 +334,32 @@ std::vector<CXFA_Node*> CXFA_WidgetData::GetEventByActivity(int32_t iActivity,
CXFA_Value CXFA_WidgetData::GetDefaultValue() {
CXFA_Node* pTemNode = m_pNode->GetTemplateNode();
return CXFA_Value(
- pTemNode ? pTemNode->GetProperty(0, XFA_Element::Value, false) : nullptr);
+ pTemNode ? pTemNode->JSNode()->GetProperty(0, XFA_Element::Value, false)
+ : nullptr);
}
CXFA_Value CXFA_WidgetData::GetFormValue() {
- return CXFA_Value(m_pNode->GetProperty(0, XFA_Element::Value, false));
+ return CXFA_Value(
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Value, false));
}
CXFA_Calculate CXFA_WidgetData::GetCalculate() {
- return CXFA_Calculate(m_pNode->GetProperty(0, XFA_Element::Calculate, false));
+ return CXFA_Calculate(
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Calculate, false));
}
CXFA_Validate CXFA_WidgetData::GetValidate(bool bModified) {
return CXFA_Validate(
- m_pNode->GetProperty(0, XFA_Element::Validate, bModified));
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Validate, bModified));
}
CXFA_Bind CXFA_WidgetData::GetBind() {
- return CXFA_Bind(m_pNode->GetProperty(0, XFA_Element::Bind, false));
+ return CXFA_Bind(m_pNode->JSNode()->GetProperty(0, XFA_Element::Bind, false));
}
CXFA_Assist CXFA_WidgetData::GetAssist() {
- return CXFA_Assist(m_pNode->GetProperty(0, XFA_Element::Assist, false));
+ return CXFA_Assist(
+ m_pNode->JSNode()->GetProperty(0, XFA_Element::Assist, false));
}
bool CXFA_WidgetData::GetWidth(float& fWidth) {
@@ -379,15 +388,15 @@ bool CXFA_WidgetData::GetMaxHeight(float& fMaxHeight) {
CXFA_Border CXFA_WidgetData::GetUIBorder() {
CXFA_Node* pUIChild = GetUIChild();
- return CXFA_Border(pUIChild
- ? pUIChild->GetProperty(0, XFA_Element::Border, false)
- : nullptr);
+ return CXFA_Border(
+ pUIChild ? pUIChild->JSNode()->GetProperty(0, XFA_Element::Border, false)
+ : nullptr);
}
CFX_RectF CXFA_WidgetData::GetUIMargin() {
CXFA_Node* pUIChild = GetUIChild();
CXFA_Margin mgUI = CXFA_Margin(
- pUIChild ? pUIChild->GetProperty(0, XFA_Element::Margin, false)
+ pUIChild ? pUIChild->JSNode()->GetProperty(0, XFA_Element::Margin, false)
: nullptr);
if (!mgUI)
@@ -425,7 +434,7 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() {
int32_t CXFA_WidgetData::GetButtonHighlight() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetEnum(XFA_ATTRIBUTE_Highlight);
+ return pUIChild->JSNode()->GetEnum(XFA_ATTRIBUTE_Highlight);
return GetAttributeDefaultValue_Enum(
XFA_Element::Button, XFA_ATTRIBUTE_Highlight, XFA_XDPPACKET_Form);
}
@@ -436,9 +445,9 @@ bool CXFA_WidgetData::GetButtonRollover(WideString& wsRollover,
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pText) {
WideStringView wsName;
- pText->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ pText->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName);
if (wsName == L"rollover") {
- pText->TryContent(wsRollover);
+ pText->JSNode()->TryContent(wsRollover);
bRichText = pText->GetElementType() == XFA_Element::ExData;
return !wsRollover.IsEmpty();
}
@@ -453,9 +462,9 @@ bool CXFA_WidgetData::GetButtonDown(WideString& wsDown, bool& bRichText) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pText) {
WideStringView wsName;
- pText->TryCData(XFA_ATTRIBUTE_Name, wsName);
+ pText->JSNode()->TryCData(XFA_ATTRIBUTE_Name, wsName);
if (wsName == L"down") {
- pText->TryContent(wsDown);
+ pText->JSNode()->TryContent(wsDown);
bRichText = pText->GetElementType() == XFA_Element::ExData;
return !wsDown.IsEmpty();
}
@@ -468,7 +477,7 @@ bool CXFA_WidgetData::GetButtonDown(WideString& wsDown, bool& bRichText) {
int32_t CXFA_WidgetData::GetCheckButtonShape() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetEnum(XFA_ATTRIBUTE_Shape);
+ return pUIChild->JSNode()->GetEnum(XFA_ATTRIBUTE_Shape);
return GetAttributeDefaultValue_Enum(XFA_Element::CheckButton,
XFA_ATTRIBUTE_Shape, XFA_XDPPACKET_Form);
}
@@ -476,7 +485,7 @@ int32_t CXFA_WidgetData::GetCheckButtonShape() {
int32_t CXFA_WidgetData::GetCheckButtonMark() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetEnum(XFA_ATTRIBUTE_Mark);
+ return pUIChild->JSNode()->GetEnum(XFA_ATTRIBUTE_Mark);
return GetAttributeDefaultValue_Enum(XFA_Element::CheckButton,
XFA_ATTRIBUTE_Mark, XFA_XDPPACKET_Form);
}
@@ -490,7 +499,9 @@ bool CXFA_WidgetData::IsRadioButton() {
float CXFA_WidgetData::GetCheckButtonSize() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetMeasure(XFA_ATTRIBUTE_Size).ToUnit(XFA_UNIT_Pt);
+ 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);
@@ -499,7 +510,7 @@ float CXFA_WidgetData::GetCheckButtonSize() {
bool CXFA_WidgetData::IsAllowNeutral() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetBoolean(XFA_ATTRIBUTE_AllowNeutral);
+ return pUIChild->JSNode()->GetBoolean(XFA_ATTRIBUTE_AllowNeutral);
return GetAttributeDefaultValue_Boolean(
XFA_Element::CheckButton, XFA_ATTRIBUTE_AllowNeutral, XFA_XDPPACKET_Form);
}
@@ -514,7 +525,7 @@ XFA_CHECKSTATE CXFA_WidgetData::GetCheckState() {
int32_t i = 0;
while (pText) {
WideString wsContent;
- if (pText->TryContent(wsContent) && (wsContent == wsValue))
+ if (pText->JSNode()->TryContent(wsContent) && (wsContent == wsValue))
return (XFA_CHECKSTATE)i;
i++;
@@ -532,7 +543,7 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
if (CXFA_Node* pItems = m_pNode->GetChild(0, XFA_Element::Items)) {
CXFA_Node* pText = pItems->GetNodeItem(XFA_NODEITEM_FirstChild);
if (pText)
- pText->TryContent(wsValue);
+ pText->JSNode()->TryContent(wsValue);
}
}
CXFA_Node* pChild =
@@ -549,12 +560,12 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
if (!pItemchild)
continue;
- WideString text = pItemchild->GetContent();
+ WideString text = pItemchild->JSNode()->GetContent();
WideString wsChildValue = text;
if (wsValue != text) {
pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling);
if (pItemchild)
- wsChildValue = pItemchild->GetContent();
+ wsChildValue = pItemchild->JSNode()->GetContent();
else
wsChildValue.clear();
}
@@ -573,7 +584,7 @@ void CXFA_WidgetData::SetCheckState(XFA_CHECKSTATE eCheckState, bool bNotify) {
while (pText) {
i++;
if (i == eCheckState) {
- pText->TryContent(wsContent);
+ pText->JSNode()->TryContent(wsContent);
break;
}
pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling);
@@ -638,22 +649,22 @@ void CXFA_WidgetData::SetSelectedMemberByValue(const WideStringView& wsValue,
if (!pItemchild)
continue;
- WideString wsChildValue = pItemchild->GetContent();
+ WideString wsChildValue = pItemchild->JSNode()->GetContent();
if (wsValue != wsChildValue) {
pItemchild = pItemchild->GetNodeItem(XFA_NODEITEM_NextSibling);
if (pItemchild)
- wsChildValue = pItemchild->GetContent();
+ wsChildValue = pItemchild->JSNode()->GetContent();
else
wsChildValue.clear();
} else {
wsExclGroup = wsValue;
}
- pNode->SetContent(wsChildValue, wsChildValue, bNotify, bScriptModify,
- false);
+ pNode->JSNode()->SetContent(wsChildValue, wsChildValue, bNotify,
+ bScriptModify, false);
}
if (m_pNode) {
- m_pNode->SetContent(wsExclGroup, wsExclGroup, bNotify, bScriptModify,
- bSyncData);
+ m_pNode->JSNode()->SetContent(wsExclGroup, wsExclGroup, bNotify,
+ bScriptModify, bSyncData);
}
}
@@ -688,7 +699,7 @@ CXFA_Node* CXFA_WidgetData::GetExclGroupNextMember(CXFA_Node* pNode) {
int32_t CXFA_WidgetData::GetChoiceListCommitOn() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetEnum(XFA_ATTRIBUTE_CommitOn);
+ return pUIChild->JSNode()->GetEnum(XFA_ATTRIBUTE_CommitOn);
return GetAttributeDefaultValue_Enum(
XFA_Element::ChoiceList, XFA_ATTRIBUTE_CommitOn, XFA_XDPPACKET_Form);
}
@@ -696,7 +707,7 @@ int32_t CXFA_WidgetData::GetChoiceListCommitOn() {
bool CXFA_WidgetData::IsChoiceListAllowTextEntry() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetBoolean(XFA_ATTRIBUTE_TextEntry);
+ return pUIChild->JSNode()->GetBoolean(XFA_ATTRIBUTE_TextEntry);
return GetAttributeDefaultValue_Boolean(
XFA_Element::ChoiceList, XFA_ATTRIBUTE_TextEntry, XFA_XDPPACKET_Form);
}
@@ -704,7 +715,7 @@ bool CXFA_WidgetData::IsChoiceListAllowTextEntry() {
int32_t CXFA_WidgetData::GetChoiceListOpen() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetEnum(XFA_ATTRIBUTE_Open);
+ return pUIChild->JSNode()->GetEnum(XFA_ATTRIBUTE_Open);
return GetAttributeDefaultValue_Enum(XFA_Element::ChoiceList,
XFA_ATTRIBUTE_Open, XFA_XDPPACKET_Form);
}
@@ -732,8 +743,8 @@ int32_t CXFA_WidgetData::CountChoiceListItems(bool bSaveValue) {
CXFA_Node* pItem = pItems[0];
if (iCount > 1) {
- bool bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save);
- bool bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bItemOneHasSave = pItems[0]->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bItemTwoHasSave = pItems[1]->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
pItem = pItems[1];
}
@@ -761,15 +772,17 @@ bool CXFA_WidgetData::GetChoiceListItem(WideString& wsText,
pItems = pItemsArray[0];
if (iCount > 1) {
- bool bItemOneHasSave = pItemsArray[0]->GetBoolean(XFA_ATTRIBUTE_Save);
- bool bItemTwoHasSave = pItemsArray[1]->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bItemOneHasSave =
+ pItemsArray[0]->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bItemTwoHasSave =
+ pItemsArray[1]->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
pItems = pItemsArray[1];
}
if (pItems) {
CXFA_Node* pItem = pItems->GetChild(nIndex, XFA_Element::Unknown);
if (pItem) {
- pItem->TryContent(wsText);
+ pItem->JSNode()->TryContent(wsText);
return true;
}
}
@@ -789,8 +802,8 @@ std::vector<WideString> CXFA_WidgetData::GetChoiceListItems(bool bSaveValue) {
CXFA_Node* pItem = items.front();
if (items.size() > 1) {
- bool bItemOneHasSave = items[0]->GetBoolean(XFA_ATTRIBUTE_Save);
- bool bItemTwoHasSave = items[1]->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bItemOneHasSave = items[0]->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bItemTwoHasSave = items[1]->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
pItem = items[1];
}
@@ -799,7 +812,7 @@ std::vector<WideString> CXFA_WidgetData::GetChoiceListItems(bool bSaveValue) {
for (CXFA_Node* pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
wsTextArray.emplace_back();
- pNode->TryContent(wsTextArray.back());
+ pNode->JSNode()->TryContent(wsTextArray.back());
}
return wsTextArray;
}
@@ -897,8 +910,8 @@ void CXFA_WidgetData::SetItemState(int32_t nIndex,
wsValue += L"\n";
}
wsValue += wsSaveTextArray[nIndex];
- m_pNode->SetContent(wsValue, wsValue, bNotify, bScriptModify,
- bSyncData);
+ m_pNode->JSNode()->SetContent(wsValue, wsValue, bNotify, bScriptModify,
+ bSyncData);
}
} else if (iSel >= 0) {
std::vector<int32_t> iSelArray = GetSelectedItems();
@@ -913,12 +926,12 @@ void CXFA_WidgetData::SetItemState(int32_t nIndex,
WideString wsSaveText = wsSaveTextArray[nIndex];
WideString wsFormatText(wsSaveText);
GetFormatDataValue(wsSaveText, wsFormatText);
- m_pNode->SetContent(wsSaveText, wsFormatText, bNotify, bScriptModify,
- bSyncData);
+ m_pNode->JSNode()->SetContent(wsSaveText, wsFormatText, bNotify,
+ bScriptModify, bSyncData);
}
} else if (iSel >= 0) {
- m_pNode->SetContent(WideString(), WideString(), bNotify, bScriptModify,
- bSyncData);
+ m_pNode->JSNode()->SetContent(WideString(), WideString(), bNotify,
+ bScriptModify, bSyncData);
}
}
}
@@ -942,7 +955,8 @@ void CXFA_WidgetData::SetSelectedItems(const std::vector<int32_t>& iSelArray,
if (GetChoiceListOpen() != XFA_ATTRIBUTEENUM_MultiSelect)
GetFormatDataValue(wsValue, wsFormat);
- m_pNode->SetContent(wsValue, wsFormat, bNotify, bScriptModify, bSyncData);
+ m_pNode->JSNode()->SetContent(wsValue, wsFormat, bNotify, bScriptModify,
+ bSyncData);
}
void CXFA_WidgetData::ClearAllSelections() {
@@ -976,12 +990,12 @@ void CXFA_WidgetData::InsertItem(const WideString& wsLabel,
InsertListTextItem(pItems, wsLabel, nIndex);
CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_Element::Items);
m_pNode->InsertChild(-1, pSaveItems);
- pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, true);
+ pSaveItems->JSNode()->SetBoolean(XFA_ATTRIBUTE_Save, true);
InsertListTextItem(pSaveItems, wsNewValue, nIndex);
} else if (listitems.size() > 1) {
for (int32_t i = 0; i < 2; i++) {
CXFA_Node* pNode = listitems[i];
- bool bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bHasSave = pNode->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
if (bHasSave)
InsertListTextItem(pNode, wsNewValue, nIndex);
else
@@ -989,17 +1003,18 @@ void CXFA_WidgetData::InsertItem(const WideString& wsLabel,
}
} else {
CXFA_Node* pNode = listitems[0];
- pNode->SetBoolean(XFA_ATTRIBUTE_Save, false);
- pNode->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible);
+ pNode->JSNode()->SetBoolean(XFA_ATTRIBUTE_Save, false);
+ pNode->JSNode()->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Visible);
CXFA_Node* pSaveItems = m_pNode->CreateSamePacketNode(XFA_Element::Items);
m_pNode->InsertChild(-1, pSaveItems);
- pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, true);
- pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden);
+ pSaveItems->JSNode()->SetBoolean(XFA_ATTRIBUTE_Save, true);
+ pSaveItems->JSNode()->SetEnum(XFA_ATTRIBUTE_Presence,
+ XFA_ATTRIBUTEENUM_Hidden);
CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
int32_t i = 0;
while (pListNode) {
WideString wsOldValue;
- pListNode->TryContent(wsOldValue);
+ pListNode->JSNode()->TryContent(wsOldValue);
InsertListTextItem(pSaveItems, wsOldValue, i);
i++;
pListNode = pListNode->GetNodeItem(XFA_NODEITEM_NextSibling);
@@ -1029,7 +1044,7 @@ void CXFA_WidgetData::GetItemLabel(const WideStringView& wsValue,
wsLabel = wsValue;
} else {
CXFA_Node* pLabelItems = listitems[0];
- bool bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bSave = pLabelItems->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
CXFA_Node* pSaveItems = nullptr;
if (bSave) {
pSaveItems = pLabelItems;
@@ -1043,7 +1058,7 @@ void CXFA_WidgetData::GetItemLabel(const WideStringView& wsValue,
CXFA_Node* pChildItem = pSaveItems->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pChildItem;
pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- pChildItem->TryContent(wsContent);
+ pChildItem->JSNode()->TryContent(wsContent);
if (wsContent == wsValue) {
iSearch = iCount;
break;
@@ -1054,7 +1069,7 @@ void CXFA_WidgetData::GetItemLabel(const WideStringView& wsValue,
return;
if (CXFA_Node* pText =
pLabelItems->GetChild(iSearch, XFA_Element::Unknown)) {
- pText->TryContent(wsLabel);
+ pText->JSNode()->TryContent(wsLabel);
}
}
}
@@ -1074,7 +1089,7 @@ void CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel,
wsValue = wsLabel;
} else {
CXFA_Node* pLabelItems = listitems[0];
- bool bSave = pLabelItems->GetBoolean(XFA_ATTRIBUTE_Save);
+ bool bSave = pLabelItems->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save);
CXFA_Node* pSaveItems = nullptr;
if (bSave) {
pSaveItems = pLabelItems;
@@ -1088,7 +1103,7 @@ void CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel,
CXFA_Node* pChildItem = pLabelItems->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pChildItem;
pChildItem = pChildItem->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- pChildItem->TryContent(wsContent);
+ pChildItem->JSNode()->TryContent(wsContent);
if (wsContent == wsLabel) {
iSearch = iCount;
break;
@@ -1098,7 +1113,7 @@ void CXFA_WidgetData::GetItemValue(const WideStringView& wsLabel,
if (iSearch < 0)
return;
if (CXFA_Node* pText = pSaveItems->GetChild(iSearch, XFA_Element::Unknown))
- pText->TryContent(wsValue);
+ pText->JSNode()->TryContent(wsValue);
}
}
@@ -1116,7 +1131,7 @@ bool CXFA_WidgetData::DeleteItem(int32_t nIndex,
pItems->RemoveChild(pNode);
}
} else {
- if (!bSetValue && pItems->GetBoolean(XFA_ATTRIBUTE_Save)) {
+ if (!bSetValue && pItems->JSNode()->GetBoolean(XFA_ATTRIBUTE_Save)) {
SetItemState(nIndex, false, true, bScriptModify, true);
bSetValue = true;
}
@@ -1140,7 +1155,7 @@ bool CXFA_WidgetData::DeleteItem(int32_t nIndex,
int32_t CXFA_WidgetData::GetHorizontalScrollPolicy() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetEnum(XFA_ATTRIBUTE_HScrollPolicy);
+ return pUIChild->JSNode()->GetEnum(XFA_ATTRIBUTE_HScrollPolicy);
return XFA_ATTRIBUTEENUM_Auto;
}
@@ -1149,20 +1164,21 @@ int32_t CXFA_WidgetData::GetNumberOfCells() {
if (!pUIChild)
return -1;
if (CXFA_Node* pNode = pUIChild->GetChild(0, XFA_Element::Comb))
- return pNode->GetInteger(XFA_ATTRIBUTE_NumberOfCells);
+ return pNode->JSNode()->GetInteger(XFA_ATTRIBUTE_NumberOfCells);
return -1;
}
WideString CXFA_WidgetData::GetBarcodeType() {
CXFA_Node* pUIChild = GetUIChild();
- return pUIChild ? WideString(pUIChild->GetCData(XFA_ATTRIBUTE_Type))
+ return pUIChild ? WideString(pUIChild->JSNode()->GetCData(XFA_ATTRIBUTE_Type))
: WideString();
}
bool CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t* val) {
CXFA_Node* pUIChild = GetUIChild();
WideString wsCharEncoding;
- if (pUIChild->TryCData(XFA_ATTRIBUTE_CharEncoding, wsCharEncoding)) {
+ if (pUIChild->JSNode()->TryCData(XFA_ATTRIBUTE_CharEncoding,
+ wsCharEncoding)) {
if (wsCharEncoding.CompareNoCase(L"UTF-16")) {
*val = CHAR_ENCODING_UNICODE;
return true;
@@ -1178,7 +1194,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_CharEncoding(int32_t* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_Checksum(bool* val) {
CXFA_Node* pUIChild = GetUIChild();
XFA_ATTRIBUTEENUM eChecksum;
- if (pUIChild->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) {
+ if (pUIChild->JSNode()->TryEnum(XFA_ATTRIBUTE_Checksum, eChecksum)) {
switch (eChecksum) {
case XFA_ATTRIBUTEENUM_None:
*val = false;
@@ -1202,7 +1218,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_Checksum(bool* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t* val) {
CXFA_Node* pUIChild = GetUIChild();
WideString wsDataLength;
- if (pUIChild->TryCData(XFA_ATTRIBUTE_DataLength, wsDataLength)) {
+ if (pUIChild->JSNode()->TryCData(XFA_ATTRIBUTE_DataLength, wsDataLength)) {
*val = FXSYS_wtoi(wsDataLength.c_str());
return true;
}
@@ -1212,7 +1228,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_DataLength(int32_t* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_StartChar(char* val) {
CXFA_Node* pUIChild = GetUIChild();
WideStringView wsStartEndChar;
- if (pUIChild->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) {
+ if (pUIChild->JSNode()->TryCData(XFA_ATTRIBUTE_StartChar, wsStartEndChar)) {
if (wsStartEndChar.GetLength()) {
*val = static_cast<char>(wsStartEndChar[0]);
return true;
@@ -1224,7 +1240,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_StartChar(char* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_EndChar(char* val) {
CXFA_Node* pUIChild = GetUIChild();
WideStringView wsStartEndChar;
- if (pUIChild->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) {
+ if (pUIChild->JSNode()->TryCData(XFA_ATTRIBUTE_EndChar, wsStartEndChar)) {
if (wsStartEndChar.GetLength()) {
*val = static_cast<char>(wsStartEndChar[0]);
return true;
@@ -1236,7 +1252,8 @@ bool CXFA_WidgetData::GetBarcodeAttribute_EndChar(char* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_ECLevel(int32_t* val) {
CXFA_Node* pUIChild = GetUIChild();
WideString wsECLevel;
- if (pUIChild->TryCData(XFA_ATTRIBUTE_ErrorCorrectionLevel, wsECLevel)) {
+ if (pUIChild->JSNode()->TryCData(XFA_ATTRIBUTE_ErrorCorrectionLevel,
+ wsECLevel)) {
*val = FXSYS_wtoi(wsECLevel.c_str());
return true;
}
@@ -1246,7 +1263,8 @@ bool CXFA_WidgetData::GetBarcodeAttribute_ECLevel(int32_t* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_ModuleWidth(int32_t* val) {
CXFA_Node* pUIChild = GetUIChild();
CXFA_Measurement mModuleWidthHeight;
- if (pUIChild->TryMeasure(XFA_ATTRIBUTE_ModuleWidth, mModuleWidthHeight)) {
+ if (pUIChild->JSNode()->TryMeasure(XFA_ATTRIBUTE_ModuleWidth,
+ mModuleWidthHeight)) {
*val = static_cast<int32_t>(mModuleWidthHeight.ToUnit(XFA_UNIT_Pt));
return true;
}
@@ -1256,7 +1274,8 @@ 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->TryMeasure(XFA_ATTRIBUTE_ModuleHeight, mModuleWidthHeight)) {
+ if (pUIChild->JSNode()->TryMeasure(XFA_ATTRIBUTE_ModuleHeight,
+ mModuleWidthHeight)) {
*val = static_cast<int32_t>(mModuleWidthHeight.ToUnit(XFA_UNIT_Pt));
return true;
}
@@ -1266,7 +1285,8 @@ bool CXFA_WidgetData::GetBarcodeAttribute_ModuleHeight(int32_t* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(bool* val) {
CXFA_Node* pUIChild = GetUIChild();
bool bPrintCheckDigit;
- if (pUIChild->TryBoolean(XFA_ATTRIBUTE_PrintCheckDigit, bPrintCheckDigit)) {
+ if (pUIChild->JSNode()->TryBoolean(XFA_ATTRIBUTE_PrintCheckDigit,
+ bPrintCheckDigit)) {
*val = bPrintCheckDigit;
return true;
}
@@ -1276,7 +1296,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_PrintChecksum(bool* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t* val) {
CXFA_Node* pUIChild = GetUIChild();
XFA_ATTRIBUTEENUM eTextLocation;
- if (pUIChild->TryEnum(XFA_ATTRIBUTE_TextLocation, eTextLocation)) {
+ if (pUIChild->JSNode()->TryEnum(XFA_ATTRIBUTE_TextLocation, eTextLocation)) {
switch (eTextLocation) {
case XFA_ATTRIBUTEENUM_None:
*val = BC_TEXT_LOC_NONE;
@@ -1303,7 +1323,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_TextLocation(int32_t* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_Truncate(bool* val) {
CXFA_Node* pUIChild = GetUIChild();
bool bTruncate;
- if (!pUIChild->TryBoolean(XFA_ATTRIBUTE_Truncate, bTruncate))
+ if (!pUIChild->JSNode()->TryBoolean(XFA_ATTRIBUTE_Truncate, bTruncate))
return false;
*val = bTruncate;
@@ -1313,7 +1333,8 @@ bool CXFA_WidgetData::GetBarcodeAttribute_Truncate(bool* val) {
bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(float* val) {
CXFA_Node* pUIChild = GetUIChild();
WideString wsWideNarrowRatio;
- if (pUIChild->TryCData(XFA_ATTRIBUTE_WideNarrowRatio, wsWideNarrowRatio)) {
+ if (pUIChild->JSNode()->TryCData(XFA_ATTRIBUTE_WideNarrowRatio,
+ wsWideNarrowRatio)) {
auto ptPos = wsWideNarrowRatio.Find(':');
float fRatio = 0;
if (!ptPos.has_value()) {
@@ -1337,7 +1358,7 @@ bool CXFA_WidgetData::GetBarcodeAttribute_WideNarrowRatio(float* val) {
void CXFA_WidgetData::GetPasswordChar(WideString& wsPassWord) {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild) {
- pUIChild->TryCData(XFA_ATTRIBUTE_PasswordChar, wsPassWord);
+ pUIChild->JSNode()->TryCData(XFA_ATTRIBUTE_PasswordChar, wsPassWord);
} else {
wsPassWord = GetAttributeDefaultValue_Cdata(XFA_Element::PasswordEdit,
XFA_ATTRIBUTE_PasswordChar,
@@ -1348,7 +1369,7 @@ void CXFA_WidgetData::GetPasswordChar(WideString& wsPassWord) {
bool CXFA_WidgetData::IsMultiLine() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetBoolean(XFA_ATTRIBUTE_MultiLine);
+ return pUIChild->JSNode()->GetBoolean(XFA_ATTRIBUTE_MultiLine);
return GetAttributeDefaultValue_Boolean(
XFA_Element::TextEdit, XFA_ATTRIBUTE_MultiLine, XFA_XDPPACKET_Form);
}
@@ -1356,7 +1377,7 @@ bool CXFA_WidgetData::IsMultiLine() {
int32_t CXFA_WidgetData::GetVerticalScrollPolicy() {
CXFA_Node* pUIChild = GetUIChild();
if (pUIChild)
- return pUIChild->GetEnum(XFA_ATTRIBUTE_VScrollPolicy);
+ return pUIChild->JSNode()->GetEnum(XFA_ATTRIBUTE_VScrollPolicy);
return GetAttributeDefaultValue_Enum(
XFA_Element::TextEdit, XFA_ATTRIBUTE_VScrollPolicy, XFA_XDPPACKET_Form);
}
@@ -1367,10 +1388,10 @@ int32_t CXFA_WidgetData::GetMaxChars(XFA_Element& eType) {
switch (pChild->GetElementType()) {
case XFA_Element::Text:
eType = XFA_Element::Text;
- return pChild->GetInteger(XFA_ATTRIBUTE_MaxChars);
+ return pChild->JSNode()->GetInteger(XFA_ATTRIBUTE_MaxChars);
case XFA_Element::ExData: {
eType = XFA_Element::ExData;
- int32_t iMax = pChild->GetInteger(XFA_ATTRIBUTE_MaxLength);
+ int32_t iMax = pChild->JSNode()->GetInteger(XFA_ATTRIBUTE_MaxLength);
return iMax < 0 ? 0 : iMax;
}
default:
@@ -1384,7 +1405,8 @@ int32_t CXFA_WidgetData::GetMaxChars(XFA_Element& eType) {
bool CXFA_WidgetData::GetFracDigits(int32_t& iFracDigits) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value)) {
if (CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal))
- return pChild->TryInteger(XFA_ATTRIBUTE_FracDigits, iFracDigits);
+ return pChild->JSNode()->TryInteger(XFA_ATTRIBUTE_FracDigits,
+ iFracDigits);
}
iFracDigits = -1;
return false;
@@ -1393,7 +1415,8 @@ bool CXFA_WidgetData::GetFracDigits(int32_t& iFracDigits) {
bool CXFA_WidgetData::GetLeadDigits(int32_t& iLeadDigits) {
if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Value)) {
if (CXFA_Node* pChild = pNode->GetChild(0, XFA_Element::Decimal))
- return pChild->TryInteger(XFA_ATTRIBUTE_LeadDigits, iLeadDigits);
+ return pChild->JSNode()->TryInteger(XFA_ATTRIBUTE_LeadDigits,
+ iLeadDigits);
}
iLeadDigits = -1;
return false;
@@ -1464,7 +1487,7 @@ bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture,
case XFA_VALUEPICTURE_Display: {
if (CXFA_Node* pFormat = m_pNode->GetChild(0, XFA_Element::Format)) {
if (CXFA_Node* pPicture = pFormat->GetChild(0, XFA_Element::Picture)) {
- if (pPicture->TryContent(wsPicture))
+ if (pPicture->JSNode()->TryContent(wsPicture))
return true;
}
}
@@ -1501,7 +1524,7 @@ bool CXFA_WidgetData::GetPictureContent(WideString& wsPicture,
CXFA_Node* pUI = m_pNode->GetChild(0, XFA_Element::Ui);
if (pUI) {
if (CXFA_Node* pPicture = pUI->GetChild(0, XFA_Element::Picture)) {
- if (pPicture->TryContent(wsPicture))
+ if (pPicture->JSNode()->TryContent(wsPicture))
return true;
}
}
@@ -1558,7 +1581,7 @@ IFX_Locale* CXFA_WidgetData::GetLocal() {
bool CXFA_WidgetData::GetValue(WideString& wsValue,
XFA_VALUEPICTURE eValueType) {
- wsValue = m_pNode->GetContent();
+ wsValue = m_pNode->JSNode()->GetContent();
if (eValueType == XFA_VALUEPICTURE_Display)
GetItemLabel(wsValue.AsStringView(), wsValue);
@@ -1799,7 +1822,7 @@ void CXFA_WidgetData::SyncValue(const WideString& wsValue, bool bNotify) {
if (pContainerWidgetData)
pContainerWidgetData->GetFormatDataValue(wsValue, wsFormatValue);
- m_pNode->SetContent(wsValue, wsFormatValue, bNotify);
+ m_pNode->JSNode()->SetContent(wsValue, wsFormatValue, bNotify);
}
void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems,
@@ -1807,7 +1830,7 @@ void CXFA_WidgetData::InsertListTextItem(CXFA_Node* pItems,
int32_t nIndex) {
CXFA_Node* pText = pItems->CreateSamePacketNode(XFA_Element::Text);
pItems->InsertChild(nIndex, pText);
- pText->SetContent(wsText, wsText, false, false, false);
+ pText->JSNode()->SetContent(wsText, wsText, false, false, false);
}
WideString CXFA_WidgetData::NumericLimit(const WideString& wsValue,
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 12a1ba77c4..87fa5fe6bf 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -61,7 +61,7 @@ CXFA_Node* FormValueNode_CreateChild(CXFA_Node* pValueNode, XFA_Element iType) {
if (!pChildNode) {
if (iType == XFA_Element::Unknown)
return nullptr;
- pChildNode = pValueNode->GetProperty(0, iType);
+ pChildNode = pValueNode->JSNode()->GetProperty(0, iType);
}
return pChildNode;
}
@@ -91,8 +91,8 @@ bool FormValueNode_SetChildContent(CXFA_Node* pValueNode,
XFA_Element element = XFA_Element::Sharptext;
if (pChildNode->GetElementType() == XFA_Element::ExData) {
WideString wsContentType;
- pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType,
- false);
+ pChildNode->JSNode()->GetAttribute(XFA_ATTRIBUTE_ContentType,
+ wsContentType, false);
if (wsContentType == L"text/html")
element = XFA_Element::SharpxHTML;
else if (wsContentType == L"text/xml")
@@ -101,13 +101,13 @@ bool FormValueNode_SetChildContent(CXFA_Node* pValueNode,
pContentRawDataNode = pChildNode->CreateSamePacketNode(element);
pChildNode->InsertChild(pContentRawDataNode);
}
- pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
+ pContentRawDataNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsContent);
break;
}
case XFA_ObjectType::NodeC:
case XFA_ObjectType::TextNode:
case XFA_ObjectType::NodeV: {
- pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
+ pChildNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsContent);
break;
}
default:
@@ -120,7 +120,7 @@ bool FormValueNode_SetChildContent(CXFA_Node* pValueNode,
void CreateDataBinding(CXFA_Node* pFormNode,
CXFA_Node* pDataNode,
bool bDataToForm) {
- pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode);
+ pFormNode->JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode);
pDataNode->AddBindItem(pFormNode);
XFA_Element eType = pFormNode->GetElementType();
if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup)
@@ -129,7 +129,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
ASSERT(pWidgetData);
XFA_Element eUIType = pWidgetData->GetUIType();
- CXFA_Value defValue(pFormNode->GetProperty(0, XFA_Element::Value));
+ CXFA_Value defValue(pFormNode->JSNode()->GetProperty(0, XFA_Element::Value));
if (!bDataToForm) {
WideString wsValue;
WideString wsFormattedValue;
@@ -147,8 +147,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
static_cast<CFX_XMLElement*>(pDataNode->GetXMLMappingNode());
ASSERT(pXMLDataElement);
pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue);
- pDataNode->SetAttributeValue(wsValue, wsFormattedValue);
- pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+ pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue);
+ pDataNode->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
if (!wsHref.IsEmpty())
pXMLDataElement->SetString(L"href", wsHref);
@@ -163,10 +163,10 @@ void CreateDataBinding(CXFA_Node* pFormNode,
for (const auto& text : wsSelTextArray) {
CXFA_Node* pValue =
pDataNode->CreateSamePacketNode(XFA_Element::DataValue);
- pValue->SetCData(XFA_ATTRIBUTE_Name, L"value");
+ pValue->JSNode()->SetCData(XFA_ATTRIBUTE_Name, L"value");
pValue->CreateXMLMappingNode();
pDataNode->InsertChild(pValue);
- pValue->SetCData(XFA_ATTRIBUTE_Value, text);
+ pValue->JSNode()->SetCData(XFA_ATTRIBUTE_Value, text);
}
} else {
CFX_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode();
@@ -176,7 +176,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
}
} else if (!wsValue.IsEmpty()) {
pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue);
- pDataNode->SetAttributeValue(wsValue, wsFormattedValue);
+ pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue);
}
break;
case XFA_Element::CheckButton:
@@ -185,7 +185,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
break;
pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue);
- pDataNode->SetAttributeValue(wsValue, wsFormattedValue);
+ pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue);
break;
case XFA_Element::ExclGroup: {
CXFA_Node* pChecked = nullptr;
@@ -212,11 +212,12 @@ void CreateDataBinding(CXFA_Node* pFormNode,
continue;
WideString wsContent;
- if (pText->TryContent(wsContent) && (wsContent == wsValue)) {
+ if (pText->JSNode()->TryContent(wsContent) &&
+ (wsContent == wsValue)) {
pChecked = pChild;
wsFormattedValue = wsValue;
- pDataNode->SetAttributeValue(wsValue, wsFormattedValue);
- pFormNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
+ pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue);
+ pFormNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsContent);
break;
}
}
@@ -230,7 +231,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
if (pChild->GetElementType() != XFA_Element::Field)
continue;
- CXFA_Node* pValue = pChild->GetProperty(0, XFA_Element::Value);
+ CXFA_Node* pValue =
+ pChild->JSNode()->GetProperty(0, XFA_Element::Value);
CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items);
CXFA_Node* pText =
pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr;
@@ -239,7 +241,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
WideString wsContent;
if (pText)
- pText->TryContent(wsContent);
+ pText->JSNode()->TryContent(wsContent);
FormValueNode_SetChildContent(pValue, wsContent, XFA_Element::Text);
}
@@ -254,8 +256,9 @@ void CreateDataBinding(CXFA_Node* pFormNode,
pWidgetData->NormalizeNumStr(wsValue, wsOutput);
wsValue = wsOutput;
pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue);
- pDataNode->SetAttributeValue(wsValue, wsFormattedValue);
- CXFA_Node* pValue = pFormNode->GetProperty(0, XFA_Element::Value);
+ pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue);
+ CXFA_Node* pValue =
+ pFormNode->JSNode()->GetProperty(0, XFA_Element::Value);
FormValueNode_SetChildContent(pValue, wsValue, XFA_Element::Float);
break;
}
@@ -265,17 +268,17 @@ void CreateDataBinding(CXFA_Node* pFormNode,
break;
pWidgetData->GetFormatDataValue(wsValue, wsFormattedValue);
- pDataNode->SetAttributeValue(wsValue, wsFormattedValue);
+ pDataNode->JSNode()->SetAttributeValue(wsValue, wsFormattedValue);
break;
}
return;
}
WideString wsXMLValue;
- pDataNode->TryContent(wsXMLValue);
+ pDataNode->JSNode()->TryContent(wsXMLValue);
WideString wsNormalizeValue;
pWidgetData->GetNormalizeDataValue(wsXMLValue, wsNormalizeValue);
- pDataNode->SetAttributeValue(wsNormalizeValue, wsXMLValue);
+ pDataNode->JSNode()->SetAttributeValue(wsNormalizeValue, wsXMLValue);
switch (eUIType) {
case XFA_Element::ImageEdit: {
FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue,
@@ -289,7 +292,8 @@ void CreateDataBinding(CXFA_Node* pFormNode,
WideString wsContentType =
pXMLDataElement->GetString(L"xfa:contentType");
if (!wsContentType.IsEmpty()) {
- pDataNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
+ pDataNode->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType,
+ wsContentType);
image.SetContentType(wsContentType);
}
@@ -307,7 +311,7 @@ void CreateDataBinding(CXFA_Node* pFormNode,
wsNormalizeValue.clear();
WideString wsItem;
for (CXFA_Node* pNode : items) {
- pNode->TryContent(wsItem);
+ pNode->JSNode()->TryContent(wsItem);
wsItem = single ? wsItem : wsItem + L"\n";
wsNormalizeValue += wsItem;
}
@@ -496,7 +500,8 @@ CXFA_Node* CloneOrMergeInstanceManager(CXFA_Document* pDocument,
CXFA_Node* pFormParent,
CXFA_Node* pTemplateNode,
std::vector<CXFA_Node*>* subforms) {
- WideStringView wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
+ WideStringView wsSubformName =
+ pTemplateNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
WideString wsInstMgrNodeName = L"_" + wsSubformName;
uint32_t dwInstNameHash =
FX_HashCode_GetW(wsInstMgrNodeName.AsStringView(), false);
@@ -533,8 +538,9 @@ CXFA_Node* CloneOrMergeInstanceManager(CXFA_Document* pDocument,
CXFA_Node* pNewNode =
pDocument->CreateNode(XFA_XDPPACKET_Form, XFA_Element::InstanceManager);
- wsInstMgrNodeName = L"_" + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
- pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName);
+ wsInstMgrNodeName =
+ L"_" + pTemplateNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
+ pNewNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName);
pFormParent->InsertChild(pNewNode, nullptr);
pNewNode->SetTemplateNode(pTemplateNode);
return pNewNode;
@@ -584,8 +590,9 @@ CXFA_Node* FindMatchingDataNode(
CXFA_Node* pTemplateNodeBind =
pCurTemplateNode->GetFirstChildByClass(XFA_Element::Bind);
XFA_ATTRIBUTEENUM eMatch =
- pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match)
- : XFA_ATTRIBUTEENUM_Once;
+ pTemplateNodeBind
+ ? pTemplateNodeBind->JSNode()->GetEnum(XFA_ATTRIBUTE_Match)
+ : XFA_ATTRIBUTEENUM_Once;
eBindMatch = eMatch;
switch (eMatch) {
case XFA_ATTRIBUTEENUM_None:
@@ -601,7 +608,8 @@ CXFA_Node* FindMatchingDataNode(
(eMatchNodeType == XFA_Element::DataGroup &&
XFA_FieldIsMultiListBox(pTemplateNodeBind))) {
CXFA_Node* pGlobalBindNode = FindGlobalDataNode(
- pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name),
+ pDocument,
+ pCurTemplateNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name),
pDataScope, eMatchNodeType);
if (!pGlobalBindNode) {
pCurTemplateNode = pIterator->MoveToNext();
@@ -613,7 +621,7 @@ CXFA_Node* FindMatchingDataNode(
case XFA_ATTRIBUTEENUM_Once: {
bAccessedDataDOM = true;
CXFA_Node* pOnceBindNode = FindOnceDataNode(
- pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name),
+ pDocument, pCurTemplateNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name),
pDataScope, eMatchNodeType);
if (!pOnceBindNode) {
pCurTemplateNode = pIterator->MoveToNext();
@@ -625,7 +633,7 @@ CXFA_Node* FindMatchingDataNode(
case XFA_ATTRIBUTEENUM_DataRef: {
bAccessedDataDOM = true;
CXFA_Node* pDataRefBindNode = FindDataRefDataNode(
- pDocument, pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref),
+ pDocument, pTemplateNodeBind->JSNode()->GetCData(XFA_ATTRIBUTE_Ref),
pDataScope, eMatchNodeType, pTemplateNode, bForceBind, bUpLevel);
if (pDataRefBindNode &&
pDataRefBindNode->GetElementType() == eMatchNodeType) {
@@ -726,7 +734,7 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
XFA_ATTRIBUTEENUM eRelation =
eType == XFA_Element::SubformSet
- ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation)
+ ? pTemplateNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Relation)
: XFA_ATTRIBUTEENUM_Ordered;
int32_t iCurRepeatIndex = 0;
XFA_ATTRIBUTEENUM eParentBindMatch = XFA_ATTRIBUTEENUM_None;
@@ -1008,7 +1016,7 @@ CXFA_Node* MaybeCreateDataNode(CXFA_Document* pDocument,
if (!pParentDDNode) {
CXFA_Node* pDataNode =
pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
- pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
+ pDataNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsName);
pDataNode->CreateXMLMappingNode();
pDataParent->InsertChild(pDataNode);
pDataNode->SetFlag(XFA_NodeFlag_Initialized, false);
@@ -1024,7 +1032,7 @@ CXFA_Node* MaybeCreateDataNode(CXFA_Document* pDocument,
continue;
WideString wsNamespace;
- if (!pDDGroupNode->TryNamespace(wsNamespace) ||
+ if (!pDDGroupNode->JSNode()->TryNamespace(wsNamespace) ||
wsNamespace != L"http://ns.adobe.com/data-description/") {
continue;
}
@@ -1038,12 +1046,13 @@ CXFA_Node* MaybeCreateDataNode(CXFA_Document* pDocument,
CXFA_Node* pDataNode =
pDocument->CreateNode(XFA_XDPPACKET_Datasets, eNodeType);
- pDataNode->SetCData(XFA_ATTRIBUTE_Name, wsName);
+ pDataNode->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsName);
pDataNode->CreateXMLMappingNode();
if (eNodeType == XFA_Element::DataValue &&
- pDDNode->GetEnum(XFA_ATTRIBUTE_Contains) ==
+ pDDNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Contains) ==
XFA_ATTRIBUTEENUM_MetaData) {
- pDataNode->SetEnum(XFA_ATTRIBUTE_Contains, XFA_ATTRIBUTEENUM_MetaData);
+ pDataNode->JSNode()->SetEnum(XFA_ATTRIBUTE_Contains,
+ XFA_ATTRIBUTEENUM_MetaData);
}
pDataParent->InsertChild(pDataNode);
pDataNode->SetDataDescriptionNode(pDDNode);
@@ -1068,8 +1077,9 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_Element::Bind)
: nullptr;
XFA_ATTRIBUTEENUM eMatch =
- pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match)
- : XFA_ATTRIBUTEENUM_Once;
+ pTemplateNodeBind
+ ? pTemplateNodeBind->JSNode()->GetEnum(XFA_ATTRIBUTE_Match)
+ : XFA_ATTRIBUTEENUM_Once;
switch (eMatch) {
case XFA_ATTRIBUTEENUM_None:
if (!bDataRef || bParentDataRef)
@@ -1079,7 +1089,7 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
if (!bDataRef || bParentDataRef) {
if (!pDataNode) {
if (pFormNode->GetNameHash() != 0 &&
- pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) !=
+ pFormNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Scope) !=
XFA_ATTRIBUTEENUM_None) {
XFA_Element eDataNodeType = (eType == XFA_Element::Subform ||
XFA_FieldIsMultiListBox(pFormNode))
@@ -1087,7 +1097,8 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
: XFA_Element::DataValue;
pDataNode = MaybeCreateDataNode(
pDocument, pDataScope, eDataNodeType,
- WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name)));
+ WideString(
+ pFormNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name)));
if (pDataNode)
CreateDataBinding(pFormNode, pDataNode, false);
}
@@ -1119,7 +1130,8 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
pDataNode = MaybeCreateDataNode(
pDocument, pRecordNode, eDataNodeType,
- WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name)));
+ WideString(
+ pFormNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name)));
if (pDataNode) {
CreateDataBinding(pFormNode, pDataNode, false);
RegisterGlobalBinding(pDocument, pFormNode->GetNameHash(),
@@ -1137,7 +1149,8 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
bMatchRef = bDataRef;
bParentDataRef = true;
if (!pDataNode && bDataRef) {
- WideStringView wsRef = pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref);
+ WideStringView wsRef =
+ pTemplateNodeBind->JSNode()->GetCData(XFA_ATTRIBUTE_Ref);
uint32_t dFlags =
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode;
XFA_RESOLVENODE_RS rs;
@@ -1198,7 +1211,7 @@ void UpdateDataRelation(CXFA_Node* pDataNode, CXFA_Node* pDataDescriptionNode) {
continue;
WideString wsNamespace;
- if (!pDDGroupNode->TryNamespace(wsNamespace) ||
+ if (!pDDGroupNode->JSNode()->TryNamespace(wsNamespace) ||
wsNamespace != L"http://ns.adobe.com/data-description/") {
continue;
}
@@ -1357,14 +1370,14 @@ void CXFA_Document::DoDataMerge() {
pDatasetsXMLNode->SetString(L"xmlns:xfa",
L"http://www.xfa.org/schema/xfa-data/1.0/");
pDatasetsRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataModel);
- pDatasetsRoot->SetCData(XFA_ATTRIBUTE_Name, L"datasets");
+ pDatasetsRoot->JSNode()->SetCData(XFA_ATTRIBUTE_Name, L"datasets");
m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode);
m_pRootNode->InsertChild(pDatasetsRoot);
pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode);
}
CXFA_Node *pDataRoot = nullptr, *pDDRoot = nullptr;
WideString wsDatasetsURI;
- pDatasetsRoot->TryNamespace(wsDatasetsURI);
+ pDatasetsRoot->JSNode()->TryNamespace(wsDatasetsURI);
for (CXFA_Node* pChildNode =
pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
pChildNode;
@@ -1374,12 +1387,12 @@ void CXFA_Document::DoDataMerge() {
WideString wsNamespaceURI;
if (!pDDRoot && pChildNode->GetNameHash() == XFA_HASHCODE_DataDescription) {
- if (!pChildNode->TryNamespace(wsNamespaceURI))
+ if (!pChildNode->JSNode()->TryNamespace(wsNamespaceURI))
continue;
if (wsNamespaceURI == L"http://ns.adobe.com/data-description/")
pDDRoot = pChildNode;
} else if (!pDataRoot && pChildNode->GetNameHash() == XFA_HASHCODE_Data) {
- if (!pChildNode->TryNamespace(wsNamespaceURI))
+ if (!pChildNode->JSNode()->TryNamespace(wsNamespaceURI))
continue;
if (wsNamespaceURI == wsDatasetsURI)
pDataRoot = pChildNode;
@@ -1391,7 +1404,7 @@ void CXFA_Document::DoDataMerge() {
if (!pDataRoot) {
CFX_XMLElement* pDataRootXMLNode = new CFX_XMLElement(L"xfa:data");
pDataRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup);
- pDataRoot->SetCData(XFA_ATTRIBUTE_Name, L"data");
+ pDataRoot->JSNode()->SetCData(XFA_ATTRIBUTE_Name, L"data");
pDataRoot->SetXMLMappingNode(pDataRootXMLNode);
pDatasetsRoot->InsertChild(pDataRoot);
}
@@ -1420,7 +1433,7 @@ void CXFA_Document::DoDataMerge() {
bEmptyForm = true;
pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_Element::Form);
ASSERT(pFormRoot);
- pFormRoot->SetCData(XFA_ATTRIBUTE_Name, L"form");
+ pFormRoot->JSNode()->SetCData(XFA_ATTRIBUTE_Name, L"form");
m_pRootNode->InsertChild(pFormRoot, nullptr);
} else {
CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
@@ -1435,13 +1448,14 @@ void CXFA_Document::DoDataMerge() {
this, pFormRoot, pTemplateChosen, false, nullptr);
ASSERT(pSubformSetNode);
if (!pDataTopLevel) {
- WideStringView wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name);
+ WideStringView wsFormName =
+ pSubformSetNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name);
WideString wsDataTopLevelName(wsFormName.IsEmpty() ? L"form" : wsFormName);
CFX_XMLElement* pDataTopLevelXMLNode =
new CFX_XMLElement(wsDataTopLevelName);
pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup);
- pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName);
+ pDataTopLevel->JSNode()->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName);
pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode);
CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
pDataRoot->InsertChild(pDataTopLevel, pBeforeNode);
@@ -1505,7 +1519,7 @@ void CXFA_Document::DoDataRemerge(bool bDoDataMerge) {
if (pFormRoot) {
while (CXFA_Node* pNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild))
pFormRoot->RemoveChild(pNode);
- pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
+ pFormRoot->JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
}
m_rgGlobalBinding.clear();
if (bDoDataMerge)
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index e1ee29d2b7..45cbbd5b18 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -221,7 +221,7 @@ bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode) {
CXFA_Node* pFirstChild = pUIChild->GetNodeItem(XFA_NODEITEM_FirstChild);
if (pFirstChild &&
pFirstChild->GetElementType() == XFA_Element::ChoiceList) {
- bRet = pFirstChild->GetEnum(XFA_ATTRIBUTE_Open) ==
+ bRet = pFirstChild->JSNode()->GetEnum(XFA_ATTRIBUTE_Open) ==
XFA_ATTRIBUTEENUM_MultiSelect;
}
}