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/src/foxitlib.h" | 7 #include "xfa/src/foxitlib.h" |
8 #include "xfa/src/fxfa/src/common/xfa_common.h" | 8 #include "xfa/src/fxfa/src/common/xfa_common.h" |
9 #include "xfa_ffapp.h" | 9 #include "xfa_ffapp.h" |
10 #include "xfa_ffdoc.h" | 10 #include "xfa_ffdoc.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 pNewRoot->RemoveChild(pChildNode); | 93 pNewRoot->RemoveChild(pChildNode); |
94 pOriginRoot->InsertChild(pChildNode); | 94 pOriginRoot->InsertChild(pChildNode); |
95 pChildNode = pNextSibling; | 95 pChildNode = pNextSibling; |
96 pNextSibling = NULL; | 96 pNextSibling = NULL; |
97 } | 97 } |
98 } | 98 } |
99 } | 99 } |
100 int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { | 100 int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { |
101 int32_t iStatus = m_pDocument->GetParser()->DoParse(pPause); | 101 int32_t iStatus = m_pDocument->GetParser()->DoParse(pPause); |
102 if (iStatus == XFA_PARSESTATUS_Done && !m_pPDFDoc) { | 102 if (iStatus == XFA_PARSESTATUS_Done && !m_pPDFDoc) { |
103 CXFA_Node* pPDFNode = | 103 CXFA_Node* pPDFNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Pdf)); |
104 (CXFA_Node*)m_pDocument->GetXFAObject(XFA_HASHCODE_Pdf); | |
105 if (!pPDFNode) { | 104 if (!pPDFNode) { |
106 return XFA_PARSESTATUS_SyntaxErr; | 105 return XFA_PARSESTATUS_SyntaxErr; |
107 } | 106 } |
108 IFDE_XMLNode* pPDFXML = pPDFNode->GetXMLMappingNode(); | 107 IFDE_XMLNode* pPDFXML = pPDFNode->GetXMLMappingNode(); |
109 if (pPDFXML->GetType() != FDE_XMLNODE_Element) { | 108 if (pPDFXML->GetType() != FDE_XMLNODE_Element) { |
110 return XFA_PARSESTATUS_SyntaxErr; | 109 return XFA_PARSESTATUS_SyntaxErr; |
111 } | 110 } |
112 int32_t iBufferSize = 0; | 111 int32_t iBufferSize = 0; |
113 uint8_t* pByteBuffer = NULL; | 112 uint8_t* pByteBuffer = NULL; |
114 IFX_FileRead* pXFAReader = NULL; | 113 IFX_FileRead* pXFAReader = NULL; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 iStatus = XFA_PARSESTATUS_StatusErr; | 152 iStatus = XFA_PARSESTATUS_StatusErr; |
154 } | 153 } |
155 pParser->Release(); | 154 pParser->Release(); |
156 pParser = NULL; | 155 pParser = NULL; |
157 } | 156 } |
158 return iStatus; | 157 return iStatus; |
159 } | 158 } |
160 void CXFA_FFDoc::StopLoad() { | 159 void CXFA_FFDoc::StopLoad() { |
161 m_pApp->GetXFAFontMgr()->LoadDocFonts(this); | 160 m_pApp->GetXFAFontMgr()->LoadDocFonts(this); |
162 m_dwDocType = XFA_DOCTYPE_Static; | 161 m_dwDocType = XFA_DOCTYPE_Static; |
163 CXFA_Node* pConfig = | 162 CXFA_Node* pConfig = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Config)); |
164 (CXFA_Node*)m_pDocument->GetXFAObject(XFA_HASHCODE_Config); | |
165 if (!pConfig) { | 163 if (!pConfig) { |
166 return; | 164 return; |
167 } | 165 } |
168 CXFA_Node* pAcrobat = pConfig->GetFirstChildByClass(XFA_ELEMENT_Acrobat); | 166 CXFA_Node* pAcrobat = pConfig->GetFirstChildByClass(XFA_ELEMENT_Acrobat); |
169 if (!pAcrobat) { | 167 if (!pAcrobat) { |
170 return; | 168 return; |
171 } | 169 } |
172 CXFA_Node* pAcrobat7 = pAcrobat->GetFirstChildByClass(XFA_ELEMENT_Acrobat7); | 170 CXFA_Node* pAcrobat7 = pAcrobat->GetFirstChildByClass(XFA_ELEMENT_Acrobat7); |
173 if (!pAcrobat7) { | 171 if (!pAcrobat7) { |
174 return; | 172 return; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 imageDIBDpi->iImageXDpi = iImageXDpi; | 388 imageDIBDpi->iImageXDpi = iImageXDpi; |
391 imageDIBDpi->iImageYDpi = iImageYDpi; | 389 imageDIBDpi->iImageYDpi = iImageYDpi; |
392 pImageFileRead->Release(); | 390 pImageFileRead->Release(); |
393 } | 391 } |
394 m_mapNamedImages.SetAt((void*)(uintptr_t)dwHash, imageDIBDpi); | 392 m_mapNamedImages.SetAt((void*)(uintptr_t)dwHash, imageDIBDpi); |
395 return (CFX_DIBitmap*)imageDIBDpi->pDibSource; | 393 return (CFX_DIBitmap*)imageDIBDpi->pDibSource; |
396 } | 394 } |
397 IFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { | 395 IFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { |
398 FX_DWORD packetHash = | 396 FX_DWORD packetHash = |
399 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); | 397 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); |
400 CXFA_Object* pObject = m_pDocument->GetXFAObject(packetHash); | 398 CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); |
401 CXFA_Node* pNode = | |
402 (pObject && pObject->IsNode()) ? (CXFA_Node*)pObject : NULL; | |
403 if (!pNode) { | 399 if (!pNode) { |
404 return NULL; | 400 return NULL; |
405 } | 401 } |
406 IFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); | 402 IFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); |
407 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) | 403 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) |
408 ? (IFDE_XMLElement*)pXMLNode | 404 ? (IFDE_XMLElement*)pXMLNode |
409 : NULL; | 405 : NULL; |
410 } | 406 } |
411 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, | 407 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, |
412 IFX_FileWrite* pFile, | 408 IFX_FileWrite* pFile, |
413 IXFA_ChecksumContext* pCSContext) { | 409 IXFA_ChecksumContext* pCSContext) { |
414 IXFA_PacketExport* pExport = IXFA_PacketExport::Create(m_pDocument); | 410 IXFA_PacketExport* pExport = IXFA_PacketExport::Create(m_pDocument); |
415 if (!pExport) { | 411 if (!pExport) { |
416 return FALSE; | 412 return FALSE; |
417 } | 413 } |
418 FX_DWORD packetHash = | 414 FX_DWORD packetHash = |
419 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); | 415 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); |
420 CXFA_Node* pNode = NULL; | 416 CXFA_Node* pNode = NULL; |
421 if (packetHash == XFA_HASHCODE_Xfa) { | 417 if (packetHash == XFA_HASHCODE_Xfa) { |
422 pNode = m_pDocument->GetRoot(); | 418 pNode = m_pDocument->GetRoot(); |
423 } else { | 419 } else { |
424 CXFA_Object* pObject = m_pDocument->GetXFAObject(packetHash); | 420 pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); |
425 pNode = (pObject && pObject->IsNode()) ? (CXFA_Node*)pObject : NULL; | |
426 } | 421 } |
427 FX_BOOL bFlags = FALSE; | 422 FX_BOOL bFlags = FALSE; |
428 if (pNode) { | 423 if (pNode) { |
429 CFX_ByteString bsChecksum; | 424 CFX_ByteString bsChecksum; |
430 if (pCSContext) { | 425 if (pCSContext) { |
431 pCSContext->GetChecksum(bsChecksum); | 426 pCSContext->GetChecksum(bsChecksum); |
432 } | 427 } |
433 bFlags = pExport->Export(pFile, pNode, 0, bsChecksum.GetLength() | 428 bFlags = pExport->Export(pFile, pNode, 0, bsChecksum.GetLength() |
434 ? (const FX_CHAR*)bsChecksum | 429 ? (const FX_CHAR*)bsChecksum |
435 : NULL); | 430 : NULL); |
436 } else { | 431 } else { |
437 bFlags = pExport->Export(pFile); | 432 bFlags = pExport->Export(pFile); |
438 } | 433 } |
439 pExport->Release(); | 434 pExport->Release(); |
440 return bFlags; | 435 return bFlags; |
441 } | 436 } |
442 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { | 437 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { |
443 FX_BOOL bRet = FALSE; | 438 FX_BOOL bRet = FALSE; |
444 IXFA_PacketImport* pImport = IXFA_PacketImport::Create(m_pDocument); | 439 IXFA_PacketImport* pImport = IXFA_PacketImport::Create(m_pDocument); |
445 if (pImport) { | 440 if (pImport) { |
446 bRet = pImport->ImportData(pStream); | 441 bRet = pImport->ImportData(pStream); |
447 pImport->Release(); | 442 pImport->Release(); |
448 } | 443 } |
449 return bRet; | 444 return bRet; |
450 } | 445 } |
OLD | NEW |