Keep the declaration of FPDF_HasXFAField consistent with other XFA APIs
authorJun Fang <jun_fang@foxitsoftware.com>
Tue, 17 Feb 2015 14:50:08 +0000 (06:50 -0800)
committerJun Fang <jun_fang@foxitsoftware.com>
Tue, 17 Feb 2015 14:50:08 +0000 (06:50 -0800)
It's an enhancement requested in issue 452794.

BUG=N/A
R=tsepez@chromium.org

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

fpdfsdk/include/fpdfformfill.h
fpdfsdk/include/fpdfxfa/fpdfxfa_util.h
fpdfsdk/src/fpdfsave.cpp
fpdfsdk/src/fpdfview.cpp
fpdfsdk/src/fpdfxfa/fpdfxfa_util.cpp

index 442b93f..5191fd7 100644 (file)
 
 typedef void* FPDF_FORMHANDLE;
 
+#define DOCTYPE_PDF          0 //Normal pdf Document
+#define DOCTYPE_DYNIMIC_XFA  1 //Dynimic xfa Document Type
+#define DOCTYPE_STATIC_XFA   2 //Static xfa Document Type
+
 // Exported Functions
 #ifdef __cplusplus
 extern "C" {
@@ -1094,6 +1098,16 @@ DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle);
 **/
 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, 
                                                int size_x, int size_y, int rotate, int flags);
+/**
+ * Function: FPDF_HasXFAField
+ *                      This method is designed to check whether a pdf document has XFA fields.
+ * Parameters:
+ *                      document                -       Handle to document. Returned by FPDF_LoadDocument function.
+ *                      docType                 -       Document type defined as DOCTYPE_xxx.
+ * Return Value:
+ *                      TRUE indicates that the input document has XFA fields, otherwise FALSE.
+ **/
+DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType);
 
 /**
  * Function: FPDF_LoadXFA
index 07ea65f..28904e2 100644 (file)
@@ -7,17 +7,11 @@
 #ifndef _FPDFXFA_UTIL_H_\r
 #define _FPDFXFA_UTIL_H_\r
 \r
-#define DOCTYPE_PDF                     0\r
-#define DOCTYPE_DYNIMIC_XFA  1 //Dynimic xfa Document Type\r
-#define DOCTYPE_STATIC_XFA   2 //Static xfa Document Type\r
-\r
 #define JS_STR_VIEWERTYPE_STANDARD             L"Exchange"\r
 #define JS_STR_LANGUANGE                               L"ENU"\r
 #define JS_STR_VIEWERVARIATION                 L"Full"\r
 #define JS_STR_VIEWERVERSION_XFA               L"11"\r
 \r
-FX_BOOL FPDF_HasXFAField(CPDF_Document* pPDFDoc, int& docType);\r
-\r
 class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr, public CFX_Object\r
 {\r
 public:\r
index 229e580..de645a2 100644 (file)
@@ -7,6 +7,7 @@
 #include "../include/fsdk_define.h"
 #include "../include/fpdfsave.h"
 #include "../include/fpdfedit.h"
+#include "../include/fpdfformfill.h"
 #include "../include/fpdfxfa/fpdfxfa_doc.h"
 #include "../include/fpdfxfa/fpdfxfa_app.h"
 #include "../include/fpdfxfa/fpdfxfa_util.h"
index f726fc9..6a8f890 100644 (file)
@@ -302,13 +302,41 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY
        CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider);
        return pDocument;
 }
+
+DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType)\r
+{\r
+       if (!document)\r
+               return FALSE;\r
+\r
+       CPDF_Dictionary* pRoot = ((CPDF_Document*)document)->GetRoot();\r
+       if (!pRoot)\r
+               return FALSE;\r
+\r
+       CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");\r
+       if (!pAcroForm)\r
+               return FALSE;\r
+\r
+       CPDF_Object* pXFA = pAcroForm->GetElement("XFA");\r
+       if (!pXFA)\r
+               return FALSE;\r
+\r
+       FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE);\r
+\r
+       if (bDynamicXFA)\r
+               docType = DOCTYPE_DYNIMIC_XFA;\r
+       else\r
+               docType = DOCTYPE_STATIC_XFA;\r
+\r
+       return TRUE;\r
+}
+
 DLLEXPORT  FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document)
 {
-       if (!document||!((CPDFXFA_Document*)document)->GetPDFDoc()) 
+       if (!document) 
                return FALSE;
 
        int iDocType = DOCTYPE_PDF;
-       FX_BOOL hasXFAField = FPDF_HasXFAField(((CPDFXFA_Document*)document)->GetPDFDoc(), iDocType);
+       FX_BOOL hasXFAField = FPDF_HasXFAField(document, iDocType);
        if (!hasXFAField)
                return FALSE;
        return ((CPDFXFA_Document*)document)->LoadXFADoc();
index 9bf1b63..fb625d2 100644 (file)
@@ -8,34 +8,6 @@
 #include "../../include/fsdk_mgr.h"\r
 #include "../../include/fpdfxfa/fpdfxfa_util.h"\r
 \r
-FX_BOOL FPDF_HasXFAField(CPDF_Document* pPDFDoc, int& docType)\r
-{\r
-       if (!pPDFDoc)\r
-               return FALSE;\r
-\r
-       CPDF_Dictionary* pRoot = pPDFDoc->GetRoot();\r
-       if (!pRoot)\r
-               return FALSE;\r
-\r
-       CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");\r
-       if (!pAcroForm) \r
-               return FALSE;\r
-\r
-       CPDF_Object* pXFA = pAcroForm->GetElement("XFA");\r
-       if (!pXFA) \r
-               return FALSE;\r
-\r
-       FX_BOOL bDymasticXFA = FALSE;\r
-       bDymasticXFA = pRoot->GetBoolean("NeedsRendering", FALSE);\r
-\r
-       if(bDymasticXFA)\r
-               docType = DOCTYPE_DYNIMIC_XFA;\r
-       else\r
-               docType = DOCTYPE_STATIC_XFA;\r
-\r
-       return TRUE;\r
-}\r
-\r
 CFX_PtrArray CXFA_FWLAdapterTimerMgr::ms_timerArray;\r
 \r
 FWL_ERR CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer *pTimer, FX_DWORD dwElapse, FWL_HTIMER &hTimer, FX_BOOL bImmediately /* = TRUE */)\r