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/app/xfa_ffdoc.h" | 7 #include "xfa/include/fxfa/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" |
11 #include "core/fxcrt/include/fx_ext.h" | 11 #include "core/fxcrt/include/fx_ext.h" |
12 #include "core/include/fpdfdoc/fpdf_doc.h" | 12 #include "core/include/fpdfdoc/fpdf_doc.h" |
13 #include "xfa/fde/xml/fde_xml_imp.h" | 13 #include "xfa/fde/xml/fde_xml_imp.h" |
14 #include "xfa/fgas/crt/fgas_algorithm.h" | 14 #include "xfa/fgas/crt/fgas_algorithm.h" |
15 #include "xfa/fwl/core/ifwl_notedriver.h" | 15 #include "xfa/fwl/core/ifwl_notedriver.h" |
16 #include "xfa/fxfa/app/xfa_ffapp.h" | 16 #include "xfa/include/fxfa/xfa_ffapp.h" |
17 #include "xfa/fxfa/app/xfa_ffdocview.h" | 17 #include "xfa/include/fxfa/xfa_ffdocview.h" |
18 #include "xfa/fxfa/app/xfa_ffnotify.h" | 18 #include "xfa/fxfa/app/xfa_ffnotify.h" |
19 #include "xfa/fxfa/app/xfa_ffwidget.h" | 19 #include "xfa/fxfa/app/xfa_ffwidget.h" |
20 #include "xfa/fxfa/app/xfa_fontmgr.h" | 20 #include "xfa/include/fxfa/xfa_fontmgr.h" |
21 #include "xfa/fxfa/parser/xfa_docdata.h" | 21 #include "xfa/fxfa/parser/xfa_docdata.h" |
22 #include "xfa/fxfa/parser/xfa_parser_imp.h" | |
23 #include "xfa/fxfa/parser/xfa_document_serialize.h" | |
Tom Sepez
2016/03/31 17:01:57
nit: alphabetize
dsinclair
2016/03/31 19:52:26
Doh, forgot to run sort-headers.py
| |
24 #include "xfa/include/fxfa/xfa_checksum.h" | |
22 #include "xfa/fxfa/parser/xfa_parser.h" | 25 #include "xfa/fxfa/parser/xfa_parser.h" |
26 #include "xfa/fxfa/parser/xfa_parser_imp.h" | |
23 | 27 |
24 CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider) | 28 CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider) |
25 : m_pDocProvider(pDocProvider), | 29 : m_pDocProvider(pDocProvider), |
26 m_pDocument(nullptr), | 30 m_pDocument(nullptr), |
27 m_pStream(nullptr), | 31 m_pStream(nullptr), |
28 m_pApp(pApp), | 32 m_pApp(pApp), |
29 m_pNotify(nullptr), | 33 m_pNotify(nullptr), |
30 m_pPDFDoc(nullptr), | 34 m_pPDFDoc(nullptr), |
31 m_dwDocType(XFA_DOCTYPE_Static), | 35 m_dwDocType(XFA_DOCTYPE_Static), |
32 m_bOwnStream(TRUE) {} | 36 m_bOwnStream(TRUE) {} |
33 CXFA_FFDoc::~CXFA_FFDoc() { | 37 CXFA_FFDoc::~CXFA_FFDoc() { |
34 CloseDoc(); | 38 CloseDoc(); |
35 } | 39 } |
36 uint32_t CXFA_FFDoc::GetDocType() { | 40 uint32_t CXFA_FFDoc::GetDocType() { |
37 return m_dwDocType; | 41 return m_dwDocType; |
38 } | 42 } |
39 int32_t CXFA_FFDoc::StartLoad() { | 43 int32_t CXFA_FFDoc::StartLoad() { |
40 m_pNotify = new CXFA_FFNotify(this); | 44 m_pNotify = new CXFA_FFNotify(this); |
41 IXFA_DocParser* pDocParser = IXFA_DocParser::Create(m_pNotify); | 45 CXFA_DocumentParser* pDocParser = new CXFA_DocumentParser(m_pNotify); |
42 int32_t iStatus = pDocParser->StartParse(m_pStream); | 46 int32_t iStatus = pDocParser->StartParse(m_pStream); |
43 m_pDocument = pDocParser->GetDocument(); | 47 m_pDocument = pDocParser->GetDocument(); |
44 return iStatus; | 48 return iStatus; |
45 } | 49 } |
46 FX_BOOL XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, | 50 FX_BOOL XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, |
47 uint8_t*& pByteBuffer, | 51 uint8_t*& pByteBuffer, |
48 int32_t& iBufferSize) { | 52 int32_t& iBufferSize) { |
49 CFDE_XMLElement* pDocumentElement = NULL; | 53 CFDE_XMLElement* pDocumentElement = NULL; |
50 for (CFDE_XMLNode* pXMLNode = | 54 for (CFDE_XMLNode* pXMLNode = |
51 pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild); | 55 pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 CXFA_Node* pDynamicRender = | 179 CXFA_Node* pDynamicRender = |
176 pAcrobat7->GetFirstChildByClass(XFA_ELEMENT_DynamicRender); | 180 pAcrobat7->GetFirstChildByClass(XFA_ELEMENT_DynamicRender); |
177 if (!pDynamicRender) { | 181 if (!pDynamicRender) { |
178 return; | 182 return; |
179 } | 183 } |
180 CFX_WideString wsType; | 184 CFX_WideString wsType; |
181 if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) { | 185 if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) { |
182 m_dwDocType = XFA_DOCTYPE_Dynamic; | 186 m_dwDocType = XFA_DOCTYPE_Dynamic; |
183 } | 187 } |
184 } | 188 } |
185 IXFA_DocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) { | 189 CXFA_FFDocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) { |
186 CXFA_FFDocView* pDocView = | 190 CXFA_FFDocView* pDocView = |
187 (CXFA_FFDocView*)m_mapTypeToDocView.GetValueAt((void*)(uintptr_t)dwView); | 191 (CXFA_FFDocView*)m_mapTypeToDocView.GetValueAt((void*)(uintptr_t)dwView); |
188 if (!pDocView) { | 192 if (!pDocView) { |
189 pDocView = new CXFA_FFDocView(this); | 193 pDocView = new CXFA_FFDocView(this); |
190 m_mapTypeToDocView.SetAt((void*)(uintptr_t)dwView, pDocView); | 194 m_mapTypeToDocView.SetAt((void*)(uintptr_t)dwView, pDocView); |
191 } | 195 } |
192 return pDocView; | 196 return pDocView; |
193 } | 197 } |
194 CXFA_FFDocView* CXFA_FFDoc::GetDocView(IXFA_DocLayout* pLayout) { | 198 CXFA_FFDocView* CXFA_FFDoc::GetDocView(CXFA_LayoutProcessor* pLayout) { |
195 FX_POSITION ps = m_mapTypeToDocView.GetStartPosition(); | 199 FX_POSITION ps = m_mapTypeToDocView.GetStartPosition(); |
196 while (ps) { | 200 while (ps) { |
197 void* pType; | 201 void* pType; |
198 CXFA_FFDocView* pDocView; | 202 CXFA_FFDocView* pDocView; |
199 m_mapTypeToDocView.GetNextAssoc(ps, pType, (void*&)pDocView); | 203 m_mapTypeToDocView.GetNextAssoc(ps, pType, (void*&)pDocView); |
200 if (pDocView->GetXFALayout() == pLayout) { | 204 if (pDocView->GetXFALayout() == pLayout) { |
201 return pDocView; | 205 return pDocView; |
202 } | 206 } |
203 } | 207 } |
204 return NULL; | 208 return NULL; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 if (!pNode) { | 390 if (!pNode) { |
387 return NULL; | 391 return NULL; |
388 } | 392 } |
389 CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); | 393 CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); |
390 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) | 394 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) |
391 ? static_cast<CFDE_XMLElement*>(pXMLNode) | 395 ? static_cast<CFDE_XMLElement*>(pXMLNode) |
392 : NULL; | 396 : NULL; |
393 } | 397 } |
394 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, | 398 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, |
395 IFX_FileWrite* pFile, | 399 IFX_FileWrite* pFile, |
396 IXFA_ChecksumContext* pCSContext) { | 400 CXFA_ChecksumContext* pCSContext) { |
397 IXFA_PacketExport* pExport = IXFA_PacketExport::Create(m_pDocument); | 401 CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument); |
398 if (!pExport) { | |
399 return FALSE; | |
400 } | |
401 uint32_t packetHash = | 402 uint32_t packetHash = |
402 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); | 403 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); |
403 CXFA_Node* pNode = NULL; | 404 CXFA_Node* pNode = NULL; |
404 if (packetHash == XFA_HASHCODE_Xfa) { | 405 if (packetHash == XFA_HASHCODE_Xfa) { |
405 pNode = m_pDocument->GetRoot(); | 406 pNode = m_pDocument->GetRoot(); |
406 } else { | 407 } else { |
407 pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); | 408 pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); |
408 } | 409 } |
409 FX_BOOL bFlags = FALSE; | 410 FX_BOOL bFlags = FALSE; |
410 if (pNode) { | 411 if (pNode) { |
411 CFX_ByteString bsChecksum; | 412 CFX_ByteString bsChecksum; |
412 if (pCSContext) { | 413 if (pCSContext) { |
413 pCSContext->GetChecksum(bsChecksum); | 414 pCSContext->GetChecksum(bsChecksum); |
414 } | 415 } |
415 bFlags = pExport->Export(pFile, pNode, 0, bsChecksum.GetLength() | 416 bFlags = pExport->Export(pFile, pNode, 0, bsChecksum.GetLength() |
416 ? (const FX_CHAR*)bsChecksum | 417 ? (const FX_CHAR*)bsChecksum |
417 : NULL); | 418 : NULL); |
418 } else { | 419 } else { |
419 bFlags = pExport->Export(pFile); | 420 bFlags = pExport->Export(pFile); |
420 } | 421 } |
421 pExport->Release(); | 422 pExport->Release(); |
422 return bFlags; | 423 return bFlags; |
423 } | 424 } |
424 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { | 425 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { |
425 FX_BOOL bRet = FALSE; | 426 FX_BOOL bRet = FALSE; |
426 IXFA_PacketImport* pImport = IXFA_PacketImport::Create(m_pDocument); | 427 CXFA_DataImporter* pImport = new CXFA_DataImporter(m_pDocument); |
Tom Sepez
2016/03/31 17:01:57
nit: if this were std::unique_ptr<..., ReleaseDele
dsinclair
2016/03/31 19:52:26
Done.
| |
427 if (pImport) { | 428 bRet = pImport->ImportData(pStream); |
Tom Sepez
2016/03/31 17:01:57
... then we could lose the bret local and just ret
dsinclair
2016/03/31 19:52:26
Done.
| |
428 bRet = pImport->ImportData(pStream); | 429 pImport->Release(); |
429 pImport->Release(); | |
430 } | |
431 return bRet; | 430 return bRet; |
432 } | 431 } |
OLD | NEW |