From a85e5ca5f2dfadcf9f3812a8ef039d1f206833a4 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 1 Nov 2017 16:06:07 +0000 Subject: Split JS methods out of CXFA_Object This CL moves the javascript code from CXFA_Object to CJX_Object. The Script_* methods are proxied to CJX_Object. The ownership of the CJX_ object was removed from CXFA_Node and moved up to CXFA_Object. Change-Id: I58d286e6bb0151aa88d4f673bc7729987417bde6 Reviewed-on: https://pdfium-review.googlesource.com/17310 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- BUILD.gn | 2 + fxjs/cjx_node.cpp | 1060 +++++++++++++--------- fxjs/cjx_node.h | 17 +- fxjs/cjx_object.cpp | 55 ++ fxjs/cjx_object.h | 41 + xfa/fxfa/parser/cscript_datawindow.cpp | 5 +- xfa/fxfa/parser/cscript_eventpseudomodel.cpp | 5 +- xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 68 +- xfa/fxfa/parser/cscript_hostpseudomodel.h | 5 - xfa/fxfa/parser/cscript_layoutpseudomodel.cpp | 24 +- xfa/fxfa/parser/cscript_layoutpseudomodel.h | 1 - xfa/fxfa/parser/cscript_logpseudomodel.cpp | 5 +- xfa/fxfa/parser/cscript_signaturepseudomodel.cpp | 13 +- xfa/fxfa/parser/cxfa_node.cpp | 469 ++++------ xfa/fxfa/parser/cxfa_node.h | 15 +- xfa/fxfa/parser/cxfa_nodelist.cpp | 23 +- xfa/fxfa/parser/cxfa_object.cpp | 42 +- xfa/fxfa/parser/cxfa_object.h | 23 +- xfa/fxfa/parser/cxfa_thisproxy.cpp | 12 +- 19 files changed, 1010 insertions(+), 875 deletions(-) create mode 100644 fxjs/cjx_object.cpp create mode 100644 fxjs/cjx_object.h diff --git a/BUILD.gn b/BUILD.gn index 0e604ccf27..6c5996f675 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1301,6 +1301,8 @@ static_library("fxjs") { "fxjs/cfxjse_value.h", "fxjs/cjx_node.cpp", "fxjs/cjx_node.h", + "fxjs/cjx_object.cpp", + "fxjs/cjx_object.h", "fxjs/fxjse.h", ] } diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp index 5521146538..08b32e12bd 100644 --- a/fxjs/cjx_node.cpp +++ b/fxjs/cjx_node.cpp @@ -176,14 +176,23 @@ XFA_MAPMODULEDATA::XFA_MAPMODULEDATA() {} XFA_MAPMODULEDATA::~XFA_MAPMODULEDATA() {} -CJX_Node::CJX_Node(CXFA_Node* node) : node_(node), map_module_data_(nullptr) {} +CJX_Node::CJX_Node(CXFA_Node* node) + : CJX_Object(node), map_module_data_(nullptr) {} CJX_Node::~CJX_Node() { RemoveMapModuleKey(); } +CXFA_Node* CJX_Node::GetXFANode() { + return static_cast(GetXFAObject()); +} + +const CXFA_Node* CJX_Node::GetXFANode() const { + return static_cast(GetXFAObject()); +} + bool CJX_Node::HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); return HasMapModuleKey(pKey, bCanInherit); } @@ -197,7 +206,7 @@ bool CJX_Node::SetAttribute(XFA_ATTRIBUTE eAttr, XFA_ATTRIBUTETYPE eType = pAttr->eType; if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { const XFA_NOTSUREATTRIBUTE* pNotsure = - XFA_GetNotsureAttribute(node_->GetElementType(), pAttr->eName); + XFA_GetNotsureAttribute(GetXFANode()->GetElementType(), pAttr->eName); eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; } switch (eType) { @@ -247,7 +256,7 @@ bool CJX_Node::GetAttribute(XFA_ATTRIBUTE eAttr, XFA_ATTRIBUTETYPE eType = pAttr->eType; if (eType == XFA_ATTRIBUTETYPE_NOTSURE) { const XFA_NOTSUREATTRIBUTE* pNotsure = - XFA_GetNotsureAttribute(node_->GetElementType(), pAttr->eName); + XFA_GetNotsureAttribute(GetXFANode()->GetElementType(), pAttr->eName); eType = pNotsure ? pNotsure->eType : XFA_ATTRIBUTETYPE_Cdata; } switch (eType) { @@ -317,18 +326,121 @@ bool CJX_Node::RemoveAttribute(const WideStringView& wsAttr) { return true; } +int32_t CJX_Node::Subform_and_SubformSet_InstanceIndex() { + int32_t index = 0; + for (CXFA_Node* pNode = GetXFANode()->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; +} + +int32_t CJX_Node::InstanceManager_SetInstances(int32_t iDesired) { + CXFA_Occur nodeOccur(GetXFANode()->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 = GetXFANode()->GetCount(GetXFANode()); + 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) ? GetXFANode() + : GetXFANode()->GetItem(GetXFANode(), 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) { + GetXFANode()->RemoveItem(GetXFANode(), pRemoveInstance); + iCount--; + } + } + } else if (iDesired > iCount) { + while (iCount < iDesired) { + CXFA_Node* pNewInstance = + GetXFANode()->CreateInstance(GetXFANode(), true); + GetXFANode()->InsertItem(GetXFANode(), pNewInstance, iCount, iCount, + false); + iCount++; + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); + if (!pNotify) { + return 0; + } + pNotify->RunNodeInitialize(pNewInstance); + } + } + + CXFA_LayoutProcessor* pLayoutPro = + GetXFANode()->GetDocument()->GetLayoutProcessor(); + if (pLayoutPro) { + pLayoutPro->AddChangedContainer( + ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); + } + return 0; +} + +int32_t CJX_Node::InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom) { + int32_t iCount = GetXFANode()->GetCount(GetXFANode()); + if (iFrom > iCount || iTo > iCount - 1) { + ThrowIndexOutOfBoundsException(); + return 1; + } + if (iFrom < 0 || iTo < 0 || iFrom == iTo) + return 0; + + CXFA_Node* pMoveInstance = GetXFANode()->GetItem(GetXFANode(), iFrom); + GetXFANode()->RemoveItem(GetXFANode(), pMoveInstance, false); + GetXFANode()->InsertItem(GetXFANode(), pMoveInstance, iTo, iCount - 1, true); + CXFA_LayoutProcessor* pLayoutPro = + GetXFANode()->GetDocument()->GetLayoutProcessor(); + if (pLayoutPro) { + pLayoutPro->AddChangedContainer( + ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); + } + return 0; +} + void CJX_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"resolveNode"); + ThrowParamCountMismatchException(L"resolveNode"); return; } WideString wsExpression = WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView()); - CFXJSE_Engine* pScriptContext = node_->GetDocument()->GetScriptContext(); + CFXJSE_Engine* pScriptContext = + GetXFANode()->GetDocument()->GetScriptContext(); if (!pScriptContext) return; - CXFA_Node* refNode = node_.Get(); + CXFA_Node* refNode = GetXFANode(); if (refNode->GetElementType() == XFA_Element::Xfa) refNode = ToNode(pScriptContext->GetThisObject()); uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | @@ -363,7 +475,7 @@ void CJX_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"resolveNodes"); + ThrowParamCountMismatchException(L"resolveNodes"); return; } WideString wsExpression = @@ -374,9 +486,10 @@ void CJX_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; - CXFA_Node* refNode = node_.Get(); + CXFA_Node* refNode = GetXFANode(); if (refNode->GetElementType() == XFA_Element::Xfa) - refNode = ToNode(node_->GetDocument()->GetScriptContext()->GetThisObject()); + refNode = ToNode( + GetXFANode()->GetDocument()->GetScriptContext()->GetThisObject()); Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag, refNode); } @@ -384,15 +497,17 @@ void CJX_Node::Script_Som_ResolveNodeList(CFXJSE_Value* pValue, WideString wsExpression, uint32_t dwFlag, CXFA_Node* refNode) { - CFXJSE_Engine* pScriptContext = node_->GetDocument()->GetScriptContext(); + CFXJSE_Engine* pScriptContext = + GetXFANode()->GetDocument()->GetScriptContext(); if (!pScriptContext) return; XFA_RESOLVENODE_RS resoveNodeRS; if (!refNode) - refNode = node_.Get(); + refNode = GetXFANode(); pScriptContext->ResolveObjects(refNode, wsExpression.AsStringView(), resoveNodeRS, dwFlag); - CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(node_->GetDocument()); + CXFA_ArrayNodeList* pNodeList = + new CXFA_ArrayNodeList(GetXFANode()->GetDocument()); if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { for (CXFA_Object* pObject : resoveNodeRS.objects) { if (pObject->IsNode()) @@ -414,7 +529,7 @@ void CJX_Node::Script_TreeClass_All(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } @@ -428,7 +543,8 @@ void CJX_Node::Script_TreeClass_All(CFXJSE_Value* pValue, void CJX_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CFXJSE_Engine* pScriptContext = node_->GetDocument()->GetScriptContext(); + CFXJSE_Engine* pScriptContext = + GetXFANode()->GetDocument()->GetScriptContext(); if (!pScriptContext) return; @@ -437,7 +553,7 @@ void CJX_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue, FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView()); } else { CXFA_AttachNodeList* pNodeList = - new CXFA_AttachNodeList(node_->GetDocument(), node_.Get()); + new CXFA_AttachNodeList(GetXFANode()->GetDocument(), GetXFANode()); pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass()); } } @@ -446,11 +562,11 @@ void CJX_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; - WideString wsExpression = L"#" + node_->GetClassName() + L"[*]"; + WideString wsExpression = L"#" + GetXFANode()->GetClassName() + L"[*]"; Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); } @@ -458,14 +574,15 @@ void CJX_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - CXFA_Node* pParent = node_->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pParent = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent); if (pParent) pValue->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap(pParent)); + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pParent)); else pValue->SetNull(); } @@ -474,38 +591,38 @@ void CJX_Node::Script_TreeClass_Index(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - pValue->SetInteger(node_->GetNodeSameNameIndex()); + pValue->SetInteger(GetXFANode()->GetNodeSameNameIndex()); } void CJX_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - pValue->SetInteger(node_->GetNodeSameClassIndex()); + pValue->SetInteger(GetXFANode()->GetNodeSameClassIndex()); } void CJX_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } WideString wsSOMExpression; - node_->GetSOMExpression(wsSOMExpression); + GetXFANode()->GetSOMExpression(wsSOMExpression); pValue->SetString(wsSOMExpression.UTF8Encode().AsStringView()); } void CJX_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"applyXSL"); + ThrowParamCountMismatchException(L"applyXSL"); return; } WideString wsExpression = @@ -518,7 +635,7 @@ void CJX_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 3) { - node_->ThrowParamCountMismatchException(L"assignNode"); + ThrowParamCountMismatchException(L"assignNode"); return; } WideString wsExpression; @@ -541,19 +658,20 @@ void CJX_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"clone"); + ThrowParamCountMismatchException(L"clone"); return; } bool bClone = !!pArguments->GetInt32(0); - CXFA_Node* pCloneNode = node_->Clone(bClone); + CXFA_Node* pCloneNode = GetXFANode()->Clone(bClone); pArguments->GetReturnValue()->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap(pCloneNode)); + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pCloneNode)); } void CJX_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"getAttribute"); + ThrowParamCountMismatchException(L"getAttribute"); return; } WideString wsExpression = @@ -568,7 +686,7 @@ void CJX_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 2) { - node_->ThrowParamCountMismatchException(L"getElement"); + ThrowParamCountMismatchException(L"getElement"); return; } WideString wsExpression; @@ -580,14 +698,15 @@ void CJX_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { CXFA_Node* pNode = GetProperty( iValue, XFA_GetElementTypeForName(wsExpression.AsStringView())); pArguments->GetReturnValue()->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode)); + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pNode)); } void CJX_Node::Script_NodeClass_IsPropertySpecified( CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 3) { - node_->ThrowParamCountMismatchException(L"isPropertySpecified"); + ThrowParamCountMismatchException(L"isPropertySpecified"); return; } @@ -605,11 +724,13 @@ void CJX_Node::Script_NodeClass_IsPropertySpecified( int32_t iIndex = iLength == 3 ? pArguments->GetInt32(2) : 0; XFA_Element eType = XFA_GetElementTypeForName(wsExpression.AsStringView()); bHas = !!GetProperty(iIndex, eType); - if (!bHas && bParent && node_->GetParent()) { + if (!bHas && bParent && GetXFANode()->GetParent()) { // Also check on the parent. - bHas = node_->GetParent()->JSNode()->HasAttribute(pAttributeInfo->eName); + bHas = GetXFANode()->GetParent()->JSNode()->HasAttribute( + pAttributeInfo->eName); if (!bHas) - bHas = !!node_->GetParent()->JSNode()->GetProperty(iIndex, eType); + bHas = + !!GetXFANode()->GetParent()->JSNode()->GetProperty(iIndex, eType); } } pValue->SetBoolean(bHas); @@ -618,7 +739,7 @@ void CJX_Node::Script_NodeClass_IsPropertySpecified( void CJX_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 3) { - node_->ThrowParamCountMismatchException(L"loadXML"); + ThrowParamCountMismatchException(L"loadXML"); return; } @@ -632,7 +753,7 @@ void CJX_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { if (iLength >= 3) bOverwrite = !!pArguments->GetInt32(2); auto pParser = - pdfium::MakeUnique(node_->GetDocument(), false); + pdfium::MakeUnique(GetXFANode()->GetDocument(), false); if (!pParser) return; CFX_XMLNode* pXMLNode = pParser->ParseXMLData(wsExpression); @@ -643,7 +764,7 @@ void CJX_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { XFA_RecognizeRichText(static_cast(pXMLNode)))) { bIgnoreRoot = false; } - CXFA_Node* pFakeRoot = node_->Clone(false); + CXFA_Node* pFakeRoot = GetXFANode()->Clone(false); WideStringView wsContentType = GetCData(XFA_ATTRIBUTE_ContentType); if (!wsContentType.IsEmpty()) { pFakeRoot->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, @@ -652,12 +773,12 @@ void CJX_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { std::unique_ptr pFakeXMLRoot(pFakeRoot->GetXMLMappingNode()); if (!pFakeXMLRoot) { - CFX_XMLNode* pThisXMLRoot = node_->GetXMLMappingNode(); + CFX_XMLNode* pThisXMLRoot = GetXFANode()->GetXMLMappingNode(); pFakeXMLRoot = pThisXMLRoot ? pThisXMLRoot->Clone() : nullptr; } if (!pFakeXMLRoot) { - pFakeXMLRoot = - pdfium::MakeUnique(WideString(node_->GetClassName())); + pFakeXMLRoot = pdfium::MakeUnique( + WideString(GetXFANode()->GetClassName())); } if (bIgnoreRoot) { @@ -682,39 +803,39 @@ void CJX_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { return; if (bOverwrite) { - CXFA_Node* pChild = node_->GetNodeItem(XFA_NODEITEM_FirstChild); + CXFA_Node* pChild = GetXFANode()->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); - node_->InsertChild(index++, pNewChild); + GetXFANode()->InsertChild(index++, pNewChild); pNewChild->SetFlag(XFA_NodeFlag_Initialized, true); pNewChild = pItem; } while (pChild) { CXFA_Node* pItem = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - node_->RemoveChild(pChild); + GetXFANode()->RemoveChild(pChild); pFakeRoot->InsertChild(pChild); pChild = pItem; } - if (node_->GetPacketID() == XFA_XDPPACKET_Form && - node_->GetElementType() == XFA_Element::ExData) { - CFX_XMLNode* pTempXMLNode = node_->GetXMLMappingNode(); - node_->SetXMLMappingNode(pFakeXMLRoot.release()); - node_->SetFlag(XFA_NodeFlag_OwnXMLNode, false); + if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form && + GetXFANode()->GetElementType() == XFA_Element::ExData) { + CFX_XMLNode* pTempXMLNode = GetXFANode()->GetXMLMappingNode(); + GetXFANode()->SetXMLMappingNode(pFakeXMLRoot.release()); + GetXFANode()->SetFlag(XFA_NodeFlag_OwnXMLNode, false); if (pTempXMLNode && !pTempXMLNode->GetNodeItem(CFX_XMLNode::Parent)) pFakeXMLRoot.reset(pTempXMLNode); else pFakeXMLRoot = nullptr; } - MoveBufferMapData(pFakeRoot, node_.Get(), XFA_CalcData, true); + MoveBufferMapData(pFakeRoot, GetXFANode(), 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); - node_->InsertChild(pChild); + GetXFANode()->InsertChild(pChild); pChild->SetFlag(XFA_NodeFlag_Initialized, true); pChild = pItem; } @@ -733,29 +854,29 @@ void CJX_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 1) { - node_->ThrowParamCountMismatchException(L"saveXML"); + ThrowParamCountMismatchException(L"saveXML"); return; } bool bPrettyMode = false; if (iLength == 1) { if (pArguments->GetUTF8String(0) != "pretty") { - node_->ThrowArgumentMismatchException(); + ThrowArgumentMismatchException(); return; } bPrettyMode = true; } WideString bsXMLHeader = L"\n"; - if (node_->GetPacketID() == XFA_XDPPACKET_Form || - node_->GetPacketID() == XFA_XDPPACKET_Datasets) { + if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form || + GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) { CFX_XMLNode* pElement = nullptr; - if (node_->GetPacketID() == XFA_XDPPACKET_Datasets) { - pElement = node_->GetXMLMappingNode(); + if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) { + pElement = GetXFANode()->GetXMLMappingNode(); if (!pElement || pElement->GetType() != FX_XMLNODE_Element) { pArguments->GetReturnValue()->SetString( bsXMLHeader.UTF8Encode().AsStringView()); return; } - XFA_DataExporter_DealWithDataGroupNode(node_.Get()); + XFA_DataExporter_DealWithDataGroupNode(GetXFANode()); } auto pMemoryStream = pdfium::MakeRetain(true); auto pStream = @@ -763,8 +884,8 @@ void CJX_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { pStream->SetCodePage(FX_CODEPAGE_UTF8); pStream->WriteString(bsXMLHeader.AsStringView()); - if (node_->GetPacketID() == XFA_XDPPACKET_Form) - XFA_DataExporter_RegenerateFormFile(node_.Get(), pStream, nullptr, true); + if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form) + XFA_DataExporter_RegenerateFormFile(GetXFANode(), pStream, nullptr, true); else pElement->SaveXMLNode(pStream); // TODO(weili): Check whether we need to save pretty print XML, pdfium:501. @@ -780,7 +901,7 @@ void CJX_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 2) { - node_->ThrowParamCountMismatchException(L"setAttribute"); + ThrowParamCountMismatchException(L"setAttribute"); return; } WideString wsAttributeValue = @@ -794,7 +915,7 @@ void CJX_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1 && iLength != 2) { - node_->ThrowParamCountMismatchException(L"setElement"); + ThrowParamCountMismatchException(L"setElement"); return; } CXFA_Node* pNode = nullptr; @@ -812,7 +933,7 @@ void CJX_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } @@ -825,31 +946,32 @@ void CJX_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - pValue->Assign(node_->GetDocument()->GetScriptContext()->GetJSValueFromMap( - node_->GetModelNode())); + pValue->Assign( + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + GetXFANode()->GetModelNode())); } void CJX_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - pValue->SetBoolean(node_->IsContainerNode()); + pValue->SetBoolean(GetXFANode()->IsContainerNode()); } void CJX_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - if (node_->GetElementType() == XFA_Element::Subform) { + if (GetXFANode()->GetElementType() == XFA_Element::Subform) { pValue->SetBoolean(false); return; } @@ -861,24 +983,26 @@ void CJX_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } std::vector properties = - node_->GetNodeList(XFA_NODEFILTER_OneOfProperty); + GetXFANode()->GetNodeList(XFA_NODEFILTER_OneOfProperty); if (!properties.empty()) { - pValue->Assign(node_->GetDocument()->GetScriptContext()->GetJSValueFromMap( - properties.front())); + pValue->Assign( + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + properties.front())); } } void CJX_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} void CJX_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { - CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(node_->GetDocument()); + CXFA_ArrayNodeList* pFormNodes = + new CXFA_ArrayNodeList(GetXFANode()->GetDocument()); pArguments->GetReturnValue()->SetObject( pFormNodes, - node_->GetDocument()->GetScriptContext()->GetJseNormalClass()); + GetXFANode()->GetDocument()->GetScriptContext()->GetJseNormalClass()); } void CJX_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) {} @@ -889,7 +1013,7 @@ void CJX_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1) { - node_->ThrowParamCountMismatchException(L"isCompatibleNS"); + ThrowParamCountMismatchException(L"isCompatibleNS"); return; } WideString wsNameSpace; @@ -926,7 +1050,7 @@ void CJX_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } pValue->SetInteger(GetInteger(eAttribute)); @@ -946,7 +1070,7 @@ void CJX_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); @@ -955,66 +1079,68 @@ void CJX_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue, void CJX_Node::Script_Attribute_SendAttributeChangeMessage( XFA_ATTRIBUTE eAttribute, bool bScriptModify) { - CXFA_LayoutProcessor* pLayoutPro = node_->GetDocument()->GetLayoutProcessor(); + CXFA_LayoutProcessor* pLayoutPro = + GetXFANode()->GetDocument()->GetLayoutProcessor(); if (!pLayoutPro) return; - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - uint32_t dwPacket = node_->GetPacketID(); + uint32_t dwPacket = GetXFANode()->GetPacketID(); if (!(dwPacket & XFA_XDPPACKET_Form)) { - pNotify->OnValueChanged(node_.Get(), eAttribute, node_.Get(), node_.Get()); + pNotify->OnValueChanged(GetXFANode(), eAttribute, GetXFANode(), + GetXFANode()); return; } bool bNeedFindContainer = false; - switch (node_->GetElementType()) { + switch (GetXFANode()->GetElementType()) { case XFA_Element::Caption: bNeedFindContainer = true; - pNotify->OnValueChanged(node_.Get(), eAttribute, node_.Get(), - node_->GetNodeItem(XFA_NODEITEM_Parent)); + pNotify->OnValueChanged(GetXFANode(), eAttribute, GetXFANode(), + GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent)); break; case XFA_Element::Font: case XFA_Element::Para: { bNeedFindContainer = true; - CXFA_Node* pParentNode = node_->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pParentNode = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent); if (pParentNode->GetElementType() == XFA_Element::Caption) { - pNotify->OnValueChanged(node_.Get(), eAttribute, pParentNode, + pNotify->OnValueChanged(GetXFANode(), eAttribute, pParentNode, pParentNode->GetNodeItem(XFA_NODEITEM_Parent)); } else { - pNotify->OnValueChanged(node_.Get(), eAttribute, node_.Get(), + pNotify->OnValueChanged(GetXFANode(), eAttribute, GetXFANode(), pParentNode); } } break; case XFA_Element::Margin: { bNeedFindContainer = true; - CXFA_Node* pParentNode = node_->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pParentNode = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent); XFA_Element eParentType = pParentNode->GetElementType(); if (pParentNode->IsContainerNode()) { - pNotify->OnValueChanged(node_.Get(), eAttribute, node_.Get(), + pNotify->OnValueChanged(GetXFANode(), eAttribute, GetXFANode(), pParentNode); } else if (eParentType == XFA_Element::Caption) { - pNotify->OnValueChanged(node_.Get(), eAttribute, pParentNode, + pNotify->OnValueChanged(GetXFANode(), 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(node_.Get(), eAttribute, pNode, + pNotify->OnValueChanged(GetXFANode(), eAttribute, pNode, pNode->GetNodeItem(XFA_NODEITEM_Parent)); } } } break; case XFA_Element::Comb: { - CXFA_Node* pEditNode = node_->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pEditNode = GetXFANode()->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(node_.Get(), eAttribute, pUINode, + pNotify->OnValueChanged(GetXFANode(), eAttribute, pUINode, pUINode->GetNodeItem(XFA_NODEITEM_Parent)); } } @@ -1026,17 +1152,17 @@ void CJX_Node::Script_Attribute_SendAttributeChangeMessage( case XFA_Element::NumericEdit: case XFA_Element::PasswordEdit: case XFA_Element::TextEdit: { - CXFA_Node* pUINode = node_->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pUINode = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent); if (pUINode) { - pNotify->OnValueChanged(node_.Get(), eAttribute, pUINode, + pNotify->OnValueChanged(GetXFANode(), eAttribute, pUINode, pUINode->GetNodeItem(XFA_NODEITEM_Parent)); } } break; case XFA_Element::CheckButton: { bNeedFindContainer = true; - CXFA_Node* pUINode = node_->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pUINode = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent); if (pUINode) { - pNotify->OnValueChanged(node_.Get(), eAttribute, pUINode, + pNotify->OnValueChanged(GetXFANode(), eAttribute, pUINode, pUINode->GetNodeItem(XFA_NODEITEM_Parent)); } } break; @@ -1054,14 +1180,14 @@ void CJX_Node::Script_Attribute_SendAttributeChangeMessage( case XFA_Element::Field: case XFA_Element::Subform: case XFA_Element::SubformSet: - pLayoutPro->AddChangedContainer(node_.Get()); - pNotify->OnValueChanged(node_.Get(), eAttribute, node_.Get(), - node_.Get()); + pLayoutPro->AddChangedContainer(GetXFANode()); + pNotify->OnValueChanged(GetXFANode(), eAttribute, GetXFANode(), + GetXFANode()); break; case XFA_Element::Sharptext: case XFA_Element::Sharpxml: case XFA_Element::SharpxHTML: { - CXFA_Node* pTextNode = node_->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pTextNode = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent); if (!pTextNode) { return; } @@ -1077,16 +1203,17 @@ void CJX_Node::Script_Attribute_SendAttributeChangeMessage( if (bScriptModify) { pValueNode = pNode; } - pNotify->OnValueChanged(node_.Get(), eAttribute, pValueNode, pNode); + pNotify->OnValueChanged(GetXFANode(), eAttribute, pValueNode, pNode); } else { - pNotify->OnValueChanged(node_.Get(), eAttribute, pNode, + pNotify->OnValueChanged(GetXFANode(), 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(node_.Get(), eAttribute, pValueNode, pNode); + pNotify->OnValueChanged(GetXFANode(), eAttribute, pValueNode, + pNode); } } } @@ -1095,7 +1222,7 @@ void CJX_Node::Script_Attribute_SendAttributeChangeMessage( break; } if (bNeedFindContainer) { - CXFA_Node* pParent = node_.Get(); + CXFA_Node* pParent = GetXFANode(); while (pParent) { if (pParent->IsContainerNode()) break; @@ -1115,9 +1242,9 @@ void CJX_Node::Script_Attribute_String(CFXJSE_Value* pValue, WideString wsValue = pValue->ToWideString(); SetAttribute(eAttribute, wsValue.AsStringView(), true); if (eAttribute == XFA_ATTRIBUTE_Use && - node_->GetElementType() == XFA_Element::Desc) { - CXFA_Node* pTemplateNode = - ToNode(node_->GetDocument()->GetXFAObject(XFA_HASHCODE_Template)); + GetXFANode()->GetElementType() == XFA_Element::Desc) { + CXFA_Node* pTemplateNode = ToNode( + GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Template)); CXFA_Node* pProtoRoot = pTemplateNode->GetFirstChildByClass(XFA_Element::Subform) ->GetFirstChildByClass(XFA_Element::Proto); @@ -1138,21 +1265,23 @@ void CJX_Node::Script_Attribute_String(CFXJSE_Value* pValue, XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; XFA_RESOLVENODE_RS resoveNodeRS; - int32_t iRet = node_->GetDocument()->GetScriptContext()->ResolveObjects( - pProtoRoot, wsSOM.AsStringView(), resoveNodeRS, dwFlag); + int32_t iRet = + GetXFANode()->GetDocument()->GetScriptContext()->ResolveObjects( + pProtoRoot, wsSOM.AsStringView(), resoveNodeRS, dwFlag); if (iRet > 0 && resoveNodeRS.objects.front()->IsNode()) { pProtoNode = resoveNodeRS.objects.front()->AsNode(); } } else if (!wsID.IsEmpty()) { - pProtoNode = - node_->GetDocument()->GetNodeByID(pProtoRoot, wsID.AsStringView()); + pProtoNode = GetXFANode()->GetDocument()->GetNodeByID( + pProtoRoot, wsID.AsStringView()); } if (pProtoNode) { - CXFA_Node* pHeadChild = node_->GetNodeItem(XFA_NODEITEM_FirstChild); + CXFA_Node* pHeadChild = + GetXFANode()->GetNodeItem(XFA_NODEITEM_FirstChild); while (pHeadChild) { CXFA_Node* pSibling = pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling); - node_->RemoveChild(pHeadChild); + GetXFANode()->RemoveChild(pHeadChild); pHeadChild = pSibling; } CXFA_Node* pProtoForm = pProtoNode->CloneTemplateToForm(true); @@ -1161,10 +1290,10 @@ void CJX_Node::Script_Attribute_String(CFXJSE_Value* pValue, CXFA_Node* pSibling = pHeadChild->GetNodeItem(XFA_NODEITEM_NextSibling); pProtoForm->RemoveChild(pHeadChild); - node_->InsertChild(pHeadChild); + GetXFANode()->InsertChild(pHeadChild); pHeadChild = pSibling; } - node_->GetDocument()->RemovePurgeNode(pProtoForm); + GetXFANode()->GetDocument()->RemovePurgeNode(pProtoForm); delete pProtoForm; } } @@ -1179,7 +1308,7 @@ void CJX_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } @@ -1191,7 +1320,7 @@ void CJX_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, void CJX_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 0 && argc != 1) { - node_->ThrowParamCountMismatchException(L"execute"); + ThrowParamCountMismatchException(L"execute"); return; } pArguments->GetReturnValue()->SetBoolean(false); @@ -1199,7 +1328,7 @@ void CJX_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"restore"); + ThrowParamCountMismatchException(L"restore"); } void CJX_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue, @@ -1217,7 +1346,7 @@ void CJX_Node::Script_Delta_Target(CFXJSE_Value* pValue, void CJX_Node::Script_Som_Message(CFXJSE_Value* pValue, bool bSetting, XFA_SOM_MESSAGETYPE iMessageType) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1242,11 +1371,11 @@ void CJX_Node::Script_Som_Message(CFXJSE_Value* pValue, break; } if (!bNew) { - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { return; } - pNotify->AddCalcValidate(node_.Get()); + pNotify->AddCalcValidate(GetXFANode()); } } else { WideString wsMessage; @@ -1277,11 +1406,11 @@ void CJX_Node::Script_Field_Length(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { pValue->SetInteger(0); return; @@ -1292,7 +1421,7 @@ void CJX_Node::Script_Field_Length(CFXJSE_Value* pValue, void CJX_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - XFA_Element eType = node_->GetElementType(); + XFA_Element eType = GetXFANode()->GetElementType(); if (eType == XFA_Element::Field) { Script_Field_DefaultValue(pValue, bSetting, eAttribute); return; @@ -1312,9 +1441,9 @@ void CJX_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, WideString wsFormatValue(wsNewValue); CXFA_WidgetData* pContainerWidgetData = nullptr; - if (node_->GetPacketID() == XFA_XDPPACKET_Datasets) { + if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) { WideString wsPicture; - for (CXFA_Node* pFormNode : node_->GetBindItems()) { + for (CXFA_Node* pFormNode : GetXFANode()->GetBindItems()) { if (!pFormNode || pFormNode->HasRemovedChildren()) continue; pContainerWidgetData = pFormNode->GetContainerWidgetData(); @@ -1326,8 +1455,8 @@ void CJX_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, break; pContainerWidgetData = nullptr; } - } else if (node_->GetPacketID() == XFA_XDPPACKET_Form) { - pContainerWidgetData = node_->GetContainerWidgetData(); + } else if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form) { + pContainerWidgetData = GetXFANode()->GetContainerWidgetData(); } if (pContainerWidgetData) { pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); @@ -1353,7 +1482,7 @@ void CJX_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } @@ -1376,7 +1505,8 @@ void CJX_Node::Script_Boolean_Value(CFXJSE_Value* pValue, int32_t iValue = FXSYS_atoi(newValue.c_str()); WideString wsNewValue(iValue == 0 ? L"0" : L"1"); WideString wsFormatValue(wsNewValue); - CXFA_WidgetData* pContainerWidgetData = node_->GetContainerWidgetData(); + CXFA_WidgetData* pContainerWidgetData = + GetXFANode()->GetContainerWidgetData(); if (pContainerWidgetData) { pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); } @@ -1390,7 +1520,7 @@ void CJX_Node::Script_Boolean_Value(CFXJSE_Value* pValue, void CJX_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1423,7 +1553,7 @@ void CJX_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, void CJX_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1448,7 +1578,7 @@ void CJX_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, void CJX_Node::Script_Som_FillColor(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1482,18 +1612,19 @@ void CJX_Node::Script_Som_DataNode(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - CXFA_Node* pDataNode = node_->GetBindData(); + CXFA_Node* pDataNode = GetXFANode()->GetBindData(); if (!pDataNode) { pValue->SetNull(); return; } pValue->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap(pDataNode)); + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pDataNode)); } void CJX_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, @@ -1501,7 +1632,7 @@ void CJX_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, XFA_ATTRIBUTE eAttribute) { if (bSetting) { if (pValue && pValue->IsString()) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); ASSERT(pWidgetData); XFA_Element uiType = pWidgetData->GetUIType(); if (uiType == XFA_Element::Text) { @@ -1522,7 +1653,7 @@ void CJX_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, void CJX_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1547,7 +1678,8 @@ void CJX_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, wsNewText = pWidgetData->NumericLimit(wsNewText, iLeadDigits, iFracDigits); } - CXFA_WidgetData* pContainerWidgetData = node_->GetContainerWidgetData(); + CXFA_WidgetData* pContainerWidgetData = + GetXFANode()->GetContainerWidgetData(); WideString wsFormatText(wsNewText); if (pContainerWidgetData) { pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText); @@ -1586,7 +1718,7 @@ void CJX_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, void CJX_Node::Script_Field_EditValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1602,7 +1734,7 @@ void CJX_Node::Script_Field_EditValue(CFXJSE_Value* pValue, void CJX_Node::Script_Som_FontColor(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1640,7 +1772,7 @@ void CJX_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue, void CJX_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1656,7 +1788,7 @@ void CJX_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, void CJX_Node::Script_Som_Mandatory(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1684,7 +1816,7 @@ void CJX_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } pValue->SetNull(); @@ -1693,7 +1825,7 @@ void CJX_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, void CJX_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1710,7 +1842,7 @@ void CJX_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, } void CJX_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1719,7 +1851,7 @@ void CJX_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"execEvent"); + ThrowParamCountMismatchException(L"execEvent"); return; } @@ -1736,25 +1868,25 @@ void CJX_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execInitialize"); + ThrowParamCountMismatchException(L"execInitialize"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Initialize, false, + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, false); } void CJX_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"deleteItem"); + ThrowParamCountMismatchException(L"deleteItem"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1768,7 +1900,7 @@ void CJX_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"getSaveItem"); + ThrowParamCountMismatchException(L"getSaveItem"); return; } int32_t iIndex = pArguments->GetInt32(0); @@ -1776,7 +1908,7 @@ void CJX_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { pArguments->GetReturnValue()->SetNull(); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { pArguments->GetReturnValue()->SetNull(); return; @@ -1792,10 +1924,10 @@ void CJX_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"boundItem"); + ThrowParamCountMismatchException(L"boundItem"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1811,10 +1943,10 @@ void CJX_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"getItemState"); + ThrowParamCountMismatchException(L"getItemState"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1827,15 +1959,16 @@ void CJX_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execCalculate"); + ThrowParamCountMismatchException(L"execCalculate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Calculate, false, false); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, + false); } void CJX_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} @@ -1843,7 +1976,7 @@ void CJX_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} void CJX_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - node_->ThrowParamCountMismatchException(L"getDisplayItem"); + ThrowParamCountMismatchException(L"getDisplayItem"); return; } int32_t iIndex = pArguments->GetInt32(0); @@ -1851,7 +1984,7 @@ void CJX_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { pArguments->GetReturnValue()->SetNull(); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { pArguments->GetReturnValue()->SetNull(); return; @@ -1867,10 +2000,10 @@ void CJX_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 2) { - node_->ThrowParamCountMismatchException(L"setItemState"); + ThrowParamCountMismatchException(L"setItemState"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) return; @@ -1886,10 +2019,10 @@ void CJX_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 2) { - node_->ThrowParamCountMismatchException(L"addItem"); + ThrowParamCountMismatchException(L"addItem"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1908,17 +2041,17 @@ void CJX_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execValidate"); + ThrowParamCountMismatchException(L"execValidate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { pArguments->GetReturnValue()->SetBoolean(false); return; } - int32_t iRet = pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Validate, + int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate, false, false); pArguments->GetReturnValue()->SetBoolean( (iRet == XFA_EVENTERROR_Error) ? false : true); @@ -1928,13 +2061,13 @@ void CJX_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); } void CJX_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { return; } @@ -1943,7 +2076,7 @@ void CJX_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, true, true, true); } else { WideString wsValue = GetScriptContent(true); - XFA_VERSION curVersion = node_->GetDocument()->GetCurVersionMode(); + XFA_VERSION curVersion = GetXFANode()->GetDocument()->GetCurVersionMode(); if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { pValue->SetNull(); } else { @@ -1958,7 +2091,7 @@ void CJX_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue, void CJX_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"execEvent"); + ThrowParamCountMismatchException(L"execEvent"); return; } @@ -1971,11 +2104,11 @@ void CJX_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc < 0 || argc > 1) { - node_->ThrowParamCountMismatchException(L"selectedMember"); + ThrowParamCountMismatchException(L"selectedMember"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { pArguments->GetReturnValue()->SetNull(); return; @@ -1995,48 +2128,50 @@ void CJX_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) { return; } pArguments->GetReturnValue()->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode)); + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pReturnNode)); } void CJX_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execInitialize"); + ThrowParamCountMismatchException(L"execInitialize"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Initialize); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize); } void CJX_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execCalculate"); + ThrowParamCountMismatchException(L"execCalculate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Calculate); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate); } void CJX_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execValidate"); + ThrowParamCountMismatchException(L"execValidate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { pArguments->GetReturnValue()->SetBoolean(false); return; } - int32_t iRet = pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Validate); + int32_t iRet = + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate); pArguments->GetReturnValue()->SetBoolean( (iRet == XFA_EVENTERROR_Error) ? false : true); } @@ -2046,34 +2181,34 @@ void CJX_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, XFA_ATTRIBUTE eAttribute) { if (bSetting) { int32_t iTo = pValue->ToInteger(); - int32_t iFrom = node_->Subform_and_SubformSet_InstanceIndex(); + int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); CXFA_Node* pManagerNode = nullptr; - for (CXFA_Node* pNode = node_->GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { + for (CXFA_Node* pNode = GetXFANode()->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 = node_->GetDocument()->GetNotify(); + pManagerNode->JSNode()->InstanceManager_MoveInstance(iTo, iFrom); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { return; } - CXFA_Node* pToInstance = node_->GetItem(pManagerNode, iTo); + CXFA_Node* pToInstance = GetXFANode()->GetItem(pManagerNode, iTo); if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) { pNotify->RunSubformIndexChange(pToInstance); } - CXFA_Node* pFromInstance = node_->GetItem(pManagerNode, iFrom); + CXFA_Node* pFromInstance = GetXFANode()->GetItem(pManagerNode, iFrom); if (pFromInstance && pFromInstance->GetElementType() == XFA_Element::Subform) { pNotify->RunSubformIndexChange(pFromInstance); } } } else { - pValue->SetInteger(node_->Subform_and_SubformSet_InstanceIndex()); + pValue->SetInteger(Subform_and_SubformSet_InstanceIndex()); } } @@ -2081,14 +2216,14 @@ void CJX_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } WideStringView wsName = GetCData(XFA_ATTRIBUTE_Name); CXFA_Node* pInstanceMgr = nullptr; - for (CXFA_Node* pNode = node_->GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; - pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { + for (CXFA_Node* pNode = GetXFANode()->GetNodeItem(XFA_NODEITEM_PrevSibling); + pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { if (pNode->GetElementType() == XFA_Element::InstanceManager) { WideStringView wsInstMgrName = pNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name); @@ -2104,8 +2239,9 @@ void CJX_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, return; } - pValue->Assign(node_->GetDocument()->GetScriptContext()->GetJSValueFromMap( - pInstanceMgr)); + pValue->Assign( + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pInstanceMgr)); } void CJX_Node::Script_Subform_Locale(CFXJSE_Value* pValue, @@ -2115,14 +2251,14 @@ void CJX_Node::Script_Subform_Locale(CFXJSE_Value* pValue, SetCData(XFA_ATTRIBUTE_Locale, pValue->ToWideString(), true, true); } else { WideString wsLocaleName; - node_->GetLocaleName(wsLocaleName); + GetXFANode()->GetLocaleName(wsLocaleName); pValue->SetString(wsLocaleName.UTF8Encode().AsStringView()); } } void CJX_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"execEvent"); + ThrowParamCountMismatchException(L"execEvent"); return; } @@ -2134,55 +2270,56 @@ void CJX_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execInitialize"); + ThrowParamCountMismatchException(L"execInitialize"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Initialize); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize); } void CJX_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execCalculate"); + ThrowParamCountMismatchException(L"execCalculate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Calculate); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate); } void CJX_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execValidate"); + ThrowParamCountMismatchException(L"execValidate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { pArguments->GetReturnValue()->SetBoolean(false); return; } - int32_t iRet = pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Validate); + int32_t iRet = + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate); pArguments->GetReturnValue()->SetBoolean( (iRet == XFA_EVENTERROR_Error) ? false : true); } void CJX_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"getInvalidObjects"); + ThrowParamCountMismatchException(L"getInvalidObjects"); } void CJX_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"formNodes"); + ThrowParamCountMismatchException(L"formNodes"); return; } pArguments->GetReturnValue()->SetBoolean(true); @@ -2190,19 +2327,19 @@ void CJX_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"remerge"); + ThrowParamCountMismatchException(L"remerge"); return; } - node_->GetDocument()->DoDataRemerge(true); + GetXFANode()->GetDocument()->DoDataRemerge(true); } void CJX_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execInitialize"); + ThrowParamCountMismatchException(L"execInitialize"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { pArguments->GetReturnValue()->SetBoolean(false); return; @@ -2213,7 +2350,7 @@ void CJX_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc <= 0 || argc >= 4) { - node_->ThrowParamCountMismatchException(L"createNode"); + ThrowParamCountMismatchException(L"createNode"); return; } @@ -2231,7 +2368,7 @@ void CJX_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { } XFA_Element eType = XFA_GetElementTypeForName(strTagName.AsStringView()); - CXFA_Node* pNewNode = node_->CreateSamePacketNode(eType); + CXFA_Node* pNewNode = GetXFANode()->CreateSamePacketNode(eType); if (!pNewNode) { pArguments->GetReturnValue()->SetNull(); return; @@ -2239,13 +2376,14 @@ void CJX_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { if (strName.IsEmpty()) { pArguments->GetReturnValue()->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode)); + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pNewNode)); return; } if (!GetAttributeOfElement(eType, XFA_ATTRIBUTE_Name, XFA_XDPPACKET_UNKNOWN)) { - node_->ThrowMissingPropertyException(strTagName, L"name"); + ThrowMissingPropertyException(strTagName, L"name"); return; } @@ -2255,12 +2393,13 @@ void CJX_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { pNewNode->CreateXMLMappingNode(); pArguments->GetReturnValue()->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode)); + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pNewNode)); } void CJX_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"recalculate"); + ThrowParamCountMismatchException(L"recalculate"); return; } pArguments->GetReturnValue()->SetBoolean(true); @@ -2268,11 +2407,11 @@ void CJX_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execCalculate"); + ThrowParamCountMismatchException(L"execCalculate"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { pArguments->GetReturnValue()->SetBoolean(false); return; @@ -2282,10 +2421,10 @@ void CJX_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execValidate"); + ThrowParamCountMismatchException(L"execValidate"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { pArguments->GetReturnValue()->SetBoolean(false); return; @@ -2295,11 +2434,11 @@ void CJX_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"evaluate"); + ThrowParamCountMismatchException(L"evaluate"); return; } - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (!pWidgetData) { pArguments->GetReturnValue()->SetBoolean(false); return; @@ -2311,10 +2450,10 @@ void CJX_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - CXFA_Occur nodeOccur(node_->GetOccurNode()); + CXFA_Occur nodeOccur(GetXFANode()->GetOccurNode()); pValue->SetInteger(nodeOccur.GetMax()); } @@ -2322,10 +2461,10 @@ void CJX_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } - CXFA_Occur nodeOccur(node_->GetOccurNode()); + CXFA_Occur nodeOccur(GetXFANode()->GetOccurNode()); pValue->SetInteger(nodeOccur.GetMin()); } @@ -2334,9 +2473,9 @@ void CJX_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue, XFA_ATTRIBUTE eAttribute) { if (bSetting) { int32_t iDesired = pValue->ToInteger(); - node_->InstanceManager_SetInstances(iDesired); + InstanceManager_SetInstances(iDesired); } else { - pValue->SetInteger(node_->GetCount(node_.Get())); + pValue->SetInteger(GetXFANode()->GetCount(GetXFANode())); } } @@ -2348,16 +2487,16 @@ void CJX_Node::Script_InstanceManager_MoveInstance( } int32_t iFrom = pArguments->GetInt32(0); int32_t iTo = pArguments->GetInt32(1); - node_->InstanceManager_MoveInstance(iTo, iFrom); - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + InstanceManager_MoveInstance(iTo, iFrom); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { return; } - CXFA_Node* pToInstance = node_->GetItem(node_.Get(), iTo); + CXFA_Node* pToInstance = GetXFANode()->GetItem(GetXFANode(), iTo); if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) { pNotify->RunSubformIndexChange(pToInstance); } - CXFA_Node* pFromInstance = node_->GetItem(node_.Get(), iFrom); + CXFA_Node* pFromInstance = GetXFANode()->GetItem(GetXFANode(), iFrom); if (pFromInstance && pFromInstance->GetElementType() == XFA_Element::Subform) { pNotify->RunSubformIndexChange(pFromInstance); @@ -2371,35 +2510,36 @@ void CJX_Node::Script_InstanceManager_RemoveInstance( return; } int32_t iIndex = pArguments->GetInt32(0); - int32_t iCount = node_->GetCount(node_.Get()); + int32_t iCount = GetXFANode()->GetCount(GetXFANode()); if (iIndex < 0 || iIndex >= iCount) { - node_->ThrowIndexOutOfBoundsException(); + ThrowIndexOutOfBoundsException(); return; } - CXFA_Occur nodeOccur(node_->GetOccurNode()); + CXFA_Occur nodeOccur(GetXFANode()->GetOccurNode()); int32_t iMin = nodeOccur.GetMin(); if (iCount - 1 < iMin) { - node_->ThrowTooManyOccurancesException(L"min"); + ThrowTooManyOccurancesException(L"min"); return; } - CXFA_Node* pRemoveInstance = node_->GetItem(node_.Get(), iIndex); - node_->RemoveItem(node_.Get(), pRemoveInstance); - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_Node* pRemoveInstance = GetXFANode()->GetItem(GetXFANode(), iIndex); + GetXFANode()->RemoveItem(GetXFANode(), pRemoveInstance); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (pNotify) { for (int32_t i = iIndex; i < iCount - 1; i++) { - CXFA_Node* pSubformInstance = node_->GetItem(node_.Get(), i); + CXFA_Node* pSubformInstance = GetXFANode()->GetItem(GetXFANode(), i); if (pSubformInstance && pSubformInstance->GetElementType() == XFA_Element::Subform) { pNotify->RunSubformIndexChange(pSubformInstance); } } } - CXFA_LayoutProcessor* pLayoutPro = node_->GetDocument()->GetLayoutProcessor(); + CXFA_LayoutProcessor* pLayoutPro = + GetXFANode()->GetDocument()->GetLayoutProcessor(); if (!pLayoutPro) { return; } pLayoutPro->AddChangedContainer( - ToNode(node_->GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); + ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); } void CJX_Node::Script_InstanceManager_SetInstances( @@ -2409,50 +2549,51 @@ void CJX_Node::Script_InstanceManager_SetInstances( return; } int32_t iDesired = pArguments->GetInt32(0); - node_->InstanceManager_SetInstances(iDesired); + InstanceManager_SetInstances(iDesired); } void CJX_Node::Script_InstanceManager_AddInstance( CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 0 && argc != 1) { - node_->ThrowParamCountMismatchException(L"addInstance"); + ThrowParamCountMismatchException(L"addInstance"); return; } bool fFlags = true; if (argc == 1) { fFlags = pArguments->GetInt32(0) == 0 ? false : true; } - int32_t iCount = node_->GetCount(node_.Get()); - CXFA_Occur nodeOccur(node_->GetOccurNode()); + int32_t iCount = GetXFANode()->GetCount(GetXFANode()); + CXFA_Occur nodeOccur(GetXFANode()->GetOccurNode()); int32_t iMax = nodeOccur.GetMax(); if (iMax >= 0 && iCount >= iMax) { - node_->ThrowTooManyOccurancesException(L"max"); + ThrowTooManyOccurancesException(L"max"); return; } - CXFA_Node* pNewInstance = node_->CreateInstance(node_.Get(), fFlags); - node_->InsertItem(node_.Get(), pNewInstance, iCount, iCount, false); + CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(GetXFANode(), fFlags); + GetXFANode()->InsertItem(GetXFANode(), pNewInstance, iCount, iCount, false); pArguments->GetReturnValue()->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap( + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( pNewInstance)); - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { return; } pNotify->RunNodeInitialize(pNewInstance); - CXFA_LayoutProcessor* pLayoutPro = node_->GetDocument()->GetLayoutProcessor(); + CXFA_LayoutProcessor* pLayoutPro = + GetXFANode()->GetDocument()->GetLayoutProcessor(); if (!pLayoutPro) { return; } pLayoutPro->AddChangedContainer( - ToNode(node_->GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); + ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); } void CJX_Node::Script_InstanceManager_InsertInstance( CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 1 && argc != 2) { - node_->ThrowParamCountMismatchException(L"insertInstance"); + ThrowParamCountMismatchException(L"insertInstance"); return; } int32_t iIndex = pArguments->GetInt32(0); @@ -2460,38 +2601,39 @@ void CJX_Node::Script_InstanceManager_InsertInstance( if (argc == 2) { bBind = pArguments->GetInt32(1) == 0 ? false : true; } - CXFA_Occur nodeOccur(node_->GetOccurNode()); - int32_t iCount = node_->GetCount(node_.Get()); + CXFA_Occur nodeOccur(GetXFANode()->GetOccurNode()); + int32_t iCount = GetXFANode()->GetCount(GetXFANode()); if (iIndex < 0 || iIndex > iCount) { - node_->ThrowIndexOutOfBoundsException(); + ThrowIndexOutOfBoundsException(); return; } int32_t iMax = nodeOccur.GetMax(); if (iMax >= 0 && iCount >= iMax) { - node_->ThrowTooManyOccurancesException(L"max"); + ThrowTooManyOccurancesException(L"max"); return; } - CXFA_Node* pNewInstance = node_->CreateInstance(node_.Get(), bBind); - node_->InsertItem(node_.Get(), pNewInstance, iIndex, iCount, true); + CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(GetXFANode(), bBind); + GetXFANode()->InsertItem(GetXFANode(), pNewInstance, iIndex, iCount, true); pArguments->GetReturnValue()->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap( + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( pNewInstance)); - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { return; } pNotify->RunNodeInitialize(pNewInstance); - CXFA_LayoutProcessor* pLayoutPro = node_->GetDocument()->GetLayoutProcessor(); + CXFA_LayoutProcessor* pLayoutPro = + GetXFANode()->GetDocument()->GetLayoutProcessor(); if (!pLayoutPro) { return; } pLayoutPro->AddChangedContainer( - ToNode(node_->GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); + ToNode(GetXFANode()->GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); } void CJX_Node::Script_Occur_Max(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_Occur occur(node_.Get()); + CXFA_Occur occur(GetXFANode()); if (bSetting) { int32_t iMax = pValue->ToInteger(); occur.SetMax(iMax); @@ -2503,7 +2645,7 @@ void CJX_Node::Script_Occur_Max(CFXJSE_Value* pValue, void CJX_Node::Script_Occur_Min(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_Occur occur(node_.Get()); + CXFA_Occur occur(GetXFANode()); if (bSetting) { int32_t iMin = pValue->ToInteger(); occur.SetMin(iMin); @@ -2515,7 +2657,7 @@ void CJX_Node::Script_Occur_Min(CFXJSE_Value* pValue, void CJX_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 0 && argc != 1) { - node_->ThrowParamCountMismatchException(L"metadata"); + ThrowParamCountMismatchException(L"metadata"); return; } pArguments->GetReturnValue()->SetString(""); @@ -2523,95 +2665,97 @@ void CJX_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"formNodes"); + ThrowParamCountMismatchException(L"formNodes"); return; } CXFA_Node* pDataNode = static_cast(pArguments->GetObject(0)); if (!pDataNode) { - node_->ThrowArgumentMismatchException(); + ThrowArgumentMismatchException(); return; } std::vector formItems; - CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(node_->GetDocument()); + CXFA_ArrayNodeList* pFormNodes = + new CXFA_ArrayNodeList(GetXFANode()->GetDocument()); pFormNodes->SetArrayNodeList(formItems); pArguments->GetReturnValue()->SetObject( pFormNodes, - node_->GetDocument()->GetScriptContext()->GetJseNormalClass()); + GetXFANode()->GetDocument()->GetScriptContext()->GetJseNormalClass()); } void CJX_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"remerge"); + ThrowParamCountMismatchException(L"remerge"); return; } - node_->GetDocument()->DoDataRemerge(true); + GetXFANode()->GetDocument()->DoDataRemerge(true); } void CJX_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execInitialize"); + ThrowParamCountMismatchException(L"execInitialize"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Initialize); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize); } void CJX_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) { CXFA_EventParam* pEventParam = - node_->GetDocument()->GetScriptContext()->GetEventParam(); + GetXFANode()->GetDocument()->GetScriptContext()->GetEventParam(); if (pEventParam->m_eType == XFA_EVENT_Calculate || pEventParam->m_eType == XFA_EVENT_InitCalculate) { return; } if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"recalculate"); + ThrowParamCountMismatchException(L"recalculate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; if (pArguments->GetInt32(0) != 0) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Calculate); - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Validate); - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Ready, true); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Ready, true); } void CJX_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execCalculate"); + ThrowParamCountMismatchException(L"execCalculate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) return; - pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Calculate); + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate); } void CJX_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - node_->ThrowParamCountMismatchException(L"execValidate"); + ThrowParamCountMismatchException(L"execValidate"); return; } - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { pArguments->GetReturnValue()->SetBoolean(false); return; } - int32_t iRet = pNotify->ExecEventByDeepFirst(node_.Get(), XFA_EVENT_Validate); + int32_t iRet = + pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate); pArguments->GetReturnValue()->SetBoolean( (iRet == XFA_EVENTERROR_Error) ? false : true); } @@ -2630,12 +2774,12 @@ void CJX_Node::Script_Form_Checksum(CFXJSE_Value* pValue, void CJX_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"getAttribute"); + ThrowParamCountMismatchException(L"getAttribute"); return; } ByteString bsAttributeName = pArguments->GetUTF8String(0); WideString wsAttributeValue; - CFX_XMLNode* pXMLNode = node_->GetXMLMappingNode(); + CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { wsAttributeValue = static_cast(pXMLNode)->GetString( WideString::FromUTF8(bsAttributeName.AsStringView()).c_str()); @@ -2646,12 +2790,12 @@ void CJX_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 2) { - node_->ThrowParamCountMismatchException(L"setAttribute"); + ThrowParamCountMismatchException(L"setAttribute"); return; } ByteString bsValue = pArguments->GetUTF8String(0); ByteString bsName = pArguments->GetUTF8String(1); - CFX_XMLNode* pXMLNode = node_->GetXMLMappingNode(); + CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { static_cast(pXMLNode)->SetString( WideString::FromUTF8(bsName.AsStringView()), @@ -2662,13 +2806,13 @@ void CJX_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { void CJX_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - node_->ThrowParamCountMismatchException(L"removeAttribute"); + ThrowParamCountMismatchException(L"removeAttribute"); return; } ByteString bsName = pArguments->GetUTF8String(0); WideString wsName = WideString::FromUTF8(bsName.AsStringView()); - CFX_XMLNode* pXMLNode = node_->GetXMLMappingNode(); + CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { CFX_XMLElement* pXMLElement = static_cast(pXMLNode); if (pXMLElement->HasAttribute(wsName.c_str())) { @@ -2682,14 +2826,14 @@ void CJX_Node::Script_Packet_Content(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - CFX_XMLNode* pXMLNode = node_->GetXMLMappingNode(); + CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { CFX_XMLElement* pXMLElement = static_cast(pXMLNode); pXMLElement->SetTextData(pValue->ToWideString()); } } else { WideString wsTextData; - CFX_XMLNode* pXMLNode = node_->GetXMLMappingNode(); + CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) { CFX_XMLElement* pXMLElement = static_cast(pXMLNode); wsTextData = pXMLElement->GetTextData(); @@ -2700,87 +2844,87 @@ void CJX_Node::Script_Packet_Content(CFXJSE_Value* pValue, void CJX_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"next"); + ThrowParamCountMismatchException(L"next"); } void CJX_Node::Script_Source_CancelBatch(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"cancelBatch"); + ThrowParamCountMismatchException(L"cancelBatch"); } void CJX_Node::Script_Source_First(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"first"); + ThrowParamCountMismatchException(L"first"); } void CJX_Node::Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"updateBatch"); + ThrowParamCountMismatchException(L"updateBatch"); } void CJX_Node::Script_Source_Previous(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"previous"); + ThrowParamCountMismatchException(L"previous"); } void CJX_Node::Script_Source_IsBOF(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"isBOF"); + ThrowParamCountMismatchException(L"isBOF"); } void CJX_Node::Script_Source_IsEOF(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"isEOF"); + ThrowParamCountMismatchException(L"isEOF"); } void CJX_Node::Script_Source_Cancel(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"cancel"); + ThrowParamCountMismatchException(L"cancel"); } void CJX_Node::Script_Source_Update(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"update"); + ThrowParamCountMismatchException(L"update"); } void CJX_Node::Script_Source_Open(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"open"); + ThrowParamCountMismatchException(L"open"); } void CJX_Node::Script_Source_Delete(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"delete"); + ThrowParamCountMismatchException(L"delete"); } void CJX_Node::Script_Source_AddNew(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"addNew"); + ThrowParamCountMismatchException(L"addNew"); } void CJX_Node::Script_Source_Requery(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"requery"); + ThrowParamCountMismatchException(L"requery"); } void CJX_Node::Script_Source_Resync(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"resync"); + ThrowParamCountMismatchException(L"resync"); } void CJX_Node::Script_Source_Close(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"close"); + ThrowParamCountMismatchException(L"close"); } void CJX_Node::Script_Source_Last(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"last"); + ThrowParamCountMismatchException(L"last"); } void CJX_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) - node_->ThrowParamCountMismatchException(L"hasDataChanged"); + ThrowParamCountMismatchException(L"hasDataChanged"); } void CJX_Node::Script_Source_Db(CFXJSE_Value* pValue, @@ -2792,10 +2936,11 @@ void CJX_Node::Script_Xfa_This(CFXJSE_Value* pValue, XFA_ATTRIBUTE eAttribute) { if (!bSetting) { CXFA_Object* pThis = - node_->GetDocument()->GetScriptContext()->GetThisObject(); + GetXFANode()->GetDocument()->GetScriptContext()->GetThisObject(); ASSERT(pThis); pValue->Assign( - node_->GetDocument()->GetScriptContext()->GetJSValueFromMap(pThis)); + GetXFANode()->GetDocument()->GetScriptContext()->GetJSValueFromMap( + pThis)); } } @@ -2815,7 +2960,7 @@ void CJX_Node::Script_Script_Stateless(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - node_->ThrowInvalidPropertyException(); + ThrowInvalidPropertyException(); return; } pValue->SetString(FX_UTF8Encode(WideStringView(L"0", 1)).AsStringView()); @@ -2856,26 +3001,27 @@ bool CJX_Node::TryEnum(XFA_ATTRIBUTE eAttr, bool CJX_Node::SetMeasure(XFA_ATTRIBUTE eAttr, CXFA_Measurement mValue, bool bNotify) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); - node_->OnChanging(eAttr, bNotify); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); + GetXFANode()->OnChanging(eAttr, bNotify); SetMapModuleBuffer(pKey, &mValue, sizeof(CXFA_Measurement)); - node_->OnChanged(eAttr, bNotify, false); + GetXFANode()->OnChanged(eAttr, bNotify, false); return true; } bool CJX_Node::TryMeasure(XFA_ATTRIBUTE eAttr, CXFA_Measurement& mValue, bool bUseDefault) const { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); + void* pKey = GetMapKey_Element(GetXFANode()->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, node_->GetElementType(), eAttr, - XFA_ATTRIBUTETYPE_Measure, node_->GetPacketID())) { + if (bUseDefault && + XFA_GetAttributeDefaultValue(pValue, GetXFANode()->GetElementType(), + eAttr, XFA_ATTRIBUTETYPE_Measure, + GetXFANode()->GetPacketID())) { memcpy(&mValue, pValue, sizeof(mValue)); return true; } @@ -2891,42 +3037,43 @@ bool CJX_Node::SetCData(XFA_ATTRIBUTE eAttr, const WideString& wsValue, bool bNotify, bool bScriptModify) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); - node_->OnChanging(eAttr, bNotify); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); + GetXFANode()->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) - node_->UpdateNameHash(); + GetXFANode()->UpdateNameHash(); } - node_->OnChanged(eAttr, bNotify, bScriptModify); + GetXFANode()->OnChanged(eAttr, bNotify, bScriptModify); - if (!node_->IsNeedSavingXMLNode() || eAttr == XFA_ATTRIBUTE_QualifiedName || + if (!GetXFANode()->IsNeedSavingXMLNode() || + eAttr == XFA_ATTRIBUTE_QualifiedName || eAttr == XFA_ATTRIBUTE_BindingNode) { return true; } if (eAttr == XFA_ATTRIBUTE_Name && - (node_->GetElementType() == XFA_Element::DataValue || - node_->GetElementType() == XFA_Element::DataGroup)) { + (GetXFANode()->GetElementType() == XFA_Element::DataValue || + GetXFANode()->GetElementType() == XFA_Element::DataGroup)) { return true; } if (eAttr == XFA_ATTRIBUTE_Value) { - FX_XMLNODETYPE eXMLType = node_->GetXMLMappingNode()->GetType(); + FX_XMLNODETYPE eXMLType = GetXFANode()->GetXMLMappingNode()->GetType(); switch (eXMLType) { case FX_XMLNODE_Element: - if (node_->IsAttributeInXML()) { - static_cast(node_->GetXMLMappingNode()) + if (GetXFANode()->IsAttributeInXML()) { + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetString(WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)), wsValue); } else { bool bDeleteChildren = true; - if (node_->GetPacketID() == XFA_XDPPACKET_Datasets) { + if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) { for (CXFA_Node* pChildDataNode = - node_->GetNodeItem(XFA_NODEITEM_FirstChild); + GetXFANode()->GetNodeItem(XFA_NODEITEM_FirstChild); pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem( XFA_NODEITEM_NextSibling)) { if (!pChildDataNode->GetBindItems().empty()) { @@ -2936,15 +3083,16 @@ bool CJX_Node::SetCData(XFA_ATTRIBUTE eAttr, } } if (bDeleteChildren) { - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->DeleteChildren(); } - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetTextData(wsValue); } break; case FX_XMLNODE_Text: - static_cast(node_->GetXMLMappingNode())->SetText(wsValue); + static_cast(GetXFANode()->GetXMLMappingNode()) + ->SetText(wsValue); break; default: ASSERT(0); @@ -2954,12 +3102,12 @@ bool CJX_Node::SetCData(XFA_ATTRIBUTE eAttr, const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); if (pInfo) { - ASSERT(node_->GetXMLMappingNode()->GetType() == FX_XMLNODE_Element); + ASSERT(GetXFANode()->GetXMLMappingNode()->GetType() == FX_XMLNODE_Element); WideString wsAttrName = pInfo->pName; if (pInfo->eName == XFA_ATTRIBUTE_ContentType) { wsAttrName = L"xfa:" + wsAttrName; } - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetString(wsAttrName, wsValue); } return true; @@ -2969,24 +3117,25 @@ bool CJX_Node::SetAttributeValue(const WideString& wsValue, const WideString& wsXMLValue, bool bNotify, bool bScriptModify) { - void* pKey = GetMapKey_Element(node_->GetElementType(), XFA_ATTRIBUTE_Value); - node_->OnChanging(XFA_ATTRIBUTE_Value, bNotify); + void* pKey = + GetMapKey_Element(GetXFANode()->GetElementType(), XFA_ATTRIBUTE_Value); + GetXFANode()->OnChanging(XFA_ATTRIBUTE_Value, bNotify); WideString* pClone = new WideString(wsValue); SetUserData(pKey, pClone, &deleteWideStringCallBack); - node_->OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); - if (node_->IsNeedSavingXMLNode()) { - FX_XMLNODETYPE eXMLType = node_->GetXMLMappingNode()->GetType(); + GetXFANode()->OnChanged(XFA_ATTRIBUTE_Value, bNotify, bScriptModify); + if (GetXFANode()->IsNeedSavingXMLNode()) { + FX_XMLNODETYPE eXMLType = GetXFANode()->GetXMLMappingNode()->GetType(); switch (eXMLType) { case FX_XMLNODE_Element: - if (node_->IsAttributeInXML()) { - static_cast(node_->GetXMLMappingNode()) + if (GetXFANode()->IsAttributeInXML()) { + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetString(WideString(GetCData(XFA_ATTRIBUTE_QualifiedName)), wsXMLValue); } else { bool bDeleteChildren = true; - if (node_->GetPacketID() == XFA_XDPPACKET_Datasets) { + if (GetXFANode()->GetPacketID() == XFA_XDPPACKET_Datasets) { for (CXFA_Node* pChildDataNode = - node_->GetNodeItem(XFA_NODEITEM_FirstChild); + GetXFANode()->GetNodeItem(XFA_NODEITEM_FirstChild); pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem( XFA_NODEITEM_NextSibling)) { if (!pChildDataNode->GetBindItems().empty()) { @@ -2996,15 +3145,15 @@ bool CJX_Node::SetAttributeValue(const WideString& wsValue, } } if (bDeleteChildren) { - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->DeleteChildren(); } - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetTextData(wsXMLValue); } break; case FX_XMLNODE_Text: - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetText(wsXMLValue); break; default: @@ -3018,7 +3167,7 @@ bool CJX_Node::TryCData(XFA_ATTRIBUTE eAttr, WideString& wsValue, bool bUseDefault, bool bProto) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); if (eAttr == XFA_ATTRIBUTE_Value) { WideString* pStr = (WideString*)GetUserData(pKey, bProto); if (pStr) { @@ -3036,9 +3185,9 @@ bool CJX_Node::TryCData(XFA_ATTRIBUTE eAttr, return false; } void* pValue = nullptr; - if (XFA_GetAttributeDefaultValue(pValue, node_->GetElementType(), eAttr, - XFA_ATTRIBUTETYPE_Cdata, - node_->GetPacketID())) { + if (XFA_GetAttributeDefaultValue(pValue, GetXFANode()->GetElementType(), + eAttr, XFA_ATTRIBUTETYPE_Cdata, + GetXFANode()->GetPacketID())) { wsValue = (const wchar_t*)pValue; return true; } @@ -3049,7 +3198,7 @@ bool CJX_Node::TryCData(XFA_ATTRIBUTE eAttr, WideStringView& wsValue, bool bUseDefault, bool bProto) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); if (eAttr == XFA_ATTRIBUTE_Value) { WideString* pStr = (WideString*)GetUserData(pKey, bProto); if (pStr) { @@ -3065,9 +3214,9 @@ bool CJX_Node::TryCData(XFA_ATTRIBUTE eAttr, return false; } void* pValue = nullptr; - if (XFA_GetAttributeDefaultValue(pValue, node_->GetElementType(), eAttr, - XFA_ATTRIBUTETYPE_Cdata, - node_->GetPacketID())) { + if (XFA_GetAttributeDefaultValue(pValue, GetXFANode()->GetElementType(), + eAttr, XFA_ATTRIBUTETYPE_Cdata, + GetXFANode()->GetPacketID())) { wsValue = (WideStringView)(const wchar_t*)pValue; return true; } @@ -3077,12 +3226,12 @@ bool CJX_Node::TryCData(XFA_ATTRIBUTE eAttr, bool CJX_Node::SetObject(XFA_ATTRIBUTE eAttr, void* pData, XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); return SetUserData(pKey, pData, pCallbackInfo); } bool CJX_Node::TryObject(XFA_ATTRIBUTE eAttr, void*& pData) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); pData = GetUserData(pKey); return !!pData; } @@ -3091,31 +3240,31 @@ bool CJX_Node::SetValue(XFA_ATTRIBUTE eAttr, XFA_ATTRIBUTETYPE eType, void* pValue, bool bNotify) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); - node_->OnChanging(eAttr, bNotify); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); + GetXFANode()->OnChanging(eAttr, bNotify); SetMapModuleValue(pKey, pValue); - node_->OnChanged(eAttr, bNotify, false); - if (node_->IsNeedSavingXMLNode()) { - ASSERT(node_->GetXMLMappingNode()->GetType() == FX_XMLNODE_Element); + GetXFANode()->OnChanged(eAttr, bNotify, false); + if (GetXFANode()->IsNeedSavingXMLNode()) { + ASSERT(GetXFANode()->GetXMLMappingNode()->GetType() == FX_XMLNODE_Element); const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttr); if (pInfo) { switch (eType) { case XFA_ATTRIBUTETYPE_Enum: - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetString( pInfo->pName, GetAttributeEnumByID((XFA_ATTRIBUTEENUM)(uintptr_t)pValue) ->pName); break; case XFA_ATTRIBUTETYPE_Boolean: - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetString(pInfo->pName, pValue ? L"1" : L"0"); break; case XFA_ATTRIBUTETYPE_Integer: { WideString wsValue; wsValue.Format( L"%d", static_cast(reinterpret_cast(pValue))); - static_cast(node_->GetXMLMappingNode()) + static_cast(GetXFANode()->GetXMLMappingNode()) ->SetString(pInfo->pName, wsValue); break; } @@ -3131,15 +3280,16 @@ bool CJX_Node::GetValue(XFA_ATTRIBUTE eAttr, XFA_ATTRIBUTETYPE eType, bool bUseDefault, void*& pValue) { - void* pKey = GetMapKey_Element(node_->GetElementType(), eAttr); + void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); if (GetMapModuleValue(pKey, pValue)) { return true; } if (!bUseDefault) { return false; } - return XFA_GetAttributeDefaultValue(pValue, node_->GetElementType(), eAttr, - eType, node_->GetPacketID()); + return XFA_GetAttributeDefaultValue(pValue, GetXFANode()->GetElementType(), + eAttr, eType, + GetXFANode()->GetPacketID()); } bool CJX_Node::SetUserData(void* pKey, @@ -3165,9 +3315,9 @@ bool CJX_Node::SetScriptContent(const WideString& wsContent, bool bSyncData) { CXFA_Node* pNode = nullptr; CXFA_Node* pBindNode = nullptr; - switch (node_->GetObjectType()) { + switch (GetXFANode()->GetObjectType()) { case XFA_ObjectType::ContainerNode: { - if (XFA_FieldIsMultiListBox(node_.Get())) { + if (XFA_FieldIsMultiListBox(GetXFANode())) { CXFA_Node* pValue = GetProperty(0, XFA_Element::Value); if (!pValue) break; @@ -3177,7 +3327,7 @@ bool CJX_Node::SetScriptContent(const WideString& wsContent, pChildValue->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, L"text/xml"); pChildValue->JSNode()->SetScriptContent(wsContent, wsContent, bNotify, bScriptModify, false); - CXFA_Node* pBind = node_->GetBindData(); + CXFA_Node* pBind = GetXFANode()->GetBindData(); if (bSyncData && pBind) { std::vector wsSaveTextArray; size_t iSize = 0; @@ -3238,7 +3388,7 @@ bool CJX_Node::SetScriptContent(const WideString& wsContent, } } for (CXFA_Node* pArrayNode : pBind->GetBindItems()) { - if (pArrayNode != node_.Get()) { + if (pArrayNode != GetXFANode()) { pArrayNode->JSNode()->SetScriptContent( wsContent, wsContent, bNotify, bScriptModify, false); } @@ -3246,8 +3396,8 @@ bool CJX_Node::SetScriptContent(const WideString& wsContent, } break; } - if (node_->GetElementType() == XFA_Element::ExclGroup) { - pNode = node_.Get(); + if (GetXFANode()->GetElementType() == XFA_Element::ExclGroup) { + pNode = GetXFANode(); } else { CXFA_Node* pValue = GetProperty(0, XFA_Element::Value); if (!pValue) @@ -3258,12 +3408,12 @@ bool CJX_Node::SetScriptContent(const WideString& wsContent, pChildValue->JSNode()->SetScriptContent(wsContent, wsContent, bNotify, bScriptModify, false); } - pBindNode = node_->GetBindData(); + pBindNode = GetXFANode()->GetBindData(); if (pBindNode && bSyncData) { pBindNode->JSNode()->SetScriptContent(wsContent, wsXMLValue, bNotify, bScriptModify, false); for (CXFA_Node* pArrayNode : pBindNode->GetBindItems()) { - if (pArrayNode != node_.Get()) { + if (pArrayNode != GetXFANode()) { pArrayNode->JSNode()->SetScriptContent(wsContent, wsContent, bNotify, true, false); } @@ -3274,7 +3424,7 @@ bool CJX_Node::SetScriptContent(const WideString& wsContent, } case XFA_ObjectType::ContentNode: { WideString wsContentType; - if (node_->GetElementType() == XFA_Element::ExData) { + if (GetXFANode()->GetElementType() == XFA_Element::ExData) { GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false); if (wsContentType == L"text/html") { wsContentType = L""; @@ -3282,24 +3432,24 @@ bool CJX_Node::SetScriptContent(const WideString& wsContent, } } CXFA_Node* pContentRawDataNode = - node_->GetNodeItem(XFA_NODEITEM_FirstChild); + GetXFANode()->GetNodeItem(XFA_NODEITEM_FirstChild); if (!pContentRawDataNode) { - pContentRawDataNode = node_->CreateSamePacketNode( + pContentRawDataNode = GetXFANode()->CreateSamePacketNode( (wsContentType == L"text/xml") ? XFA_Element::Sharpxml : XFA_Element::Sharptext); - node_->InsertChild(pContentRawDataNode); + GetXFANode()->InsertChild(pContentRawDataNode); } return pContentRawDataNode->JSNode()->SetScriptContent( wsContent, wsXMLValue, bNotify, bScriptModify, bSyncData); } case XFA_ObjectType::NodeC: case XFA_ObjectType::TextNode: - pNode = node_.Get(); + pNode = GetXFANode(); break; case XFA_ObjectType::NodeV: - pNode = node_.Get(); - if (bSyncData && node_->GetPacketID() == XFA_XDPPACKET_Form) { - CXFA_Node* pParent = node_->GetNodeItem(XFA_NODEITEM_Parent); + pNode = GetXFANode(); + if (bSyncData && GetXFANode()->GetPacketID() == XFA_XDPPACKET_Form) { + CXFA_Node* pParent = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent); if (pParent) { pParent = pParent->GetNodeItem(XFA_NODEITEM_Parent); } @@ -3316,9 +3466,9 @@ bool CJX_Node::SetScriptContent(const WideString& wsContent, } break; default: - if (node_->GetElementType() == XFA_Element::DataValue) { - pNode = node_.Get(); - pBindNode = node_.Get(); + if (GetXFANode()->GetElementType() == XFA_Element::DataValue) { + pNode = GetXFANode(); + pBindNode = GetXFANode(); } break; } @@ -3357,17 +3507,17 @@ bool CJX_Node::TryContent(WideString& wsContent, bool bScriptModify, bool bProto) { CXFA_Node* pNode = nullptr; - switch (node_->GetObjectType()) { + switch (GetXFANode()->GetObjectType()) { case XFA_ObjectType::ContainerNode: - if (node_->GetElementType() == XFA_Element::ExclGroup) { - pNode = node_.Get(); + if (GetXFANode()->GetElementType() == XFA_Element::ExclGroup) { + pNode = GetXFANode(); } else { - CXFA_Node* pValue = node_->GetChild(0, XFA_Element::Value); + CXFA_Node* pValue = GetXFANode()->GetChild(0, XFA_Element::Value); if (!pValue) { return false; } CXFA_Node* pChildValue = pValue->GetNodeItem(XFA_NODEITEM_FirstChild); - if (pChildValue && XFA_FieldIsMultiListBox(node_.Get())) { + if (pChildValue && XFA_FieldIsMultiListBox(GetXFANode())) { pChildValue->JSNode()->SetAttribute(XFA_ATTRIBUTE_ContentType, L"text/xml"); } @@ -3378,10 +3528,10 @@ bool CJX_Node::TryContent(WideString& wsContent, break; case XFA_ObjectType::ContentNode: { CXFA_Node* pContentRawDataNode = - node_->GetNodeItem(XFA_NODEITEM_FirstChild); + GetXFANode()->GetNodeItem(XFA_NODEITEM_FirstChild); if (!pContentRawDataNode) { XFA_Element element = XFA_Element::Sharptext; - if (node_->GetElementType() == XFA_Element::ExData) { + if (GetXFANode()->GetElementType() == XFA_Element::ExData) { WideString wsContentType; GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, false); if (wsContentType == L"text/html") { @@ -3390,8 +3540,8 @@ bool CJX_Node::TryContent(WideString& wsContent, element = XFA_Element::Sharpxml; } } - pContentRawDataNode = node_->CreateSamePacketNode(element); - node_->InsertChild(pContentRawDataNode); + pContentRawDataNode = GetXFANode()->CreateSamePacketNode(element); + GetXFANode()->InsertChild(pContentRawDataNode); } return pContentRawDataNode->JSNode()->TryContent(wsContent, bScriptModify, bProto); @@ -3399,19 +3549,20 @@ bool CJX_Node::TryContent(WideString& wsContent, case XFA_ObjectType::NodeC: case XFA_ObjectType::NodeV: case XFA_ObjectType::TextNode: - pNode = node_.Get(); + pNode = GetXFANode(); default: - if (node_->GetElementType() == XFA_Element::DataValue) { - pNode = node_.Get(); + if (GetXFANode()->GetElementType() == XFA_Element::DataValue) { + pNode = GetXFANode(); } break; } if (pNode) { if (bScriptModify) { - CFXJSE_Engine* pScriptContext = node_->GetDocument()->GetScriptContext(); + CFXJSE_Engine* pScriptContext = + GetXFANode()->GetDocument()->GetScriptContext(); if (pScriptContext) { - node_->GetDocument()->GetScriptContext()->AddNodesOfRunScript( - node_.Get()); + GetXFANode()->GetDocument()->GetScriptContext()->AddNodesOfRunScript( + GetXFANode()); } } return TryCData(XFA_ATTRIBUTE_Value, wsContent, false, bProto); @@ -3421,8 +3572,9 @@ bool CJX_Node::TryContent(WideString& wsContent, bool CJX_Node::TryNamespace(WideString& wsNamespace) { wsNamespace.clear(); - if (node_->IsModelNode() || node_->GetElementType() == XFA_Element::Packet) { - CFX_XMLNode* pXMLNode = node_->GetXMLMappingNode(); + if (GetXFANode()->IsModelNode() || + GetXFANode()->GetElementType() == XFA_Element::Packet) { + CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element) return false; @@ -3430,16 +3582,16 @@ bool CJX_Node::TryNamespace(WideString& wsNamespace) { return true; } - if (node_->GetPacketID() != XFA_XDPPACKET_Datasets) - return node_->GetModelNode()->JSNode()->TryNamespace(wsNamespace); + if (GetXFANode()->GetPacketID() != XFA_XDPPACKET_Datasets) + return GetXFANode()->GetModelNode()->JSNode()->TryNamespace(wsNamespace); - CFX_XMLNode* pXMLNode = node_->GetXMLMappingNode(); + CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode(); if (!pXMLNode) return false; if (pXMLNode->GetType() != FX_XMLNODE_Element) return true; - if (node_->GetElementType() == XFA_Element::DataValue && + if (GetXFANode()->GetElementType() == XFA_Element::DataValue && GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) { return XFA_FDEExtension_ResolveNamespaceQualifier( static_cast(pXMLNode), @@ -3452,14 +3604,14 @@ bool CJX_Node::TryNamespace(WideString& wsNamespace) { CXFA_Node* CJX_Node::GetProperty(int32_t index, XFA_Element eProperty, bool bCreateProperty) { - XFA_Element eType = node_->GetElementType(); - uint32_t dwPacket = node_->GetPacketID(); + XFA_Element eType = GetXFANode()->GetElementType(); + uint32_t dwPacket = GetXFANode()->GetPacketID(); const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement(eType, eProperty, dwPacket); if (!pProperty || index >= pProperty->uOccur) return nullptr; - CXFA_Node* pNode = node_->GetChildNode(); + CXFA_Node* pNode = GetXFANode()->GetChildNode(); int32_t iCount = 0; for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { if (pNode->GetElementType() == eProperty) { @@ -3473,7 +3625,7 @@ CXFA_Node* CJX_Node::GetProperty(int32_t index, return nullptr; if (pProperty->uFlags & XFA_PROPERTYFLAG_OneOf) { - pNode = node_->GetChildNode(); + pNode = GetXFANode()->GetChildNode(); for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { const XFA_PROPERTY* pExistProperty = XFA_GetPropertyOfElement(eType, pNode->GetElementType(), dwPacket); @@ -3485,10 +3637,10 @@ CXFA_Node* CJX_Node::GetProperty(int32_t index, const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(dwPacket); CXFA_Node* pNewNode = nullptr; for (; iCount <= index; iCount++) { - pNewNode = node_->GetDocument()->CreateNode(pPacket, eProperty); + pNewNode = GetXFANode()->GetDocument()->CreateNode(pPacket, eProperty); if (!pNewNode) return nullptr; - node_->InsertChild(pNewNode, nullptr); + GetXFANode()->InsertChild(pNewNode, nullptr); pNewNode->SetFlag(XFA_NodeFlag_Initialized, true); } return pNewNode; @@ -3510,7 +3662,7 @@ void CJX_Node::SetMapModuleValue(void* pKey, void* pValue) { } bool CJX_Node::GetMapModuleValue(void* pKey, void*& pValue) { - for (CXFA_Node* pNode = node_.Get(); pNode; + for (CXFA_Node* pNode = GetXFANode(); pNode; pNode = pNode->GetTemplateNode()) { XFA_MAPMODULEDATA* pModule = pNode->JSNode()->GetMapModuleData(); if (pModule) { @@ -3573,7 +3725,7 @@ bool CJX_Node::GetMapModuleBuffer(void* pKey, int32_t& iBytes, bool bProtoAlso) const { XFA_MAPDATABLOCK* pBuffer = nullptr; - for (const CXFA_Node* pNode = node_.Get(); pNode; + for (const CXFA_Node* pNode = GetXFANode(); pNode; pNode = pNode->GetTemplateNode()) { XFA_MAPMODULEDATA* pModule = pNode->JSNode()->GetMapModuleData(); if (pModule) { @@ -3595,7 +3747,7 @@ bool CJX_Node::GetMapModuleBuffer(void* pKey, } bool CJX_Node::HasMapModuleKey(void* pKey, bool bProtoAlso) { - for (CXFA_Node* pNode = node_.Get(); pNode; + for (CXFA_Node* pNode = GetXFANode(); pNode; pNode = pNode->GetTemplateNode()) { XFA_MAPMODULEDATA* pModule = pNode->JSNode()->GetMapModuleData(); if (pModule) { @@ -3699,7 +3851,7 @@ void CJX_Node::MoveBufferMapData(CXFA_Node* pDstModule, void* pKey) { if (!pKey) { bNeedMove = false; } - if (pDstModule->GetElementType() != node_->GetElementType()) { + if (pDstModule->GetElementType() != GetXFANode()->GetElementType()) { bNeedMove = false; } XFA_MAPMODULEDATA* pSrcModuleData = nullptr; @@ -3758,57 +3910,69 @@ int32_t CJX_Node::execSingleEventByName(const WideStringView& wsEventName, GetEventParaInfoByName(wsEventName); if (eventParaInfo) { uint32_t validFlags = eventParaInfo->m_validFlags; - CXFA_FFNotify* pNotify = node_->GetDocument()->GetNotify(); + CXFA_FFNotify* pNotify = GetXFANode()->GetDocument()->GetNotify(); if (!pNotify) { return iRet; } if (validFlags == 1) { - iRet = pNotify->ExecEventByDeepFirst(node_.Get(), + iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), eventParaInfo->m_eventType); } else if (validFlags == 2) { iRet = pNotify->ExecEventByDeepFirst( - node_.Get(), eventParaInfo->m_eventType, false, false); + GetXFANode(), eventParaInfo->m_eventType, false, false); } else if (validFlags == 3) { if (eType == XFA_Element::Subform) { iRet = pNotify->ExecEventByDeepFirst( - node_.Get(), eventParaInfo->m_eventType, false, false); + GetXFANode(), eventParaInfo->m_eventType, false, false); } } else if (validFlags == 4) { if (eType == XFA_Element::ExclGroup || eType == XFA_Element::Field) { - CXFA_Node* pParentNode = node_->GetNodeItem(XFA_NODEITEM_Parent); + CXFA_Node* pParentNode = GetXFANode()->GetNodeItem(XFA_NODEITEM_Parent); if (pParentNode && pParentNode->GetElementType() == XFA_Element::ExclGroup) { iRet = pNotify->ExecEventByDeepFirst( - node_.Get(), eventParaInfo->m_eventType, false, false); + GetXFANode(), eventParaInfo->m_eventType, false, false); } iRet = pNotify->ExecEventByDeepFirst( - node_.Get(), eventParaInfo->m_eventType, false, false); + GetXFANode(), eventParaInfo->m_eventType, false, false); } } else if (validFlags == 5) { if (eType == XFA_Element::Field) { iRet = pNotify->ExecEventByDeepFirst( - node_.Get(), eventParaInfo->m_eventType, false, false); + GetXFANode(), eventParaInfo->m_eventType, false, false); } } else if (validFlags == 6) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (pWidgetData) { CXFA_Node* pUINode = pWidgetData->GetUIChild(); if (pUINode->GetElementType() == XFA_Element::Signature) { iRet = pNotify->ExecEventByDeepFirst( - node_.Get(), eventParaInfo->m_eventType, false, false); + GetXFANode(), eventParaInfo->m_eventType, false, false); } } } else if (validFlags == 7) { - CXFA_WidgetData* pWidgetData = node_->GetWidgetData(); + CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData(); if (pWidgetData) { CXFA_Node* pUINode = pWidgetData->GetUIChild(); if ((pUINode->GetElementType() == XFA_Element::ChoiceList) && (!pWidgetData->IsListBox())) { iRet = pNotify->ExecEventByDeepFirst( - node_.Get(), eventParaInfo->m_eventType, false, false); + GetXFANode(), eventParaInfo->m_eventType, false, false); } } } } return iRet; } + +void CJX_Node::ThrowMissingPropertyException(const WideString& obj, + const WideString& prop) const { + ThrowException(L"'%s' doesn't have property '%s'.", obj.c_str(), + prop.c_str()); +} + +void CJX_Node::ThrowTooManyOccurancesException(const WideString& obj) const { + ThrowException( + L"The element [%s] has violated its allowable number of occurrences.", + obj.c_str()); +} diff --git a/fxjs/cjx_node.h b/fxjs/cjx_node.h index 235eca144f..a70cec3ce7 100644 --- a/fxjs/cjx_node.h +++ b/fxjs/cjx_node.h @@ -10,6 +10,7 @@ #include #include "core/fxcrt/unowned_ptr.h" +#include "fxjs/cjx_object.h" #include "xfa/fxfa/fxfa_basic.h" typedef void (*PD_CALLBACK_FREEDATA)(void* pData); @@ -43,10 +44,13 @@ enum XFA_SOM_MESSAGETYPE { class CFXJSE_Arguments; class CXFA_Node; -class CJX_Node { +class CJX_Node : public CJX_Object { public: explicit CJX_Node(CXFA_Node* node); - ~CJX_Node(); + ~CJX_Node() override; + + CXFA_Node* GetXFANode(); + const CXFA_Node* GetXFANode() const; bool HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit = false); bool SetAttribute(XFA_ATTRIBUTE eAttr, @@ -165,6 +169,14 @@ class CJX_Node { void MergeAllData(void* pDstModule); + void ThrowMissingPropertyException(const WideString& obj, + const WideString& prop) const; + void ThrowTooManyOccurancesException(const WideString& obj) const; + + int32_t Subform_and_SubformSet_InstanceIndex(); + int32_t InstanceManager_SetInstances(int32_t iDesired); + int32_t InstanceManager_MoveInstance(int32_t iTo, int32_t iFrom); + void Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments); void Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments); void Script_Som_ResolveNodeList(CFXJSE_Value* pValue, @@ -489,7 +501,6 @@ class CJX_Node { int32_t execSingleEventByName(const WideStringView& wsEventName, XFA_Element eType); - UnownedPtr node_; XFA_MAPMODULEDATA* map_module_data_; }; diff --git a/fxjs/cjx_object.cpp b/fxjs/cjx_object.cpp new file mode 100644 index 0000000000..a3ba05f1b4 --- /dev/null +++ b/fxjs/cjx_object.cpp @@ -0,0 +1,55 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "fxjs/cjx_object.h" + +#include "fxjs/cfxjse_value.h" +#include "xfa/fxfa/parser/cxfa_object.h" + +CJX_Object::CJX_Object(CXFA_Object* obj) : object_(obj) {} + +CJX_Object::~CJX_Object() {} + +void CJX_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute) { + if (bSetting) { + ThrowInvalidPropertyException(); + return; + } + pValue->SetString( + FX_UTF8Encode(GetXFAObject()->GetClassName()).AsStringView()); +} + +void CJX_Object::ThrowInvalidPropertyException() const { + ThrowException(L"Invalid property set operation."); +} + +void CJX_Object::ThrowIndexOutOfBoundsException() const { + ThrowException(L"Index value is out of bounds."); +} + +void CJX_Object::ThrowParamCountMismatchException( + const WideString& method) const { + ThrowException(L"Incorrect number of parameters calling method '%.16s'.", + method.c_str()); +} + +void CJX_Object::ThrowArgumentMismatchException() const { + ThrowException(L"Argument mismatch in property or function argument."); +} + +void CJX_Object::ThrowException(const wchar_t* str, ...) const { + WideString wsMessage; + va_list arg_ptr; + + va_start(arg_ptr, str); + wsMessage.FormatV(str, arg_ptr); + va_end(arg_ptr); + + ASSERT(!wsMessage.IsEmpty()); + FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView()); +} diff --git a/fxjs/cjx_object.h b/fxjs/cjx_object.h new file mode 100644 index 0000000000..9e957d88ba --- /dev/null +++ b/fxjs/cjx_object.h @@ -0,0 +1,41 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FXJS_CJX_OBJECT_H_ +#define FXJS_CJX_OBJECT_H_ + +#include "core/fxcrt/unowned_ptr.h" +#include "core/fxcrt/widestring.h" +#include "xfa/fxfa/fxfa_basic.h" + +class CFXJSE_Value; +class CXFA_Object; + +class CJX_Object { + public: + explicit CJX_Object(CXFA_Object* object); + virtual ~CJX_Object(); + + CXFA_Object* GetXFAObject() { return object_.Get(); } + const CXFA_Object* GetXFAObject() const { return object_.Get(); } + + void Script_ObjectClass_ClassName(CFXJSE_Value* pValue, + bool bSetting, + XFA_ATTRIBUTE eAttribute); + + void ThrowInvalidPropertyException() const; + void ThrowArgumentMismatchException() const; + void ThrowIndexOutOfBoundsException() const; + void ThrowParamCountMismatchException(const WideString& method) const; + + // Make this protected when the cscript_* objects are converted to CJX. + void ThrowException(const wchar_t* str, ...) const; + + private: + UnownedPtr object_; +}; + +#endif // FXJS_CJX_OBJECT_H_ diff --git a/xfa/fxfa/parser/cscript_datawindow.cpp b/xfa/fxfa/parser/cscript_datawindow.cpp index c5b09d155b..80b31f7ca9 100644 --- a/xfa/fxfa/parser/cscript_datawindow.cpp +++ b/xfa/fxfa/parser/cscript_datawindow.cpp @@ -7,6 +7,8 @@ #include "xfa/fxfa/parser/cscript_datawindow.h" #include "fxjs/cfxjse_arguments.h" +#include "fxjs/cjx_object.h" +#include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/xfa_utils.h" @@ -15,7 +17,8 @@ CScript_DataWindow::CScript_DataWindow(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::DataWindow, - WideStringView(L"dataWindow")) {} + WideStringView(L"dataWindow"), + pdfium::MakeUnique(this)) {} CScript_DataWindow::~CScript_DataWindow() {} diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index 1f20f291e6..633ee9b7d2 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -8,6 +8,8 @@ #include "fxjs/cfxjse_arguments.h" #include "fxjs/cfxjse_engine.h" +#include "fxjs/cjx_object.h" +#include "third_party/base/ptr_util.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/cxfa_ffwidgethandler.h" @@ -47,7 +49,8 @@ CScript_EventPseudoModel::CScript_EventPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::EventPseudoModel, - WideStringView(L"eventPseudoModel")) {} + WideStringView(L"eventPseudoModel"), + pdfium::MakeUnique(this)) {} CScript_EventPseudoModel::~CScript_EventPseudoModel() {} diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index c074e0ed2e..75227cfe79 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -10,6 +10,8 @@ #include "fxjs/cfxjse_arguments.h" #include "fxjs/cfxjse_engine.h" +#include "fxjs/cjx_object.h" +#include "third_party/base/ptr_util.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" @@ -30,7 +32,8 @@ CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::HostPseudoModel, - WideStringView(L"hostPseudoModel")) {} + WideStringView(L"hostPseudoModel"), + pdfium::MakeUnique(this)) {} CScript_HostPseudoModel::~CScript_HostPseudoModel() {} @@ -41,7 +44,7 @@ void CScript_HostPseudoModel::AppType(CFXJSE_Value* pValue, if (!pNotify) return; if (bSetting) { - ThrowInvalidPropertyException(); + JSObject()->ThrowInvalidPropertyException(); return; } pValue->SetString("Exchange"); @@ -85,7 +88,7 @@ void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue, if (!pNotify) return; if (bSetting) { - ThrowSetLanguageException(); + JSObject()->ThrowException(L"Unable to set language value."); return; } pValue->SetString( @@ -101,7 +104,7 @@ void CScript_HostPseudoModel::NumPages(CFXJSE_Value* pValue, } CXFA_FFDoc* hDoc = pNotify->GetHDOC(); if (bSetting) { - ThrowSetNumPagesException(); + JSObject()->ThrowException(L"Unable to set numPages value."); return; } pValue->SetInteger(pNotify->GetDocEnvironment()->CountPages(hDoc)); @@ -114,7 +117,7 @@ void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue, if (!pNotify) return; if (bSetting) { - ThrowSetPlatformException(); + JSObject()->ThrowException(L"Unable to set platform value."); return; } pValue->SetString( @@ -168,7 +171,7 @@ void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue, if (!pNotify) return; if (bSetting) { - ThrowSetVariationException(); + JSObject()->ThrowException(L"Unable to set variation value."); return; } pValue->SetString("Full"); @@ -182,7 +185,7 @@ void CScript_HostPseudoModel::Version(CFXJSE_Value* pValue, return; } if (bSetting) { - ThrowSetVersionException(); + JSObject()->ThrowException(L"Unable to set version value."); return; } pValue->SetString("11"); @@ -196,7 +199,7 @@ void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, return; } if (bSetting) { - ThrowInvalidPropertyException(); + JSObject()->ThrowInvalidPropertyException(); return; } pValue->SetString( @@ -209,7 +212,7 @@ void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - ThrowParamCountMismatchException(L"gotoURL"); + JSObject()->ThrowParamCountMismatchException(L"gotoURL"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -231,7 +234,7 @@ void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - ThrowParamCountMismatchException(L"openList"); + JSObject()->ThrowParamCountMismatchException(L"openList"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -278,7 +281,7 @@ void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { void CScript_HostPseudoModel::Response(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 4) { - ThrowParamCountMismatchException(L"response"); + JSObject()->ThrowParamCountMismatchException(L"response"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -315,6 +318,7 @@ void CScript_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) { if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) pValue->SetInteger(0); } + static int32_t XFA_FilterName(const WideStringView& wsExpression, int32_t nStart, WideString& wsFilter) { @@ -339,10 +343,11 @@ static int32_t XFA_FilterName(const WideStringView& wsExpression, wsFilter.TrimRight(); return nStart; } + void CScript_HostPseudoModel::ResetData(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 1) { - ThrowParamCountMismatchException(L"resetData"); + JSObject()->ThrowParamCountMismatchException(L"resetData"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -387,13 +392,14 @@ void CScript_HostPseudoModel::ResetData(CFXJSE_Arguments* pArguments) { pNotify->ResetData(); } } + void CScript_HostPseudoModel::Beep(CFXJSE_Arguments* pArguments) { if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { return; } int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 1) { - ThrowParamCountMismatchException(L"beep"); + JSObject()->ThrowParamCountMismatchException(L"beep"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -406,13 +412,14 @@ void CScript_HostPseudoModel::Beep(CFXJSE_Arguments* pArguments) { } pNotify->GetAppProvider()->Beep(dwType); } + void CScript_HostPseudoModel::SetFocus(CFXJSE_Arguments* pArguments) { if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { return; } int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - ThrowParamCountMismatchException(L"setFocus"); + JSObject()->ThrowParamCountMismatchException(L"setFocus"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -465,7 +472,7 @@ void CScript_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) { } int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 4) { - ThrowParamCountMismatchException(L"messageBox"); + JSObject()->ThrowParamCountMismatchException(L"messageBox"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -504,6 +511,7 @@ void CScript_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) { if (pValue) pValue->SetInteger(iValue); } + bool CScript_HostPseudoModel::ValidateArgsForMsg(CFXJSE_Arguments* pArguments, int32_t iArgIndex, WideString& wsValue) { @@ -517,7 +525,7 @@ bool CScript_HostPseudoModel::ValidateArgsForMsg(CFXJSE_Arguments* pArguments, } std::unique_ptr pValueArg(pArguments->GetValue(iArgIndex)); if (!pValueArg->IsString() && bIsJsType) { - ThrowArgumentMismatchException(); + JSObject()->ThrowArgumentMismatchException(); return false; } if (pValueArg->IsNull()) { @@ -527,18 +535,20 @@ bool CScript_HostPseudoModel::ValidateArgsForMsg(CFXJSE_Arguments* pArguments, } return true; } + void CScript_HostPseudoModel::DocumentCountInBatch( CFXJSE_Arguments* pArguments) { if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) pValue->SetInteger(0); } + void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { return; } int32_t iLength = pArguments->GetLength(); if (iLength != 8) { - ThrowParamCountMismatchException(L"print"); + JSObject()->ThrowParamCountMismatchException(L"print"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -604,7 +614,7 @@ void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 1) { - ThrowParamCountMismatchException(L"importData"); + JSObject()->ThrowParamCountMismatchException(L"importData"); return; } // Not implemented. @@ -613,7 +623,7 @@ void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { void CScript_HostPseudoModel::ExportData(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 0 || iLength > 2) { - ThrowParamCountMismatchException(L"exportData"); + JSObject()->ThrowParamCountMismatchException(L"exportData"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); @@ -678,23 +688,3 @@ void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { if (pValue) pValue->SetString(wsDataTime.UTF8Encode().AsStringView()); } - -void CScript_HostPseudoModel::ThrowSetLanguageException() const { - ThrowException(L"Unable to set language value."); -} - -void CScript_HostPseudoModel::ThrowSetNumPagesException() const { - ThrowException(L"Unable to set numPages value."); -} - -void CScript_HostPseudoModel::ThrowSetPlatformException() const { - ThrowException(L"Unable to set platform value."); -} - -void CScript_HostPseudoModel::ThrowSetVariationException() const { - ThrowException(L"Unable to set variation value."); -} - -void CScript_HostPseudoModel::ThrowSetVersionException() const { - ThrowException(L"Unable to set version value."); -} diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.h b/xfa/fxfa/parser/cscript_hostpseudomodel.h index 4ec92dd73a..de07b1cd45 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.h +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.h @@ -55,11 +55,6 @@ class CScript_HostPseudoModel : public CXFA_Object { bool ValidateArgsForMsg(CFXJSE_Arguments* pArguments, int32_t iArgIndex, WideString& wsValue); - void ThrowSetLanguageException() const; - void ThrowSetNumPagesException() const; - void ThrowSetPlatformException() const; - void ThrowSetVariationException() const; - void ThrowSetVersionException() const; }; #endif // XFA_FXFA_PARSER_CSCRIPT_HOSTPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp index 574b62644a..4c7d7f2006 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp @@ -10,6 +10,8 @@ #include "fxjs/cfxjse_arguments.h" #include "fxjs/cfxjse_engine.h" +#include "fxjs/cjx_object.h" +#include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_arraynodelist.h" @@ -28,7 +30,8 @@ CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::LayoutPseudoModel, - WideStringView(L"layoutPseudoModel")) {} + WideStringView(L"layoutPseudoModel"), + pdfium::MakeUnique(this)) {} CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} @@ -40,7 +43,7 @@ void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue, return; } if (bSetting) { - ThrowSetReadyException(); + JSObject()->ThrowException(L"Unable to set ready value."); return; } int32_t iStatus = pNotify->GetLayoutStatus(); @@ -66,7 +69,7 @@ void CScript_LayoutPseudoModel::HWXY(CFXJSE_Arguments* pArguments, methodName = L"y"; break; } - ThrowParamCountMismatchException(methodName); + JSObject()->ThrowParamCountMismatchException(methodName); return; } CXFA_Node* pNode = static_cast(pArguments->GetObject(0)); @@ -170,7 +173,7 @@ void CScript_LayoutPseudoModel::PageCount(CFXJSE_Arguments* pArguments) { void CScript_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - ThrowParamCountMismatchException(L"pageSpan"); + JSObject()->ThrowParamCountMismatchException(L"pageSpan"); return; } CXFA_Node* pNode = nullptr; @@ -334,7 +337,7 @@ std::vector CScript_LayoutPseudoModel::GetObjArray( void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 3) { - ThrowParamCountMismatchException(L"pageContent"); + JSObject()->ThrowParamCountMismatchException(L"pageContent"); return; } int32_t iIndex = 0; @@ -398,7 +401,7 @@ void CScript_LayoutPseudoModel::AbsPageSpan(CFXJSE_Arguments* pArguments) { void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - ThrowParamCountMismatchException(L"absPageInBatch"); + JSObject()->ThrowParamCountMismatchException(L"absPageInBatch"); return; } @@ -407,7 +410,7 @@ void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) { void CScript_LayoutPseudoModel::SheetInBatch(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 1) { - ThrowParamCountMismatchException(L"sheetInBatch"); + JSObject()->ThrowParamCountMismatchException(L"sheetInBatch"); return; } @@ -433,7 +436,8 @@ void CScript_LayoutPseudoModel::PageInternals(CFXJSE_Arguments* pArguments, bool bAbsPage) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { - ThrowParamCountMismatchException(bAbsPage ? L"absPage" : L"page"); + JSObject()->ThrowParamCountMismatchException(bAbsPage ? L"absPage" + : L"page"); return; } @@ -454,7 +458,3 @@ void CScript_LayoutPseudoModel::PageInternals(CFXJSE_Arguments* pArguments, int32_t iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); pValue->SetInteger(bAbsPage ? iPage : iPage + 1); } - -void CScript_LayoutPseudoModel::ThrowSetReadyException() const { - ThrowException(L"Unable to set ready value."); -} diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.h b/xfa/fxfa/parser/cscript_layoutpseudomodel.h index 539fcce4ca..c38871ab95 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.h +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.h @@ -57,7 +57,6 @@ class CScript_LayoutPseudoModel : public CXFA_Object { bool bOnPageArea); void PageInternals(CFXJSE_Arguments* pArguments, bool bAbsPage); - void ThrowSetReadyException() const; }; #endif // XFA_FXFA_PARSER_CSCRIPT_LAYOUTPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/cscript_logpseudomodel.cpp b/xfa/fxfa/parser/cscript_logpseudomodel.cpp index f0747f4a12..2c99972042 100644 --- a/xfa/fxfa/parser/cscript_logpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_logpseudomodel.cpp @@ -7,6 +7,8 @@ #include "xfa/fxfa/parser/cscript_logpseudomodel.h" #include "fxjs/cfxjse_arguments.h" +#include "fxjs/cjx_object.h" +#include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/xfa_utils.h" @@ -15,7 +17,8 @@ CScript_LogPseudoModel::CScript_LogPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::LogPseudoModel, - WideStringView(L"logPseudoModel")) {} + WideStringView(L"logPseudoModel"), + pdfium::MakeUnique(this)) {} CScript_LogPseudoModel::~CScript_LogPseudoModel() {} diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp index ff98953590..c08c166ec4 100644 --- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp @@ -8,6 +8,8 @@ #include "fxjs/cfxjse_arguments.h" #include "fxjs/cfxjse_engine.h" +#include "fxjs/cjx_object.h" +#include "third_party/base/ptr_util.h" #include "xfa/fxfa/cxfa_ffnotify.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" @@ -18,14 +20,15 @@ CScript_SignaturePseudoModel::CScript_SignaturePseudoModel( : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::SignaturePseudoModel, - WideStringView(L"signaturePseudoModel")) {} + WideStringView(L"signaturePseudoModel"), + pdfium::MakeUnique(this)) {} CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {} void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 4) { - ThrowParamCountMismatchException(L"verify"); + JSObject()->ThrowParamCountMismatchException(L"verify"); return; } @@ -37,7 +40,7 @@ void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) { void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 3 || iLength > 7) { - ThrowParamCountMismatchException(L"sign"); + JSObject()->ThrowParamCountMismatchException(L"sign"); return; } @@ -48,7 +51,7 @@ void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) { void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) { if (pArguments->GetLength() != 0) { - ThrowParamCountMismatchException(L"enumerate"); + JSObject()->ThrowParamCountMismatchException(L"enumerate"); return; } return; @@ -57,7 +60,7 @@ void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) { void CScript_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 2) { - ThrowParamCountMismatchException(L"clear"); + JSObject()->ThrowParamCountMismatchException(L"clear"); return; } diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index a33a5c21ac..6b3859e0d2 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -148,7 +148,11 @@ CXFA_Node::CXFA_Node(CXFA_Document* pDoc, XFA_ObjectType oType, XFA_Element eType, const WideStringView& elementName) - : CXFA_Object(pDoc, oType, eType, elementName), + : CXFA_Object(pDoc, + oType, + eType, + elementName, + pdfium::MakeUnique(this)), m_pNext(nullptr), m_pChild(nullptr), m_pLastChild(nullptr), @@ -157,8 +161,7 @@ CXFA_Node::CXFA_Node(CXFA_Document* pDoc, m_ePacket(ePacket), m_uNodeFlags(XFA_NodeFlag_None), m_dwNameHash(0), - m_pAuxNode(nullptr), - m_JSNode(this) { + m_pAuxNode(nullptr) { ASSERT(m_pDocument); } @@ -180,15 +183,15 @@ CXFA_Node* CXFA_Node::Clone(bool bRecursive) { if (!pClone) return nullptr; - m_JSNode.MergeAllData(pClone); + JSNode()->MergeAllData(pClone); pClone->UpdateNameHash(); if (IsNeedSavingXMLNode()) { std::unique_ptr pCloneXML; if (IsAttributeInXML()) { WideString wsName; - m_JSNode.GetAttribute(XFA_ATTRIBUTE_Name, wsName, false); + JSNode()->GetAttribute(XFA_ATTRIBUTE_Name, wsName, false); auto pCloneXMLElement = pdfium::MakeUnique(wsName); - WideStringView wsValue = m_JSNode.GetCData(XFA_ATTRIBUTE_Value); + WideStringView wsValue = JSNode()->GetCData(XFA_ATTRIBUTE_Value); if (!wsValue.IsEmpty()) { pCloneXMLElement->SetTextData(WideString(wsValue)); } @@ -371,18 +374,19 @@ void CXFA_Node::SetTemplateNode(CXFA_Node* pTemplateNode) { CXFA_Node* CXFA_Node::GetBindData() { ASSERT(GetPacketID() == XFA_XDPPACKET_Form); - return static_cast(m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode)); + return static_cast( + JSNode()->GetObject(XFA_ATTRIBUTE_BindingNode)); } std::vector CXFA_Node::GetBindItems() { if (BindsFormItems()) { void* pBinding = nullptr; - m_JSNode.TryObject(XFA_ATTRIBUTE_BindingNode, pBinding); + JSNode()->TryObject(XFA_ATTRIBUTE_BindingNode, pBinding); return *static_cast*>(pBinding); } std::vector result; CXFA_Node* pFormNode = - static_cast(m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode)); + static_cast(JSNode()->GetObject(XFA_ATTRIBUTE_BindingNode)); if (pFormNode) result.push_back(pFormNode); return result; @@ -392,24 +396,24 @@ int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) { ASSERT(pFormNode); if (BindsFormItems()) { void* pBinding = nullptr; - m_JSNode.TryObject(XFA_ATTRIBUTE_BindingNode, pBinding); + JSNode()->TryObject(XFA_ATTRIBUTE_BindingNode, pBinding); auto* pItems = static_cast*>(pBinding); if (!pdfium::ContainsValue(*pItems, pFormNode)) pItems->push_back(pFormNode); return pdfium::CollectionSize(*pItems); } CXFA_Node* pOldFormItem = - static_cast(m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode)); + static_cast(JSNode()->GetObject(XFA_ATTRIBUTE_BindingNode)); if (!pOldFormItem) { - m_JSNode.SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode); + JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode); return 1; } if (pOldFormItem == pFormNode) return 1; std::vector* pItems = new std::vector; - m_JSNode.SetObject(XFA_ATTRIBUTE_BindingNode, pItems, - &deleteBindItemCallBack); + JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, pItems, + &deleteBindItemCallBack); pItems->push_back(pOldFormItem); pItems->push_back(pFormNode); m_uNodeFlags |= XFA_NodeFlag_BindFormItems; @@ -419,15 +423,15 @@ int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) { int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) { if (BindsFormItems()) { void* pBinding = nullptr; - m_JSNode.TryObject(XFA_ATTRIBUTE_BindingNode, pBinding); + JSNode()->TryObject(XFA_ATTRIBUTE_BindingNode, pBinding); auto* pItems = static_cast*>(pBinding); auto iter = std::find(pItems->begin(), pItems->end(), pFormNode); if (iter != pItems->end()) { *iter = pItems->back(); pItems->pop_back(); if (pItems->size() == 1) { - m_JSNode.SetObject(XFA_ATTRIBUTE_BindingNode, - (*pItems)[0]); // Invalidates pItems. + JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, + (*pItems)[0]); // Invalidates pItems. m_uNodeFlags &= ~XFA_NodeFlag_BindFormItems; return 1; } @@ -435,21 +439,21 @@ int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) { return pdfium::CollectionSize(*pItems); } CXFA_Node* pOldFormItem = - static_cast(m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode)); + static_cast(JSNode()->GetObject(XFA_ATTRIBUTE_BindingNode)); if (pOldFormItem != pFormNode) return pOldFormItem ? 1 : 0; - m_JSNode.SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); + JSNode()->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); return 0; } bool CXFA_Node::HasBindItem() { return GetPacketID() == XFA_XDPPACKET_Datasets && - m_JSNode.GetObject(XFA_ATTRIBUTE_BindingNode); + JSNode()->GetObject(XFA_ATTRIBUTE_BindingNode); } CXFA_WidgetData* CXFA_Node::GetWidgetData() { - return (CXFA_WidgetData*)m_JSNode.GetObject(XFA_ATTRIBUTE_WidgetData); + return (CXFA_WidgetData*)JSNode()->GetObject(XFA_ATTRIBUTE_WidgetData); } CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() { @@ -546,7 +550,7 @@ bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) { XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() { CXFA_Node* pKeep = GetFirstChildByClass(XFA_Element::Keep); - XFA_ATTRIBUTEENUM eLayoutType = m_JSNode.GetEnum(XFA_ATTRIBUTE_Layout); + XFA_ATTRIBUTEENUM eLayoutType = JSNode()->GetEnum(XFA_ATTRIBUTE_Layout); if (pKeep) { XFA_ATTRIBUTEENUM eIntact; if (pKeep->JSNode()->TryEnum(XFA_ATTRIBUTE_Intact, eIntact, false)) { @@ -607,7 +611,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 (m_JSNode.TryMeasure(XFA_ATTRIBUTE_H, measureH, false)) + if (JSNode()->TryMeasure(XFA_ATTRIBUTE_H, measureH, false)) return XFA_ATTRIBUTEENUM_ContentArea; } return XFA_ATTRIBUTEENUM_None; @@ -633,830 +637,734 @@ void CXFA_Node::SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode) { m_pAuxNode = pDataDescriptionNode; } -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; -} - -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 = 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; -} - -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; -} - void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_TreeClass_ResolveNode(pArguments); + JSNode()->Script_TreeClass_ResolveNode(pArguments); } void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_TreeClass_ResolveNodes(pArguments); + JSNode()->Script_TreeClass_ResolveNodes(pArguments); } void CXFA_Node::Script_Som_ResolveNodeList(CFXJSE_Value* pValue, WideString wsExpression, uint32_t dwFlag, CXFA_Node* refNode) { - m_JSNode.Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag, refNode); + JSNode()->Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag, refNode); } void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_TreeClass_All(pValue, bSetting, eAttribute); + JSNode()->Script_TreeClass_All(pValue, bSetting, eAttribute); } void CXFA_Node::Script_TreeClass_Nodes(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_TreeClass_Nodes(pValue, bSetting, eAttribute); + JSNode()->Script_TreeClass_Nodes(pValue, bSetting, eAttribute); } void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_TreeClass_ClassAll(pValue, bSetting, eAttribute); + JSNode()->Script_TreeClass_ClassAll(pValue, bSetting, eAttribute); } void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_TreeClass_Parent(pValue, bSetting, eAttribute); + JSNode()->Script_TreeClass_Parent(pValue, bSetting, eAttribute); } void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_TreeClass_Index(pValue, bSetting, eAttribute); + JSNode()->Script_TreeClass_Index(pValue, bSetting, eAttribute); } void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_TreeClass_ClassIndex(pValue, bSetting, eAttribute); + JSNode()->Script_TreeClass_ClassIndex(pValue, bSetting, eAttribute); } void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_TreeClass_SomExpression(pValue, bSetting, eAttribute); + JSNode()->Script_TreeClass_SomExpression(pValue, bSetting, eAttribute); } void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_ApplyXSL(pArguments); + JSNode()->Script_NodeClass_ApplyXSL(pArguments); } void CXFA_Node::Script_NodeClass_AssignNode(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_AssignNode(pArguments); + JSNode()->Script_NodeClass_AssignNode(pArguments); } void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_Clone(pArguments); + JSNode()->Script_NodeClass_Clone(pArguments); } void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_GetAttribute(pArguments); + JSNode()->Script_NodeClass_GetAttribute(pArguments); } void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_GetElement(pArguments); + JSNode()->Script_NodeClass_GetElement(pArguments); } void CXFA_Node::Script_NodeClass_IsPropertySpecified( CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_IsPropertySpecified(pArguments); + JSNode()->Script_NodeClass_IsPropertySpecified(pArguments); } void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_LoadXML(pArguments); + JSNode()->Script_NodeClass_LoadXML(pArguments); } void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_SaveFilteredXML(pArguments); + JSNode()->Script_NodeClass_SaveFilteredXML(pArguments); } void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_SaveXML(pArguments); + JSNode()->Script_NodeClass_SaveXML(pArguments); } void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_SetAttribute(pArguments); + JSNode()->Script_NodeClass_SetAttribute(pArguments); } void CXFA_Node::Script_NodeClass_SetElement(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_NodeClass_SetElement(pArguments); + JSNode()->Script_NodeClass_SetElement(pArguments); } void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_NodeClass_Ns(pValue, bSetting, eAttribute); + JSNode()->Script_NodeClass_Ns(pValue, bSetting, eAttribute); } void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_NodeClass_Model(pValue, bSetting, eAttribute); + JSNode()->Script_NodeClass_Model(pValue, bSetting, eAttribute); } void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_NodeClass_IsContainer(pValue, bSetting, eAttribute); + JSNode()->Script_NodeClass_IsContainer(pValue, bSetting, eAttribute); } void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_NodeClass_IsNull(pValue, bSetting, eAttribute); + JSNode()->Script_NodeClass_IsNull(pValue, bSetting, eAttribute); } void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_NodeClass_OneOfChild(pValue, bSetting, eAttribute); + JSNode()->Script_NodeClass_OneOfChild(pValue, bSetting, eAttribute); } void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ContainerClass_GetDelta(pArguments); + JSNode()->Script_ContainerClass_GetDelta(pArguments); } void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ContainerClass_GetDeltas(pArguments); + JSNode()->Script_ContainerClass_GetDeltas(pArguments); } void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ModelClass_ClearErrorList(pArguments); + JSNode()->Script_ModelClass_ClearErrorList(pArguments); } void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ModelClass_CreateNode(pArguments); + JSNode()->Script_ModelClass_CreateNode(pArguments); } void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ModelClass_IsCompatibleNS(pArguments); + JSNode()->Script_ModelClass_IsCompatibleNS(pArguments); } void CXFA_Node::Script_ModelClass_Context(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_ModelClass_Context(pValue, bSetting, eAttribute); + JSNode()->Script_ModelClass_Context(pValue, bSetting, eAttribute); } void CXFA_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_ModelClass_AliasNode(pValue, bSetting, eAttribute); + JSNode()->Script_ModelClass_AliasNode(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Attribute_Integer(pValue, bSetting, eAttribute); + JSNode()->Script_Attribute_Integer(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Attribute_IntegerRead(pValue, bSetting, eAttribute); + JSNode()->Script_Attribute_IntegerRead(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Attribute_BOOL(pValue, bSetting, eAttribute); + JSNode()->Script_Attribute_BOOL(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Attribute_BOOLRead(pValue, bSetting, eAttribute); + JSNode()->Script_Attribute_BOOLRead(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( XFA_ATTRIBUTE eAttribute, bool bScriptModify) { - m_JSNode.Script_Attribute_SendAttributeChangeMessage(eAttribute, - bScriptModify); + JSNode()->Script_Attribute_SendAttributeChangeMessage(eAttribute, + bScriptModify); } void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Attribute_String(pValue, bSetting, eAttribute); + JSNode()->Script_Attribute_String(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Attribute_StringRead(pValue, bSetting, eAttribute); + JSNode()->Script_Attribute_StringRead(pValue, bSetting, eAttribute); } void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_WsdlConnection_Execute(pArguments); + JSNode()->Script_WsdlConnection_Execute(pArguments); } void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Delta_Restore(pArguments); + JSNode()->Script_Delta_Restore(pArguments); } void CXFA_Node::Script_Delta_CurrentValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Delta_CurrentValue(pValue, bSetting, eAttribute); + JSNode()->Script_Delta_CurrentValue(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Delta_SavedValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Delta_SavedValue(pValue, bSetting, eAttribute); + JSNode()->Script_Delta_SavedValue(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Delta_Target(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Delta_Target(pValue, bSetting, eAttribute); + JSNode()->Script_Delta_Target(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_Message(CFXJSE_Value* pValue, bool bSetting, XFA_SOM_MESSAGETYPE iMessageType) { - m_JSNode.Script_Som_Message(pValue, bSetting, iMessageType); + JSNode()->Script_Som_Message(pValue, bSetting, iMessageType); } void CXFA_Node::Script_Som_ValidationMessage(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_ValidationMessage(pValue, bSetting, eAttribute); + JSNode()->Script_Som_ValidationMessage(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Field_Length(pValue, bSetting, eAttribute); + JSNode()->Script_Field_Length(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_DefaultValue(pValue, bSetting, eAttribute); + JSNode()->Script_Som_DefaultValue(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_DefaultValue_Read(pValue, bSetting, eAttribute); + JSNode()->Script_Som_DefaultValue_Read(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Boolean_Value(pValue, bSetting, eAttribute); + JSNode()->Script_Boolean_Value(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_BorderColor(pValue, bSetting, eAttribute); + JSNode()->Script_Som_BorderColor(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_BorderWidth(pValue, bSetting, eAttribute); + JSNode()->Script_Som_BorderWidth(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_FillColor(pValue, bSetting, eAttribute); + JSNode()->Script_Som_FillColor(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_DataNode(pValue, bSetting, eAttribute); + JSNode()->Script_Som_DataNode(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Draw_DefaultValue(pValue, bSetting, eAttribute); + JSNode()->Script_Draw_DefaultValue(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Field_DefaultValue(pValue, bSetting, eAttribute); + JSNode()->Script_Field_DefaultValue(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Field_EditValue(pValue, bSetting, eAttribute); + JSNode()->Script_Field_EditValue(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_FontColor(pValue, bSetting, eAttribute); + JSNode()->Script_Som_FontColor(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Field_FormatMessage(pValue, bSetting, eAttribute); + JSNode()->Script_Field_FormatMessage(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Field_FormattedValue(pValue, bSetting, eAttribute); + JSNode()->Script_Field_FormattedValue(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_Mandatory(pValue, bSetting, eAttribute); + JSNode()->Script_Som_Mandatory(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Som_MandatoryMessage(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_MandatoryMessage(pValue, bSetting, eAttribute); + JSNode()->Script_Som_MandatoryMessage(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Field_ParentSubform(pValue, bSetting, eAttribute); + JSNode()->Script_Field_ParentSubform(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Field_SelectedIndex(pValue, bSetting, eAttribute); + JSNode()->Script_Field_SelectedIndex(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_ClearItems(pArguments); + JSNode()->Script_Field_ClearItems(pArguments); } void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_ExecEvent(pArguments); + JSNode()->Script_Field_ExecEvent(pArguments); } void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_ExecInitialize(pArguments); + JSNode()->Script_Field_ExecInitialize(pArguments); } void CXFA_Node::Script_Field_DeleteItem(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_DeleteItem(pArguments); + JSNode()->Script_Field_DeleteItem(pArguments); } void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_GetSaveItem(pArguments); + JSNode()->Script_Field_GetSaveItem(pArguments); } void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_BoundItem(pArguments); + JSNode()->Script_Field_BoundItem(pArguments); } void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_GetItemState(pArguments); + JSNode()->Script_Field_GetItemState(pArguments); } void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_ExecCalculate(pArguments); + JSNode()->Script_Field_ExecCalculate(pArguments); } void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_SetItems(pArguments); + JSNode()->Script_Field_SetItems(pArguments); } void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_GetDisplayItem(pArguments); + JSNode()->Script_Field_GetDisplayItem(pArguments); } void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_SetItemState(pArguments); + JSNode()->Script_Field_SetItemState(pArguments); } void CXFA_Node::Script_Field_AddItem(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_AddItem(pArguments); + JSNode()->Script_Field_AddItem(pArguments); } void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Field_ExecValidate(pArguments); + JSNode()->Script_Field_ExecValidate(pArguments); } void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_ExclGroup_ErrorText(pValue, bSetting, eAttribute); + JSNode()->Script_ExclGroup_ErrorText(pValue, bSetting, eAttribute); } void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_ExclGroup_DefaultAndRawValue(pValue, bSetting, eAttribute); + JSNode()->Script_ExclGroup_DefaultAndRawValue(pValue, bSetting, eAttribute); } void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_ExclGroup_Transient(pValue, bSetting, eAttribute); + JSNode()->Script_ExclGroup_Transient(pValue, bSetting, eAttribute); } void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ExclGroup_ExecEvent(pArguments); + JSNode()->Script_ExclGroup_ExecEvent(pArguments); } void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ExclGroup_SelectedMember(pArguments); + JSNode()->Script_ExclGroup_SelectedMember(pArguments); } void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ExclGroup_ExecInitialize(pArguments); + JSNode()->Script_ExclGroup_ExecInitialize(pArguments); } void CXFA_Node::Script_ExclGroup_ExecCalculate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ExclGroup_ExecCalculate(pArguments); + JSNode()->Script_ExclGroup_ExecCalculate(pArguments); } void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_ExclGroup_ExecValidate(pArguments); + JSNode()->Script_ExclGroup_ExecValidate(pArguments); } void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Som_InstanceIndex(pValue, bSetting, eAttribute); + JSNode()->Script_Som_InstanceIndex(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Subform_InstanceManager(pValue, bSetting, eAttribute); + JSNode()->Script_Subform_InstanceManager(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Subform_Locale(pValue, bSetting, eAttribute); + JSNode()->Script_Subform_Locale(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Subform_ExecEvent(pArguments); + JSNode()->Script_Subform_ExecEvent(pArguments); } void CXFA_Node::Script_Subform_ExecInitialize(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Subform_ExecInitialize(pArguments); + JSNode()->Script_Subform_ExecInitialize(pArguments); } void CXFA_Node::Script_Subform_ExecCalculate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Subform_ExecInitialize(pArguments); + JSNode()->Script_Subform_ExecInitialize(pArguments); } void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Subform_ExecValidate(pArguments); + JSNode()->Script_Subform_ExecValidate(pArguments); } void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Subform_GetInvalidObjects(pArguments); + JSNode()->Script_Subform_GetInvalidObjects(pArguments); } void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Template_FormNodes(pArguments); + JSNode()->Script_Template_FormNodes(pArguments); } void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Template_Remerge(pArguments); + JSNode()->Script_Template_Remerge(pArguments); } void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Template_ExecInitialize(pArguments); + JSNode()->Script_Template_ExecInitialize(pArguments); } void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Template_CreateNode(pArguments); + JSNode()->Script_Template_CreateNode(pArguments); } void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Template_Recalculate(pArguments); + JSNode()->Script_Template_Recalculate(pArguments); } void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Template_ExecCalculate(pArguments); + JSNode()->Script_Template_ExecCalculate(pArguments); } void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Template_ExecValidate(pArguments); + JSNode()->Script_Template_ExecValidate(pArguments); } void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Manifest_Evaluate(pArguments); + JSNode()->Script_Manifest_Evaluate(pArguments); } void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_InstanceManager_Max(pValue, bSetting, eAttribute); + JSNode()->Script_InstanceManager_Max(pValue, bSetting, eAttribute); } void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_InstanceManager_Min(pValue, bSetting, eAttribute); + JSNode()->Script_InstanceManager_Min(pValue, bSetting, eAttribute); } void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_InstanceManager_Count(pValue, bSetting, eAttribute); + JSNode()->Script_InstanceManager_Count(pValue, bSetting, eAttribute); } void CXFA_Node::Script_InstanceManager_MoveInstance( CFXJSE_Arguments* pArguments) { - m_JSNode.Script_InstanceManager_MoveInstance(pArguments); + JSNode()->Script_InstanceManager_MoveInstance(pArguments); } void CXFA_Node::Script_InstanceManager_RemoveInstance( CFXJSE_Arguments* pArguments) { - m_JSNode.Script_InstanceManager_RemoveInstance(pArguments); + JSNode()->Script_InstanceManager_RemoveInstance(pArguments); } void CXFA_Node::Script_InstanceManager_SetInstances( CFXJSE_Arguments* pArguments) { - m_JSNode.Script_InstanceManager_SetInstances(pArguments); + JSNode()->Script_InstanceManager_SetInstances(pArguments); } void CXFA_Node::Script_InstanceManager_AddInstance( CFXJSE_Arguments* pArguments) { - m_JSNode.Script_InstanceManager_AddInstance(pArguments); + JSNode()->Script_InstanceManager_AddInstance(pArguments); } void CXFA_Node::Script_InstanceManager_InsertInstance( CFXJSE_Arguments* pArguments) { - m_JSNode.Script_InstanceManager_InsertInstance(pArguments); + JSNode()->Script_InstanceManager_InsertInstance(pArguments); } void CXFA_Node::Script_Occur_Max(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Occur_Max(pValue, bSetting, eAttribute); + JSNode()->Script_Occur_Max(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Occur_Min(pValue, bSetting, eAttribute); + JSNode()->Script_Occur_Min(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Desc_Metadata(pArguments); + JSNode()->Script_Desc_Metadata(pArguments); } void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Form_FormNodes(pArguments); + JSNode()->Script_Form_FormNodes(pArguments); } void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Form_Remerge(pArguments); + JSNode()->Script_Form_Remerge(pArguments); } void CXFA_Node::Script_Form_ExecInitialize(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Form_ExecInitialize(pArguments); + JSNode()->Script_Form_ExecInitialize(pArguments); } void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Form_Recalculate(pArguments); + JSNode()->Script_Form_Recalculate(pArguments); } void CXFA_Node::Script_Form_ExecCalculate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Form_ExecCalculate(pArguments); + JSNode()->Script_Form_ExecCalculate(pArguments); } void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Form_ExecValidate(pArguments); + JSNode()->Script_Form_ExecValidate(pArguments); } void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Form_Checksum(pValue, bSetting, eAttribute); + JSNode()->Script_Form_Checksum(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Packet_GetAttribute(pArguments); + JSNode()->Script_Packet_GetAttribute(pArguments); } void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Packet_SetAttribute(pArguments); + JSNode()->Script_Packet_SetAttribute(pArguments); } void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Packet_RemoveAttribute(pArguments); + JSNode()->Script_Packet_RemoveAttribute(pArguments); } void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Packet_Content(pValue, bSetting, eAttribute); + JSNode()->Script_Packet_Content(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Next(pArguments); + JSNode()->Script_Source_Next(pArguments); } void CXFA_Node::Script_Source_CancelBatch(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_CancelBatch(pArguments); + JSNode()->Script_Source_CancelBatch(pArguments); } void CXFA_Node::Script_Source_First(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_First(pArguments); + JSNode()->Script_Source_First(pArguments); } void CXFA_Node::Script_Source_UpdateBatch(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_UpdateBatch(pArguments); + JSNode()->Script_Source_UpdateBatch(pArguments); } void CXFA_Node::Script_Source_Previous(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Previous(pArguments); + JSNode()->Script_Source_Previous(pArguments); } void CXFA_Node::Script_Source_IsBOF(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_IsBOF(pArguments); + JSNode()->Script_Source_IsBOF(pArguments); } void CXFA_Node::Script_Source_IsEOF(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_IsEOF(pArguments); + JSNode()->Script_Source_IsEOF(pArguments); } void CXFA_Node::Script_Source_Cancel(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Cancel(pArguments); + JSNode()->Script_Source_Cancel(pArguments); } void CXFA_Node::Script_Source_Update(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Update(pArguments); + JSNode()->Script_Source_Update(pArguments); } void CXFA_Node::Script_Source_Open(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Open(pArguments); + JSNode()->Script_Source_Open(pArguments); } void CXFA_Node::Script_Source_Delete(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Delete(pArguments); + JSNode()->Script_Source_Delete(pArguments); } void CXFA_Node::Script_Source_AddNew(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_AddNew(pArguments); + JSNode()->Script_Source_AddNew(pArguments); } void CXFA_Node::Script_Source_Requery(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Requery(pArguments); + JSNode()->Script_Source_Requery(pArguments); } void CXFA_Node::Script_Source_Resync(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Resync(pArguments); + JSNode()->Script_Source_Resync(pArguments); } void CXFA_Node::Script_Source_Close(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Close(pArguments); + JSNode()->Script_Source_Close(pArguments); } void CXFA_Node::Script_Source_Last(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_Last(pArguments); + JSNode()->Script_Source_Last(pArguments); } void CXFA_Node::Script_Source_HasDataChanged(CFXJSE_Arguments* pArguments) { - m_JSNode.Script_Source_HasDataChanged(pArguments); + JSNode()->Script_Source_HasDataChanged(pArguments); } void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Source_Db(pValue, bSetting, eAttribute); + JSNode()->Script_Source_Db(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Xfa_This(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Xfa_This(pValue, bSetting, eAttribute); + JSNode()->Script_Xfa_This(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Handler_Version(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Handler_Version(pValue, bSetting, eAttribute); + JSNode()->Script_Handler_Version(pValue, bSetting, eAttribute); } void CXFA_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_SubmitFormat_Mode(pValue, bSetting, eAttribute); + JSNode()->Script_SubmitFormat_Mode(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Extras_Type(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Extras_Type(pValue, bSetting, eAttribute); + JSNode()->Script_Extras_Type(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Script_Stateless(pValue, bSetting, eAttribute); + JSNode()->Script_Script_Stateless(pValue, bSetting, eAttribute); } void CXFA_Node::Script_Encrypt_Format(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - m_JSNode.Script_Encrypt_Format(pValue, bSetting, eAttribute); + JSNode()->Script_Encrypt_Format(pValue, bSetting, eAttribute); } CXFA_Node* CXFA_Node::GetModelNode() { @@ -1673,7 +1581,7 @@ bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { WideString wsName; pNode->JSNode()->GetAttribute(XFA_ATTRIBUTE_Name, wsName, false); CFX_XMLElement* pNewXMLElement = new CFX_XMLElement(wsName); - WideStringView wsValue = m_JSNode.GetCData(XFA_ATTRIBUTE_Value); + WideStringView wsValue = JSNode()->GetCData(XFA_ATTRIBUTE_Value); if (!wsValue.IsEmpty()) { pNewXMLElement->SetTextData(WideString(wsValue)); } @@ -1776,7 +1684,7 @@ CXFA_Node* CXFA_Node::GetInstanceMgrOfSubform() { break; } if (eType == XFA_Element::InstanceManager) { - WideStringView wsName = m_JSNode.GetCData(XFA_ATTRIBUTE_Name); + WideStringView wsName = JSNode()->GetCData(XFA_ATTRIBUTE_Name); WideStringView wsInstName = pNode->JSNode()->GetCData(XFA_ATTRIBUTE_Name); if (wsInstName.GetLength() > 0 && wsInstName[0] == '_' && @@ -1817,7 +1725,8 @@ void CXFA_Node::ClearFlag(uint32_t dwFlag) { } bool CXFA_Node::IsAttributeInXML() { - return m_JSNode.GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData; + return JSNode()->GetEnum(XFA_ATTRIBUTE_Contains) == + XFA_ATTRIBUTEENUM_MetaData; } void CXFA_Node::OnRemoved(bool bNotify) { @@ -1851,17 +1760,17 @@ void CXFA_Node::UpdateNameHash() { XFA_GetNotsureAttribute(GetElementType(), XFA_ATTRIBUTE_Name); WideStringView wsName; if (!pNotsure || pNotsure->eType == XFA_ATTRIBUTETYPE_Cdata) { - wsName = m_JSNode.GetCData(XFA_ATTRIBUTE_Name); + wsName = JSNode()->GetCData(XFA_ATTRIBUTE_Name); m_dwNameHash = FX_HashCode_GetW(wsName, false); } else if (pNotsure->eType == XFA_ATTRIBUTETYPE_Enum) { - wsName = GetAttributeEnumByID(m_JSNode.GetEnum(XFA_ATTRIBUTE_Name))->pName; + wsName = GetAttributeEnumByID(JSNode()->GetEnum(XFA_ATTRIBUTE_Name))->pName; m_dwNameHash = FX_HashCode_GetW(wsName, false); } } CFX_XMLNode* CXFA_Node::CreateXMLMappingNode() { if (!m_pXMLNode) { - WideString wsTag(m_JSNode.GetCData(XFA_ATTRIBUTE_Name)); + WideString wsTag(JSNode()->GetCData(XFA_ATTRIBUTE_Name)); m_pXMLNode = new CFX_XMLElement(wsTag); SetFlag(XFA_NodeFlag_OwnXMLNode, false); } @@ -1873,18 +1782,6 @@ bool CXFA_Node::IsNeedSavingXMLNode() { GetElementType() == XFA_Element::Xfa); } -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::ThrowTooManyOccurancesException(const WideString& obj) const { - ThrowException( - L"The element [%s] has violated its allowable number of occurrences.", - obj.c_str()); -} - CXFA_Node* CXFA_Node::GetItem(CXFA_Node* pInstMgrNode, int32_t iIndex) { ASSERT(pInstMgrNode); int32_t iCount = 0; diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 6151d738a2..02326d933a 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -53,8 +53,10 @@ class CXFA_Node : public CXFA_Object { 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; } + CJX_Node* JSNode() { return static_cast(JSObject()); } + const CJX_Node* JSNode() const { + return static_cast(JSObject()); + } CXFA_Node* GetParent() { return m_pParent; } CXFA_Node* GetChildNode() { return m_pChild; } @@ -141,10 +143,6 @@ class CXFA_Node : public CXFA_Object { 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); @@ -429,10 +427,6 @@ 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; @@ -456,7 +450,6 @@ class CXFA_Node : public CXFA_Object { uint16_t m_uNodeFlags; uint32_t m_dwNameHash; CXFA_Node* m_pAuxNode; - CJX_Node m_JSNode; }; #endif // XFA_FXFA_PARSER_CXFA_NODE_H_ diff --git a/xfa/fxfa/parser/cxfa_nodelist.cpp b/xfa/fxfa/parser/cxfa_nodelist.cpp index cbee420870..4c5e5435c2 100644 --- a/xfa/fxfa/parser/cxfa_nodelist.cpp +++ b/xfa/fxfa/parser/cxfa_nodelist.cpp @@ -17,7 +17,8 @@ CXFA_NodeList::CXFA_NodeList(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::NodeList, XFA_Element::NodeList, - WideStringView(L"nodeList")) { + WideStringView(L"nodeList"), + pdfium::MakeUnique(this)) { m_pDocument->GetScriptContext()->AddToCacheList( std::unique_ptr(this)); } @@ -38,13 +39,13 @@ CXFA_Node* CXFA_NodeList::NamedItem(const WideStringView& wsName) { void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 1) { - ThrowParamCountMismatchException(L"append"); + JSObject()->ThrowParamCountMismatchException(L"append"); return; } CXFA_Node* pNode = static_cast(pArguments->GetObject(0)); if (!pNode) { - ThrowArgumentMismatchException(); + JSObject()->ThrowArgumentMismatchException(); return; } Append(pNode); @@ -53,14 +54,14 @@ void CXFA_NodeList::Script_ListClass_Append(CFXJSE_Arguments* pArguments) { void CXFA_NodeList::Script_ListClass_Insert(CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 2) { - ThrowParamCountMismatchException(L"insert"); + JSObject()->ThrowParamCountMismatchException(L"insert"); return; } CXFA_Node* pNewNode = static_cast(pArguments->GetObject(0)); CXFA_Node* pBeforeNode = static_cast(pArguments->GetObject(1)); if (!pNewNode) { - ThrowArgumentMismatchException(); + JSObject()->ThrowArgumentMismatchException(); return; } Insert(pNewNode, pBeforeNode); @@ -69,13 +70,13 @@ void CXFA_NodeList::Script_ListClass_Insert(CFXJSE_Arguments* pArguments) { void CXFA_NodeList::Script_ListClass_Remove(CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 1) { - ThrowParamCountMismatchException(L"remove"); + JSObject()->ThrowParamCountMismatchException(L"remove"); return; } CXFA_Node* pNode = static_cast(pArguments->GetObject(0)); if (!pNode) { - ThrowArgumentMismatchException(); + JSObject()->ThrowArgumentMismatchException(); return; } Remove(pNode); @@ -84,13 +85,13 @@ void CXFA_NodeList::Script_ListClass_Remove(CFXJSE_Arguments* pArguments) { void CXFA_NodeList::Script_ListClass_Item(CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 1) { - ThrowParamCountMismatchException(L"item"); + JSObject()->ThrowParamCountMismatchException(L"item"); return; } int32_t iIndex = pArguments->GetInt32(0); if (iIndex < 0 || iIndex >= GetLength()) { - ThrowIndexOutOfBoundsException(); + JSObject()->ThrowIndexOutOfBoundsException(); return; } pArguments->GetReturnValue()->Assign( @@ -101,7 +102,7 @@ void CXFA_NodeList::Script_TreelistClass_NamedItem( CFXJSE_Arguments* pArguments) { int32_t argc = pArguments->GetLength(); if (argc != 1) { - ThrowParamCountMismatchException(L"namedItem"); + JSObject()->ThrowParamCountMismatchException(L"namedItem"); return; } @@ -119,7 +120,7 @@ void CXFA_NodeList::Script_ListClass_Length(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { if (bSetting) { - ThrowInvalidPropertyException(); + JSObject()->ThrowInvalidPropertyException(); return; } pValue->SetInteger(GetLength()); diff --git a/xfa/fxfa/parser/cxfa_object.cpp b/xfa/fxfa/parser/cxfa_object.cpp index c23420446a..d9deaaac9a 100644 --- a/xfa/fxfa/parser/cxfa_object.cpp +++ b/xfa/fxfa/parser/cxfa_object.cpp @@ -6,6 +6,8 @@ #include "xfa/fxfa/parser/cxfa_object.h" +#include + #include "core/fxcrt/fx_extension.h" #include "fxjs/cfxjse_value.h" #include "xfa/fxfa/cxfa_ffnotify.h" @@ -16,52 +18,22 @@ CXFA_Object::CXFA_Object(CXFA_Document* pDocument, XFA_ObjectType objectType, XFA_Element elementType, - const WideStringView& elementName) + const WideStringView& elementName, + std::unique_ptr jsObject) : CFXJSE_HostObject(kXFA), m_pDocument(pDocument), m_objectType(objectType), m_elementType(elementType), m_elementNameHash(FX_HashCode_GetW(elementName, false)), - m_elementName(elementName) {} + m_elementName(elementName), + m_pJSObject(std::move(jsObject)) {} CXFA_Object::~CXFA_Object() {} void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - if (bSetting) { - ThrowInvalidPropertyException(); - return; - } - pValue->SetString(FX_UTF8Encode(GetClassName()).AsStringView()); -} - -void CXFA_Object::ThrowInvalidPropertyException() const { - ThrowException(L"Invalid property set operation."); -} - -void CXFA_Object::ThrowIndexOutOfBoundsException() const { - ThrowException(L"Index value is out of bounds."); -} - -void CXFA_Object::ThrowParamCountMismatchException( - const WideString& method) const { - ThrowException(L"Incorrect number of parameters calling method '%.16s'.", - method.c_str()); -} - -void CXFA_Object::ThrowArgumentMismatchException() const { - ThrowException(L"Argument mismatch in property or function argument."); -} - -void CXFA_Object::ThrowException(const wchar_t* str, ...) const { - WideString wsMessage; - va_list arg_ptr; - va_start(arg_ptr, str); - wsMessage.FormatV(str, arg_ptr); - va_end(arg_ptr); - ASSERT(!wsMessage.IsEmpty()); - FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView()); + JSObject()->Script_ObjectClass_ClassName(pValue, bSetting, eAttribute); } CXFA_Node* CXFA_Object::AsNode() { diff --git a/xfa/fxfa/parser/cxfa_object.h b/xfa/fxfa/parser/cxfa_object.h index 3e305008b7..cec3346e8b 100644 --- a/xfa/fxfa/parser/cxfa_object.h +++ b/xfa/fxfa/parser/cxfa_object.h @@ -7,6 +7,8 @@ #ifndef XFA_FXFA_PARSER_CXFA_OBJECT_H_ #define XFA_FXFA_PARSER_CXFA_OBJECT_H_ +#include + #include "core/fxcrt/fx_string.h" #include "fxjs/fxjse.h" #include "xfa/fxfa/fxfa_basic.h" @@ -26,16 +28,13 @@ enum class XFA_ObjectType { }; class CFXJSE_Value; +class CJX_Object; class CXFA_Document; class CXFA_Node; class CXFA_NodeList; class CXFA_Object : public CFXJSE_HostObject { public: - CXFA_Object(CXFA_Document* pDocument, - XFA_ObjectType objectType, - XFA_Element eType, - const WideStringView& elementName); ~CXFA_Object() override; CXFA_Document* GetDocument() const { return m_pDocument.Get(); } @@ -70,6 +69,9 @@ class CXFA_Object : public CFXJSE_HostObject { const CXFA_Node* AsNode() const; const CXFA_NodeList* AsNodeList() const; + CJX_Object* JSObject() { return m_pJSObject.get(); } + const CJX_Object* JSObject() const { return m_pJSObject.get(); } + XFA_Element GetElementType() const { return m_elementType; } WideStringView GetClassName() const { return m_elementName; } uint32_t GetClassHashCode() const { return m_elementNameHash; } @@ -78,13 +80,12 @@ class CXFA_Object : public CFXJSE_HostObject { bool bSetting, XFA_ATTRIBUTE eAttribute); - void ThrowInvalidPropertyException() const; - void ThrowArgumentMismatchException() const; - void ThrowIndexOutOfBoundsException() const; - void ThrowParamCountMismatchException(const WideString& method) const; - protected: - void ThrowException(const wchar_t* str, ...) const; + CXFA_Object(CXFA_Document* pDocument, + XFA_ObjectType objectType, + XFA_Element eType, + const WideStringView& elementName, + std::unique_ptr jsObject); UnownedPtr const m_pDocument; const XFA_ObjectType m_objectType; @@ -92,6 +93,8 @@ class CXFA_Object : public CFXJSE_HostObject { const uint32_t m_elementNameHash; const WideStringView m_elementName; + + std::unique_ptr m_pJSObject; }; CXFA_Node* ToNode(CXFA_Object* pObj); diff --git a/xfa/fxfa/parser/cxfa_thisproxy.cpp b/xfa/fxfa/parser/cxfa_thisproxy.cpp index 55e676ecdc..6b84913afb 100644 --- a/xfa/fxfa/parser/cxfa_thisproxy.cpp +++ b/xfa/fxfa/parser/cxfa_thisproxy.cpp @@ -6,17 +6,17 @@ #include "xfa/fxfa/parser/cxfa_thisproxy.h" +#include "fxjs/cjx_object.h" +#include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_node.h" CXFA_ThisProxy::CXFA_ThisProxy(CXFA_Node* pThisNode, CXFA_Node* pScriptNode) : CXFA_Object(pThisNode->GetDocument(), XFA_ObjectType::VariablesThis, XFA_Element::Unknown, - WideStringView()), - m_pThisNode(nullptr), - m_pScriptNode(nullptr) { - m_pThisNode = pThisNode; - m_pScriptNode = pScriptNode; -} + WideStringView(), + pdfium::MakeUnique(this)), + m_pThisNode(pThisNode), + m_pScriptNode(pScriptNode) {} CXFA_ThisProxy::~CXFA_ThisProxy() {} -- cgit v1.2.3