| 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 "xfa/fxfa/include/xfa_ffdoc.h" | 7 #include "xfa/fxfa/include/xfa_ffdoc.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); | 355 uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); |
| 356 CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); | 356 CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); |
| 357 if (!pNode) { | 357 if (!pNode) { |
| 358 return NULL; | 358 return NULL; |
| 359 } | 359 } |
| 360 CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); | 360 CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); |
| 361 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) | 361 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) |
| 362 ? static_cast<CFDE_XMLElement*>(pXMLNode) | 362 ? static_cast<CFDE_XMLElement*>(pXMLNode) |
| 363 : NULL; | 363 : NULL; |
| 364 } | 364 } |
| 365 |
| 365 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, | 366 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, |
| 366 IFX_FileWrite* pFile, | 367 IFX_FileWrite* pFile, |
| 367 CXFA_ChecksumContext* pCSContext) { | 368 CXFA_ChecksumContext* pCSContext) { |
| 368 CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument); | 369 std::unique_ptr<CXFA_DataExporter> pExport( |
| 370 new CXFA_DataExporter(m_pDocument)); |
| 369 uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); | 371 uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); |
| 370 CXFA_Node* pNode = NULL; | 372 CXFA_Node* pNode = packetHash == XFA_HASHCODE_Xfa |
| 371 if (packetHash == XFA_HASHCODE_Xfa) { | 373 ? m_pDocument->GetRoot() |
| 372 pNode = m_pDocument->GetRoot(); | 374 : ToNode(m_pDocument->GetXFAObject(packetHash)); |
| 373 } else { | 375 if (!pNode) |
| 374 pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); | 376 return pExport->Export(pFile); |
| 375 } | 377 |
| 376 FX_BOOL bFlags = FALSE; | 378 CFX_ByteString bsChecksum; |
| 377 if (pNode) { | 379 if (pCSContext) |
| 378 CFX_ByteString bsChecksum; | 380 pCSContext->GetChecksum(bsChecksum); |
| 379 if (pCSContext) { | 381 |
| 380 pCSContext->GetChecksum(bsChecksum); | 382 return pExport->Export(pFile, pNode, 0, |
| 381 } | 383 bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); |
| 382 bFlags = pExport->Export( | |
| 383 pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : NULL); | |
| 384 } else { | |
| 385 bFlags = pExport->Export(pFile); | |
| 386 } | |
| 387 pExport->Release(); | |
| 388 return bFlags; | |
| 389 } | 384 } |
| 385 |
| 390 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { | 386 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { |
| 391 std::unique_ptr<CXFA_DataImporter, ReleaseDeleter<CXFA_DataImporter>> | 387 std::unique_ptr<CXFA_DataImporter> importer( |
| 392 importer(new CXFA_DataImporter(m_pDocument)); | 388 new CXFA_DataImporter(m_pDocument)); |
| 393 | |
| 394 return importer->ImportData(pStream); | 389 return importer->ImportData(pStream); |
| 395 } | 390 } |
| OLD | NEW |