From cb78ef507c272488fd7e4fd6862014333d8a9de5 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 2 Oct 2015 10:10:49 -0700 Subject: XFA: Remove checks for new returning NULL in fpdfsdk. Based on parts of https://codereview.chromium.org/1089823004 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1383933003 . --- fpdfsdk/src/fpdf_dataavail.cpp | 3 +-- fpdfsdk/src/fpdf_flatten.cpp | 2 -- fpdfsdk/src/fpdfeditpage.cpp | 11 ++--------- fpdfsdk/src/fpdfview.cpp | 21 +++------------------ 4 files changed, 6 insertions(+), 31 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/src/fpdf_dataavail.cpp b/fpdfsdk/src/fpdf_dataavail.cpp index 58bd384bf5..d3b44160a8 100644 --- a/fpdfsdk/src/fpdf_dataavail.cpp +++ b/fpdfsdk/src/fpdf_dataavail.cpp @@ -115,8 +115,7 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS); CPDF_Document* pPDFDoc = pParser->GetDocument(); CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); - CPDFXFA_Document* pDocument = new CPDFXFA_Document(pPDFDoc, pApp); - return pDocument; + return new CPDFXFA_Document(pPDFDoc, pApp); } DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) { diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp index 3049384db6..3619ef4a99 100644 --- a/fpdfsdk/src/fpdf_flatten.cpp +++ b/fpdfsdk/src/fpdf_flatten.cpp @@ -197,8 +197,6 @@ void SetPageContents(CFX_ByteString key, // Create a new contents dictionary if (!key.IsEmpty()) { CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, new CPDF_Dictionary); - if (!pNewContents) - return; pPage->SetAtReference("Contents", pDocument, pDocument->AddIndirectObject(pNewContents)); diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp index e158bee7e6..145d8ca5c3 100644 --- a/fpdfsdk/src/fpdfeditpage.cpp +++ b/fpdfsdk/src/fpdfeditpage.cpp @@ -19,8 +19,6 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() { CPDF_Document* pDoc = new CPDF_Document; - if (!pDoc) - return NULL; pDoc->CreateNewDoc(); time_t currentTime; @@ -46,8 +44,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() { } CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); - CPDFXFA_Document* document = new CPDFXFA_Document(pDoc, pApp); - return document; + return new CPDFXFA_Document(pDoc, pApp); } DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) { @@ -89,10 +86,6 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, pPageDict->SetAt("Rotate", new CPDF_Number(0)); pPageDict->SetAt("Resources", new CPDF_Dictionary); - // CPDF_Page* pPage = new CPDF_Page; - // pPage->Load(pDoc,pPageDict); - // pPage->ParseContent(); - CPDFXFA_Page* pPage = new CPDFXFA_Page((CPDFXFA_Document*)document, page_index); pPage->LoadPDFPage(pPageDict); @@ -288,7 +281,7 @@ DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; if (pPageObj == NULL) return; - // PDF_ImageObject* pImageObj = new CPDF_ImageObject; + CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, (FX_FLOAT)e, (FX_FLOAT)f); pPageObj->Transform(matrix); diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index 414ade7070..47da1f49de 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -265,8 +265,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, return NULL; CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); - CPDFXFA_Document* pDocument = new CPDFXFA_Document(pPDFDoc, pProvider); - return pDocument; + return new CPDFXFA_Document(pPDFDoc, pProvider); } DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, @@ -351,8 +350,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, return NULL; CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); - CPDFXFA_Document* pDocument = new CPDFXFA_Document(pPDFDoc, pProvider); - return pDocument; + return new CPDFXFA_Document(pPDFDoc, pProvider); } DLLEXPORT FPDF_DOCUMENT STDCALL @@ -375,8 +373,7 @@ FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, return NULL; CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance(); - CPDFXFA_Document* pDocument = new CPDFXFA_Document(pPDFDoc, pProvider); - return pDocument; + return new CPDFXFA_Document(pPDFDoc, pProvider); } DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, @@ -885,18 +882,6 @@ DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, double* width, double* height) { - // CPDF_Document* pDoc = (CPDF_Document*)document; - // if(pDoc == NULL) - // return FALSE; - // - // CPDF_Dictionary* pDict = pDoc->GetPage(page_index); - // if (pDict == NULL) return FALSE; - // - // CPDF_Page page; - // page.Load(pDoc, pDict); - // *width = page.GetPageWidth(); - // *height = page.GetPageHeight(); - CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; if (pDoc == NULL) return FALSE; -- cgit v1.2.3