| OLD | NEW |
| 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 "public/fpdf_save.h" | 7 #include "public/fpdf_save.h" |
| 8 | 8 |
| 9 #include "core/include/fpdfapi/fpdf_serial.h" | 9 #include "core/include/fpdfapi/fpdf_serial.h" |
| 10 #include "fpdfsdk/include/fsdk_define.h" | 10 #include "fpdfsdk/include/fsdk_define.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 IXFA_DocHandler* pXFADocHandler = | 78 IXFA_DocHandler* pXFADocHandler = |
| 79 CPDFXFA_App::GetInstance()->GetXFAApp()->GetDocHandler(); | 79 CPDFXFA_App::GetInstance()->GetXFAApp()->GetDocHandler(); |
| 80 CPDF_Document* pPDFDocument = pDocument->GetPDFDoc(); | 80 CPDF_Document* pPDFDocument = pDocument->GetPDFDoc(); |
| 81 if (pDocument == NULL) | 81 if (pDocument == NULL) |
| 82 return FALSE; | 82 return FALSE; |
| 83 | 83 |
| 84 CPDF_Dictionary* pRoot = pPDFDocument->GetRoot(); | 84 CPDF_Dictionary* pRoot = pPDFDocument->GetRoot(); |
| 85 if (pRoot == NULL) | 85 if (pRoot == NULL) |
| 86 return FALSE; | 86 return FALSE; |
| 87 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); | 87 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); |
| 88 if (NULL == pAcroForm) | 88 if (NULL == pAcroForm) |
| 89 return FALSE; | 89 return FALSE; |
| 90 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); | 90 CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); |
| 91 if (pXFA == NULL) | 91 if (pXFA == NULL) |
| 92 return TRUE; | 92 return TRUE; |
| 93 if (!pXFA->IsArray()) | 93 if (!pXFA->IsArray()) |
| 94 return FALSE; | 94 return FALSE; |
| 95 CPDF_Array* pArray = pXFA->GetArray(); | 95 CPDF_Array* pArray = pXFA->GetArray(); |
| 96 if (NULL == pArray) | 96 if (NULL == pArray) |
| 97 return FALSE; | 97 return FALSE; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 112 iTemplate = i + 1; | 112 iTemplate = i + 1; |
| 113 } | 113 } |
| 114 IXFA_ChecksumContext* pContext = NULL; | 114 IXFA_ChecksumContext* pContext = NULL; |
| 115 // Checksum | 115 // Checksum |
| 116 pContext = XFA_Checksum_Create(); | 116 pContext = XFA_Checksum_Create(); |
| 117 FXSYS_assert(pContext); | 117 FXSYS_assert(pContext); |
| 118 pContext->StartChecksum(); | 118 pContext->StartChecksum(); |
| 119 | 119 |
| 120 // template | 120 // template |
| 121 if (iTemplate > -1) { | 121 if (iTemplate > -1) { |
| 122 CPDF_Stream* pTemplateStream = pArray->GetStream(iTemplate); | 122 CPDF_Stream* pTemplateStream = pArray->GetStreamAt(iTemplate); |
| 123 CPDF_StreamAcc streamAcc; | 123 CPDF_StreamAcc streamAcc; |
| 124 streamAcc.LoadAllData(pTemplateStream); | 124 streamAcc.LoadAllData(pTemplateStream); |
| 125 uint8_t* pData = (uint8_t*)streamAcc.GetData(); | 125 uint8_t* pData = (uint8_t*)streamAcc.GetData(); |
| 126 FX_DWORD dwSize2 = streamAcc.GetSize(); | 126 FX_DWORD dwSize2 = streamAcc.GetSize(); |
| 127 IFX_FileStream* pTemplate = FX_CreateMemoryStream(pData, dwSize2); | 127 IFX_FileStream* pTemplate = FX_CreateMemoryStream(pData, dwSize2); |
| 128 pContext->UpdateChecksum((IFX_FileRead*)pTemplate); | 128 pContext->UpdateChecksum((IFX_FileRead*)pTemplate); |
| 129 pTemplate->Release(); | 129 pTemplate->Release(); |
| 130 } | 130 } |
| 131 CPDF_Stream* pFormStream = NULL; | 131 CPDF_Stream* pFormStream = NULL; |
| 132 CPDF_Stream* pDataSetsStream = NULL; | 132 CPDF_Stream* pDataSetsStream = NULL; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 FPDF_DWORD flags) { | 321 FPDF_DWORD flags) { |
| 322 return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); | 322 return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE, 0); |
| 323 } | 323 } |
| 324 | 324 |
| 325 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, | 325 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, |
| 326 FPDF_FILEWRITE* pFileWrite, | 326 FPDF_FILEWRITE* pFileWrite, |
| 327 FPDF_DWORD flags, | 327 FPDF_DWORD flags, |
| 328 int fileVersion) { | 328 int fileVersion) { |
| 329 return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); | 329 return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE, fileVersion); |
| 330 } | 330 } |
| OLD | NEW |