Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: fpdfsdk/src/fpdfview.cpp

Issue 973673002: Check whether a pdf has XFA fields before loading XFA fields (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | samples/pdfium_test.cc » ('j') | samples/pdfium_test.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fpdfview.cpp
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 6a8f8901151245d22673a241466f122f7710ea84..3c5e775165d3f1cffc7a0b1938af16282cb4a623 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -303,43 +303,36 @@ 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 || !((CPDFXFA_Document*)document)->GetPDFDoc())
Tom Sepez 2015/03/03 00:53:34 nit: I'd do this as a local variable assignment fo
jun_fang 2015/03/03 01:02:31 OK.
+ return FALSE;
+
+ CPDF_Dictionary* pRoot = (((CPDFXFA_Document*)document)->GetPDFDoc())->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 && ((CPDFXFA_Document*)document)->LoadXFADoc());
Tom Sepez 2015/03/03 00:53:34 nit: outer ( ) not needed.
jun_fang 2015/03/03 01:02:30 OK.
}
« no previous file with comments | « no previous file | samples/pdfium_test.cc » ('j') | samples/pdfium_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698