summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-14 12:13:22 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-14 19:59:49 +0000
commitf8a943908a414836271a1b7d7e4a97635d941b7f (patch)
tree7f900d57e21c72a67a0347e4f25d0784bdad7c83 /xfa/fxfa/parser/cscript_layoutpseudomodel.cpp
parent05df075154a832fcb476e1dfcfb865722d0ea898 (diff)
downloadpdfium-f8a943908a414836271a1b7d7e4a97635d941b7f.tar.xz
Replace CXFA_{Object,Node}Array with std::vector
These two ought to happen at the same time as they are intertwined in spots. Remove blatant casts between the two along the way. Change-Id: I9ce5d2faadf1e38aba7cade316560d24a66d8669 Reviewed-on: https://pdfium-review.googlesource.com/2933 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cscript_layoutpseudomodel.cpp')
-rw-r--r--xfa/fxfa/parser/cscript_layoutpseudomodel.cpp82
1 files changed, 40 insertions, 42 deletions
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);
}