| 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 "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 CPDF_Document* CXFA_FFDoc::GetPDFDoc() { | 319 CPDF_Document* CXFA_FFDoc::GetPDFDoc() { |
| 320 return m_pPDFDoc; | 320 return m_pPDFDoc; |
| 321 } | 321 } |
| 322 | 322 |
| 323 CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, | 323 CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, |
| 324 int32_t& iImageXDpi, | 324 int32_t& iImageXDpi, |
| 325 int32_t& iImageYDpi) { | 325 int32_t& iImageYDpi) { |
| 326 if (!m_pPDFDoc) | 326 if (!m_pPDFDoc) |
| 327 return nullptr; | 327 return nullptr; |
| 328 | 328 |
| 329 uint32_t dwHash = | 329 uint32_t dwHash = FX_HashCode_GetW(wsName, false); |
| 330 FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength(), FALSE); | |
| 331 FX_IMAGEDIB_AND_DPI* imageDIBDpi = nullptr; | 330 FX_IMAGEDIB_AND_DPI* imageDIBDpi = nullptr; |
| 332 if (m_mapNamedImages.Lookup((void*)(uintptr_t)dwHash, (void*&)imageDIBDpi)) { | 331 if (m_mapNamedImages.Lookup((void*)(uintptr_t)dwHash, (void*&)imageDIBDpi)) { |
| 333 iImageXDpi = imageDIBDpi->iImageXDpi; | 332 iImageXDpi = imageDIBDpi->iImageXDpi; |
| 334 iImageYDpi = imageDIBDpi->iImageYDpi; | 333 iImageYDpi = imageDIBDpi->iImageYDpi; |
| 335 return static_cast<CFX_DIBitmap*>(imageDIBDpi->pDibSource); | 334 return static_cast<CFX_DIBitmap*>(imageDIBDpi->pDibSource); |
| 336 } | 335 } |
| 337 | 336 |
| 338 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); | 337 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); |
| 339 if (!pRoot) | 338 if (!pRoot) |
| 340 return nullptr; | 339 return nullptr; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi); | 376 pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi); |
| 378 imageDIBDpi->iImageXDpi = iImageXDpi; | 377 imageDIBDpi->iImageXDpi = iImageXDpi; |
| 379 imageDIBDpi->iImageYDpi = iImageYDpi; | 378 imageDIBDpi->iImageYDpi = iImageYDpi; |
| 380 pImageFileRead->Release(); | 379 pImageFileRead->Release(); |
| 381 } | 380 } |
| 382 m_mapNamedImages.SetAt((void*)(uintptr_t)dwHash, imageDIBDpi); | 381 m_mapNamedImages.SetAt((void*)(uintptr_t)dwHash, imageDIBDpi); |
| 383 return (CFX_DIBitmap*)imageDIBDpi->pDibSource; | 382 return (CFX_DIBitmap*)imageDIBDpi->pDibSource; |
| 384 } | 383 } |
| 385 | 384 |
| 386 CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { | 385 CFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { |
| 387 uint32_t packetHash = | 386 uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); |
| 388 FX_HashCode_String_GetW(wsPackage.c_str(), wsPackage.GetLength()); | |
| 389 CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); | 387 CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); |
| 390 if (!pNode) { | 388 if (!pNode) { |
| 391 return NULL; | 389 return NULL; |
| 392 } | 390 } |
| 393 CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); | 391 CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); |
| 394 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) | 392 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) |
| 395 ? static_cast<CFDE_XMLElement*>(pXMLNode) | 393 ? static_cast<CFDE_XMLElement*>(pXMLNode) |
| 396 : NULL; | 394 : NULL; |
| 397 } | 395 } |
| 398 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, | 396 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, |
| 399 IFX_FileWrite* pFile, | 397 IFX_FileWrite* pFile, |
| 400 CXFA_ChecksumContext* pCSContext) { | 398 CXFA_ChecksumContext* pCSContext) { |
| 401 CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument); | 399 CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument); |
| 402 uint32_t packetHash = | 400 uint32_t packetHash = FX_HashCode_GetW(wsPackage, false); |
| 403 FX_HashCode_String_GetW(wsPackage.c_str(), wsPackage.GetLength()); | |
| 404 CXFA_Node* pNode = NULL; | 401 CXFA_Node* pNode = NULL; |
| 405 if (packetHash == XFA_HASHCODE_Xfa) { | 402 if (packetHash == XFA_HASHCODE_Xfa) { |
| 406 pNode = m_pDocument->GetRoot(); | 403 pNode = m_pDocument->GetRoot(); |
| 407 } else { | 404 } else { |
| 408 pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); | 405 pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); |
| 409 } | 406 } |
| 410 FX_BOOL bFlags = FALSE; | 407 FX_BOOL bFlags = FALSE; |
| 411 if (pNode) { | 408 if (pNode) { |
| 412 CFX_ByteString bsChecksum; | 409 CFX_ByteString bsChecksum; |
| 413 if (pCSContext) { | 410 if (pCSContext) { |
| 414 pCSContext->GetChecksum(bsChecksum); | 411 pCSContext->GetChecksum(bsChecksum); |
| 415 } | 412 } |
| 416 bFlags = pExport->Export( | 413 bFlags = pExport->Export( |
| 417 pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : NULL); | 414 pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : NULL); |
| 418 } else { | 415 } else { |
| 419 bFlags = pExport->Export(pFile); | 416 bFlags = pExport->Export(pFile); |
| 420 } | 417 } |
| 421 pExport->Release(); | 418 pExport->Release(); |
| 422 return bFlags; | 419 return bFlags; |
| 423 } | 420 } |
| 424 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { | 421 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { |
| 425 std::unique_ptr<CXFA_DataImporter, ReleaseDeleter<CXFA_DataImporter>> | 422 std::unique_ptr<CXFA_DataImporter, ReleaseDeleter<CXFA_DataImporter>> |
| 426 importer(new CXFA_DataImporter(m_pDocument)); | 423 importer(new CXFA_DataImporter(m_pDocument)); |
| 427 | 424 |
| 428 return importer->ImportData(pStream); | 425 return importer->ImportData(pStream); |
| 429 } | 426 } |
| OLD | NEW |