summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdfsave.cpp8
-rw-r--r--fpdfsdk/fpdfview.cpp18
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp11
-rw-r--r--xfa/fxfa/cxfa_ffapp.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp8
-rw-r--r--xfa/fxfa/cxfa_ffdocview.h3
-rw-r--r--xfa/fxfa/cxfa_ffpageview.cpp8
-rw-r--r--xfa/fxfa/cxfa_ffpageview.h14
-rw-r--r--xfa/fxfa/cxfa_rendercontext.cpp4
-rw-r--r--xfa/fxfa/fxfa.h4
10 files changed, 38 insertions, 42 deletions
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 8e92579518..638c22be26 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -240,8 +240,8 @@ bool SendPostSaveToXFADoc(CPDFXFA_Context* pContext) {
return false;
CXFA_FFWidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler();
- std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
- pXFADocView->CreateWidgetAccIterator());
+ std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator =
+ pXFADocView->CreateWidgetAccIterator();
while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) {
CXFA_EventParam preParam;
preParam.m_eType = XFA_EVENT_PostSave;
@@ -264,8 +264,8 @@ bool SendPreSaveToXFADoc(
return true;
CXFA_FFWidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler();
- std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
- pXFADocView->CreateWidgetAccIterator());
+ std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator =
+ pXFADocView->CreateWidgetAccIterator();
while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) {
CXFA_EventParam preParam;
preParam.m_eType = XFA_EVENT_PreSave;
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index c928ebe445..72ef75ce07 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -140,9 +140,8 @@ void RenderPageImpl(CPDF_PageRenderContext* pContext,
class CPDF_CustomAccess final : public IFX_SeekableReadStream {
public:
- static CFX_RetainPtr<CPDF_CustomAccess> Create(FPDF_FILEACCESS* pFileAccess) {
- return CFX_RetainPtr<CPDF_CustomAccess>(new CPDF_CustomAccess(pFileAccess));
- }
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
// IFX_SeekableReadStream
FX_FILESIZE GetSize() override;
@@ -180,9 +179,9 @@ bool CPDF_CustomAccess::ReadBlock(void* buffer,
#ifdef PDF_ENABLE_XFA
class CFPDF_FileStream : public IFX_SeekableStream {
public:
- static CFX_RetainPtr<CFPDF_FileStream> Create(FPDF_FILEHANDLER* pFS) {
- return CFX_RetainPtr<CFPDF_FileStream>(new CFPDF_FileStream(pFS));
- }
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
+
~CFPDF_FileStream() override;
// IFX_SeekableStream:
@@ -328,13 +327,13 @@ CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) {
CFX_RetainPtr<IFX_SeekableReadStream> MakeSeekableReadStream(
FPDF_FILEACCESS* pFileAccess) {
- return CPDF_CustomAccess::Create(pFileAccess);
+ return pdfium::MakeRetain<CPDF_CustomAccess>(pFileAccess);
}
#ifdef PDF_ENABLE_XFA
CFX_RetainPtr<IFX_SeekableStream> MakeSeekableStream(
FPDF_FILEHANDLER* pFilehandler) {
- return CFPDF_FileStream::Create(pFilehandler);
+ return pdfium::MakeRetain<CFPDF_FileStream>(pFilehandler);
}
#endif // PDF_ENABLE_XFA
@@ -594,8 +593,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
DLLEXPORT FPDF_DOCUMENT STDCALL
FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess,
FPDF_BYTESTRING password) {
- CFX_RetainPtr<CPDF_CustomAccess> pFile =
- CPDF_CustomAccess::Create(pFileAccess);
+ auto pFile = pdfium::MakeRetain<CPDF_CustomAccess>(pFileAccess);
auto pParser = pdfium::MakeUnique<CPDF_Parser>();
pParser->SetPassword(password);
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index bd16f43ffc..4464f1c43a 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -624,8 +624,8 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
if (!pWidgetHandler)
return true;
- std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
- m_pContext->GetXFADocView()->CreateWidgetAccIterator());
+ std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator =
+ m_pContext->GetXFADocView()->CreateWidgetAccIterator();
if (pWidgetAccIterator) {
CXFA_EventParam Param;
Param.m_eType = XFA_EVENT_PreSubmit;
@@ -633,8 +633,7 @@ bool CPDFXFA_DocEnvironment::OnBeforeNotifySubmit() {
pWidgetHandler->ProcessEvent(pWidgetAcc, &Param);
}
- pWidgetAccIterator.reset(
- m_pContext->GetXFADocView()->CreateWidgetAccIterator());
+ pWidgetAccIterator = m_pContext->GetXFADocView()->CreateWidgetAccIterator();
if (!pWidgetAccIterator)
return true;
@@ -676,8 +675,8 @@ void CPDFXFA_DocEnvironment::OnAfterNotifySubmit() {
if (!pWidgetHandler)
return;
- std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator(
- m_pContext->GetXFADocView()->CreateWidgetAccIterator());
+ std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator =
+ m_pContext->GetXFADocView()->CreateWidgetAccIterator();
if (!pWidgetAccIterator)
return;
diff --git a/xfa/fxfa/cxfa_ffapp.cpp b/xfa/fxfa/cxfa_ffapp.cpp
index a71112c93e..742cd14c30 100644
--- a/xfa/fxfa/cxfa_ffapp.cpp
+++ b/xfa/fxfa/cxfa_ffapp.cpp
@@ -26,7 +26,7 @@
CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider)
: m_pProvider(pProvider),
m_pWidgetMgrDelegate(nullptr),
- m_pFWLApp(new CFWL_App(this)) {}
+ m_pFWLApp(pdfium::MakeUnique<CFWL_App>(this)) {}
CXFA_FFApp::~CXFA_FFApp() {}
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 00f759a7f5..bcf5ef2772 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -306,10 +306,12 @@ CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() {
return m_pWidgetHandler.get();
}
-CXFA_WidgetAccIterator* CXFA_FFDocView::CreateWidgetAccIterator(
- XFA_WIDGETORDER eOrder) {
+std::unique_ptr<CXFA_WidgetAccIterator>
+CXFA_FFDocView::CreateWidgetAccIterator() {
CXFA_Node* pFormRoot = GetRootSubform();
- return pFormRoot ? new CXFA_WidgetAccIterator(pFormRoot) : nullptr;
+ if (!pFormRoot)
+ return nullptr;
+ return pdfium::MakeUnique<CXFA_WidgetAccIterator>(pFormRoot);
}
CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() {
diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h
index 05ed9d7086..7b443d4019 100644
--- a/xfa/fxfa/cxfa_ffdocview.h
+++ b/xfa/fxfa/cxfa_ffdocview.h
@@ -55,8 +55,7 @@ class CXFA_FFDocView {
int32_t ProcessWidgetEvent(CXFA_EventParam* pParam,
CXFA_WidgetAcc* pWidgetAcc);
CXFA_FFWidgetHandler* GetWidgetHandler();
- CXFA_WidgetAccIterator* CreateWidgetAccIterator(
- XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder);
+ std::unique_ptr<CXFA_WidgetAccIterator> CreateWidgetAccIterator();
CXFA_FFWidget* GetFocusWidget();
void KillFocus();
bool SetFocus(CXFA_FFWidget* hWidget);
diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp
index 49033bc0de..d027a83ce1 100644
--- a/xfa/fxfa/cxfa_ffpageview.cpp
+++ b/xfa/fxfa/cxfa_ffpageview.cpp
@@ -127,14 +127,16 @@ CFX_Matrix CXFA_FFPageView::GetDisplayMatrix(const CFX_Rect& rtDisp,
return GetPageMatrix(CFX_RectF(0, 0, GetPageSize()), rtDisp, iRotate, 0);
}
-IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator(
+std::unique_ptr<IXFA_WidgetIterator> CXFA_FFPageView::CreateWidgetIterator(
uint32_t dwTraverseWay,
uint32_t dwWidgetFilter) {
switch (dwTraverseWay) {
case XFA_TRAVERSEWAY_Tranvalse:
- return new CXFA_FFTabOrderPageWidgetIterator(this, dwWidgetFilter);
+ return pdfium::MakeUnique<CXFA_FFTabOrderPageWidgetIterator>(
+ this, dwWidgetFilter);
case XFA_TRAVERSEWAY_Form:
- return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter);
+ return pdfium::MakeUnique<CXFA_FFPageWidgetIterator>(this,
+ dwWidgetFilter);
}
return nullptr;
}
diff --git a/xfa/fxfa/cxfa_ffpageview.h b/xfa/fxfa/cxfa_ffpageview.h
index df4fc6d2c1..01409f3403 100644
--- a/xfa/fxfa/cxfa_ffpageview.h
+++ b/xfa/fxfa/cxfa_ffpageview.h
@@ -7,6 +7,7 @@
#ifndef XFA_FXFA_CXFA_FFPAGEVIEW_H_
#define XFA_FXFA_CXFA_FFPAGEVIEW_H_
+#include <memory>
#include <vector>
#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
@@ -25,18 +26,17 @@ class CXFA_FFPageView : public CXFA_ContainerLayoutItem {
CXFA_FFDocView* GetDocView() const;
CFX_RectF GetPageViewRect() const;
CFX_Matrix GetDisplayMatrix(const CFX_Rect& rtDisp, int32_t iRotate) const;
- IXFA_WidgetIterator* CreateWidgetIterator(
- uint32_t dwTraverseWay = XFA_TRAVERSEWAY_Form,
- uint32_t dwWidgetFilter = XFA_WidgetStatus_Visible |
- XFA_WidgetStatus_Viewable);
+ std::unique_ptr<IXFA_WidgetIterator> CreateWidgetIterator(
+ uint32_t dwTraverseWay,
+ uint32_t dwWidgetFilter);
protected:
CXFA_FFDocView* const m_pDocView;
};
-typedef CXFA_NodeIteratorTemplate<CXFA_LayoutItem,
- CXFA_TraverseStrategy_LayoutItem>
- CXFA_LayoutItemIterator;
+using CXFA_LayoutItemIterator =
+ CXFA_NodeIteratorTemplate<CXFA_LayoutItem,
+ CXFA_TraverseStrategy_LayoutItem>;
class CXFA_FFPageWidgetIterator : public IXFA_WidgetIterator {
public:
diff --git a/xfa/fxfa/cxfa_rendercontext.cpp b/xfa/fxfa/cxfa_rendercontext.cpp
index ecb42918cb..4b48dd4d18 100644
--- a/xfa/fxfa/cxfa_rendercontext.cpp
+++ b/xfa/fxfa/cxfa_rendercontext.cpp
@@ -41,8 +41,8 @@ int32_t CXFA_RenderContext::StartRender(CXFA_FFPageView* pPageView,
uint32_t dwFilterType = XFA_WidgetStatus_Visible |
(m_options.m_bPrint ? XFA_WidgetStatus_Printable
: XFA_WidgetStatus_Viewable);
- m_pWidgetIterator.reset(
- m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType));
+ m_pWidgetIterator =
+ m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType);
m_pWidget = m_pWidgetIterator->MoveToNext();
return XFA_RENDERSTATUS_Ready;
}
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index 559035cba1..2b4e2377af 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -86,10 +86,6 @@ enum XFA_WidgetStatus {
XFA_WidgetStatus_Visible = 1 << 9
};
-enum XFA_WIDGETORDER {
- XFA_WIDGETORDER_PreOrder,
-};
-
enum XFA_WIDGETTYPE {
XFA_WIDGETTYPE_Barcode,
XFA_WIDGETTYPE_PushButton,