summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/src/fpdfview.cpp63
1 files changed, 30 insertions, 33 deletions
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 6a8f890115..db191245f3 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -303,43 +303,40 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, FPDF_BY
return pDocument;
}
-DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType)
-{
- if (!document)
- return FALSE;
-
- CPDF_Dictionary* pRoot = ((CPDF_Document*)document)->GetRoot();
- if (!pRoot)
- return FALSE;
-
- CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
- if (!pAcroForm)
- return FALSE;
-
- CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
- if (!pXFA)
- return FALSE;
-
- FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE);
-
- if (bDynamicXFA)
- docType = DOCTYPE_DYNIMIC_XFA;
- else
- docType = DOCTYPE_STATIC_XFA;
-
- return TRUE;
-}
-
-DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document)
+DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType)
{
- if (!document)
+ if (!document)
+ return FALSE;
+
+ CPDF_Document *pdfDoc = (static_cast<CPDFXFA_Document *>(document))->GetPDFDoc();
+ if (!pdfDoc)
+ return FALSE;
+
+ CPDF_Dictionary* pRoot = pdfDoc->GetRoot();
+ if (!pRoot)
+ return FALSE;
+
+ CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
+ if (!pAcroForm)
return FALSE;
- int iDocType = DOCTYPE_PDF;
- FX_BOOL hasXFAField = FPDF_HasXFAField(document, iDocType);
- if (!hasXFAField)
+ CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
+ if (!pXFA)
return FALSE;
- return ((CPDFXFA_Document*)document)->LoadXFADoc();
+
+ FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE);
+
+ if (bDynamicXFA)
+ docType = DOCTYPE_DYNIMIC_XFA;
+ else
+ docType = DOCTYPE_STATIC_XFA;
+
+ return TRUE;
+}
+
+DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document)
+{
+ return document && (static_cast<CPDFXFA_Document *>(document))->LoadXFADoc();
}