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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | samples/pdfium_test.cc » ('j') | samples/pdfium_test.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/fpdfview.h" 9 #include "../include/fpdfview.h"
10 #include "../include/fsdk_rendercontext.h" 10 #include "../include/fsdk_rendercontext.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (!pPDFDoc) 298 if (!pPDFDoc)
299 return NULL; 299 return NULL;
300 300
301 CPDFXFA_App* pProvider = FPDFXFA_GetApp(); 301 CPDFXFA_App* pProvider = FPDFXFA_GetApp();
302 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider ); 302 CPDFXFA_Document* pDocument = FX_NEW CPDFXFA_Document(pPDFDoc, pProvider );
303 return pDocument; 303 return pDocument;
304 } 304 }
305 305
306 DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType) 306 DLLEXPORT FX_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, int& docType)
307 { 307 {
308 » if (!document) 308 » 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.
309 return FALSE; 309 return FALSE;
310 310
311 » CPDF_Dictionary* pRoot = ((CPDF_Document*)document)->GetRoot(); 311 » CPDF_Dictionary* pRoot = (((CPDFXFA_Document*)document)->GetPDFDoc())->G etRoot();
312 if (!pRoot) 312 if (!pRoot)
313 return FALSE; 313 return FALSE;
314 314
315 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); 315 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
316 if (!pAcroForm) 316 if (!pAcroForm)
317 return FALSE; 317 return FALSE;
318 318
319 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); 319 CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
320 if (!pXFA) 320 if (!pXFA)
321 return FALSE; 321 return FALSE;
322 322
323 FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE); 323 FX_BOOL bDynamicXFA = pRoot->GetBoolean("NeedsRendering", FALSE);
324 324
325 if (bDynamicXFA) 325 if (bDynamicXFA)
326 docType = DOCTYPE_DYNIMIC_XFA; 326 docType = DOCTYPE_DYNIMIC_XFA;
327 else 327 else
328 docType = DOCTYPE_STATIC_XFA; 328 docType = DOCTYPE_STATIC_XFA;
329 329
330 return TRUE; 330 return TRUE;
331 } 331 }
332 332
333 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document) 333 DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document)
334 { 334 {
335 » if (!document) 335 » 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.
336 » » return FALSE;
337
338 » int iDocType = DOCTYPE_PDF;
339 » FX_BOOL hasXFAField = FPDF_HasXFAField(document, iDocType);
340 » if (!hasXFAField)
341 » » return FALSE;
342 » return ((CPDFXFA_Document*)document)->LoadXFADoc();
343 } 336 }
344 337
345 338
346 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); 339 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code);
347 340
348 class CMemFile FX_FINAL: public IFX_FileRead, public CFX_Object 341 class CMemFile FX_FINAL: public IFX_FileRead, public CFX_Object
349 { 342 {
350 public: 343 public:
351 CMemFile(FX_BYTE* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {} 344 CMemFile(FX_BYTE* pBuf, FX_FILESIZE size):m_pBuf(pBuf),m_size(size) {}
352 345
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 if (!buffer) { 1081 if (!buffer) {
1089 buflen = len; 1082 buflen = len;
1090 } else if (buflen >= len) { 1083 } else if (buflen >= len) {
1091 memcpy(buffer, utf16Name.c_str(), len); 1084 memcpy(buffer, utf16Name.c_str(), len);
1092 buflen = len; 1085 buflen = len;
1093 } else { 1086 } else {
1094 buflen = -1; 1087 buflen = -1;
1095 } 1088 }
1096 return (FPDF_DEST)pDestObj; 1089 return (FPDF_DEST)pDestObj;
1097 } 1090 }
OLDNEW
« 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