summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app
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
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')
-rw-r--r--xfa/fxfa/app/xfa_ffdocview.cpp20
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp52
-rw-r--r--xfa/fxfa/app/xfa_ffwidgethandler.cpp21
3 files changed, 36 insertions, 57 deletions
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp
index 545afcad00..1447d09140 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -514,10 +514,9 @@ CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
return nullptr;
}
if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
- CXFA_Node* pNode = resoveNodeRS.nodes[0]->AsNode();
- if (pNode) {
- return (CXFA_WidgetAcc*)pNode->GetWidgetData();
- }
+ CXFA_Node* pNode = resoveNodeRS.objects.front()->AsNode();
+ if (pNode)
+ return static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData());
}
return nullptr;
}
@@ -722,6 +721,7 @@ bool CXFA_FFDocView::RunEventLayoutReady() {
RunLayout();
return true;
}
+
void CXFA_FFDocView::RunBindItems() {
for (auto* item : m_BindItems) {
if (item->HasRemovedChildren())
@@ -743,9 +743,8 @@ void CXFA_FFDocView::RunBindItems() {
XFA_RESOLVENODE_ALL;
XFA_RESOLVENODE_RS rs;
pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle);
- int32_t iCount = rs.nodes.GetSize();
pAcc->DeleteItem(-1);
- if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || iCount < 1)
+ if (rs.dwFlags != XFA_RESOVENODE_RSTYPE_Nodes || rs.objects.empty())
continue;
CFX_WideStringC wsValueRef, wsLabelRef;
@@ -757,12 +756,10 @@ void CXFA_FFDocView::RunBindItems() {
CFX_WideString wsValue;
CFX_WideString wsLabel;
uint32_t uValueHash = FX_HashCode_GetW(wsValueRef, false);
- for (int32_t j = 0; j < iCount; j++) {
- CXFA_Object* refObj = rs.nodes[j];
- if (!refObj->IsNode()) {
+ for (CXFA_Object* refObject : rs.objects) {
+ CXFA_Node* refNode = refObject->AsNode();
+ if (!refNode)
continue;
- }
- CXFA_Node* refNode = refObj->AsNode();
if (bValueUseContent) {
wsValue = refNode->GetContent();
} else {
@@ -785,6 +782,7 @@ void CXFA_FFDocView::RunBindItems() {
}
m_BindItems.clear();
}
+
void CXFA_FFDocView::SetChangeMark() {
if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) {
return;
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,
diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp
index dc3850c778..8ecc4565e1 100644
--- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp
@@ -164,34 +164,25 @@ void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget,
bool CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc,
XFA_EVENTTYPE eEventType) {
- if (!pWidgetAcc || eEventType == XFA_EVENT_Unknown)
+ if (eEventType == XFA_EVENT_Unknown)
return false;
- if (pWidgetAcc->GetElementType() == XFA_Element::Draw)
+
+ if (!pWidgetAcc || pWidgetAcc->GetElementType() == XFA_Element::Draw)
return false;
switch (eEventType) {
case XFA_EVENT_Calculate: {
CXFA_Calculate calc = pWidgetAcc->GetCalculate();
- if (!calc)
- return false;
- if (calc.GetScript())
- return true;
- return false;
+ return calc && calc.GetScript();
}
case XFA_EVENT_Validate: {
CXFA_Validate val = pWidgetAcc->GetValidate();
- if (!val)
- return false;
- if (val.GetScript())
- return true;
- return false;
+ return val && val.GetScript();
}
default:
break;
}
- CXFA_NodeArray eventArray;
- return pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType],
- eventArray) > 0;
+ return !pWidgetAcc->GetEventByActivity(gs_EventActivity[eEventType]).empty();
}
int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc,