Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: xfa/fxfa/app/xfa_ffdoc.cpp

Issue 1846993002: Remove IXFA_* interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_ffdoc.h ('k') | xfa/fxfa/app/xfa_ffdochandler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fxcrt/include/fx_memory.h"
12 #include "core/include/fpdfdoc/fpdf_doc.h" 13 #include "core/include/fpdfdoc/fpdf_doc.h"
13 #include "xfa/fde/xml/fde_xml_imp.h" 14 #include "xfa/fde/xml/fde_xml_imp.h"
14 #include "xfa/fgas/crt/fgas_algorithm.h" 15 #include "xfa/fgas/crt/fgas_algorithm.h"
15 #include "xfa/fwl/core/ifwl_notedriver.h" 16 #include "xfa/fwl/core/ifwl_notedriver.h"
16 #include "xfa/fxfa/app/xfa_ffapp.h"
17 #include "xfa/fxfa/app/xfa_ffdocview.h"
18 #include "xfa/fxfa/app/xfa_ffnotify.h" 17 #include "xfa/fxfa/app/xfa_ffnotify.h"
19 #include "xfa/fxfa/app/xfa_ffwidget.h" 18 #include "xfa/fxfa/app/xfa_ffwidget.h"
20 #include "xfa/fxfa/app/xfa_fontmgr.h"
21 #include "xfa/fxfa/parser/xfa_docdata.h" 19 #include "xfa/fxfa/parser/xfa_docdata.h"
20 #include "xfa/fxfa/parser/xfa_document_serialize.h"
22 #include "xfa/fxfa/parser/xfa_parser.h" 21 #include "xfa/fxfa/parser/xfa_parser.h"
22 #include "xfa/fxfa/parser/xfa_parser_imp.h"
23 #include "xfa/fxfa/parser/xfa_parser_imp.h"
24 #include "xfa/include/fxfa/xfa_checksum.h"
25 #include "xfa/include/fxfa/xfa_ffapp.h"
26 #include "xfa/include/fxfa/xfa_ffdocview.h"
27 #include "xfa/include/fxfa/xfa_fontmgr.h"
23 28
24 CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider) 29 CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider)
25 : m_pDocProvider(pDocProvider), 30 : m_pDocProvider(pDocProvider),
26 m_pDocument(nullptr), 31 m_pDocument(nullptr),
27 m_pStream(nullptr), 32 m_pStream(nullptr),
28 m_pApp(pApp), 33 m_pApp(pApp),
29 m_pNotify(nullptr), 34 m_pNotify(nullptr),
30 m_pPDFDoc(nullptr), 35 m_pPDFDoc(nullptr),
31 m_dwDocType(XFA_DOCTYPE_Static), 36 m_dwDocType(XFA_DOCTYPE_Static),
32 m_bOwnStream(TRUE) {} 37 m_bOwnStream(TRUE) {}
33 CXFA_FFDoc::~CXFA_FFDoc() { 38 CXFA_FFDoc::~CXFA_FFDoc() {
34 CloseDoc(); 39 CloseDoc();
35 } 40 }
36 uint32_t CXFA_FFDoc::GetDocType() { 41 uint32_t CXFA_FFDoc::GetDocType() {
37 return m_dwDocType; 42 return m_dwDocType;
38 } 43 }
39 int32_t CXFA_FFDoc::StartLoad() { 44 int32_t CXFA_FFDoc::StartLoad() {
40 m_pNotify = new CXFA_FFNotify(this); 45 m_pNotify = new CXFA_FFNotify(this);
41 IXFA_DocParser* pDocParser = IXFA_DocParser::Create(m_pNotify); 46 CXFA_DocumentParser* pDocParser = new CXFA_DocumentParser(m_pNotify);
42 int32_t iStatus = pDocParser->StartParse(m_pStream); 47 int32_t iStatus = pDocParser->StartParse(m_pStream);
43 m_pDocument = pDocParser->GetDocument(); 48 m_pDocument = pDocParser->GetDocument();
44 return iStatus; 49 return iStatus;
45 } 50 }
46 FX_BOOL XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, 51 FX_BOOL XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement,
47 uint8_t*& pByteBuffer, 52 uint8_t*& pByteBuffer,
48 int32_t& iBufferSize) { 53 int32_t& iBufferSize) {
49 CFDE_XMLElement* pDocumentElement = NULL; 54 CFDE_XMLElement* pDocumentElement = NULL;
50 for (CFDE_XMLNode* pXMLNode = 55 for (CFDE_XMLNode* pXMLNode =
51 pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild); 56 pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 CXFA_Node* pDynamicRender = 180 CXFA_Node* pDynamicRender =
176 pAcrobat7->GetFirstChildByClass(XFA_ELEMENT_DynamicRender); 181 pAcrobat7->GetFirstChildByClass(XFA_ELEMENT_DynamicRender);
177 if (!pDynamicRender) { 182 if (!pDynamicRender) {
178 return; 183 return;
179 } 184 }
180 CFX_WideString wsType; 185 CFX_WideString wsType;
181 if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) { 186 if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) {
182 m_dwDocType = XFA_DOCTYPE_Dynamic; 187 m_dwDocType = XFA_DOCTYPE_Dynamic;
183 } 188 }
184 } 189 }
185 IXFA_DocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) { 190 CXFA_FFDocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) {
186 CXFA_FFDocView* pDocView = 191 CXFA_FFDocView* pDocView =
187 (CXFA_FFDocView*)m_mapTypeToDocView.GetValueAt((void*)(uintptr_t)dwView); 192 (CXFA_FFDocView*)m_mapTypeToDocView.GetValueAt((void*)(uintptr_t)dwView);
188 if (!pDocView) { 193 if (!pDocView) {
189 pDocView = new CXFA_FFDocView(this); 194 pDocView = new CXFA_FFDocView(this);
190 m_mapTypeToDocView.SetAt((void*)(uintptr_t)dwView, pDocView); 195 m_mapTypeToDocView.SetAt((void*)(uintptr_t)dwView, pDocView);
191 } 196 }
192 return pDocView; 197 return pDocView;
193 } 198 }
194 CXFA_FFDocView* CXFA_FFDoc::GetDocView(IXFA_DocLayout* pLayout) { 199 CXFA_FFDocView* CXFA_FFDoc::GetDocView(CXFA_LayoutProcessor* pLayout) {
195 FX_POSITION ps = m_mapTypeToDocView.GetStartPosition(); 200 FX_POSITION ps = m_mapTypeToDocView.GetStartPosition();
196 while (ps) { 201 while (ps) {
197 void* pType; 202 void* pType;
198 CXFA_FFDocView* pDocView; 203 CXFA_FFDocView* pDocView;
199 m_mapTypeToDocView.GetNextAssoc(ps, pType, (void*&)pDocView); 204 m_mapTypeToDocView.GetNextAssoc(ps, pType, (void*&)pDocView);
200 if (pDocView->GetXFALayout() == pLayout) { 205 if (pDocView->GetXFALayout() == pLayout) {
201 return pDocView; 206 return pDocView;
202 } 207 }
203 } 208 }
204 return NULL; 209 return NULL;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 if (!pNode) { 391 if (!pNode) {
387 return NULL; 392 return NULL;
388 } 393 }
389 CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); 394 CFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode();
390 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) 395 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element)
391 ? static_cast<CFDE_XMLElement*>(pXMLNode) 396 ? static_cast<CFDE_XMLElement*>(pXMLNode)
392 : NULL; 397 : NULL;
393 } 398 }
394 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, 399 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage,
395 IFX_FileWrite* pFile, 400 IFX_FileWrite* pFile,
396 IXFA_ChecksumContext* pCSContext) { 401 CXFA_ChecksumContext* pCSContext) {
397 IXFA_PacketExport* pExport = IXFA_PacketExport::Create(m_pDocument); 402 CXFA_DataExporter* pExport = new CXFA_DataExporter(m_pDocument);
398 if (!pExport) {
399 return FALSE;
400 }
401 uint32_t packetHash = 403 uint32_t packetHash =
402 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); 404 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength());
403 CXFA_Node* pNode = NULL; 405 CXFA_Node* pNode = NULL;
404 if (packetHash == XFA_HASHCODE_Xfa) { 406 if (packetHash == XFA_HASHCODE_Xfa) {
405 pNode = m_pDocument->GetRoot(); 407 pNode = m_pDocument->GetRoot();
406 } else { 408 } else {
407 pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); 409 pNode = ToNode(m_pDocument->GetXFAObject(packetHash));
408 } 410 }
409 FX_BOOL bFlags = FALSE; 411 FX_BOOL bFlags = FALSE;
410 if (pNode) { 412 if (pNode) {
411 CFX_ByteString bsChecksum; 413 CFX_ByteString bsChecksum;
412 if (pCSContext) { 414 if (pCSContext) {
413 pCSContext->GetChecksum(bsChecksum); 415 pCSContext->GetChecksum(bsChecksum);
414 } 416 }
415 bFlags = pExport->Export(pFile, pNode, 0, bsChecksum.GetLength() 417 bFlags = pExport->Export(pFile, pNode, 0, bsChecksum.GetLength()
416 ? (const FX_CHAR*)bsChecksum 418 ? (const FX_CHAR*)bsChecksum
417 : NULL); 419 : NULL);
418 } else { 420 } else {
419 bFlags = pExport->Export(pFile); 421 bFlags = pExport->Export(pFile);
420 } 422 }
421 pExport->Release(); 423 pExport->Release();
422 return bFlags; 424 return bFlags;
423 } 425 }
424 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { 426 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) {
425 FX_BOOL bRet = FALSE; 427 std::unique_ptr<CXFA_DataImporter, ReleaseDeleter<CXFA_DataImporter>>
426 IXFA_PacketImport* pImport = IXFA_PacketImport::Create(m_pDocument); 428 importer(new CXFA_DataImporter(m_pDocument));
427 if (pImport) { 429
428 bRet = pImport->ImportData(pStream); 430 return importer->ImportData(pStream);
429 pImport->Release();
430 }
431 return bRet;
432 } 431 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffdoc.h ('k') | xfa/fxfa/app/xfa_ffdochandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698