summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cscript_hostpseudomodel.cpp21
-rw-r--r--xfa/fxfa/parser/cscript_layoutpseudomodel.cpp82
-rw-r--r--xfa/fxfa/parser/cscript_layoutpseudomodel.h11
-rw-r--r--xfa/fxfa/parser/cxfa_arraynodelist.cpp44
-rw-r--r--xfa/fxfa/parser/cxfa_data.h2
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_document.h5
-rw-r--r--xfa/fxfa/parser/cxfa_event.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_event.h8
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp39
-rw-r--r--xfa/fxfa/parser/cxfa_layoutprocessor.cpp23
-rw-r--r--xfa/fxfa/parser/cxfa_layoutprocessor.h7
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp231
-rw-r--r--xfa/fxfa/parser/cxfa_nodehelper.cpp122
-rw-r--r--xfa/fxfa/parser/cxfa_nodehelper.h8
-rw-r--r--xfa/fxfa/parser/cxfa_resolveprocessor.cpp444
-rw-r--r--xfa/fxfa/parser/cxfa_resolveprocessor.h5
-rw-r--r--xfa/fxfa/parser/cxfa_scriptcontext.cpp119
-rw-r--r--xfa/fxfa/parser/cxfa_scriptcontext.h14
-rw-r--r--xfa/fxfa/parser/cxfa_valuearray.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_valuearray.h4
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp102
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h7
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.cpp77
-rw-r--r--xfa/fxfa/parser/xfa_document_datamerger_imp.h13
-rw-r--r--xfa/fxfa/parser/xfa_object.h19
-rw-r--r--xfa/fxfa/parser/xfa_resolvenode_rs.h16
27 files changed, 659 insertions, 781 deletions
diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
index 94958a58e6..45013ee5d6 100644
--- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp
@@ -224,6 +224,7 @@ void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) {
}
pNotify->GetDocEnvironment()->GotoURL(hDoc, wsURL);
}
+
void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) {
if (!m_pDocument->GetScriptContext()->IsRunAtClient()) {
return;
@@ -256,10 +257,10 @@ void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) {
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
pObject, pValue->ToWideString().AsStringC(), resoveNodeRS, dwFlag);
- if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode())
+ if (iRet < 1 || !resoveNodeRS.objects.front()->IsNode())
return;
- pNode = resoveNodeRS.nodes[0]->AsNode();
+ pNode = resoveNodeRS.objects.front()->AsNode();
}
}
CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
@@ -364,22 +365,22 @@ void CScript_HostPseudoModel::ResetData(CFXJSE_Arguments* pArguments) {
while (iStart < iExpLength) {
iStart = XFA_FilterName(wsExpression.AsStringC(), iStart, wsName);
CXFA_ScriptContext* pScriptContext = m_pDocument->GetScriptContext();
- if (!pScriptContext) {
+ if (!pScriptContext)
return;
- }
+
CXFA_Object* pObject = pScriptContext->GetThisObject();
- if (!pObject) {
+ if (!pObject)
return;
- }
+
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(pObject, wsName.AsStringC(),
resoveNodeRS, dwFlag);
- if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode()) {
+ if (iRet < 1 || !resoveNodeRS.objects.front()->IsNode()) {
continue;
}
- pNode = resoveNodeRS.nodes[0]->AsNode();
+ pNode = resoveNodeRS.objects.front()->AsNode();
pNotify->ResetData(pNode->GetWidgetData());
}
if (!pNode) {
@@ -437,10 +438,10 @@ void CScript_HostPseudoModel::SetFocus(CFXJSE_Arguments* pArguments) {
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
pObject, pValue->ToWideString().AsStringC(), resoveNodeRS, dwFlag);
- if (iRet < 1 || !resoveNodeRS.nodes[0]->IsNode())
+ if (iRet < 1 || !resoveNodeRS.objects.front()->IsNode())
return;
- pNode = resoveNodeRS.nodes[0]->AsNode();
+ pNode = resoveNodeRS.objects.front()->AsNode();
}
}
pNotify->SetFocusWidgetNode(pNode);
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
index 9ffad911b2..1ebb20d2c1 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
@@ -209,39 +209,38 @@ void CScript_LayoutPseudoModel::Page(CFXJSE_Arguments* pArguments) {
PageImp(pArguments, false);
}
-void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout,
- int32_t iPageNo,
- const CFX_WideString& wsType,
- bool bOnPageArea,
- CXFA_NodeArray& retArray) {
+std::vector<CXFA_Node*> CScript_LayoutPseudoModel::GetObjArray(
+ CXFA_LayoutProcessor* pDocLayout,
+ int32_t iPageNo,
+ const CFX_WideString& wsType,
+ bool bOnPageArea) {
CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(iPageNo);
- if (!pLayoutPage) {
- return;
- }
+ if (!pLayoutPage)
+ return std::vector<CXFA_Node*>();
+
+ std::vector<CXFA_Node*> retArray;
if (wsType == L"pageArea") {
- if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) {
- retArray.Add(pMasterPage);
- }
- return;
+ if (pLayoutPage->m_pFormNode)
+ retArray.push_back(pLayoutPage->m_pFormNode);
+ return retArray;
}
if (wsType == L"contentArea") {
for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
pItem = pItem->m_pNextSibling) {
- if (pItem->m_pFormNode->GetElementType() == XFA_Element::ContentArea) {
- retArray.Add(pItem->m_pFormNode);
- }
+ if (pItem->m_pFormNode->GetElementType() == XFA_Element::ContentArea)
+ retArray.push_back(pItem->m_pFormNode);
}
- return;
+ return retArray;
}
std::set<CXFA_Node*> formItems;
if (wsType.IsEmpty()) {
- if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) {
- retArray.Add(pMasterPage);
- }
+ if (pLayoutPage->m_pFormNode)
+ retArray.push_back(pLayoutPage->m_pFormNode);
+
for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
pItem = pItem->m_pNextSibling) {
if (pItem->m_pFormNode->GetElementType() == XFA_Element::ContentArea) {
- retArray.Add(pItem->m_pFormNode);
+ retArray.push_back(pItem->m_pFormNode);
if (!bOnPageArea) {
CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
CXFA_TraverseStrategy_ContentLayoutItem>
@@ -260,7 +259,7 @@ void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout,
continue;
formItems.insert(pItemChild->m_pFormNode);
- retArray.Add(pItemChild->m_pFormNode);
+ retArray.push_back(pItemChild->m_pFormNode);
}
}
} else {
@@ -281,12 +280,12 @@ void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout,
if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode))
continue;
formItems.insert(pItemChild->m_pFormNode);
- retArray.Add(pItemChild->m_pFormNode);
+ retArray.push_back(pItemChild->m_pFormNode);
}
}
}
}
- return;
+ return retArray;
}
XFA_Element eType = XFA_Element::Unknown;
if (wsType == L"field") {
@@ -315,7 +314,7 @@ void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout,
if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode))
continue;
formItems.insert(pItemChild->m_pFormNode);
- retArray.Add(pItemChild->m_pFormNode);
+ retArray.push_back(pItemChild->m_pFormNode);
}
}
} else {
@@ -332,13 +331,13 @@ void CScript_LayoutPseudoModel::GetObjArray(CXFA_LayoutProcessor* pDocLayout,
if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode))
continue;
formItems.insert(pItemChild->m_pFormNode);
- retArray.Add(pItemChild->m_pFormNode);
+ retArray.push_back(pItemChild->m_pFormNode);
}
}
}
}
- return;
}
+ return retArray;
}
void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) {
@@ -350,30 +349,30 @@ void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) {
int32_t iIndex = 0;
CFX_WideString wsType;
bool bOnPageArea = false;
- if (iLength >= 1) {
+ if (iLength >= 1)
iIndex = pArguments->GetInt32(0);
- }
+
if (iLength >= 2) {
CFX_ByteString bsType = pArguments->GetUTF8String(1);
wsType = CFX_WideString::FromUTF8(bsType.AsStringC());
}
- if (iLength >= 3) {
+ if (iLength >= 3)
bOnPageArea = pArguments->GetInt32(2) == 0 ? false : true;
- }
+
CXFA_FFNotify* pNotify = m_pDocument->GetNotify();
- if (!pNotify) {
+ if (!pNotify)
return;
- }
+
CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout();
- if (!pDocLayout) {
+ if (!pDocLayout)
return;
- }
- CXFA_NodeArray retArray;
- GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, retArray);
- CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument);
- pArrayNodeList->SetArrayNodeList(retArray);
+
+ auto pArrayNodeList = pdfium::MakeUnique<CXFA_ArrayNodeList>(m_pDocument);
+ pArrayNodeList->SetArrayNodeList(
+ GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea));
pArguments->GetReturnValue()->SetObject(
- pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass());
+ pArrayNodeList.release(),
+ m_pDocument->GetScriptContext()->GetJseNormalClass());
}
void CScript_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) {
@@ -397,12 +396,11 @@ void CScript_LayoutPseudoModel::SheetCountInBatch(
void CScript_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) {
CXFA_Node* pRootNode = m_pDocument->GetRoot();
CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form);
- ASSERT(pFormRoot);
CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor();
- if (pContentRootNode) {
+ if (pContentRootNode)
pLayoutProcessor->AddChangedContainer(pContentRootNode);
- }
+
pLayoutProcessor->SetForceReLayout(true);
}
diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.h b/xfa/fxfa/parser/cscript_layoutpseudomodel.h
index 55a00db14a..e5e1131adc 100644
--- a/xfa/fxfa/parser/cscript_layoutpseudomodel.h
+++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXFA_PARSER_CSCRIPT_LAYOUTPSEUDOMODEL_H_
#define XFA_FXFA_PARSER_CSCRIPT_LAYOUTPSEUDOMODEL_H_
+#include <vector>
+
#include "fxjs/cfxjse_arguments.h"
#include "xfa/fxfa/parser/xfa_object.h"
@@ -49,11 +51,10 @@ class CScript_LayoutPseudoModel : public CXFA_Object {
void AbsPage(CFXJSE_Arguments* pArguments);
protected:
- void GetObjArray(CXFA_LayoutProcessor* pDocLayout,
- int32_t iPageNo,
- const CFX_WideString& wsType,
- bool bOnPageArea,
- CXFA_NodeArray& retArray);
+ std::vector<CXFA_Node*> GetObjArray(CXFA_LayoutProcessor* pDocLayout,
+ int32_t iPageNo,
+ const CFX_WideString& wsType,
+ bool bOnPageArea);
void PageImp(CFXJSE_Arguments* pArguments, bool bAbsPage);
private:
diff --git a/xfa/fxfa/parser/cxfa_arraynodelist.cpp b/xfa/fxfa/parser/cxfa_arraynodelist.cpp
index 8c9040a121..ff1d1d916b 100644
--- a/xfa/fxfa/parser/cxfa_arraynodelist.cpp
+++ b/xfa/fxfa/parser/cxfa_arraynodelist.cpp
@@ -4,6 +4,9 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <vector>
+
+#include "third_party/base/stl_util.h"
#include "xfa/fxfa/parser/xfa_object.h"
CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument)
@@ -11,51 +14,40 @@ CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument)
CXFA_ArrayNodeList::~CXFA_ArrayNodeList() {}
-void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) {
- if (srcArray.GetSize() > 0) {
- m_array.Copy(srcArray);
- }
+void CXFA_ArrayNodeList::SetArrayNodeList(
+ const std::vector<CXFA_Node*>& srcArray) {
+ if (!srcArray.empty())
+ m_array = srcArray;
}
int32_t CXFA_ArrayNodeList::GetLength() {
- return m_array.GetSize();
+ return pdfium::CollectionSize<int32_t>(m_array);
}
bool CXFA_ArrayNodeList::Append(CXFA_Node* pNode) {
- m_array.Add(pNode);
+ m_array.push_back(pNode);
return true;
}
bool CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) {
if (!pBeforeNode) {
- m_array.Add(pNewNode);
+ m_array.push_back(pNewNode);
} else {
- int32_t iSize = m_array.GetSize();
- for (int32_t i = 0; i < iSize; ++i) {
- if (m_array[i] == pBeforeNode) {
- m_array.InsertAt(i, pNewNode);
- break;
- }
- }
+ auto it = std::find(m_array.begin(), m_array.end(), pBeforeNode);
+ if (it != m_array.end())
+ m_array.insert(it, pNewNode);
}
return true;
}
bool CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) {
- int32_t iSize = m_array.GetSize();
- for (int32_t i = 0; i < iSize; ++i) {
- if (m_array[i] == pNode) {
- m_array.RemoveAt(i);
- break;
- }
- }
+ auto it = std::find(m_array.begin(), m_array.end(), pNode);
+ if (it != m_array.end())
+ m_array.erase(it);
return true;
}
CXFA_Node* CXFA_ArrayNodeList::Item(int32_t iIndex) {
- int32_t iSize = m_array.GetSize();
- if (iIndex >= 0 && iIndex < iSize) {
- return m_array[iIndex];
- }
- return nullptr;
+ int32_t iSize = pdfium::CollectionSize<int32_t>(m_array);
+ return (iIndex >= 0 && iIndex < iSize) ? m_array[iIndex] : nullptr;
}
diff --git a/xfa/fxfa/parser/cxfa_data.h b/xfa/fxfa/parser/cxfa_data.h
index 4801f08dc5..90b689020b 100644
--- a/xfa/fxfa/parser/cxfa_data.h
+++ b/xfa/fxfa/parser/cxfa_data.h
@@ -19,7 +19,7 @@ class CXFA_Data {
explicit CXFA_Data(CXFA_Node* pNode) : m_pNode(pNode) {}
- operator bool() const { return !!m_pNode; }
+ explicit operator bool() const { return !!m_pNode; }
CXFA_Node* GetNode() const { return m_pNode; }
XFA_Element GetElementType() const;
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index b7d429aa4a..fed35c86b4 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -418,8 +418,8 @@ void CXFA_Document::DoProtoMerge() {
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = m_pScriptContext->ResolveObjects(pUseHrefNode, wsSOM,
resoveNodeRS, dwFlag);
- if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode())
- pProtoNode = resoveNodeRS.nodes[0]->AsNode();
+ if (iRet > 0 && resoveNodeRS.objects.front()->IsNode())
+ pProtoNode = resoveNodeRS.objects.front()->AsNode();
} else if (!wsID.IsEmpty()) {
auto it = mIDMap.find(FX_HashCode_GetW(wsID, false));
if (it == mIDMap.end())
diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h
index b1ee35f07e..0bf7e1989d 100644
--- a/xfa/fxfa/parser/cxfa_document.h
+++ b/xfa/fxfa/parser/cxfa_document.h
@@ -9,6 +9,7 @@
#include <map>
#include <unordered_set>
+#include <vector>
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/xfa_localemgr.h"
@@ -70,7 +71,7 @@ class CXFA_Document {
CXFA_LocaleMgr* GetLocalMgr();
CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash);
CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const CFX_WideStringC& wsID);
- CXFA_Node* GetNotBindNode(CXFA_ObjArray& arrayNodes);
+ CXFA_Node* GetNotBindNode(const std::vector<CXFA_Object*>& arrayNodes);
CXFA_LayoutProcessor* GetLayoutProcessor();
CXFA_LayoutProcessor* GetDocLayout();
CXFA_ScriptContext* GetScriptContext();
@@ -105,7 +106,7 @@ class CXFA_Document {
void ClearLayoutData();
std::map<uint32_t, CXFA_Node*> m_rgGlobalBinding;
- CXFA_NodeArray m_pPendingPageSet;
+ std::vector<CXFA_Node*> m_pPendingPageSet;
protected:
CXFA_DocumentParser* m_pParser;
diff --git a/xfa/fxfa/parser/cxfa_event.cpp b/xfa/fxfa/parser/cxfa_event.cpp
index 3e5639617b..1fe03a4935 100644
--- a/xfa/fxfa/parser/cxfa_event.cpp
+++ b/xfa/fxfa/parser/cxfa_event.cpp
@@ -14,7 +14,7 @@ int32_t CXFA_Event::GetActivity() {
return m_pNode->GetEnum(XFA_ATTRIBUTE_Activity);
}
-XFA_Element CXFA_Event::GetEventType() {
+XFA_Element CXFA_Event::GetEventType() const {
CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pChild) {
XFA_Element eType = pChild->GetElementType();
@@ -30,11 +30,11 @@ void CXFA_Event::GetRef(CFX_WideStringC& wsRef) {
m_pNode->TryCData(XFA_ATTRIBUTE_Ref, wsRef);
}
-CXFA_Script CXFA_Event::GetScript() {
+CXFA_Script CXFA_Event::GetScript() const {
return CXFA_Script(m_pNode->GetChild(0, XFA_Element::Script));
}
-CXFA_Submit CXFA_Event::GetSubmit() {
+CXFA_Submit CXFA_Event::GetSubmit() const {
return CXFA_Submit(m_pNode->GetChild(0, XFA_Element::Submit));
}
diff --git a/xfa/fxfa/parser/cxfa_event.h b/xfa/fxfa/parser/cxfa_event.h
index b151b399b5..fc0bcf34cc 100644
--- a/xfa/fxfa/parser/cxfa_event.h
+++ b/xfa/fxfa/parser/cxfa_event.h
@@ -21,12 +21,10 @@ class CXFA_Event : public CXFA_Data {
explicit CXFA_Event(CXFA_Node* pNode);
int32_t GetActivity();
- XFA_Element GetEventType();
+ XFA_Element GetEventType() const;
+ CXFA_Script GetScript() const;
+ CXFA_Submit GetSubmit() const;
void GetRef(CFX_WideStringC& wsRef);
-
- CXFA_Script GetScript();
- CXFA_Submit GetSubmit();
-
void GetSignDataTarget(CFX_WideString& wsTarget);
};
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index c8f4b65a16..7b4cf2651a 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/cxfa_layoutpagemgr.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
@@ -172,8 +173,8 @@ CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings |
XFA_RESOLVENODE_Parent);
- if (iCount > 0 && rs.nodes[0]->IsNode())
- return rs.nodes[0]->AsNode();
+ if (iCount > 0 && rs.objects.front()->IsNode())
+ return rs.objects.front()->AsNode();
}
iSplitIndex = iSplitNextIndex;
}
@@ -1661,22 +1662,19 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_FFNotify* pNotify = pDocument->GetNotify();
CXFA_LayoutProcessor* pDocLayout = pDocument->GetDocLayout();
CXFA_ContainerLayoutItem* pRootLayout = GetRootLayoutItem();
- {
- for (int32_t iIndex = 0; iIndex < pDocument->m_pPendingPageSet.GetSize();
- iIndex++) {
- CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
- sIterator(pDocument->m_pPendingPageSet.GetAt(iIndex));
- for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
- pNode = sIterator.MoveToNext()) {
- if (pNode->IsContainerNode()) {
- CXFA_Node* pBindNode = pNode->GetBindData();
- if (pBindNode) {
- pBindNode->RemoveBindItem(pNode);
- pNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
- }
+ for (CXFA_Node* pPageNode : pDocument->m_pPendingPageSet) {
+ CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
+ sIterator(pPageNode);
+ for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode;
+ pNode = sIterator.MoveToNext()) {
+ if (pNode->IsContainerNode()) {
+ CXFA_Node* pBindNode = pNode->GetBindData();
+ if (pBindNode) {
+ pBindNode->RemoveBindItem(pNode);
+ pNode->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
}
- pNode->SetFlag(XFA_NodeFlag_UnusedNode, true);
}
+ pNode->SetFlag(XFA_NodeFlag_UnusedNode, true);
}
}
@@ -1691,8 +1689,9 @@ void CXFA_LayoutPageMgr::MergePageSetContents() {
CXFA_ContainerLayoutItem* pRootPageSetContainerItem = iterator.GetCurrent();
ASSERT(pRootPageSetContainerItem->m_pFormNode->GetElementType() ==
XFA_Element::PageSet);
- if (iIndex < pDocument->m_pPendingPageSet.GetSize()) {
- pPendingPageSet = pDocument->m_pPendingPageSet.GetAt(iIndex);
+ if (iIndex <
+ pdfium::CollectionSize<int32_t>(pDocument->m_pPendingPageSet)) {
+ pPendingPageSet = pDocument->m_pPendingPageSet[iIndex];
iIndex++;
}
if (!pPendingPageSet) {
@@ -1958,7 +1957,7 @@ void CXFA_LayoutPageMgr::PrepareLayout() {
if (pRootLayoutItem &&
pRootLayoutItem->m_pFormNode->GetPacketID() == XFA_XDPPACKET_Form) {
CXFA_Node* pPageSetFormNode = pRootLayoutItem->m_pFormNode;
- pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.RemoveAll();
+ pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.clear();
if (pPageSetFormNode->HasRemovedChildren()) {
XFA_ReleaseLayoutItem(pRootLayoutItem);
m_pPageSetLayoutItemRoot = nullptr;
@@ -1971,7 +1970,7 @@ void CXFA_LayoutPageMgr::PrepareLayout() {
pPageSetFormNode->GetNextSameClassSibling(XFA_Element::PageSet);
pPageSetFormNode->GetNodeItem(XFA_NODEITEM_Parent)
->RemoveChild(pPageSetFormNode, false);
- pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.Add(
+ pRootLayoutItem->m_pFormNode->GetDocument()->m_pPendingPageSet.push_back(
pPageSetFormNode);
pPageSetFormNode = pNextPageSet;
}
diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
index a41b546aa8..c97a1cea58 100644
--- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_layoutpagemgr.h"
@@ -18,9 +19,7 @@
#include "xfa/fxfa/parser/xfa_utils.h"
CXFA_LayoutProcessor::CXFA_LayoutProcessor(CXFA_Document* pDocument)
- : m_pDocument(pDocument),
- m_nProgressCounter(0),
- m_bNeeLayout(true) {}
+ : m_pDocument(pDocument), m_nProgressCounter(0), m_bNeedLayout(true) {}
CXFA_LayoutProcessor::~CXFA_LayoutProcessor() {}
@@ -85,8 +84,8 @@ int32_t CXFA_LayoutProcessor::DoLayout(IFX_Pause* pPause) {
if (eStatus == XFA_ItemLayoutProcessorResult::Done) {
m_pLayoutPageMgr->FinishPaginatedPageSets();
m_pLayoutPageMgr->SyncLayoutData();
- m_bNeeLayout = false;
- m_rgChangedContainers.RemoveAll();
+ m_bNeedLayout = false;
+ m_rgChangedContainers.clear();
}
return 100 * (eStatus == XFA_ItemLayoutProcessorResult::Done
? m_nProgressCounter
@@ -95,13 +94,11 @@ int32_t CXFA_LayoutProcessor::DoLayout(IFX_Pause* pPause) {
}
bool CXFA_LayoutProcessor::IncrementLayout() {
- if (m_bNeeLayout) {
+ if (m_bNeedLayout) {
StartLayout(true);
return DoLayout(nullptr) == 100;
}
-
- for (int32_t i = 0, c = m_rgChangedContainers.GetSize(); i < c; i++) {
- CXFA_Node* pNode = m_rgChangedContainers[i];
+ for (CXFA_Node* pNode : m_rgChangedContainers) {
CXFA_Node* pParentNode =
pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
if (!pParentNode)
@@ -111,7 +108,7 @@ bool CXFA_LayoutProcessor::IncrementLayout() {
return false;
}
}
- m_rgChangedContainers.RemoveAll();
+ m_rgChangedContainers.clear();
return true;
}
@@ -129,8 +126,8 @@ CXFA_LayoutItem* CXFA_LayoutProcessor::GetLayoutItem(CXFA_Node* pFormItem) {
}
void CXFA_LayoutProcessor::AddChangedContainer(CXFA_Node* pContainer) {
- if (m_rgChangedContainers.Find(pContainer) < 0)
- m_rgChangedContainers.Add(pContainer);
+ if (!pdfium::ContainsValue(m_rgChangedContainers, pContainer))
+ m_rgChangedContainers.push_back(pContainer);
}
CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetRootLayoutItem() const {
@@ -138,5 +135,5 @@ CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetRootLayoutItem() const {
}
bool CXFA_LayoutProcessor::IsNeedLayout() {
- return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0;
+ return m_bNeedLayout || !m_rgChangedContainers.empty();
}
diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.h b/xfa/fxfa/parser/cxfa_layoutprocessor.h
index 5861bf7048..c6950052a9 100644
--- a/xfa/fxfa/parser/cxfa_layoutprocessor.h
+++ b/xfa/fxfa/parser/cxfa_layoutprocessor.h
@@ -8,6 +8,7 @@
#define XFA_FXFA_PARSER_CXFA_LAYOUTPROCESSOR_H_
#include <memory>
+#include <vector>
#include "core/fxcrt/fx_system.h"
#include "xfa/fxfa/parser/xfa_object.h"
@@ -33,7 +34,7 @@ class CXFA_LayoutProcessor {
CXFA_ContainerLayoutItem* GetPage(int32_t index) const;
CXFA_LayoutItem* GetLayoutItem(CXFA_Node* pFormItem);
void AddChangedContainer(CXFA_Node* pContainer);
- void SetForceReLayout(bool bForceRestart) { m_bNeeLayout = bForceRestart; }
+ void SetForceReLayout(bool bForceRestart) { m_bNeedLayout = bForceRestart; }
CXFA_ContainerLayoutItem* GetRootLayoutItem() const;
CXFA_ItemLayoutProcessor* GetRootRootItemLayoutProcessor() const {
return m_pRootItemLayoutProcessor.get();
@@ -48,9 +49,9 @@ class CXFA_LayoutProcessor {
CXFA_Document* const m_pDocument;
std::unique_ptr<CXFA_ItemLayoutProcessor> m_pRootItemLayoutProcessor;
std::unique_ptr<CXFA_LayoutPageMgr> m_pLayoutPageMgr;
- CXFA_NodeArray m_rgChangedContainers;
+ std::vector<CXFA_Node*> m_rgChangedContainers;
uint32_t m_nProgressCounter;
- bool m_bNeeLayout;
+ bool m_bNeedLayout;
};
#endif // XFA_FXFA_PARSER_CXFA_LAYOUTPROCESSOR_H_
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 8d618e9719..645f907525 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -45,7 +45,7 @@ XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = {XFA_DeleteWideString,
XFA_CopyWideString};
void XFA_DataNodeDeleteBindItem(void* pData) {
- delete static_cast<CXFA_NodeArray*>(pData);
+ delete static_cast<std::vector<CXFA_Node*>*>(pData);
}
XFA_MAPDATABLOCKCALLBACKINFO deleteBindItemCallBack = {
@@ -82,10 +82,10 @@ int32_t GetCount(CXFA_Node* pInstMgrNode) {
}
void SortNodeArrayByDocumentIdx(const std::unordered_set<CXFA_Node*>& rgNodeSet,
- CXFA_NodeArray& rgNodeArray,
+ std::vector<CXFA_Node*>& rgNodeArray,
CFX_ArrayTemplate<int32_t>& rgIdxArray) {
int32_t iCount = pdfium::CollectionSize<int32_t>(rgNodeSet);
- rgNodeArray.SetSize(iCount);
+ rgNodeArray.resize(iCount);
rgIdxArray.SetSize(iCount);
if (iCount == 0)
return;
@@ -158,8 +158,8 @@ void ReorderDataNodes(const std::unordered_set<CXFA_Node*>& sSet1,
if (!pNodeSetPair)
continue;
if (!pNodeSetPair->first.empty() && !pNodeSetPair->second.empty()) {
- CXFA_NodeArray rgNodeArray1;
- CXFA_NodeArray rgNodeArray2;
+ std::vector<CXFA_Node*> rgNodeArray1;
+ std::vector<CXFA_Node*> rgNodeArray2;
CFX_ArrayTemplate<int32_t> rgIdxArray1;
CFX_ArrayTemplate<int32_t> rgIdxArray2;
SortNodeArrayByDocumentIdx(pNodeSetPair->first, rgNodeArray1,
@@ -614,34 +614,18 @@ CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem,
return pNode;
}
-int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes,
- uint32_t dwTypeFilter,
- XFA_Element eTypeFilter,
- int32_t iLevel) {
- if (--iLevel < 0) {
- return nodes.GetSize();
- }
+std::vector<CXFA_Node*> CXFA_Node::GetNodeList(uint32_t dwTypeFilter,
+ XFA_Element eTypeFilter) {
+ std::vector<CXFA_Node*> nodes;
if (eTypeFilter != XFA_Element::Unknown) {
- CXFA_Node* pChild = m_pChild;
- while (pChild) {
- if (pChild->GetElementType() == eTypeFilter) {
- nodes.Add(pChild);
- if (iLevel > 0) {
- GetNodeList(nodes, dwTypeFilter, eTypeFilter, iLevel);
- }
- }
- pChild = pChild->m_pNext;
+ for (CXFA_Node* pChild = m_pChild; pChild; pChild = pChild->m_pNext) {
+ if (pChild->GetElementType() == eTypeFilter)
+ nodes.push_back(pChild);
}
} else if (dwTypeFilter ==
(XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties)) {
- CXFA_Node* pChild = m_pChild;
- while (pChild) {
- nodes.Add(pChild);
- if (iLevel > 0) {
- GetNodeList(nodes, dwTypeFilter, eTypeFilter, iLevel);
- }
- pChild = pChild->m_pNext;
- }
+ for (CXFA_Node* pChild = m_pChild; pChild; pChild = pChild->m_pNext)
+ nodes.push_back(pChild);
} else if (dwTypeFilter != 0) {
bool bFilterChildren = !!(dwTypeFilter & XFA_NODEFILTER_Children);
bool bFilterProperties = !!(dwTypeFilter & XFA_NODEFILTER_Properties);
@@ -653,26 +637,26 @@ int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes,
GetElementType(), pChild->GetElementType(), XFA_XDPPACKET_UNKNOWN);
if (pProperty) {
if (bFilterProperties) {
- nodes.Add(pChild);
+ nodes.push_back(pChild);
} else if (bFilterOneOfProperties &&
(pProperty->uFlags & XFA_PROPERTYFLAG_OneOf)) {
- nodes.Add(pChild);
+ nodes.push_back(pChild);
} else if (bFilterChildren &&
(pChild->GetElementType() == XFA_Element::Variables ||
pChild->GetElementType() == XFA_Element::PageSet)) {
- nodes.Add(pChild);
+ nodes.push_back(pChild);
}
} else if (bFilterChildren) {
- nodes.Add(pChild);
+ nodes.push_back(pChild);
}
pChild = pChild->m_pNext;
}
- if (bFilterOneOfProperties && nodes.GetSize() < 1) {
+ if (bFilterOneOfProperties && nodes.empty()) {
int32_t iProperties = 0;
const XFA_PROPERTY* pProperty =
XFA_GetElementProperties(GetElementType(), iProperties);
if (!pProperty || iProperties < 1)
- return 0;
+ return nodes;
for (int32_t i = 0; i < iProperties; i++) {
if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) {
const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID());
@@ -682,13 +666,13 @@ int32_t CXFA_Node::GetNodeList(CXFA_NodeArray& nodes,
break;
InsertChild(pNewNode, nullptr);
pNewNode->SetFlag(XFA_NodeFlag_Initialized, true);
- nodes.Add(pNewNode);
+ nodes.push_back(pNewNode);
break;
}
}
}
}
- return nodes.GetSize();
+ return nodes;
}
CXFA_Node* CXFA_Node::CreateSamePacketNode(XFA_Element eType,
@@ -731,74 +715,72 @@ CXFA_Node* CXFA_Node::GetBindData() {
return static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
}
-int32_t CXFA_Node::GetBindItems(CXFA_NodeArray& formItems) {
+std::vector<CXFA_Node*> CXFA_Node::GetBindItems() {
if (BindsFormItems()) {
- CXFA_NodeArray* pItems = nullptr;
- TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems);
- formItems.Copy(*pItems);
- return formItems.GetSize();
+ void* pBinding = nullptr;
+ TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
+ return *static_cast<std::vector<CXFA_Node*>*>(pBinding);
}
+ std::vector<CXFA_Node*> result;
CXFA_Node* pFormNode =
static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
if (pFormNode)
- formItems.Add(pFormNode);
- return formItems.GetSize();
+ result.push_back(pFormNode);
+ return result;
}
int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) {
ASSERT(pFormNode);
if (BindsFormItems()) {
- CXFA_NodeArray* pItems = nullptr;
- TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems);
- ASSERT(pItems);
- if (pItems->Find(pFormNode) < 0) {
- pItems->Add(pFormNode);
- }
- return pItems->GetSize();
+ void* pBinding = nullptr;
+ TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
+ auto* pItems = static_cast<std::vector<CXFA_Node*>*>(pBinding);
+ if (!pdfium::ContainsValue(*pItems, pFormNode))
+ pItems->push_back(pFormNode);
+ return pdfium::CollectionSize<int32_t>(*pItems);
}
CXFA_Node* pOldFormItem =
static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
if (!pOldFormItem) {
SetObject(XFA_ATTRIBUTE_BindingNode, pFormNode);
return 1;
- } else if (pOldFormItem == pFormNode) {
- return 1;
}
- CXFA_NodeArray* pItems = new CXFA_NodeArray;
+ if (pOldFormItem == pFormNode)
+ return 1;
+
+ std::vector<CXFA_Node*>* pItems = new std::vector<CXFA_Node*>;
SetObject(XFA_ATTRIBUTE_BindingNode, pItems, &deleteBindItemCallBack);
- pItems->Add(pOldFormItem);
- pItems->Add(pFormNode);
+ pItems->push_back(pOldFormItem);
+ pItems->push_back(pFormNode);
m_uNodeFlags |= XFA_NodeFlag_BindFormItems;
return 2;
}
int32_t CXFA_Node::RemoveBindItem(CXFA_Node* pFormNode) {
if (BindsFormItems()) {
- CXFA_NodeArray* pItems = nullptr;
- TryObject(XFA_ATTRIBUTE_BindingNode, (void*&)pItems);
- ASSERT(pItems);
- int32_t iIndex = pItems->Find(pFormNode);
- int32_t iCount = pItems->GetSize();
- if (iIndex >= 0) {
- if (iIndex != iCount - 1)
- pItems->SetAt(iIndex, pItems->GetAt(iCount - 1));
- pItems->RemoveAt(iCount - 1);
- if (iCount == 2) {
- CXFA_Node* pLastFormNode = pItems->GetAt(0);
- SetObject(XFA_ATTRIBUTE_BindingNode, pLastFormNode);
+ void* pBinding = nullptr;
+ TryObject(XFA_ATTRIBUTE_BindingNode, pBinding);
+ auto* pItems = static_cast<std::vector<CXFA_Node*>*>(pBinding);
+ auto iter = std::find(pItems->begin(), pItems->end(), pFormNode);
+ if (iter != pItems->end()) {
+ *iter = pItems->back();
+ pItems->pop_back();
+ if (pItems->size() == 1) {
+ SetObject(XFA_ATTRIBUTE_BindingNode,
+ (*pItems)[0]); // Invalidates pItems.
m_uNodeFlags &= ~XFA_NodeFlag_BindFormItems;
+ return 1;
}
- iCount--;
}
- return iCount;
+ return pdfium::CollectionSize<int32_t>(*pItems);
}
CXFA_Node* pOldFormItem =
static_cast<CXFA_Node*>(GetObject(XFA_ATTRIBUTE_BindingNode));
- if (pOldFormItem == pFormNode) {
- SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
- pOldFormItem = nullptr;
- }
- return pOldFormItem ? 1 : 0;
+ if (pOldFormItem != pFormNode)
+ return pOldFormItem ? 1 : 0;
+
+ SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
+ return 0;
}
bool CXFA_Node::HasBindItem() {
@@ -838,10 +820,7 @@ CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() {
if (!pDataNode)
return nullptr;
pFieldWidgetData = nullptr;
- CXFA_NodeArray formNodes;
- pDataNode->GetBindItems(formNodes);
- for (int32_t i = 0; i < formNodes.GetSize(); i++) {
- CXFA_Node* pFormNode = formNodes.GetAt(i);
+ for (CXFA_Node* pFormNode : pDataNode->GetBindItems()) {
if (!pFormNode || pFormNode->HasRemovedChildren())
continue;
pFieldWidgetData = pFormNode->GetWidgetData();
@@ -1018,16 +997,16 @@ void CXFA_Node::Script_TreeClass_ResolveNode(CFXJSE_Arguments* pArguments) {
return;
}
if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
- CXFA_Object* pNode = resoveNodeRS.nodes[0];
+ CXFA_Object* pObject = resoveNodeRS.objects.front();
pArguments->GetReturnValue()->Assign(
- pScriptContext->GetJSValueFromMap(pNode));
+ pScriptContext->GetJSValueFromMap(pObject));
} else {
const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
resoveNodeRS.pScriptAttribute;
if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) {
std::unique_ptr<CFXJSE_Value> pValue(
new CFXJSE_Value(pScriptContext->GetRuntime()));
- (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))(
+ (resoveNodeRS.objects.front()->*(lpAttributeInfo->lpfnCallback))(
pValue.get(), false, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
pArguments->GetReturnValue()->Assign(pValue.get());
} else {
@@ -1070,18 +1049,16 @@ void CXFA_Node::Script_Som_ResolveNodeList(CFXJSE_Value* pValue,
resoveNodeRS, dwFlag);
CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(m_pDocument);
if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
- for (int32_t i = 0; i < resoveNodeRS.nodes.GetSize(); i++) {
- if (resoveNodeRS.nodes[i]->IsNode())
- pNodeList->Append(resoveNodeRS.nodes[i]->AsNode());
+ for (CXFA_Object* pObject : resoveNodeRS.objects) {
+ if (pObject->IsNode())
+ pNodeList->Append(pObject->AsNode());
}
} else {
CXFA_ValueArray valueArray(pScriptContext->GetRuntime());
if (resoveNodeRS.GetAttributeResult(valueArray) > 0) {
- CXFA_ObjArray objectArray;
- valueArray.GetAttributeObject(objectArray);
- for (int32_t i = 0; i < objectArray.GetSize(); i++) {
- if (objectArray[i]->IsNode())
- pNodeList->Append(objectArray[i]->AsNode());
+ for (CXFA_Object* pObject : valueArray.GetAttributeObject()) {
+ if (pObject->IsNode())
+ pNodeList->Append(pObject->AsNode());
}
}
}
@@ -1554,12 +1531,11 @@ void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue,
ThrowInvalidPropertyException();
return;
}
-
- CXFA_NodeArray properts;
- int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty);
- if (iSize > 0) {
+ std::vector<CXFA_Node*> properties =
+ GetNodeList(XFA_NODEFILTER_OneOfProperty);
+ if (!properties.empty()) {
pValue->Assign(
- m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0]));
+ m_pDocument->GetScriptContext()->GetJSValueFromMap(properties.front()));
}
}
@@ -1828,8 +1804,8 @@ void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue,
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = m_pDocument->GetScriptContext()->ResolveObjects(
pProtoRoot, wsSOM.AsStringC(), resoveNodeRS, dwFlag);
- if (iRet > 0 && resoveNodeRS.nodes[0]->IsNode()) {
- pProtoNode = resoveNodeRS.nodes[0]->AsNode();
+ if (iRet > 0 && resoveNodeRS.objects.front()->IsNode()) {
+ pProtoNode = resoveNodeRS.objects.front()->AsNode();
}
} else if (!wsID.IsEmpty()) {
pProtoNode = m_pDocument->GetNodeByID(pProtoRoot, wsID.AsStringC());
@@ -2000,22 +1976,17 @@ void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue,
CFX_WideString wsFormatValue(wsNewValue);
CXFA_WidgetData* pContainerWidgetData = nullptr;
if (GetPacketID() == XFA_XDPPACKET_Datasets) {
- CXFA_NodeArray formNodes;
- GetBindItems(formNodes);
CFX_WideString wsPicture;
- for (int32_t i = 0; i < formNodes.GetSize(); i++) {
- CXFA_Node* pFormNode = formNodes.GetAt(i);
- if (!pFormNode || pFormNode->HasRemovedChildren()) {
+ for (CXFA_Node* pFormNode : GetBindItems()) {
+ if (!pFormNode || pFormNode->HasRemovedChildren())
continue;
- }
pContainerWidgetData = pFormNode->GetContainerWidgetData();
if (pContainerWidgetData) {
pContainerWidgetData->GetPictureContent(wsPicture,
XFA_VALUEPICTURE_DataBind);
}
- if (!wsPicture.IsEmpty()) {
+ if (!wsPicture.IsEmpty())
break;
- }
pContainerWidgetData = nullptr;
}
} else if (GetPacketID() == XFA_XDPPACKET_Form) {
@@ -3312,7 +3283,7 @@ void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) {
return;
}
- CXFA_NodeArray formItems;
+ std::vector<CXFA_Node*> formItems;
CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument);
pFormNodes->SetArrayNodeList(formItems);
pArguments->GetReturnValue()->SetObject(
@@ -3844,8 +3815,7 @@ bool CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr,
GetNodeItem(XFA_NODEITEM_FirstChild);
pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
XFA_NODEITEM_NextSibling)) {
- CXFA_NodeArray formNodes;
- if (pChildDataNode->GetBindItems(formNodes) > 0) {
+ if (!pChildDataNode->GetBindItems().empty()) {
bDeleteChildren = false;
break;
}
@@ -3902,8 +3872,7 @@ bool CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue,
GetNodeItem(XFA_NODEITEM_FirstChild);
pChildDataNode; pChildDataNode = pChildDataNode->GetNodeItem(
XFA_NODEITEM_NextSibling)) {
- CXFA_NodeArray formNodes;
- if (pChildDataNode->GetBindItems(formNodes) > 0) {
+ if (!pChildDataNode->GetBindItems().empty()) {
bDeleteChildren = false;
break;
}
@@ -4082,7 +4051,7 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
CXFA_Node* pBind = GetBindData();
if (bSyncData && pBind) {
std::vector<CFX_WideString> wsSaveTextArray;
- int32_t iSize = 0;
+ size_t iSize = 0;
if (!wsContent.IsEmpty()) {
int32_t iStart = 0;
int32_t iLength = wsContent.GetLength();
@@ -4100,7 +4069,7 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
wsContent.Mid(iStart, iLength - iStart));
}
}
- iSize = pdfium::CollectionSize<int32_t>(wsSaveTextArray);
+ iSize = wsSaveTextArray.size();
}
if (iSize == 0) {
while (CXFA_Node* pChildNode =
@@ -4108,11 +4077,11 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
pBind->RemoveChild(pChildNode);
}
} else {
- CXFA_NodeArray valueNodes;
- int32_t iDatas = pBind->GetNodeList(
- valueNodes, XFA_NODEFILTER_Children, XFA_Element::DataValue);
+ std::vector<CXFA_Node*> valueNodes = pBind->GetNodeList(
+ XFA_NODEFILTER_Children, XFA_Element::DataValue);
+ size_t iDatas = valueNodes.size();
if (iDatas < iSize) {
- int32_t iAddNodes = iSize - iDatas;
+ size_t iAddNodes = iSize - iDatas;
CXFA_Node* pValueNodes = nullptr;
while (iAddNodes-- > 0) {
pValueNodes =
@@ -4123,7 +4092,7 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
}
pValueNodes = nullptr;
} else if (iDatas > iSize) {
- int32_t iDelNodes = iDatas - iSize;
+ size_t iDelNodes = iDatas - iSize;
while (iDelNodes-- > 0) {
pBind->RemoveChild(pBind->GetNodeItem(XFA_NODEITEM_FirstChild));
}
@@ -4138,12 +4107,10 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
i++;
}
}
- CXFA_NodeArray nodeArray;
- pBind->GetBindItems(nodeArray);
- for (int32_t i = 0; i < nodeArray.GetSize(); i++) {
- if (nodeArray[i] != this) {
- nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify,
- bScriptModify, false);
+ for (CXFA_Node* pArrayNode : pBind->GetBindItems()) {
+ if (pArrayNode != this) {
+ pArrayNode->SetScriptContent(wsContent, wsContent, bNotify,
+ bScriptModify, false);
}
}
}
@@ -4161,12 +4128,10 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
if (pBindNode && bSyncData) {
pBindNode->SetScriptContent(wsContent, wsXMLValue, bNotify,
bScriptModify, false);
- CXFA_NodeArray nodeArray;
- pBindNode->GetBindItems(nodeArray);
- for (int32_t i = 0; i < nodeArray.GetSize(); i++) {
- if (nodeArray[i] != this) {
- nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify, true,
- false);
+ for (CXFA_Node* pArrayNode : pBindNode->GetBindItems()) {
+ if (pArrayNode != this) {
+ pArrayNode->SetScriptContent(wsContent, wsContent, bNotify, true,
+ false);
}
}
}
@@ -4225,11 +4190,9 @@ bool CXFA_Node::SetScriptContent(const CFX_WideString& wsContent,
if (pNode) {
SetAttributeValue(wsContent, wsXMLValue, bNotify, bScriptModify);
if (pBindNode && bSyncData) {
- CXFA_NodeArray nodeArray;
- pBindNode->GetBindItems(nodeArray);
- for (int32_t i = 0; i < nodeArray.GetSize(); i++) {
- nodeArray[i]->SetScriptContent(wsContent, wsContent, bNotify,
- bScriptModify, false);
+ for (CXFA_Node* pArrayNode : pBindNode->GetBindItems()) {
+ pArrayNode->SetScriptContent(wsContent, wsContent, bNotify,
+ bScriptModify, false);
}
}
return true;
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp
index 641697dc81..692f0b2338 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.cpp
+++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp
@@ -27,21 +27,18 @@ CXFA_NodeHelper::~CXFA_NodeHelper() {}
CXFA_Node* CXFA_NodeHelper::ResolveNodes_GetOneChild(CXFA_Node* parent,
const wchar_t* pwsName,
bool bIsClassName) {
- if (!parent) {
+ if (!parent)
return nullptr;
- }
- CXFA_NodeArray siblings;
+
+ std::vector<CXFA_Node*> siblings;
uint32_t uNameHash = FX_HashCode_GetW(CFX_WideStringC(pwsName), false);
NodeAcc_TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName);
- if (siblings.GetSize() == 0) {
- return nullptr;
- }
- return siblings[0];
+ return !siblings.empty() ? siblings[0] : nullptr;
}
int32_t CXFA_NodeHelper::CountSiblings(CXFA_Node* pNode,
XFA_LOGIC_TYPE eLogicType,
- CXFA_NodeArray* pSiblings,
+ std::vector<CXFA_Node*>* pSiblings,
bool bIsClassName) {
if (!pNode)
return 0;
@@ -52,99 +49,81 @@ int32_t CXFA_NodeHelper::CountSiblings(CXFA_Node* pNode,
parent->GetElementType(), pNode->GetElementType(), XFA_XDPPACKET_UNKNOWN);
if (!pProperty && eLogicType == XFA_LOGIC_Transparent) {
parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent);
- if (!parent) {
+ if (!parent)
return 0;
- }
}
if (bIsClassName) {
return NodeAcc_TraverseSiblings(parent, pNode->GetClassHashCode(),
pSiblings, eLogicType, bIsClassName);
- } else {
- return NodeAcc_TraverseSiblings(parent, pNode->GetNameHash(), pSiblings,
- eLogicType, bIsClassName);
}
+ return NodeAcc_TraverseSiblings(parent, pNode->GetNameHash(), pSiblings,
+ eLogicType, bIsClassName);
}
-int32_t CXFA_NodeHelper::NodeAcc_TraverseAnySiblings(CXFA_Node* parent,
- uint32_t dNameHash,
- CXFA_NodeArray* pSiblings,
- bool bIsClassName) {
- if (!parent || !pSiblings) {
+int32_t CXFA_NodeHelper::NodeAcc_TraverseAnySiblings(
+ CXFA_Node* parent,
+ uint32_t dNameHash,
+ std::vector<CXFA_Node*>* pSiblings,
+ bool bIsClassName) {
+ if (!parent || !pSiblings)
return 0;
- }
+
int32_t nCount = 0;
- int32_t i = 0;
- CXFA_NodeArray properties;
- parent->GetNodeList(properties, XFA_NODEFILTER_Properties);
- int32_t nProperties = properties.GetSize();
- for (i = 0; i < nProperties; ++i) {
- CXFA_Node* child = properties[i];
+ for (CXFA_Node* child : parent->GetNodeList(XFA_NODEFILTER_Properties)) {
if (bIsClassName) {
if (child->GetClassHashCode() == dNameHash) {
- pSiblings->Add(child);
+ pSiblings->push_back(child);
nCount++;
}
} else {
if (child->GetNameHash() == dNameHash) {
- pSiblings->Add(child);
+ pSiblings->push_back(child);
nCount++;
}
}
- if (nCount > 0) {
+ if (nCount > 0)
return nCount;
- }
+
nCount +=
NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, bIsClassName);
}
- CXFA_NodeArray children;
- parent->GetNodeList(children, XFA_NODEFILTER_Children);
- int32_t nChildren = children.GetSize();
- for (i = 0; i < nChildren; i++) {
- CXFA_Node* child = children[i];
+ for (CXFA_Node* child : parent->GetNodeList(XFA_NODEFILTER_Children)) {
if (bIsClassName) {
if (child->GetClassHashCode() == dNameHash) {
- if (pSiblings) {
- pSiblings->Add(child);
- }
+ pSiblings->push_back(child);
nCount++;
}
} else {
if (child->GetNameHash() == dNameHash) {
- if (pSiblings) {
- pSiblings->Add(child);
- }
+ pSiblings->push_back(child);
nCount++;
}
}
- if (nCount > 0) {
+ if (nCount > 0)
return nCount;
- }
+
nCount +=
NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, bIsClassName);
}
return nCount;
}
-int32_t CXFA_NodeHelper::NodeAcc_TraverseSiblings(CXFA_Node* parent,
- uint32_t dNameHash,
- CXFA_NodeArray* pSiblings,
- XFA_LOGIC_TYPE eLogicType,
- bool bIsClassName,
- bool bIsFindProperty) {
- if (!parent || !pSiblings) {
+int32_t CXFA_NodeHelper::NodeAcc_TraverseSiblings(
+ CXFA_Node* parent,
+ uint32_t dNameHash,
+ std::vector<CXFA_Node*>* pSiblings,
+ XFA_LOGIC_TYPE eLogicType,
+ bool bIsClassName,
+ bool bIsFindProperty) {
+ if (!parent || !pSiblings)
return 0;
- }
+
int32_t nCount = 0;
- int32_t i = 0;
if (bIsFindProperty) {
- CXFA_NodeArray properties;
- parent->GetNodeList(properties, XFA_NODEFILTER_Properties);
- int32_t nProperties = properties.GetSize();
- for (i = 0; i < nProperties; ++i) {
- CXFA_Node* child = properties[i];
+ for (CXFA_Node* child : parent->GetNodeList(XFA_NODEFILTER_Properties)) {
if (bIsClassName) {
if (child->GetClassHashCode() == dNameHash) {
- pSiblings->Add(child);
+ pSiblings->push_back(child);
nCount++;
}
} else {
@@ -152,7 +131,7 @@ int32_t CXFA_NodeHelper::NodeAcc_TraverseSiblings(CXFA_Node* parent,
if (child->GetElementType() != XFA_Element::PageSet &&
child->GetElementType() != XFA_Element::Extras &&
child->GetElementType() != XFA_Element::Items) {
- pSiblings->Add(child);
+ pSiblings->push_back(child);
nCount++;
}
}
@@ -163,36 +142,27 @@ int32_t CXFA_NodeHelper::NodeAcc_TraverseSiblings(CXFA_Node* parent,
eLogicType, bIsClassName, false);
}
}
- if (nCount > 0) {
+ if (nCount > 0)
return nCount;
- }
}
- CXFA_NodeArray children;
- parent->GetNodeList(children, XFA_NODEFILTER_Children);
- int32_t nChildren = children.GetSize();
- for (i = 0; i < nChildren; i++) {
- CXFA_Node* child = children[i];
- if (child->GetElementType() == XFA_Element::Variables) {
+ for (CXFA_Node* child : parent->GetNodeList(XFA_NODEFILTER_Children)) {
+ if (child->GetElementType() == XFA_Element::Variables)
continue;
- }
+
if (bIsClassName) {
if (child->GetClassHashCode() == dNameHash) {
- if (pSiblings) {
- pSiblings->Add(child);
- }
+ pSiblings->push_back(child);
nCount++;
}
} else {
if (child->GetNameHash() == dNameHash) {
- if (pSiblings) {
- pSiblings->Add(child);
- }
+ pSiblings->push_back(child);
nCount++;
}
}
- if (eLogicType == XFA_LOGIC_NoTransparent) {
+ if (eLogicType == XFA_LOGIC_NoTransparent)
continue;
- }
+
if (NodeIsTransparent(child) &&
child->GetElementType() != XFA_Element::PageSet) {
nCount += NodeAcc_TraverseSiblings(child, dNameHash, pSiblings,
@@ -245,7 +215,7 @@ int32_t CXFA_NodeHelper::GetIndex(CXFA_Node* pNode,
if (bIsClassIndex) {
dwHashName = pNode->GetClassHashCode();
}
- CXFA_NodeArray siblings;
+ std::vector<CXFA_Node*> siblings;
int32_t iSize = NodeAcc_TraverseSiblings(parent, dwHashName, &siblings,
eLogicType, bIsClassIndex);
for (int32_t i = 0; i < iSize; ++i) {
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.h b/xfa/fxfa/parser/cxfa_nodehelper.h
index 1db8321690..7da6c5dece 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.h
+++ b/xfa/fxfa/parser/cxfa_nodehelper.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXFA_PARSER_CXFA_NODEHELPER_H_
#define XFA_FXFA_PARSER_CXFA_NODEHELPER_H_
+#include <vector>
+
#include "xfa/fxfa/parser/xfa_object.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
@@ -31,17 +33,17 @@ class CXFA_NodeHelper {
int32_t NodeAcc_TraverseSiblings(CXFA_Node* parent,
uint32_t dNameHash,
- CXFA_NodeArray* pSiblings,
+ std::vector<CXFA_Node*>* pSiblings,
XFA_LOGIC_TYPE eLogicType,
bool bIsClassName = false,
bool bIsFindProperty = true);
int32_t NodeAcc_TraverseAnySiblings(CXFA_Node* parent,
uint32_t dNameHash,
- CXFA_NodeArray* pSiblings,
+ std::vector<CXFA_Node*>* pSiblings,
bool bIsClassName = false);
int32_t CountSiblings(CXFA_Node* pNode,
XFA_LOGIC_TYPE eLogicType,
- CXFA_NodeArray* pSiblings,
+ std::vector<CXFA_Node*>* pSiblings,
bool bIsClassName = false);
int32_t GetIndex(CXFA_Node* pNode,
XFA_LOGIC_TYPE eLogicType = XFA_LOGIC_NoTransparent,
diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
index 94fd761bdf..a00b4a6254 100644
--- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
@@ -6,7 +6,13 @@
#include "xfa/fxfa/parser/cxfa_resolveprocessor.h"
+#include <algorithm>
+#include <utility>
+#include <vector>
+
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_nodehelper.h"
#include "xfa/fxfa/parser/cxfa_scriptcontext.h"
@@ -21,12 +27,12 @@ CXFA_ResolveProcessor::CXFA_ResolveProcessor()
CXFA_ResolveProcessor::~CXFA_ResolveProcessor() {}
int32_t CXFA_ResolveProcessor::Resolve(CXFA_ResolveNodesData& rnd) {
- if (!rnd.m_CurNode) {
+ if (!rnd.m_CurObject)
return -1;
- }
- if (!rnd.m_CurNode->IsNode()) {
+
+ if (!rnd.m_CurObject->IsNode()) {
if (rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) {
- return ResolveForAttributeRs(rnd.m_CurNode, rnd,
+ return ResolveForAttributeRs(rnd.m_CurObject, rnd,
rnd.m_wsName.AsStringC());
}
return 0;
@@ -51,62 +57,66 @@ int32_t CXFA_ResolveProcessor::Resolve(CXFA_ResolveNodesData& rnd) {
break;
}
if (rnd.m_uHashName == XFA_HASHCODE_This && rnd.m_nLevel == 0) {
- rnd.m_Nodes.Add(rnd.m_pSC->GetThisObject());
+ rnd.m_Objects.push_back(rnd.m_pSC->GetThisObject());
return 1;
- } else if (rnd.m_CurNode->GetElementType() == XFA_Element::Xfa) {
+ }
+ if (rnd.m_CurObject->GetElementType() == XFA_Element::Xfa) {
CXFA_Object* pObjNode =
rnd.m_pSC->GetDocument()->GetXFAObject(rnd.m_uHashName);
if (pObjNode) {
- rnd.m_Nodes.Add(pObjNode);
+ rnd.m_Objects.push_back(pObjNode);
} else if (rnd.m_uHashName == XFA_HASHCODE_Xfa) {
- rnd.m_Nodes.Add(rnd.m_CurNode);
+ rnd.m_Objects.push_back(rnd.m_CurObject);
} else if ((rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) &&
- ResolveForAttributeRs(rnd.m_CurNode, rnd,
+ ResolveForAttributeRs(rnd.m_CurObject, rnd,
rnd.m_wsName.AsStringC())) {
return 1;
}
- if (rnd.m_Nodes.GetSize() > 0) {
+ if (!rnd.m_Objects.empty())
FilterCondition(rnd, rnd.m_wsCondition);
- }
- return rnd.m_Nodes.GetSize();
- }
- int32_t nRet = ResolveNormal(rnd);
- if (nRet < 1 && rnd.m_uHashName == XFA_HASHCODE_Xfa) {
- rnd.m_Nodes.Add(rnd.m_pSC->GetDocument()->GetRoot());
+
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
- return rnd.m_Nodes.GetSize();
+ if (ResolveNormal(rnd) < 1 && rnd.m_uHashName == XFA_HASHCODE_Xfa)
+ rnd.m_Objects.push_back(rnd.m_pSC->GetDocument()->GetRoot());
+
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
+
int32_t CXFA_ResolveProcessor::ResolveAnyChild(CXFA_ResolveNodesData& rnd) {
CFX_WideString wsName = rnd.m_wsName;
CFX_WideString wsCondition = rnd.m_wsCondition;
CXFA_Node* findNode = nullptr;
- CXFA_NodeArray siblings;
bool bClassName = false;
if (wsName.GetAt(0) == '#') {
bClassName = true;
wsName = wsName.Right(wsName.GetLength() - 1);
}
findNode = m_pNodeHelper->ResolveNodes_GetOneChild(
- ToNode(rnd.m_CurNode), wsName.c_str(), bClassName);
+ ToNode(rnd.m_CurObject), wsName.c_str(), bClassName);
if (!findNode) {
return 0;
}
if (wsCondition.IsEmpty()) {
- rnd.m_Nodes.Add(findNode);
- return rnd.m_Nodes.GetSize();
- }
- m_pNodeHelper->CountSiblings(findNode, XFA_LOGIC_Transparent,
- (CXFA_NodeArray*)&rnd.m_Nodes, bClassName);
+ rnd.m_Objects.push_back(findNode);
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
+ }
+ std::vector<CXFA_Node*> tempNodes;
+ for (CXFA_Object* pObject : rnd.m_Objects)
+ tempNodes.push_back(pObject->AsNode());
+ m_pNodeHelper->CountSiblings(findNode, XFA_LOGIC_Transparent, &tempNodes,
+ bClassName);
+ rnd.m_Objects = std::vector<CXFA_Object*>(tempNodes.begin(), tempNodes.end());
FilterCondition(rnd, wsCondition);
- return rnd.m_Nodes.GetSize();
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
+
int32_t CXFA_ResolveProcessor::ResolveDollar(CXFA_ResolveNodesData& rnd) {
- CXFA_ObjArray& nodes = rnd.m_Nodes;
CFX_WideString wsName = rnd.m_wsName;
CFX_WideString wsCondition = rnd.m_wsCondition;
int32_t iNameLen = wsName.GetLength();
if (iNameLen == 1) {
- nodes.Add(rnd.m_CurNode);
+ rnd.m_Objects.push_back(rnd.m_CurObject);
return 1;
}
if (rnd.m_nLevel > 0) {
@@ -115,30 +125,30 @@ int32_t CXFA_ResolveProcessor::ResolveDollar(CXFA_ResolveNodesData& rnd) {
XFA_HashCode dwNameHash = static_cast<XFA_HashCode>(FX_HashCode_GetW(
CFX_WideStringC(wsName.c_str() + 1, iNameLen - 1), false));
if (dwNameHash == XFA_HASHCODE_Xfa) {
- nodes.Add(rnd.m_pSC->GetDocument()->GetRoot());
+ rnd.m_Objects.push_back(rnd.m_pSC->GetDocument()->GetRoot());
} else {
CXFA_Object* pObjNode = rnd.m_pSC->GetDocument()->GetXFAObject(dwNameHash);
- if (pObjNode) {
- rnd.m_Nodes.Add(pObjNode);
- }
+ if (pObjNode)
+ rnd.m_Objects.push_back(pObjNode);
}
- if (rnd.m_Nodes.GetSize() > 0) {
+ if (!rnd.m_Objects.empty())
FilterCondition(rnd, wsCondition);
- }
- return rnd.m_Nodes.GetSize();
+
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
+
int32_t CXFA_ResolveProcessor::ResolveExcalmatory(CXFA_ResolveNodesData& rnd) {
- if (rnd.m_nLevel > 0) {
+ if (rnd.m_nLevel > 0)
return 0;
- }
+
CXFA_Node* datasets =
ToNode(rnd.m_pSC->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets));
- if (!datasets) {
+ if (!datasets)
return 0;
- }
+
CXFA_ResolveNodesData rndFind;
rndFind.m_pSC = rnd.m_pSC;
- rndFind.m_CurNode = datasets;
+ rndFind.m_CurObject = datasets;
rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1);
rndFind.m_uHashName = static_cast<XFA_HashCode>(
FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false));
@@ -146,19 +156,18 @@ int32_t CXFA_ResolveProcessor::ResolveExcalmatory(CXFA_ResolveNodesData& rnd) {
rndFind.m_dwStyles = XFA_RESOLVENODE_Children;
rndFind.m_wsCondition = rnd.m_wsCondition;
Resolve(rndFind);
- if (rndFind.m_Nodes.GetSize() > 0) {
- rnd.m_Nodes.Append(rndFind.m_Nodes);
- rndFind.m_Nodes.RemoveAll();
- }
- return rnd.m_Nodes.GetSize();
+ rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
+ rndFind.m_Objects.end());
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
+
int32_t CXFA_ResolveProcessor::ResolveNumberSign(CXFA_ResolveNodesData& rnd) {
CFX_WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1);
CFX_WideString wsCondition = rnd.m_wsCondition;
- CXFA_Node* curNode = ToNode(rnd.m_CurNode);
- if (ResolveForAttributeRs(curNode, rnd, wsName.AsStringC())) {
+ CXFA_Node* curNode = ToNode(rnd.m_CurObject);
+ if (ResolveForAttributeRs(curNode, rnd, wsName.AsStringC()))
return 1;
- }
+
CXFA_ResolveNodesData rndFind;
rndFind.m_pSC = rnd.m_pSC;
rndFind.m_nLevel = rnd.m_nLevel + 1;
@@ -169,42 +178,42 @@ int32_t CXFA_ResolveProcessor::ResolveNumberSign(CXFA_ResolveNodesData& rnd) {
rndFind.m_uHashName = static_cast<XFA_HashCode>(
FX_HashCode_GetW(rndFind.m_wsName.AsStringC(), false));
rndFind.m_wsCondition = wsCondition;
- rndFind.m_CurNode = curNode;
+ rndFind.m_CurObject = curNode;
ResolveNormal(rndFind);
- if (rndFind.m_Nodes.GetSize() > 0) {
- if (wsCondition.GetLength() == 0 && rndFind.m_Nodes.Find(curNode) >= 0) {
- rnd.m_Nodes.Add(curNode);
- } else {
- rnd.m_Nodes.Append(rndFind.m_Nodes);
- rndFind.m_Nodes.RemoveAll();
- }
+ if (rndFind.m_Objects.empty())
+ return 0;
+
+ if (wsCondition.GetLength() == 0 &&
+ pdfium::ContainsValue(rndFind.m_Objects, curNode)) {
+ rnd.m_Objects.push_back(curNode);
+ } else {
+ rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
+ rndFind.m_Objects.end());
}
- return rnd.m_Nodes.GetSize();
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
+
int32_t CXFA_ResolveProcessor::ResolveForAttributeRs(
CXFA_Object* curNode,
CXFA_ResolveNodesData& rnd,
const CFX_WideStringC& strAttr) {
const XFA_SCRIPTATTRIBUTEINFO* lpScriptAttribute =
XFA_GetScriptAttributeByName(curNode->GetElementType(), strAttr);
- if (lpScriptAttribute) {
- rnd.m_pScriptAttribute = lpScriptAttribute;
- rnd.m_Nodes.Add(curNode);
- rnd.m_dwFlag = XFA_RESOVENODE_RSTYPE_Attribute;
- return 1;
- }
- return 0;
+ if (!lpScriptAttribute)
+ return 0;
+
+ rnd.m_pScriptAttribute = lpScriptAttribute;
+ rnd.m_Objects.push_back(curNode);
+ rnd.m_dwFlag = XFA_RESOVENODE_RSTYPE_Attribute;
+ return 1;
}
+
int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
- if (rnd.m_nLevel > 32) {
+ if (rnd.m_nLevel > 32 || !rnd.m_CurObject->IsNode())
return 0;
- }
- if (!rnd.m_CurNode->IsNode()) {
- return 0;
- }
- CXFA_Node* curNode = ToNode(rnd.m_CurNode);
- CXFA_ObjArray& nodes = rnd.m_Nodes;
- int32_t nNum = nodes.GetSize();
+
+ CXFA_Node* curNode = rnd.m_CurObject->AsNode();
+ size_t nNum = rnd.m_Objects.size();
uint32_t dwStyles = rnd.m_dwStyles;
CFX_WideString& wsName = rnd.m_wsName;
XFA_HashCode uNameHash = rnd.m_uHashName;
@@ -215,69 +224,59 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
rndFind.m_pSC = rnd.m_pSC;
rndFind.m_nLevel = rnd.m_nLevel + 1;
rndFind.m_uHashName = uNameHash;
- CXFA_NodeArray children;
- CXFA_NodeArray properties;
+ std::vector<CXFA_Node*> children;
+ std::vector<CXFA_Node*> properties;
CXFA_Node* pVariablesNode = nullptr;
CXFA_Node* pPageSetNode = nullptr;
- CXFA_Node* pChild = curNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- while (pChild) {
+ for (CXFA_Node* pChild = curNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pChild->GetElementType() == XFA_Element::Variables) {
pVariablesNode = pChild;
- pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
continue;
- } else if (pChild->GetElementType() == XFA_Element::PageSet) {
+ }
+ if (pChild->GetElementType() == XFA_Element::PageSet) {
pPageSetNode = pChild;
- pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
continue;
- } else {
- const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement(
- curNode->GetElementType(), pChild->GetElementType(),
- XFA_XDPPACKET_UNKNOWN);
- if (pPropert) {
- properties.Add(pChild);
- } else {
- children.Add(pChild);
- }
}
- pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
+ const XFA_PROPERTY* pProperty = XFA_GetPropertyOfElement(
+ curNode->GetElementType(), pChild->GetElementType(),
+ XFA_XDPPACKET_UNKNOWN);
+ if (pProperty)
+ properties.push_back(pChild);
+ else
+ children.push_back(pChild);
}
if ((dwStyles & XFA_RESOLVENODE_Properties) && pVariablesNode) {
uint32_t uPropHash = pVariablesNode->GetClassHashCode();
if (uPropHash == uNameHash) {
- nodes.Add(pVariablesNode);
+ rnd.m_Objects.push_back(pVariablesNode);
} else {
- rndFind.m_CurNode = pVariablesNode;
+ rndFind.m_CurObject = pVariablesNode;
SetStylesForChild(dwStyles, rndFind);
CFX_WideString wsSaveCondition = rndFind.m_wsCondition;
rndFind.m_wsCondition.clear();
ResolveNormal(rndFind);
rndFind.m_wsCondition = wsSaveCondition;
- if (rndFind.m_Nodes.GetSize() > 0) {
- nodes.Append(rndFind.m_Nodes);
- rndFind.m_Nodes.RemoveAll();
- }
+ rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
+ rndFind.m_Objects.end());
+ rndFind.m_Objects.clear();
}
- if (nodes.GetSize() > nNum) {
+ if (rnd.m_Objects.size() > nNum) {
FilterCondition(rnd, wsCondition);
- if (nodes.GetSize() > 0) {
- return 1;
- }
- return 0;
+ return !rnd.m_Objects.empty() ? 1 : 0;
}
}
if (dwStyles & XFA_RESOLVENODE_Children) {
bool bSetFlag = false;
- if (pPageSetNode && (dwStyles & XFA_RESOLVENODE_Properties)) {
- children.Add(pPageSetNode);
- }
- for (int32_t i = 0; i < children.GetSize(); i++) {
- CXFA_Node* child = children[i];
+ if (pPageSetNode && (dwStyles & XFA_RESOLVENODE_Properties))
+ children.push_back(pPageSetNode);
+
+ for (CXFA_Node* child : children) {
if (dwStyles & XFA_RESOLVENODE_TagName) {
- if (child->GetClassHashCode() == uNameHash) {
- nodes.Add(child);
- }
+ if (child->GetClassHashCode() == uNameHash)
+ rnd.m_Objects.push_back(child);
} else if (child->GetNameHash() == uNameHash) {
- nodes.Add(child);
+ rnd.m_Objects.push_back(child);
}
if (m_pNodeHelper->NodeIsTransparent(child) &&
child->GetElementType() != XFA_Element::PageSet) {
@@ -285,64 +284,55 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
SetStylesForChild(dwStyles, rndFind);
bSetFlag = true;
}
- rndFind.m_CurNode = child;
+ rndFind.m_CurObject = child;
CFX_WideString wsSaveCondition = rndFind.m_wsCondition;
rndFind.m_wsCondition.clear();
ResolveNormal(rndFind);
rndFind.m_wsCondition = wsSaveCondition;
- if (rndFind.m_Nodes.GetSize() > 0) {
- nodes.Append(rndFind.m_Nodes);
- rndFind.m_Nodes.RemoveAll();
- }
+ rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
+ rndFind.m_Objects.end());
+ rndFind.m_Objects.clear();
}
}
- if (nodes.GetSize() > nNum) {
+ if (rnd.m_Objects.size() > nNum) {
if (!(dwStyles & XFA_RESOLVENODE_ALL)) {
- CXFA_NodeArray upArrayNodes;
+ std::vector<CXFA_Node*> upArrayNodes;
if (m_pNodeHelper->NodeIsTransparent(ToNode(curNode))) {
- m_pNodeHelper->CountSiblings(ToNode(nodes[0]), XFA_LOGIC_Transparent,
- &upArrayNodes,
+ m_pNodeHelper->CountSiblings(ToNode(rnd.m_Objects[0]),
+ XFA_LOGIC_Transparent, &upArrayNodes,
!!(dwStyles & XFA_RESOLVENODE_TagName));
}
- if (upArrayNodes.GetSize() > nodes.GetSize()) {
- upArrayNodes[0] = ToNode(nodes[0]);
- nodes.RemoveAll();
- nodes.Append((CXFA_ObjArray&)upArrayNodes);
- upArrayNodes.RemoveAll();
+ if (upArrayNodes.size() > rnd.m_Objects.size()) {
+ CXFA_Object* pSaveObject = rnd.m_Objects.front();
+ rnd.m_Objects = std::vector<CXFA_Object*>(upArrayNodes.begin(),
+ upArrayNodes.end());
+ rnd.m_Objects.front() = pSaveObject;
}
}
FilterCondition(rnd, wsCondition);
- if (nodes.GetSize() > 0) {
- return 1;
- }
- return 0;
+ return !rnd.m_Objects.empty() ? 1 : 0;
}
}
if (dwStyles & XFA_RESOLVENODE_Attributes) {
- if (ResolveForAttributeRs(curNode, rnd, wsName.AsStringC())) {
+ if (ResolveForAttributeRs(curNode, rnd, wsName.AsStringC()))
return 1;
- }
}
if (dwStyles & XFA_RESOLVENODE_Properties) {
- for (int32_t i = 0; i < properties.GetSize(); i++) {
- CXFA_Node* childProperty = properties[i];
- if (childProperty->IsUnnamed()) {
- uint32_t uPropHash = childProperty->GetClassHashCode();
- if (uPropHash == uNameHash) {
- nodes.Add(childProperty);
- }
- } else if (childProperty->GetNameHash() == uNameHash &&
- childProperty->GetElementType() != XFA_Element::Extras &&
- childProperty->GetElementType() != XFA_Element::Items) {
- nodes.Add(childProperty);
+ for (CXFA_Node* pChildProperty : properties) {
+ if (pChildProperty->IsUnnamed()) {
+ if (pChildProperty->GetClassHashCode() == uNameHash)
+ rnd.m_Objects.push_back(pChildProperty);
+ continue;
+ }
+ if (pChildProperty->GetNameHash() == uNameHash &&
+ pChildProperty->GetElementType() != XFA_Element::Extras &&
+ pChildProperty->GetElementType() != XFA_Element::Items) {
+ rnd.m_Objects.push_back(pChildProperty);
}
}
- if (nodes.GetSize() > nNum) {
+ if (rnd.m_Objects.size() > nNum) {
FilterCondition(rnd, wsCondition);
- if (nodes.GetSize() > 0) {
- return 1;
- }
- return 0;
+ return !rnd.m_Objects.empty() ? 1 : 0;
}
CXFA_Node* pProp = nullptr;
if (XFA_Element::Subform == curNode->GetElementType() &&
@@ -360,8 +350,8 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
}
}
if (pProp) {
- nodes.Add(pProp);
- return nodes.GetSize();
+ rnd.m_Objects.push_back(pProp);
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
}
CXFA_Node* parentNode = m_pNodeHelper->ResolveNodes_GetParent(
@@ -369,11 +359,10 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
uint32_t uCurClassHash = curNode->GetClassHashCode();
if (!parentNode) {
if (uCurClassHash == uNameHash) {
- nodes.Add(curNode->AsNode());
+ rnd.m_Objects.push_back(curNode->AsNode());
FilterCondition(rnd, wsCondition);
- if (nodes.GetSize() > 0) {
+ if (!rnd.m_Objects.empty())
return 1;
- }
}
return 0;
}
@@ -381,25 +370,23 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
CXFA_Node* child = parentNode->GetNodeItem(XFA_NODEITEM_FirstChild);
uint32_t dwSubStyles =
XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties;
- if (dwStyles & XFA_RESOLVENODE_TagName) {
+ if (dwStyles & XFA_RESOLVENODE_TagName)
dwSubStyles |= XFA_RESOLVENODE_TagName;
- }
- if (dwStyles & XFA_RESOLVENODE_ALL) {
+ if (dwStyles & XFA_RESOLVENODE_ALL)
dwSubStyles |= XFA_RESOLVENODE_ALL;
- }
rndFind.m_dwStyles = dwSubStyles;
while (child) {
if (child == curNode) {
if (dwStyles & XFA_RESOLVENODE_TagName) {
if (uCurClassHash == uNameHash) {
- nodes.Add(curNode);
+ rnd.m_Objects.push_back(curNode);
}
} else {
if (child->GetNameHash() == uNameHash) {
- nodes.Add(curNode);
+ rnd.m_Objects.push_back(curNode);
if (rnd.m_nLevel == 0 && wsCondition.GetLength() == 0) {
- nodes.RemoveAll();
- nodes.Add(curNode);
+ rnd.m_Objects.clear();
+ rnd.m_Objects.push_back(curNode);
return 1;
}
}
@@ -408,11 +395,10 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
continue;
}
if (dwStyles & XFA_RESOLVENODE_TagName) {
- if (child->GetClassHashCode() == uNameHash) {
- nodes.Add(child);
- }
+ if (child->GetClassHashCode() == uNameHash)
+ rnd.m_Objects.push_back(child);
} else if (child->GetNameHash() == uNameHash) {
- nodes.Add(child);
+ rnd.m_Objects.push_back(child);
}
const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement(
parentNode->GetElementType(), child->GetElementType(),
@@ -429,7 +415,7 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
}
}
if (bInnerSearch) {
- rndFind.m_CurNode = child;
+ rndFind.m_CurObject = child;
CFX_WideString wsOriginCondition = rndFind.m_wsCondition;
rndFind.m_wsCondition.clear();
uint32_t dwOriginStyle = rndFind.m_dwStyles;
@@ -437,31 +423,27 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
ResolveNormal(rndFind);
rndFind.m_dwStyles = dwOriginStyle;
rndFind.m_wsCondition = wsOriginCondition;
- if (rndFind.m_Nodes.GetSize() > 0) {
- nodes.Append(rndFind.m_Nodes);
- rndFind.m_Nodes.RemoveAll();
- }
+ rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
+ rndFind.m_Objects.end());
+ rndFind.m_Objects.clear();
}
child = child->GetNodeItem(XFA_NODEITEM_NextSibling);
}
- if (nodes.GetSize() > nNum) {
+ if (rnd.m_Objects.size() > nNum) {
if (m_pNodeHelper->NodeIsTransparent(parentNode)) {
- CXFA_NodeArray upArrayNodes;
- m_pNodeHelper->CountSiblings(ToNode(nodes[0]), XFA_LOGIC_Transparent,
- &upArrayNodes,
+ std::vector<CXFA_Node*> upArrayNodes;
+ m_pNodeHelper->CountSiblings(ToNode(rnd.m_Objects.front()),
+ XFA_LOGIC_Transparent, &upArrayNodes,
!!(dwStyles & XFA_RESOLVENODE_TagName));
- if (upArrayNodes.GetSize() > nodes.GetSize()) {
- upArrayNodes[0] = ToNode(nodes[0]);
- nodes.RemoveAll();
- nodes.Append((CXFA_ObjArray&)upArrayNodes);
- upArrayNodes.RemoveAll();
+ if (upArrayNodes.size() > rnd.m_Objects.size()) {
+ CXFA_Object* pSaveObject = rnd.m_Objects.front();
+ rnd.m_Objects = std::vector<CXFA_Object*>(upArrayNodes.begin(),
+ upArrayNodes.end());
+ rnd.m_Objects.front() = pSaveObject;
}
}
FilterCondition(rnd, wsCondition);
- if (nodes.GetSize() > 0) {
- return 1;
- }
- return 0;
+ return !rnd.m_Objects.empty() ? 1 : 0;
}
}
if (dwStyles & XFA_RESOLVENODE_Parent) {
@@ -474,29 +456,26 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
dwSubStyles |= XFA_RESOLVENODE_ALL;
}
rndFind.m_dwStyles = dwSubStyles;
- rndFind.m_CurNode = parentNode;
- CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray();
- array.Add(parentNode);
+ rndFind.m_CurObject = parentNode;
+ rnd.m_pSC->GetUpObjectArray()->push_back(parentNode);
ResolveNormal(rndFind);
- if (rndFind.m_Nodes.GetSize() > 0) {
- nodes.Append(rndFind.m_Nodes);
- rndFind.m_Nodes.RemoveAll();
- }
- if (nodes.GetSize() > nNum) {
+ rnd.m_Objects.insert(rnd.m_Objects.end(), rndFind.m_Objects.begin(),
+ rndFind.m_Objects.end());
+ rndFind.m_Objects.clear();
+ if (rnd.m_Objects.size() > nNum)
return 1;
- }
}
return 0;
}
+
int32_t CXFA_ResolveProcessor::ResolveAsterisk(CXFA_ResolveNodesData& rnd) {
- CXFA_Node* curNode = ToNode(rnd.m_CurNode);
- CXFA_ObjArray& nodes = rnd.m_Nodes;
- CXFA_NodeArray array;
- curNode->GetNodeList(array,
- XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties);
- nodes.Append((CXFA_ObjArray&)array);
- return nodes.GetSize();
+ CXFA_Node* curNode = ToNode(rnd.m_CurObject);
+ std::vector<CXFA_Node*> array =
+ curNode->GetNodeList(XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties);
+ rnd.m_Objects.insert(rnd.m_Objects.end(), array.begin(), array.end());
+ return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
+
int32_t CXFA_ResolveProcessor::ResolvePopStack(
CFX_ArrayTemplate<int32_t>& stack) {
int32_t nType = -1;
@@ -611,7 +590,6 @@ void CXFA_ResolveProcessor::ConditionArray(int32_t iCurIndex,
CFX_WideString wsCondition,
int32_t iFoundCount,
CXFA_ResolveNodesData& rnd) {
- CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes;
int32_t iLen = wsCondition.GetLength();
bool bRelative = false;
bool bAll = false;
@@ -634,15 +612,15 @@ void CXFA_ResolveProcessor::ConditionArray(int32_t iCurIndex,
if (bAll) {
if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) {
if (rnd.m_dwStyles & XFA_RESOLVENODE_Bind) {
- m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode);
+ m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurObject);
m_pNodeHelper->m_iCreateCount = 1;
- findNodes.RemoveAll();
+ rnd.m_Objects.clear();
m_pNodeHelper->m_iCurAllStart = -1;
m_pNodeHelper->m_pAllStartParent = nullptr;
} else {
if (m_pNodeHelper->m_iCurAllStart == -1) {
m_pNodeHelper->m_iCurAllStart = m_iCurStart;
- m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurNode);
+ m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurObject);
}
}
} else if (rnd.m_dwStyles & XFA_RESOLVENODE_BindNew) {
@@ -663,22 +641,22 @@ void CXFA_ResolveProcessor::ConditionArray(int32_t iCurIndex,
}
if (iFoundCount <= iIndex || iIndex < 0) {
if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) {
- m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode);
+ m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurObject);
m_pNodeHelper->m_iCreateCount = iIndex - iFoundCount + 1;
}
- findNodes.RemoveAll();
+ rnd.m_Objects.clear();
} else {
- CXFA_Node* ret = findNodes[iIndex];
- findNodes.RemoveAll();
- findNodes.Add(ret);
+ CXFA_Object* ret = rnd.m_Objects[iIndex];
+ rnd.m_Objects.clear();
+ rnd.m_Objects.push_back(ret);
}
}
+
void CXFA_ResolveProcessor::DoPredicateFilter(int32_t iCurIndex,
CFX_WideString wsCondition,
int32_t iFoundCount,
CXFA_ResolveNodesData& rnd) {
- CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes;
- ASSERT(iFoundCount == findNodes.GetSize());
+ ASSERT(iFoundCount == pdfium::CollectionSize<int32_t>(rnd.m_Objects));
CFX_WideString wsExpression;
XFA_SCRIPTLANGTYPE eLangType = XFA_SCRIPTLANGTYPE_Unkown;
if (wsCondition.Left(2) == L".[" && wsCondition.Right(1) == L"]") {
@@ -692,25 +670,20 @@ void CXFA_ResolveProcessor::DoPredicateFilter(int32_t iCurIndex,
CXFA_ScriptContext* pContext = rnd.m_pSC;
wsExpression = wsCondition.Mid(2, wsCondition.GetLength() - 3);
for (int32_t i = iFoundCount - 1; i >= 0; i--) {
- CXFA_Object* node = findNodes[i];
- bool bRet = false;
- std::unique_ptr<CFXJSE_Value> pRetValue(
- new CFXJSE_Value(rnd.m_pSC->GetRuntime()));
- bRet = pContext->RunScript(eLangType, wsExpression.AsStringC(),
- pRetValue.get(), node);
+ auto pRetValue = pdfium::MakeUnique<CFXJSE_Value>(rnd.m_pSC->GetRuntime());
+ bool bRet = pContext->RunScript(eLangType, wsExpression.AsStringC(),
+ pRetValue.get(), rnd.m_Objects[i]);
if (!bRet || !pRetValue->ToBoolean())
- findNodes.RemoveAt(i);
+ rnd.m_Objects.erase(rnd.m_Objects.begin() + i);
}
}
void CXFA_ResolveProcessor::FilterCondition(CXFA_ResolveNodesData& rnd,
CFX_WideString wsCondition) {
- CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes;
int32_t iCurrIndex = 0;
- const CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray();
- int32_t iSize = array.GetSize();
- if (iSize) {
- CXFA_Node* curNode = array[iSize - 1];
+ const std::vector<CXFA_Node*>* pArray = rnd.m_pSC->GetUpObjectArray();
+ if (!pArray->empty()) {
+ CXFA_Node* curNode = pArray->back();
bool bIsProperty = m_pNodeHelper->NodeIsProperty(curNode);
if (curNode->IsUnnamed() ||
(bIsProperty && curNode->GetElementType() != XFA_Element::PageSet)) {
@@ -721,7 +694,7 @@ void CXFA_ResolveProcessor::FilterCondition(CXFA_ResolveNodesData& rnd,
bIsProperty, false);
}
}
- int32_t iFoundCount = findNodes.GetSize();
+ int32_t iFoundCount = pdfium::CollectionSize<int32_t>(rnd.m_Objects);
wsCondition.TrimLeft();
wsCondition.TrimRight();
int32_t iLen = wsCondition.GetLength();
@@ -734,15 +707,15 @@ void CXFA_ResolveProcessor::FilterCondition(CXFA_ResolveNodesData& rnd,
}
if (iFoundCount <= iCurrIndex) {
if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) {
- m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode);
+ m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurObject);
m_pNodeHelper->m_iCreateCount = iCurrIndex - iFoundCount + 1;
}
- findNodes.RemoveAll();
+ rnd.m_Objects.clear();
return;
} else {
- CXFA_Node* ret = findNodes[iCurrIndex];
- findNodes.RemoveAll();
- findNodes.Add(ret);
+ CXFA_Object* ret = rnd.m_Objects[iCurrIndex];
+ rnd.m_Objects.clear();
+ rnd.m_Objects.push_back(ret);
return;
}
}
@@ -775,22 +748,23 @@ void CXFA_ResolveProcessor::SetStylesForChild(uint32_t dwParentStyles,
dwSubStyles |= XFA_RESOLVENODE_ALL;
rnd.m_dwStyles = dwSubStyles;
}
+
int32_t CXFA_ResolveProcessor::SetResultCreateNode(
XFA_RESOLVENODE_RS& resolveNodeRS,
CFX_WideString& wsLastCondition) {
- if (m_pNodeHelper->m_pCreateParent) {
- resolveNodeRS.nodes.Add(m_pNodeHelper->m_pCreateParent);
- } else {
+ if (m_pNodeHelper->m_pCreateParent)
+ resolveNodeRS.objects.push_back(m_pNodeHelper->m_pCreateParent);
+ else
m_pNodeHelper->CreateNode_ForCondition(wsLastCondition);
- }
+
resolveNodeRS.dwFlags = m_pNodeHelper->m_iCreateFlag;
if (resolveNodeRS.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) {
- if (m_pNodeHelper->m_iCurAllStart != -1) {
+ if (m_pNodeHelper->m_iCurAllStart != -1)
resolveNodeRS.dwFlags = XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll;
- }
}
- return resolveNodeRS.nodes.GetSize();
+ return pdfium::CollectionSize<int32_t>(resolveNodeRS.objects);
}
+
void CXFA_ResolveProcessor::SetIndexDataBind(CFX_WideString& wsNextCondition,
int32_t& iIndex,
int32_t iCount) {
@@ -807,16 +781,14 @@ void CXFA_ResolveProcessor::SetIndexDataBind(CFX_WideString& wsNextCondition,
CXFA_ResolveNodesData::CXFA_ResolveNodesData(CXFA_ScriptContext* pSC)
: m_pSC(pSC),
- m_CurNode(nullptr),
+ m_CurObject(nullptr),
m_wsName(),
m_uHashName(XFA_HASHCODE_None),
m_wsCondition(),
m_nLevel(0),
- m_Nodes(),
+ m_Objects(),
m_dwStyles(XFA_RESOLVENODE_Children),
m_pScriptAttribute(nullptr),
m_dwFlag(XFA_RESOVENODE_RSTYPE_Nodes) {}
-CXFA_ResolveNodesData::~CXFA_ResolveNodesData() {
- m_Nodes.RemoveAll();
-}
+CXFA_ResolveNodesData::~CXFA_ResolveNodesData() {}
diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.h b/xfa/fxfa/parser/cxfa_resolveprocessor.h
index d806d57b93..e9c2cce439 100644
--- a/xfa/fxfa/parser/cxfa_resolveprocessor.h
+++ b/xfa/fxfa/parser/cxfa_resolveprocessor.h
@@ -8,6 +8,7 @@
#define XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_
#include <memory>
+#include <vector>
#include "xfa/fxfa/parser/xfa_object.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
@@ -21,12 +22,12 @@ class CXFA_ResolveNodesData {
~CXFA_ResolveNodesData();
CXFA_ScriptContext* m_pSC;
- CXFA_Object* m_CurNode;
+ CXFA_Object* m_CurObject;
CFX_WideString m_wsName;
XFA_HashCode m_uHashName;
CFX_WideString m_wsCondition;
int32_t m_nLevel;
- CXFA_ObjArray m_Nodes;
+ std::vector<CXFA_Object*> m_Objects; // Not owned.
uint32_t m_dwStyles;
const XFA_SCRIPTATTRIBUTEINFO* m_pScriptAttribute;
XFA_RESOVENODE_RSTYPE m_dwFlag;
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
index 584cd76bed..03fd128332 100644
--- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp
+++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
@@ -13,6 +13,7 @@
#include "fxjs/cfxjse_class.h"
#include "fxjs/cfxjse_value.h"
#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -131,7 +132,6 @@ CXFA_ScriptContext::~CXFA_ScriptContext() {
delete pVariableContext;
}
m_mapVariableToContext.clear();
- m_upObjectArray.RemoveAll();
}
void CXFA_ScriptContext::Initialize(v8::Isolate* pIsolate) {
@@ -146,7 +146,7 @@ bool CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType,
CFXJSE_Value* hRetValue,
CXFA_Object* pThisObject) {
CFX_ByteString btScript;
- XFA_SCRIPTLANGTYPE eSaveType = m_eScriptType;
+ CFX_AutoRestorer<XFA_SCRIPTLANGTYPE> typeRestorer(&m_eScriptType);
m_eScriptType = eScriptType;
if (eScriptType == XFA_SCRIPTLANGTYPE_Formcalc) {
if (!m_FM2JSContext) {
@@ -165,14 +165,12 @@ bool CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType,
} else {
btScript = FX_UTF8Encode(wsScript);
}
- CXFA_Object* pOriginalObject = m_pThisObject;
+ CFX_AutoRestorer<CXFA_Object*> nodeRestorer(&m_pThisObject);
m_pThisObject = pThisObject;
CFXJSE_Value* pValue = pThisObject ? GetJSValueFromMap(pThisObject) : nullptr;
- bool bRet = m_JsContext->ExecuteScript(btScript.c_str(), hRetValue, pValue);
- m_pThisObject = pOriginalObject;
- m_eScriptType = eSaveType;
- return bRet;
+ return m_JsContext->ExecuteScript(btScript.c_str(), hRetValue, pValue);
}
+
void CXFA_ScriptContext::GlobalPropertySetter(CFXJSE_Value* pObject,
const CFX_ByteStringC& szPropName,
CFXJSE_Value* pValue) {
@@ -215,13 +213,13 @@ bool CXFA_ScriptContext::QueryNodeByFlag(CXFA_Node* refNode,
if (ResolveObjects(refNode, propname, resolveRs, dwFlag) <= 0)
return false;
if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
- pValue->Assign(GetJSValueFromMap(resolveRs.nodes[0]));
+ pValue->Assign(GetJSValueFromMap(resolveRs.objects.front()));
return true;
}
if (resolveRs.dwFlags == XFA_RESOVENODE_RSTYPE_Attribute) {
const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = resolveRs.pScriptAttribute;
if (lpAttributeInfo) {
- (resolveRs.nodes[0]->*(lpAttributeInfo->lpfnCallback))(
+ (resolveRs.objects.front()->*(lpAttributeInfo->lpfnCallback))(
pValue, bSetting, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute);
}
}
@@ -495,12 +493,9 @@ bool CXFA_ScriptContext::RunVariablesScript(CXFA_Node* pScriptNode) {
CXFA_Node* pThisObject = pParent->GetNodeItem(XFA_NODEITEM_Parent);
CFXJSE_Context* pVariablesContext =
CreateVariablesContext(pScriptNode, pThisObject);
- CXFA_Object* pOriginalObject = m_pThisObject;
+ CFX_AutoRestorer<CXFA_Object*> nodeRestorer(&m_pThisObject);
m_pThisObject = pThisObject;
- bool bRet =
- pVariablesContext->ExecuteScript(btScript.c_str(), hRetValue.get());
- m_pThisObject = pOriginalObject;
- return bRet;
+ return pVariablesContext->ExecuteScript(btScript.c_str(), hRetValue.get());
}
bool CXFA_ScriptContext::QueryVariableValue(CXFA_Node* pScriptNode,
@@ -556,38 +551,41 @@ void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const {
CFXJSE_Class* CXFA_ScriptContext::GetJseNormalClass() {
return m_pJsClass;
}
-int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
+
+int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refObject,
const CFX_WideStringC& wsExpression,
XFA_RESOLVENODE_RS& resolveNodeRS,
uint32_t dwStyles,
CXFA_Node* bindNode) {
- if (wsExpression.IsEmpty()) {
+ if (wsExpression.IsEmpty())
return 0;
- }
+
if (m_eScriptType != XFA_SCRIPTLANGTYPE_Formcalc ||
(dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) {
- m_upObjectArray.RemoveAll();
+ m_upObjectArray.clear();
}
- if (refNode && refNode->IsNode() &&
+ if (refObject && refObject->IsNode() &&
(dwStyles & (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings))) {
- m_upObjectArray.Add(refNode->AsNode());
+ m_upObjectArray.push_back(refObject->AsNode());
}
+
bool bNextCreate = false;
if (dwStyles & XFA_RESOLVENODE_CreateNode) {
m_ResolveProcessor->GetNodeHelper()->SetCreateNodeType(bindNode);
}
m_ResolveProcessor->GetNodeHelper()->m_pCreateParent = nullptr;
m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart = -1;
+
CXFA_ResolveNodesData rndFind;
int32_t nStart = 0;
int32_t nLevel = 0;
int32_t nRet = -1;
rndFind.m_pSC = this;
- CXFA_ObjArray findNodes;
- findNodes.Add(refNode ? refNode : m_pDocument->GetRoot());
+ std::vector<CXFA_Object*> findObjects;
+ findObjects.push_back(refObject ? refObject : m_pDocument->GetRoot());
int32_t nNodes = 0;
while (true) {
- nNodes = findNodes.GetSize();
+ nNodes = pdfium::CollectionSize<int32_t>(findObjects);
int32_t i = 0;
rndFind.m_dwStyles = dwStyles;
m_ResolveProcessor->SetCurStart(nStart);
@@ -597,21 +595,22 @@ int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
CXFA_Node* pDataNode = nullptr;
nStart = m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart;
if (nStart != -1) {
- pDataNode = m_pDocument->GetNotBindNode(findNodes);
+ pDataNode = m_pDocument->GetNotBindNode(findObjects);
if (pDataNode) {
- findNodes.RemoveAll();
- findNodes.Add(pDataNode);
+ findObjects.clear();
+ findObjects.push_back(pDataNode);
break;
}
} else {
- pDataNode = findNodes[0]->AsNode();
- findNodes.RemoveAll();
- findNodes.Add(pDataNode);
+ pDataNode = findObjects.front()->AsNode();
+ findObjects.clear();
+ findObjects.push_back(pDataNode);
break;
}
dwStyles |= XFA_RESOLVENODE_Bind;
- findNodes.RemoveAll();
- findNodes.Add(m_ResolveProcessor->GetNodeHelper()->m_pAllStartParent);
+ findObjects.clear();
+ findObjects.push_back(
+ m_ResolveProcessor->GetNodeHelper()->m_pAllStartParent);
continue;
} else {
break;
@@ -628,7 +627,7 @@ int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
break;
}
}
- CXFA_ObjArray retNodes;
+ std::vector<CXFA_Object*> retObjects;
while (i < nNodes) {
bool bDataBind = false;
if (((dwStyles & XFA_RESOLVENODE_Bind) ||
@@ -639,7 +638,7 @@ int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
m_ResolveProcessor->SetIndexDataBind(rndBind.m_wsCondition, i, nNodes);
bDataBind = true;
}
- rndFind.m_CurNode = findNodes[i++];
+ rndFind.m_CurObject = findObjects[i++];
rndFind.m_nLevel = nLevel;
rndFind.m_dwFlag = XFA_RESOVENODE_RSTYPE_Nodes;
nRet = m_ResolveProcessor->Resolve(rndFind);
@@ -649,29 +648,28 @@ int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute &&
rndFind.m_pScriptAttribute && nStart < wsExpression.GetLength()) {
std::unique_ptr<CFXJSE_Value> pValue(new CFXJSE_Value(m_pIsolate));
- (rndFind.m_Nodes[0]->*(rndFind.m_pScriptAttribute->lpfnCallback))(
+ (rndFind.m_Objects.front()
+ ->*(rndFind.m_pScriptAttribute->lpfnCallback))(
pValue.get(), false,
(XFA_ATTRIBUTE)rndFind.m_pScriptAttribute->eAttribute);
- rndFind.m_Nodes.SetAt(0, ToObject(pValue.get(), nullptr));
+ rndFind.m_Objects.front() = ToObject(pValue.get(), nullptr);
}
- int32_t iSize = m_upObjectArray.GetSize();
- if (iSize) {
- m_upObjectArray.RemoveAt(iSize - 1);
- }
- retNodes.Append(rndFind.m_Nodes);
- rndFind.m_Nodes.RemoveAll();
- if (bDataBind) {
+ if (!m_upObjectArray.empty())
+ m_upObjectArray.pop_back();
+ retObjects.insert(retObjects.end(), rndFind.m_Objects.begin(),
+ rndFind.m_Objects.end());
+ rndFind.m_Objects.clear();
+ if (bDataBind)
break;
- }
}
- findNodes.RemoveAll();
- nNodes = retNodes.GetSize();
+ findObjects.clear();
+ nNodes = pdfium::CollectionSize<int32_t>(retObjects);
if (nNodes < 1) {
if (dwStyles & XFA_RESOLVENODE_CreateNode) {
bNextCreate = true;
if (!m_ResolveProcessor->GetNodeHelper()->m_pCreateParent) {
m_ResolveProcessor->GetNodeHelper()->m_pCreateParent =
- ToNode(rndFind.m_CurNode);
+ ToNode(rndFind.m_CurObject);
m_ResolveProcessor->GetNodeHelper()->m_iCreateCount = 1;
}
bool bCreate =
@@ -687,8 +685,9 @@ int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
break;
}
}
- findNodes.Copy(retNodes);
- rndFind.m_Nodes.RemoveAll();
+ findObjects =
+ std::vector<CXFA_Object*>(retObjects.begin(), retObjects.end());
+ rndFind.m_Objects.clear();
if (nLevel == 0) {
dwStyles &= ~(XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings);
}
@@ -697,7 +696,8 @@ int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
if (!bNextCreate) {
resolveNodeRS.dwFlags = rndFind.m_dwFlag;
if (nNodes > 0) {
- resolveNodeRS.nodes.Append(findNodes);
+ resolveNodeRS.objects.insert(resolveNodeRS.objects.end(),
+ findObjects.begin(), findObjects.end());
}
if (rndFind.m_dwFlag == XFA_RESOVENODE_RSTYPE_Attribute) {
resolveNodeRS.pScriptAttribute = rndFind.m_pScriptAttribute;
@@ -711,7 +711,7 @@ int32_t CXFA_ScriptContext::ResolveObjects(CXFA_Object* refNode,
if (!bNextCreate && (dwStyles & XFA_RESOLVENODE_CreateNode)) {
resolveNodeRS.dwFlags = XFA_RESOVENODE_RSTYPE_ExistNodes;
}
- return resolveNodeRS.nodes.GetSize();
+ return pdfium::CollectionSize<int32_t>(resolveNodeRS.objects);
}
return nNodes;
}
@@ -752,18 +752,17 @@ void CXFA_ScriptContext::GetSomExpression(CXFA_Node* refNode,
lpNodeHelper->GetNameExpression(refNode, wsExpression, true,
XFA_LOGIC_Transparent);
}
-void CXFA_ScriptContext::SetNodesOfRunScript(CXFA_NodeArray* pArray) {
+void CXFA_ScriptContext::SetNodesOfRunScript(std::vector<CXFA_Node*>* pArray) {
m_pScriptNodeArray = pArray;
}
-void CXFA_ScriptContext::AddNodesOfRunScript(const CXFA_NodeArray& nodes) {
- if (!m_pScriptNodeArray)
- return;
- if (nodes.GetSize() > 0)
- m_pScriptNodeArray->Copy(nodes);
+
+void CXFA_ScriptContext::AddNodesOfRunScript(
+ const std::vector<CXFA_Node*>& nodes) {
+ if (m_pScriptNodeArray && !nodes.empty())
+ *m_pScriptNodeArray = nodes;
}
+
void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) {
- if (!m_pScriptNodeArray)
- return;
- if (m_pScriptNodeArray->Find(pNode) == -1)
- m_pScriptNodeArray->Add(pNode);
+ if (m_pScriptNodeArray && !pdfium::ContainsValue(*m_pScriptNodeArray, pNode))
+ m_pScriptNodeArray->push_back(pNode);
}
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.h b/xfa/fxfa/parser/cxfa_scriptcontext.h
index 6d4f73a632..3f81bb8ebe 100644
--- a/xfa/fxfa/parser/cxfa_scriptcontext.h
+++ b/xfa/fxfa/parser/cxfa_scriptcontext.h
@@ -32,9 +32,9 @@ class CXFA_ScriptContext {
bool RunScript(XFA_SCRIPTLANGTYPE eScriptType,
const CFX_WideStringC& wsScript,
CFXJSE_Value* pRetValue,
- CXFA_Object* pThisObject = nullptr);
+ CXFA_Object* pThisObject);
- int32_t ResolveObjects(CXFA_Object* refNode,
+ int32_t ResolveObjects(CXFA_Object* refObject,
const CFX_WideStringC& wsExpression,
XFA_RESOLVENODE_RS& resolveNodeRS,
uint32_t dwStyles = XFA_RESOLVENODE_Children,
@@ -48,8 +48,8 @@ class CXFA_ScriptContext {
int32_t GetIndexByClassName(CXFA_Node* refNode);
void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression);
- void SetNodesOfRunScript(CXFA_NodeArray* pArray);
- void AddNodesOfRunScript(const CXFA_NodeArray& nodes);
+ void SetNodesOfRunScript(std::vector<CXFA_Node*>* pArray);
+ void AddNodesOfRunScript(const std::vector<CXFA_Node*>& nodes);
void AddNodesOfRunScript(CXFA_Node* pNode);
CFXJSE_Class* GetJseNormalClass();
@@ -91,7 +91,7 @@ class CXFA_ScriptContext {
CXFA_Object* GetVariablesThis(CXFA_Object* pObject, bool bScriptNode = false);
bool IsStrictScopeInJavaScript();
XFA_SCRIPTLANGTYPE GetType();
- CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; }
+ std::vector<CXFA_Node*>* GetUpObjectArray() { return &m_upObjectArray; }
CXFA_Document* GetDocument() const { return m_pDocument; }
static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass);
@@ -111,10 +111,10 @@ class CXFA_ScriptContext {
std::map<CXFA_Object*, std::unique_ptr<CFXJSE_Value>> m_mapObjectToValue;
std::map<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext;
CXFA_EventParam m_eventParam;
- CXFA_NodeArray m_upObjectArray;
+ std::vector<CXFA_Node*> m_upObjectArray;
// CacheList holds the NodeList items so we can clean them up when we're done.
std::vector<std::unique_ptr<CXFA_NodeList>> m_CacheList;
- CXFA_NodeArray* m_pScriptNodeArray;
+ std::vector<CXFA_Node*>* m_pScriptNodeArray;
std::unique_ptr<CXFA_ResolveProcessor> m_ResolveProcessor;
std::unique_ptr<CXFA_FM2JSContext> m_FM2JSContext;
CXFA_Object* m_pThisObject;
diff --git a/xfa/fxfa/parser/cxfa_valuearray.cpp b/xfa/fxfa/parser/cxfa_valuearray.cpp
index 04afc40b0e..1170010139 100644
--- a/xfa/fxfa/parser/cxfa_valuearray.cpp
+++ b/xfa/fxfa/parser/cxfa_valuearray.cpp
@@ -16,7 +16,10 @@ CXFA_ValueArray::~CXFA_ValueArray() {
delete GetAt(i);
}
-void CXFA_ValueArray::GetAttributeObject(CXFA_ObjArray& objArray) {
+std::vector<CXFA_Object*> CXFA_ValueArray::GetAttributeObject() {
+ std::vector<CXFA_Object*> objArray;
for (int32_t i = 0; i < GetSize(); i++)
- objArray.Add(CXFA_ScriptContext::ToObject(GetAt(i), nullptr));
+ objArray.push_back(CXFA_ScriptContext::ToObject(GetAt(i), nullptr));
+
+ return objArray;
}
diff --git a/xfa/fxfa/parser/cxfa_valuearray.h b/xfa/fxfa/parser/cxfa_valuearray.h
index 2c4ea29779..48efae4774 100644
--- a/xfa/fxfa/parser/cxfa_valuearray.h
+++ b/xfa/fxfa/parser/cxfa_valuearray.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
#define XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
+#include <vector>
+
#include "fxjs/cfxjse_value.h"
#include "xfa/fxfa/fxfa.h"
@@ -15,7 +17,7 @@ class CXFA_ValueArray : public CFX_ArrayTemplate<CFXJSE_Value*> {
explicit CXFA_ValueArray(v8::Isolate* pIsolate);
~CXFA_ValueArray();
- void GetAttributeObject(CXFA_ObjArray& objArray);
+ std::vector<CXFA_Object*> GetAttributeObject();
v8::Isolate* const m_pIsolate;
};
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index cbdb7cfed4..b2673818d9 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -315,35 +315,32 @@ CXFA_Para CXFA_WidgetData::GetPara(bool bModified) {
return CXFA_Para(m_pNode->GetProperty(0, XFA_Element::Para, bModified));
}
-void CXFA_WidgetData::GetEventList(CXFA_NodeArray& events) {
- m_pNode->GetNodeList(events, 0, XFA_Element::Event);
-}
-
-int32_t CXFA_WidgetData::GetEventByActivity(int32_t iActivity,
- CXFA_NodeArray& events,
- bool bIsFormReady) {
- CXFA_NodeArray allEvents;
- GetEventList(allEvents);
- int32_t iCount = allEvents.GetSize();
- for (int32_t i = 0; i < iCount; i++) {
- CXFA_Event event(allEvents[i]);
+std::vector<CXFA_Node*> CXFA_WidgetData::GetEventList() {
+ return m_pNode->GetNodeList(0, XFA_Element::Event);
+}
+
+std::vector<CXFA_Node*> CXFA_WidgetData::GetEventByActivity(int32_t iActivity,
+ bool bIsFormReady) {
+ std::vector<CXFA_Node*> events;
+ for (CXFA_Node* pNode : GetEventList()) {
+ CXFA_Event event(pNode);
if (event.GetActivity() == iActivity) {
if (iActivity == XFA_ATTRIBUTEENUM_Ready) {
CFX_WideStringC wsRef;
event.GetRef(wsRef);
if (bIsFormReady) {
if (wsRef == CFX_WideStringC(L"$form"))
- events.Add(allEvents[i]);
+ events.push_back(pNode);
} else {
if (wsRef == CFX_WideStringC(L"$layout"))
- events.Add(allEvents[i]);
+ events.push_back(pNode);
}
} else {
- events.Add(allEvents[i]);
+ events.push_back(pNode);
}
}
}
- return events.GetSize();
+ return events;
}
CXFA_Value CXFA_WidgetData::GetDefaultValue(bool bModified) {
@@ -733,35 +730,32 @@ int32_t CXFA_WidgetData::GetChoiceListOpen() {
bool CXFA_WidgetData::IsListBox() {
int32_t iOpenMode = GetChoiceListOpen();
- return (iOpenMode == XFA_ATTRIBUTEENUM_Always ||
- iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect);
+ return iOpenMode == XFA_ATTRIBUTEENUM_Always ||
+ iOpenMode == XFA_ATTRIBUTEENUM_MultiSelect;
}
int32_t CXFA_WidgetData::CountChoiceListItems(bool bSaveValue) {
- CXFA_NodeArray pItems;
- CXFA_Node* pItem = nullptr;
+ std::vector<CXFA_Node*> pItems;
int32_t iCount = 0;
- CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ for (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
+ pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pNode->GetElementType() != XFA_Element::Items)
continue;
-
iCount++;
- pItems.Add(pNode);
+ pItems.push_back(pNode);
if (iCount == 2)
break;
}
if (iCount == 0)
return 0;
- pItem = pItems[0];
+ CXFA_Node* pItem = pItems[0];
if (iCount > 1) {
bool bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save);
bool bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save);
if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
pItem = pItems[1];
}
- pItems.RemoveAll();
return pItem->CountChildren(XFA_Element::Unknown);
}
@@ -769,16 +763,15 @@ bool CXFA_WidgetData::GetChoiceListItem(CFX_WideString& wsText,
int32_t nIndex,
bool bSaveValue) {
wsText.clear();
- CXFA_NodeArray pItemsArray;
+ std::vector<CXFA_Node*> pItemsArray;
CXFA_Node* pItems = nullptr;
int32_t iCount = 0;
CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pNode->GetElementType() != XFA_Element::Items)
continue;
-
iCount++;
- pItemsArray.Add(pNode);
+ pItemsArray.push_back(pNode);
if (iCount == 2)
break;
}
@@ -805,32 +798,29 @@ bool CXFA_WidgetData::GetChoiceListItem(CFX_WideString& wsText,
void CXFA_WidgetData::GetChoiceListItems(
std::vector<CFX_WideString>& wsTextArray,
bool bSaveValue) {
- CXFA_NodeArray pItems;
- CXFA_Node* pItem = nullptr;
+ std::vector<CXFA_Node*> pItems;
int32_t iCount = 0;
- CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ for (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
+ pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pNode->GetElementType() != XFA_Element::Items)
continue;
-
iCount++;
- pItems.Add(pNode);
+ pItems.push_back(pNode);
if (iCount == 2)
break;
}
if (iCount == 0)
return;
- pItem = pItems[0];
+ CXFA_Node* pItem = pItems[0];
if (iCount > 1) {
bool bItemOneHasSave = pItems[0]->GetBoolean(XFA_ATTRIBUTE_Save);
bool bItemTwoHasSave = pItems[1]->GetBoolean(XFA_ATTRIBUTE_Save);
if (bItemOneHasSave != bItemTwoHasSave && bSaveValue == bItemTwoHasSave)
pItem = pItems[1];
}
- pItems.RemoveAll();
- pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ for (CXFA_Node* pNode = pItem->GetNodeItem(XFA_NODEITEM_FirstChild); pNode;
+ pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
wsTextArray.emplace_back();
pNode->TryContent(wsTextArray.back());
}
@@ -1038,18 +1028,13 @@ void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
if (wsNewValue.IsEmpty())
wsNewValue = wsLabel;
- CXFA_NodeArray listitems;
- int32_t iCount = 0;
- CXFA_Node* pItemNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pItemNode;
- pItemNode = pItemNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
- if (pItemNode->GetElementType() != XFA_Element::Items)
- continue;
-
- listitems.Add(pItemNode);
- iCount++;
+ std::vector<CXFA_Node*> listitems;
+ for (CXFA_Node* pItem = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); pItem;
+ pItem = pItem->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ if (pItem->GetElementType() == XFA_Element::Items)
+ listitems.push_back(pItem);
}
- if (iCount < 1) {
+ if (listitems.empty()) {
CXFA_Node* pItems = m_pNode->CreateSamePacketNode(XFA_Element::Items);
m_pNode->InsertChild(-1, pItems);
InsertListTextItem(pItems, wsLabel, nIndex);
@@ -1057,7 +1042,7 @@ void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
m_pNode->InsertChild(-1, pSaveItems);
pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, true);
InsertListTextItem(pSaveItems, wsNewValue, nIndex);
- } else if (iCount > 1) {
+ } else if (listitems.size() > 1) {
for (int32_t i = 0; i < 2; i++) {
CXFA_Node* pNode = listitems[i];
bool bHasSave = pNode->GetBoolean(XFA_ATTRIBUTE_Save);
@@ -1074,7 +1059,6 @@ void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
m_pNode->InsertChild(-1, pSaveItems);
pSaveItems->SetBoolean(XFA_ATTRIBUTE_Save, true);
pSaveItems->SetEnum(XFA_ATTRIBUTE_Presence, XFA_ATTRIBUTEENUM_Hidden);
- listitems.RemoveAll();
CXFA_Node* pListNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
int32_t i = 0;
while (pListNode) {
@@ -1097,14 +1081,13 @@ void CXFA_WidgetData::InsertItem(const CFX_WideString& wsLabel,
void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue,
CFX_WideString& wsLabel) {
int32_t iCount = 0;
- CXFA_NodeArray listitems;
+ std::vector<CXFA_Node*> listitems;
CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pItems->GetElementType() != XFA_Element::Items)
continue;
-
iCount++;
- listitems.Add(pItems);
+ listitems.push_back(pItems);
}
if (iCount <= 1) {
wsLabel = wsValue;
@@ -1143,14 +1126,13 @@ void CXFA_WidgetData::GetItemLabel(const CFX_WideStringC& wsValue,
void CXFA_WidgetData::GetItemValue(const CFX_WideStringC& wsLabel,
CFX_WideString& wsValue) {
int32_t iCount = 0;
- CXFA_NodeArray listitems;
- CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
- for (; pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) {
+ std::vector<CXFA_Node*> listitems;
+ for (CXFA_Node* pItems = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
+ pItems; pItems = pItems->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pItems->GetElementType() != XFA_Element::Items)
continue;
-
iCount++;
- listitems.Add(pItems);
+ listitems.push_back(pItems);
}
if (iCount <= 1) {
wsValue = wsLabel;
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 1de04df088..a04726e105 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -53,10 +53,9 @@ class CXFA_WidgetData : public CXFA_Data {
CXFA_Font GetFont(bool bModified = false);
CXFA_Margin GetMargin(bool bModified = false);
CXFA_Para GetPara(bool bModified = false);
- void GetEventList(CXFA_NodeArray& events);
- int32_t GetEventByActivity(int32_t iActivity,
- CXFA_NodeArray& events,
- bool bIsFormReady = false);
+ std::vector<CXFA_Node*> GetEventList();
+ std::vector<CXFA_Node*> GetEventByActivity(int32_t iActivity,
+ bool bIsFormReady = false);
CXFA_Value GetDefaultValue(bool bModified = false);
CXFA_Value GetFormValue(bool bModified = false);
CXFA_Calculate GetCalculate(bool bModified = false);
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
index 03ab81e39f..227064a73b 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp
@@ -297,20 +297,19 @@ void CreateDataBinding(CXFA_Node* pFormNode,
}
case XFA_Element::ChoiceList:
if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
- CXFA_NodeArray items;
- pDataNode->GetNodeList(items);
- int32_t iCounts = items.GetSize();
- if (iCounts > 0) {
+ std::vector<CXFA_Node*> items = pDataNode->GetNodeList();
+ if (!items.empty()) {
+ bool single = items.size() == 1;
wsNormalizeValue.clear();
CFX_WideString wsItem;
- for (int32_t i = 0; i < iCounts; i++) {
- items[i]->TryContent(wsItem);
- wsItem = (iCounts == 1) ? wsItem : wsItem + L"\n";
+ for (CXFA_Node* pNode : items) {
+ pNode->TryContent(wsItem);
+ wsItem = single ? wsItem : wsItem + L"\n";
wsNormalizeValue += wsItem;
}
CXFA_ExData exData = defValue.GetExData();
ASSERT(exData);
- exData.SetContentType(iCounts == 1 ? L"text/plain" : L"text/xml");
+ exData.SetContentType(single ? L"text/plain" : L"text/xml");
}
FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue,
XFA_Element::ExData);
@@ -464,12 +463,12 @@ CXFA_Node* FindDataRefDataNode(CXFA_Document* pDocument,
pTemplateNode);
if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll ||
rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll ||
- rs.nodes.GetSize() > 1) {
- return pDocument->GetNotBindNode(rs.nodes);
+ rs.objects.size() > 1) {
+ return pDocument->GetNotBindNode(rs.objects);
}
if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) {
- CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : nullptr;
+ CXFA_Object* pObject = !rs.objects.empty() ? rs.objects[0] : nullptr;
CXFA_Node* pNode = ToNode(pObject);
return (bForceBind || !pNode || !pNode->HasBindItem()) ? pNode : nullptr;
}
@@ -492,7 +491,7 @@ bool NeedGenerateForm(CXFA_Node* pTemplateChild, bool bUseInstanceManager) {
CXFA_Node* CloneOrMergeInstanceManager(CXFA_Document* pDocument,
CXFA_Node* pFormParent,
CXFA_Node* pTemplateNode,
- CXFA_NodeArray& subforms) {
+ std::vector<CXFA_Node*>* subforms) {
CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
CFX_WideString wsInstMgrNodeName = L"_" + wsSubformName;
uint32_t dwInstNameHash =
@@ -518,7 +517,7 @@ CXFA_Node* CloneOrMergeInstanceManager(CXFA_Document* pDocument,
CXFA_Node* pNextNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling);
pFormParent->RemoveChild(pNode);
- subforms.Add(pNode);
+ subforms->push_back(pNode);
pNode = pNextNode;
}
pFormParent->RemoveChild(pExistingNode);
@@ -700,13 +699,13 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
bool bUseInstanceManager =
pFormParentNode->GetElementType() != XFA_Element::Area;
CXFA_Node* pInstMgrNode = nullptr;
- CXFA_NodeArray subformArray;
- CXFA_NodeArray* pSearchArray = nullptr;
+ std::vector<CXFA_Node*> subformArray;
+ std::vector<CXFA_Node*>* pSearchArray = nullptr;
if (!bOneInstance &&
(eType == XFA_Element::SubformSet || eType == XFA_Element::Subform)) {
pInstMgrNode = bUseInstanceManager ? CloneOrMergeInstanceManager(
pDocument, pFormParentNode,
- pTemplateNode, subformArray)
+ pTemplateNode, &subformArray)
: nullptr;
if (CXFA_Node* pOccurTemplateNode =
pTemplateNode->GetFirstChildByClass(XFA_Element::Occur)) {
@@ -724,10 +723,9 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
pSearchArray = &subformArray;
if (pFormParentNode->GetElementType() == XFA_Element::PageArea) {
bOneInstance = true;
- if (subformArray.GetSize() < 1)
+ if (subformArray.empty())
pSearchArray = nullptr;
- } else if ((pTemplateNode->GetNameHash() == 0) &&
- (subformArray.GetSize() < 1)) {
+ } else if (pTemplateNode->GetNameHash() == 0 && subformArray.empty()) {
pSearchArray = nullptr;
}
}
@@ -753,7 +751,7 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
sNodeIterator.MoveToNext();
} else {
std::map<CXFA_Node*, CXFA_Node*> subformMapArray;
- CXFA_NodeArray nodeArray;
+ std::vector<CXFA_Node*> nodeArray;
for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) {
bool bSelfMatch = false;
XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None;
@@ -772,11 +770,10 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
CreateDataBinding(pSubformNode, pDataNode, true);
ASSERT(pSubformNode);
subformMapArray[pSubformNode] = pDataNode;
- nodeArray.Add(pSubformNode);
+ nodeArray.push_back(pSubformNode);
}
- for (int32_t iIndex = 0; iIndex < nodeArray.GetSize(); iIndex++) {
- CXFA_Node* pSubform = nodeArray[iIndex];
+ for (CXFA_Node* pSubform : nodeArray) {
CXFA_Node* pDataNode = nullptr;
auto it = subformMapArray.find(pSubform);
if (it != subformMapArray.end())
@@ -904,14 +901,14 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
if (iCurRepeatIndex == 0 && bAccessedDataDOM == false) {
int32_t iLimit = iMax;
if (pInstMgrNode && pTemplateNode->GetNameHash() == 0) {
- iLimit = subformArray.GetSize();
+ iLimit = pdfium::CollectionSize<int32_t>(subformArray);
if (iLimit < iMin)
iLimit = iInit;
}
for (; (iLimit < 0 || iCurRepeatIndex < iLimit); iCurRepeatIndex++) {
if (pInstMgrNode) {
- if (pSearchArray && pSearchArray->GetSize() < 1) {
+ if (pSearchArray && pSearchArray->empty()) {
if (pTemplateNode->GetNameHash() != 0)
break;
pSearchArray = nullptr;
@@ -1157,8 +1154,7 @@ void UpdateBindingRelations(CXFA_Document* pDocument,
XFA_RESOLVENODE_RS rs;
pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs,
dFlags, pTemplateNode);
- CXFA_Object* pObject =
- (rs.nodes.GetSize() > 0) ? rs.nodes[0] : nullptr;
+ CXFA_Object* pObject = !rs.objects.empty() ? rs.objects[0] : nullptr;
pDataNode = ToNode(pObject);
if (pDataNode) {
CreateDataBinding(pFormNode, pDataNode,
@@ -1247,21 +1243,21 @@ CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument,
return nullptr;
}
-CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument,
- CXFA_Node* pFormParent,
- CXFA_Node* pTemplateNode,
- bool bRecursive,
- CXFA_NodeArray* pSubformArray) {
+CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(
+ CXFA_Document* pDocument,
+ CXFA_Node* pFormParent,
+ CXFA_Node* pTemplateNode,
+ bool bRecursive,
+ std::vector<CXFA_Node*>* pSubformArray) {
CXFA_Node* pExistingNode = nullptr;
if (!pSubformArray) {
pExistingNode = XFA_DataMerge_FindFormDOMInstance(
pDocument, pTemplateNode->GetElementType(),
pTemplateNode->GetNameHash(), pFormParent);
- } else if (pSubformArray->GetSize() > 0) {
- pExistingNode = pSubformArray->GetAt(0);
- pSubformArray->RemoveAt(0);
+ } else if (!pSubformArray->empty()) {
+ pExistingNode = pSubformArray->front();
+ pSubformArray->erase(pSubformArray->begin());
}
-
if (pExistingNode) {
if (pSubformArray) {
pFormParent->InsertChild(pExistingNode);
@@ -1354,9 +1350,10 @@ void CXFA_Document::DataMerge_UpdateBindingRelations(
UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, true, false);
}
-CXFA_Node* CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes) {
- for (int32_t i = 0; i < arrayNodes.GetSize(); i++) {
- CXFA_Node* pNode = arrayNodes[i]->AsNode();
+CXFA_Node* CXFA_Document::GetNotBindNode(
+ const std::vector<CXFA_Object*>& arrayObjects) {
+ for (CXFA_Object* pObject : arrayObjects) {
+ CXFA_Node* pNode = pObject->AsNode();
if (pNode && !pNode->HasBindItem())
return pNode;
}
@@ -1482,7 +1479,7 @@ void CXFA_Document::DoDataMerge() {
CXFA_Node* pPageSetNode =
pSubformSetNode->GetFirstChildByClass(XFA_Element::PageSet);
while (pPageSetNode) {
- m_pPendingPageSet.Add(pPageSetNode);
+ m_pPendingPageSet.push_back(pPageSetNode);
CXFA_Node* pNextPageSetNode =
pPageSetNode->GetNextSameClassSibling(XFA_Element::PageSet);
pSubformSetNode->RemoveChild(pPageSetNode);
diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.h b/xfa/fxfa/parser/xfa_document_datamerger_imp.h
index f9ea087731..2337502a4f 100644
--- a/xfa/fxfa/parser/xfa_document_datamerger_imp.h
+++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.h
@@ -7,13 +7,16 @@
#ifndef XFA_FXFA_PARSER_XFA_DOCUMENT_DATAMERGER_IMP_H_
#define XFA_FXFA_PARSER_XFA_DOCUMENT_DATAMERGER_IMP_H_
+#include <vector>
+
#include "xfa/fxfa/parser/xfa_object.h"
-CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument,
- CXFA_Node* pFormParent,
- CXFA_Node* pTemplateNode,
- bool bRecursive,
- CXFA_NodeArray* pSubformArray);
+CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(
+ CXFA_Document* pDocument,
+ CXFA_Node* pFormParent,
+ CXFA_Node* pTemplateNode,
+ bool bRecursive,
+ std::vector<CXFA_Node*>* pSubformArray);
CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode);
CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument,
XFA_Element eType,
diff --git a/xfa/fxfa/parser/xfa_object.h b/xfa/fxfa/parser/xfa_object.h
index 2300cc2209..91b88631ed 100644
--- a/xfa/fxfa/parser/xfa_object.h
+++ b/xfa/fxfa/parser/xfa_object.h
@@ -8,6 +8,7 @@
#define XFA_FXFA_PARSER_XFA_OBJECT_H_
#include <map>
+#include <vector>
#include "core/fxcrt/fx_basic.h"
#include "fxjs/cfxjse_arguments.h"
@@ -107,7 +108,6 @@ class CXFA_Object : public CFXJSE_HostObject {
const uint32_t m_elementNameHash;
const CFX_WideStringC m_elementName;
};
-using CXFA_ObjArray = CFX_ArrayTemplate<CXFA_Object*>;
#define XFA_NODEFILTER_Children 0x01
#define XFA_NODEFILTER_Properties 0x02
@@ -125,8 +125,6 @@ enum XFA_SOM_MESSAGETYPE {
XFA_SOM_MandatoryMessage
};
-using CXFA_NodeArray = CFX_ArrayTemplate<CXFA_Node*>;
-
typedef void (*PD_CALLBACK_FREEDATA)(void* pData);
typedef void (*PD_CALLBACK_DUPLICATEDATA)(void*& pData);
@@ -302,11 +300,10 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node* Clone(bool bRecursive);
CXFA_Node* GetNodeItem(XFA_NODEITEM eItem) const;
CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_ObjectType eType) const;
- int32_t GetNodeList(CXFA_NodeArray& nodes,
- uint32_t dwTypeFilter = XFA_NODEFILTER_Children |
- XFA_NODEFILTER_Properties,
- XFA_Element eTypeFilter = XFA_Element::Unknown,
- int32_t iLevel = 1);
+ std::vector<CXFA_Node*> GetNodeList(
+ uint32_t dwTypeFilter = XFA_NODEFILTER_Children |
+ XFA_NODEFILTER_Properties,
+ XFA_Element eTypeFilter = XFA_Element::Unknown);
CXFA_Node* CreateSamePacketNode(XFA_Element eType,
uint32_t dwFlags = XFA_NodeFlag_Initialized);
CXFA_Node* CloneTemplateToForm(bool bRecursive);
@@ -315,7 +312,7 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node* GetDataDescriptionNode();
void SetDataDescriptionNode(CXFA_Node* pDataDescriptionNode);
CXFA_Node* GetBindData();
- int32_t GetBindItems(CXFA_NodeArray& formItems);
+ std::vector<CXFA_Node*> GetBindItems();
int32_t AddBindItem(CXFA_Node* pFormNode);
int32_t RemoveBindItem(CXFA_Node* pFormNode);
bool HasBindItem();
@@ -738,10 +735,10 @@ class CXFA_ArrayNodeList : public CXFA_NodeList {
bool Remove(CXFA_Node* pNode) override;
CXFA_Node* Item(int32_t iIndex) override;
- void SetArrayNodeList(const CXFA_NodeArray& srcArray);
+ void SetArrayNodeList(const std::vector<CXFA_Node*>& srcArray);
protected:
- CXFA_NodeArray m_array;
+ std::vector<CXFA_Node*> m_array;
};
class CXFA_AttachNodeList : public CXFA_NodeList {
diff --git a/xfa/fxfa/parser/xfa_resolvenode_rs.h b/xfa/fxfa/parser/xfa_resolvenode_rs.h
index 7ad218efe8..a60ef9a3c6 100644
--- a/xfa/fxfa/parser/xfa_resolvenode_rs.h
+++ b/xfa/fxfa/parser/xfa_resolvenode_rs.h
@@ -8,8 +8,10 @@
#define XFA_FXFA_PARSER_XFA_RESOLVENODE_RS_H_
#include <memory>
+#include <vector>
#include "fxjs/cfxjse_value.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_valuearray.h"
@@ -45,10 +47,9 @@ struct XFA_RESOLVENODE_RS {
int32_t GetAttributeResult(CXFA_ValueArray& valueArray) const {
if (pScriptAttribute && pScriptAttribute->eValueType == XFA_SCRIPT_Object) {
- v8::Isolate* pIsolate = valueArray.m_pIsolate;
- for (int32_t i = 0; i < nodes.GetSize(); i++) {
- std::unique_ptr<CFXJSE_Value> pValue(new CFXJSE_Value(pIsolate));
- (nodes[i]->*(pScriptAttribute->lpfnCallback))(
+ for (CXFA_Object* pObject : objects) {
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(valueArray.m_pIsolate);
+ (pObject->*(pScriptAttribute->lpfnCallback))(
pValue.get(), false, (XFA_ATTRIBUTE)pScriptAttribute->eAttribute);
valueArray.Add(pValue.release());
}
@@ -56,7 +57,7 @@ struct XFA_RESOLVENODE_RS {
return valueArray.GetSize();
}
- CXFA_ObjArray nodes;
+ std::vector<CXFA_Object*> objects; // Not owned.
XFA_RESOVENODE_RSTYPE dwFlags;
const XFA_SCRIPTATTRIBUTEINFO* pScriptAttribute;
};
@@ -64,7 +65,6 @@ struct XFA_RESOLVENODE_RS {
inline XFA_RESOLVENODE_RS::XFA_RESOLVENODE_RS()
: dwFlags(XFA_RESOVENODE_RSTYPE_Nodes), pScriptAttribute(nullptr) {}
-inline XFA_RESOLVENODE_RS::~XFA_RESOLVENODE_RS() {
- nodes.RemoveAll();
-}
+inline XFA_RESOLVENODE_RS::~XFA_RESOLVENODE_RS() {}
+
#endif // XFA_FXFA_PARSER_XFA_RESOLVENODE_RS_H_