Changes to master to more closely match XFA.
authorTom Sepez <tsepez@chromium.org>
Tue, 13 Oct 2015 22:17:46 +0000 (15:17 -0700)
committerTom Sepez <tsepez@chromium.org>
Tue, 13 Oct 2015 22:17:46 +0000 (15:17 -0700)
These files should change in master in order to reduce the number of
"noise diffs" between master and XFA as seen in
    https://codereview.chromium.org/1399273003/

This includes: whitespace, matching header ordering, and implementing
a GetPageFromFPDFPage() from XFA.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1407583004 .

fpdfsdk/src/formfiller/FFL_IFormFiller.cpp
fpdfsdk/src/fpdf_transformpage.cpp
fpdfsdk/src/fpdfdoc.cpp
fpdfsdk/src/fpdfeditimg.cpp
fpdfsdk/src/fpdfeditpage.cpp
fpdfsdk/src/fpdfformfill.cpp
fpdfsdk/src/fpdfview.cpp
fpdfsdk/src/fsdk_mgr.cpp

index 69ff932..ce0a67f 100644 (file)
@@ -509,23 +509,15 @@ FX_BOOL CFFL_IFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) {
 }
 
 FX_BOOL CFFL_IFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) {
-  ASSERT(pWidget != NULL);
-
   if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON)
     return TRUE;
-  else {
-    CPDF_Page* pPage = pWidget->GetPDFPage();
-    ASSERT(pPage != NULL);
-
-    CPDF_Document* pDocument = pPage->m_pDocument;
-    ASSERT(pDocument != NULL);
 
-    FX_DWORD dwPermissions = pDocument->GetUserPermissions();
-    return (dwPermissions & FPDFPERM_FILL_FORM) ||
-           (dwPermissions & FPDFPERM_ANNOT_FORM) ||
-           (dwPermissions & FPDFPERM_MODIFY);
-  }
-  return TRUE;
+  CPDF_Page* pPage = pWidget->GetPDFPage();
+  CPDF_Document* pDocument = pPage->m_pDocument;
+  FX_DWORD dwPermissions = pDocument->GetUserPermissions();
+  return (dwPermissions & FPDFPERM_FILL_FORM) ||
+         (dwPermissions & FPDFPERM_ANNOT_FORM) ||
+         (dwPermissions & FPDFPERM_MODIFY);
 }
 
 CFFL_FormFiller* CFFL_IFormFiller::GetFormFiller(CPDFSDK_Annot* pAnnot,
@@ -802,13 +794,10 @@ void CFFL_IFormFiller::OnFormat(CPDFSDK_Widget* pWidget,
 
 FX_BOOL CFFL_IFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView,
                                        CPDFSDK_Annot* pAnnot) {
-  ASSERT(pPageView != NULL);
-  ASSERT(pAnnot != NULL);
-
   if (pPageView)
     return pPageView->IsValidAnnot(pAnnot->GetPDFAnnot());
-  else
-    return FALSE;
+
+  return FALSE;
 }
 
 void CFFL_IFormFiller::OnBeforeKeyStroke(FX_BOOL bEditOrList,
index 614c7a4..d0dee59 100644 (file)
@@ -9,6 +9,10 @@
 
 namespace {
 
+CPDF_Page* GetPageFromFPDFPage(FPDF_PAGE page) {
+  return static_cast<CPDF_Page*>(page);
+}
+
 void SetBoundingBox(CPDF_Page* page,
                     const CFX_ByteStringC& key,
                     float left,
@@ -49,11 +53,11 @@ DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page,
                                             float bottom,
                                             float right,
                                             float top) {
-  if (!page)
+  CPDF_Page* pPage = GetPageFromFPDFPage(page);
+  if (!pPage)
     return;
 
-  SetBoundingBox(static_cast<CPDF_Page*>(page), "MediaBox", left, bottom, right,
-                 top);
+  SetBoundingBox(pPage, "MediaBox", left, bottom, right, top);
 }
 
 DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page,
@@ -61,11 +65,11 @@ DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page,
                                            float bottom,
                                            float right,
                                            float top) {
-  if (!page)
+  CPDF_Page* pPage = GetPageFromFPDFPage(page);
+  if (!pPage)
     return;
 
-  SetBoundingBox(static_cast<CPDF_Page*>(page), "CropBox", left, bottom, right,
-                 top);
+  SetBoundingBox(pPage, "CropBox", left, bottom, right, top);
 }
 
 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page,
@@ -73,8 +77,8 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page,
                                                  float* bottom,
                                                  float* right,
                                                  float* top) {
-  return page && GetBoundingBox(static_cast<CPDF_Page*>(page), "MediaBox", left,
-                                bottom, right, top);
+  CPDF_Page* pPage = GetPageFromFPDFPage(page);
+  return pPage && GetBoundingBox(pPage, "MediaBox", left, bottom, right, top);
 }
 
 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page,
@@ -82,14 +86,15 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page,
                                                 float* bottom,
                                                 float* right,
                                                 float* top) {
-  return page && GetBoundingBox(static_cast<CPDF_Page*>(page), "CropBox", left,
-                                bottom, right, top);
+  CPDF_Page* pPage = GetPageFromFPDFPage(page);
+  return pPage && GetBoundingBox(pPage, "CropBox", left, bottom, right, top);
 }
 
 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
                                                        FS_MATRIX* matrix,
                                                        FS_RECTF* clipRect) {
-  if (!page)
+  CPDF_Page* pPage = GetPageFromFPDFPage(page);
+  if (!pPage)
     return FALSE;
 
   CFX_ByteTextBuf textBuf;
@@ -107,7 +112,6 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
                  matrix->d, matrix->e, matrix->f);
   textBuf << bsMatix;
 
-  CPDF_Page* pPage = (CPDF_Page*)page;
   CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
   CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
   if (!pContentObj)
@@ -263,9 +267,10 @@ void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) {
 
 DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
                                                FPDF_CLIPPATH clipPath) {
-  if (!page)
+  CPDF_Page* pPage = GetPageFromFPDFPage(page);
+  if (!pPage)
     return;
-  CPDF_Page* pPage = (CPDF_Page*)page;
+
   CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
   CPDF_Object* pContentObj = pPageDic ? pPageDic->GetElement("Contents") : NULL;
   if (!pContentObj)
index 97f5cf3..4e2e7f3 100644 (file)
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "../include/fsdk_define.h"
 #include "../../public/fpdf_doc.h"
+#include "../include/fsdk_define.h"
 
 namespace {
 
index 3b5272c..bb71078 100644 (file)
@@ -22,7 +22,7 @@ FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages,
                           int nCount,
                           FPDF_PAGEOBJECT image_object,
                           FPDF_FILEACCESS* fileAccess) {
-  if (!image_object || !fileAccess)
+  if (!image_object || !fileAccess || !pages)
     return FALSE;
 
   IFX_FileRead* pFile = new CPDF_CustomAccess(fileAccess);
@@ -61,7 +61,7 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,
                                                    int nCount,
                                                    FPDF_PAGEOBJECT image_object,
                                                    FPDF_BITMAP bitmap) {
-  if (!image_object || !bitmap)
+  if (!image_object || !bitmap || !pages)
     return FALSE;
   CFX_DIBitmap* pBmp = NULL;
   pBmp = (CFX_DIBitmap*)bitmap;
index 0219c9c..8796d0e 100644 (file)
@@ -5,6 +5,7 @@
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #include "../../public/fpdf_edit.h"
+#include "../../public/fpdf_formfill.h"
 #include "../include/fsdk_define.h"
 
 #if _FX_OS_ == _FX_ANDROID_
@@ -274,6 +275,7 @@ DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
   CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
   if (pPageObj == NULL)
     return;
+
   CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
                           (FX_FLOAT)e, (FX_FLOAT)f);
   pPageObj->Transform(matrix);
index 272e781..cca4834 100644 (file)
@@ -322,14 +322,8 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
   CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
   if (pPageView) {
     CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();
-    ASSERT(pEnv != NULL);
-
     CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
-    ASSERT(pActionHandler != NULL);
-
     CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
-    ASSERT(pPageDict != NULL);
-
     CPDF_AAction aa = pPageDict->GetDict(FX_BSTRC("AA"));
 
     FX_BOOL bExistOAAction = FALSE;
index b050e03..dfa91d1 100644 (file)
@@ -121,6 +121,7 @@ DLLEXPORT void STDCALL FPDF_DestroyLibrary() {
 #endif
   CPDF_ModuleMgr::Destroy();
   CFX_GEModule::Destroy();
+
   delete g_pCodecModule;
   g_pCodecModule = nullptr;
 }
index 33e56de..b7962d5 100644 (file)
@@ -223,6 +223,7 @@ CPDFDoc_Environment::~CPDFDoc_Environment() {
 
   delete m_pAnnotHandlerMgr;
   m_pAnnotHandlerMgr = NULL;
+
   delete m_pActionHandler;
   m_pActionHandler = NULL;
 }