summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfsave.cpp20
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp54
-rw-r--r--xfa/fxfa/include/xfa_ffdocview.h2
3 files changed, 29 insertions, 47 deletions
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index d48bfbb3b1..84de668dde 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -232,17 +232,13 @@ bool SendPostSaveToXFADoc(CPDFXFA_Document* pDocument) {
return false;
CXFA_FFWidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler();
- CXFA_WidgetAcc* pWidgetAcc = NULL;
- CXFA_WidgetAccIterator* pWidgetAccIterator =
- pXFADocView->CreateWidgetAccIterator();
- pWidgetAcc = pWidgetAccIterator->MoveToNext();
- while (pWidgetAcc) {
+ std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
+ pXFADocView->CreateWidgetAccIterator());
+ while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) {
CXFA_EventParam preParam;
preParam.m_eType = XFA_EVENT_PostSave;
pWidgetHander->ProcessEvent(pWidgetAcc, &preParam);
- pWidgetAcc = pWidgetAccIterator->MoveToNext();
}
- pWidgetAccIterator->Release();
pXFADocView->UpdateDocView();
pDocument->_ClearChangeMark();
return true;
@@ -259,17 +255,13 @@ bool SendPreSaveToXFADoc(CPDFXFA_Document* pDocument,
return true;
CXFA_FFWidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler();
- CXFA_WidgetAcc* pWidgetAcc = NULL;
- CXFA_WidgetAccIterator* pWidgetAccIterator =
- pXFADocView->CreateWidgetAccIterator();
- pWidgetAcc = pWidgetAccIterator->MoveToNext();
- while (pWidgetAcc) {
+ std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
+ pXFADocView->CreateWidgetAccIterator());
+ while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) {
CXFA_EventParam preParam;
preParam.m_eType = XFA_EVENT_PreSave;
pWidgetHander->ProcessEvent(pWidgetAcc, &preParam);
- pWidgetAcc = pWidgetAccIterator->MoveToNext();
}
- pWidgetAccIterator->Release();
pXFADocView->UpdateDocView();
return SaveXFADocumentData(pDocument, fileList);
}
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index 7a9d074624..29d3d5fc0a 100644
--- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
+++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
@@ -346,11 +346,7 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget,
return FALSE;
CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc();
- int nRotate = 0;
-#ifdef PDF_ENABLE_XFA
- nRotate = pWidgetAcc->GetRotate();
-#endif
-
+ int nRotate = pWidgetAcc->GetRotate();
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
if (!pEnv)
return FALSE;
@@ -358,7 +354,6 @@ FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget,
pEnv->FFI_GetPageViewRect(pPage, pageViewRect);
CFX_FloatRect rcAnchor;
-
rcAnchor.left = rtAnchor.left;
rcAnchor.top = rtAnchor.bottom();
rcAnchor.right = rtAnchor.right();
@@ -845,27 +840,26 @@ FX_BOOL CPDFXFA_Document::_NotifySubmit(FX_BOOL bPrevOrPost) {
}
FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() {
-#ifdef PDF_ENABLE_XFA
if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
return TRUE;
- if (m_pXFADocView == NULL)
+
+ if (!m_pXFADocView)
return TRUE;
+
CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
- if (pWidgetHandler == NULL)
+ if (!pWidgetHandler)
return TRUE;
- CXFA_WidgetAccIterator* pWidgetAccIterator =
- m_pXFADocView->CreateWidgetAccIterator();
+
+ std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
+ m_pXFADocView->CreateWidgetAccIterator());
if (pWidgetAccIterator) {
CXFA_EventParam Param;
Param.m_eType = XFA_EVENT_PreSubmit;
- CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
- while (pWidgetAcc) {
+ while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext())
pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
- pWidgetAcc = pWidgetAccIterator->MoveToNext();
- }
- pWidgetAccIterator->Release();
}
- pWidgetAccIterator = m_pXFADocView->CreateWidgetAccIterator();
+
+ pWidgetAccIterator.reset(m_pXFADocView->CreateWidgetAccIterator());
if (pWidgetAccIterator) {
CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
pWidgetAcc = pWidgetAccIterator->MoveToNext();
@@ -873,7 +867,7 @@ FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() {
int fRet = pWidgetAcc->ProcessValidate(-1);
if (fRet == XFA_EVENTERROR_Error) {
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
- if (pEnv == NULL)
+ if (!pEnv)
return FALSE;
CFX_WideString ws;
ws.FromLocal(IDS_XFA_Validate_Input);
@@ -883,38 +877,38 @@ FX_BOOL CPDFXFA_Document::_OnBeforeNotifySumbit() {
(FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)),
(FPDF_WIDESTRING)L"", 0, 1);
bs.ReleaseBuffer(len * sizeof(unsigned short));
- pWidgetAccIterator->Release();
return FALSE;
}
pWidgetAcc = pWidgetAccIterator->MoveToNext();
}
- pWidgetAccIterator->Release();
m_pXFADocView->UpdateDocView();
}
-#endif
return TRUE;
}
+
void CPDFXFA_Document::_OnAfterNotifySumbit() {
if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA)
return;
- if (m_pXFADocView == NULL)
+
+ if (!m_pXFADocView)
return;
+
CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler();
- if (pWidgetHandler == NULL)
+ if (!pWidgetHandler)
return;
- CXFA_WidgetAccIterator* pWidgetAccIterator =
- m_pXFADocView->CreateWidgetAccIterator();
- if (pWidgetAccIterator == NULL)
+
+ std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
+ m_pXFADocView->CreateWidgetAccIterator());
+ if (!pWidgetAccIterator)
return;
+
CXFA_EventParam Param;
Param.m_eType = XFA_EVENT_PostSubmit;
-
CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext();
while (pWidgetAcc) {
pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
pWidgetAcc = pWidgetAccIterator->MoveToNext();
}
- pWidgetAccIterator->Release();
m_pXFADocView->UpdateDocView();
}
@@ -1137,7 +1131,6 @@ FX_BOOL CPDFXFA_Document::_MailToInfo(CFX_WideString& csURL,
}
FX_BOOL CPDFXFA_Document::_SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) {
-#ifdef PDF_ENABLE_XFA
CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
if (!pEnv)
return FALSE;
@@ -1232,9 +1225,6 @@ FX_BOOL CPDFXFA_Document::_SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) {
bs.ReleaseBuffer(len * sizeof(unsigned short));
}
return bRet;
-#else
- return TRUE;
-#endif
}
FX_BOOL CPDFXFA_Document::SetGlobalProperty(CXFA_FFDoc* hDoc,
diff --git a/xfa/fxfa/include/xfa_ffdocview.h b/xfa/fxfa/include/xfa_ffdocview.h
index 473b820def..0210d2a4ff 100644
--- a/xfa/fxfa/include/xfa_ffdocview.h
+++ b/xfa/fxfa/include/xfa_ffdocview.h
@@ -145,12 +145,12 @@ class CXFA_FFDocWidgetIterator : public IXFA_WidgetIterator {
CXFA_FFDocView* m_pDocView;
CXFA_FFWidget* m_pCurWidget;
};
+
class CXFA_WidgetAccIterator {
public:
CXFA_WidgetAccIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot);
~CXFA_WidgetAccIterator();
- void Release() { delete this; }
void Reset();
CXFA_WidgetAcc* MoveToFirst();
CXFA_WidgetAcc* MoveToLast();