summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app/xfa_ffwidgetacc.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/app/xfa_ffwidgetacc.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/app/xfa_ffwidgetacc.cpp')
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp52
1 files changed, 21 insertions, 31 deletions
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index 52c11508aa..4afd5e8023 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -303,25 +303,22 @@ IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() {
}
int32_t CXFA_WidgetAcc::ProcessEvent(int32_t iActivity,
CXFA_EventParam* pEventParam) {
- if (GetElementType() == XFA_Element::Draw) {
+ if (GetElementType() == XFA_Element::Draw)
return XFA_EVENTERROR_NotExist;
- }
+
+ std::vector<CXFA_Node*> eventArray =
+ GetEventByActivity(iActivity, pEventParam->m_bIsFormReady);
+ bool first = true;
int32_t iRet = XFA_EVENTERROR_NotExist;
- CXFA_NodeArray eventArray;
- int32_t iCounts =
- GetEventByActivity(iActivity, eventArray, pEventParam->m_bIsFormReady);
- for (int32_t i = 0; i < iCounts; i++) {
- CXFA_Event event(eventArray[i]);
- int32_t result = ProcessEvent(event, pEventParam);
- if (i == 0) {
- iRet = result;
- } else if (result == XFA_EVENTERROR_Success) {
+ for (CXFA_Node* pNode : eventArray) {
+ int32_t result = ProcessEvent(CXFA_Event(pNode), pEventParam);
+ if (first || result == XFA_EVENTERROR_Success)
iRet = result;
- }
+ first = false;
}
return iRet;
}
-int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event& event,
+int32_t CXFA_WidgetAcc::ProcessEvent(const CXFA_Event& event,
CXFA_EventParam* pEventParam) {
if (!event)
return XFA_EVENTERROR_NotExist;
@@ -329,16 +326,13 @@ int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event& event,
switch (event.GetEventType()) {
case XFA_Element::Execute:
break;
- case XFA_Element::Script: {
- CXFA_Script script = event.GetScript();
- return ExecuteScript(script, pEventParam);
- } break;
+ case XFA_Element::Script:
+ return ExecuteScript(event.GetScript(), pEventParam);
case XFA_Element::SignData:
break;
- case XFA_Element::Submit: {
- CXFA_Submit submit = event.GetSubmit();
- return GetDoc()->GetDocEnvironment()->SubmitData(GetDoc(), submit);
- }
+ case XFA_Element::Submit:
+ return GetDoc()->GetDocEnvironment()->SubmitData(GetDoc(),
+ event.GetSubmit());
default:
break;
}
@@ -631,7 +625,7 @@ int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
CXFA_ScriptContext* pContext = pDoc->GetXFADoc()->GetScriptContext();
pContext->SetEventParam(*pEventParam);
pContext->SetRunAtType((XFA_ATTRIBUTEENUM)script.GetRunAt());
- CXFA_NodeArray refNodes;
+ std::vector<CXFA_Node*> refNodes;
if (pEventParam->m_eType == XFA_EVENT_InitCalculate ||
pEventParam->m_eType == XFA_EVENT_Calculate) {
pContext->SetNodesOfRunScript(&refNodes);
@@ -663,16 +657,12 @@ int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script script,
m_pDocView->AddValidateWidget(this);
}
}
- int32_t iRefs = refNodes.GetSize();
- for (int32_t r = 0; r < iRefs; r++) {
- CXFA_WidgetAcc* pRefAcc =
- static_cast<CXFA_WidgetAcc*>(refNodes[r]->GetWidgetData());
- if (pRefAcc && pRefAcc == this) {
+ for (CXFA_Node* pRefNode : refNodes) {
+ if (static_cast<CXFA_WidgetAcc*>(pRefNode->GetWidgetData()) == this)
continue;
- }
- CXFA_Node* pRefNode = refNodes[r];
- CXFA_CalcData* pGlobalData =
- (CXFA_CalcData*)pRefNode->GetUserData(XFA_CalcData);
+
+ auto* pGlobalData =
+ static_cast<CXFA_CalcData*>(pRefNode->GetUserData(XFA_CalcData));
if (!pGlobalData) {
pGlobalData = new CXFA_CalcData;
pRefNode->SetUserData(XFA_CalcData, pGlobalData,