From 40baddef7fda756c29b813dc1fd67b28d745aa8c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 1 May 2017 13:21:39 -0700 Subject: Remove more |new|s, part 6 Change-Id: I4adbeafa7ecfd509abca08d97be132fd709e1261 Reviewed-on: https://pdfium-review.googlesource.com/4691 Reviewed-by: dsinclair Commit-Queue: dsinclair --- fpdfsdk/fpdfsave.cpp | 8 ++++---- fpdfsdk/fpdfview.cpp | 18 ++++++++---------- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 11 +++++------ 3 files changed, 17 insertions(+), 20 deletions(-) (limited to 'fpdfsdk') 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 pWidgetAccIterator( - pXFADocView->CreateWidgetAccIterator()); + std::unique_ptr 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 pWidgetAccIterator( - pXFADocView->CreateWidgetAccIterator()); + std::unique_ptr 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 Create(FPDF_FILEACCESS* pFileAccess) { - return CFX_RetainPtr(new CPDF_CustomAccess(pFileAccess)); - } + template + friend CFX_RetainPtr 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 Create(FPDF_FILEHANDLER* pFS) { - return CFX_RetainPtr(new CFPDF_FileStream(pFS)); - } + template + friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + ~CFPDF_FileStream() override; // IFX_SeekableStream: @@ -328,13 +327,13 @@ CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) { CFX_RetainPtr MakeSeekableReadStream( FPDF_FILEACCESS* pFileAccess) { - return CPDF_CustomAccess::Create(pFileAccess); + return pdfium::MakeRetain(pFileAccess); } #ifdef PDF_ENABLE_XFA CFX_RetainPtr MakeSeekableStream( FPDF_FILEHANDLER* pFilehandler) { - return CFPDF_FileStream::Create(pFilehandler); + return pdfium::MakeRetain(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 pFile = - CPDF_CustomAccess::Create(pFileAccess); + auto pFile = pdfium::MakeRetain(pFileAccess); auto pParser = pdfium::MakeUnique(); 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 pWidgetAccIterator( - m_pContext->GetXFADocView()->CreateWidgetAccIterator()); + std::unique_ptr 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 pWidgetAccIterator( - m_pContext->GetXFADocView()->CreateWidgetAccIterator()); + std::unique_ptr pWidgetAccIterator = + m_pContext->GetXFADocView()->CreateWidgetAccIterator(); if (!pWidgetAccIterator) return; -- cgit v1.2.3