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 .
diff --git a/fpdfsdk/src/fpdf_dataavail.cpp b/fpdfsdk/src/fpdf_dataavail.cpp
index 58bd384..d3b4416 100644
--- a/fpdfsdk/src/fpdf_dataavail.cpp
+++ b/fpdfsdk/src/fpdf_dataavail.cpp
@@ -115,8 +115,7 @@
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 3049384..3619ef4 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -197,8 +197,6 @@
// 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 e158bee..145d8ca 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 @@
}
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 @@
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 @@
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 414ade7..47da1f4 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -265,8 +265,7 @@
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 @@
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 @@
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 @@
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;