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

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

Issue 1830323006: Remove FX_DWORD from XFA. (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_ffchoicelist.cpp ('k') | xfa/fxfa/app/xfa_ffdochandler.cpp » ('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/fxfa/app/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 14 matching lines...) Expand all
25 m_pDocument(nullptr), 25 m_pDocument(nullptr),
26 m_pStream(nullptr), 26 m_pStream(nullptr),
27 m_pApp(pApp), 27 m_pApp(pApp),
28 m_pNotify(nullptr), 28 m_pNotify(nullptr),
29 m_pPDFDoc(nullptr), 29 m_pPDFDoc(nullptr),
30 m_dwDocType(XFA_DOCTYPE_Static), 30 m_dwDocType(XFA_DOCTYPE_Static),
31 m_bOwnStream(TRUE) {} 31 m_bOwnStream(TRUE) {}
32 CXFA_FFDoc::~CXFA_FFDoc() { 32 CXFA_FFDoc::~CXFA_FFDoc() {
33 CloseDoc(); 33 CloseDoc();
34 } 34 }
35 FX_DWORD CXFA_FFDoc::GetDocType() { 35 uint32_t CXFA_FFDoc::GetDocType() {
36 return m_dwDocType; 36 return m_dwDocType;
37 } 37 }
38 int32_t CXFA_FFDoc::StartLoad() { 38 int32_t CXFA_FFDoc::StartLoad() {
39 m_pNotify = new CXFA_FFNotify(this); 39 m_pNotify = new CXFA_FFNotify(this);
40 IXFA_DocParser* pDocParser = IXFA_DocParser::Create(m_pNotify); 40 IXFA_DocParser* pDocParser = IXFA_DocParser::Create(m_pNotify);
41 int32_t iStatus = pDocParser->StartParse(m_pStream); 41 int32_t iStatus = pDocParser->StartParse(m_pStream);
42 m_pDocument = pDocParser->GetDocument(); 42 m_pDocument = pDocParser->GetDocument();
43 return iStatus; 43 return iStatus;
44 } 44 }
45 FX_BOOL XFA_GetPDFContentsFromPDFXML(IFDE_XMLNode* pPDFElement, 45 FX_BOOL XFA_GetPDFContentsFromPDFXML(IFDE_XMLNode* pPDFElement,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 CXFA_Node* pDynamicRender = 174 CXFA_Node* pDynamicRender =
175 pAcrobat7->GetFirstChildByClass(XFA_ELEMENT_DynamicRender); 175 pAcrobat7->GetFirstChildByClass(XFA_ELEMENT_DynamicRender);
176 if (!pDynamicRender) { 176 if (!pDynamicRender) {
177 return; 177 return;
178 } 178 }
179 CFX_WideString wsType; 179 CFX_WideString wsType;
180 if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) { 180 if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) {
181 m_dwDocType = XFA_DOCTYPE_Dynamic; 181 m_dwDocType = XFA_DOCTYPE_Dynamic;
182 } 182 }
183 } 183 }
184 IXFA_DocView* CXFA_FFDoc::CreateDocView(FX_DWORD dwView) { 184 IXFA_DocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) {
185 CXFA_FFDocView* pDocView = 185 CXFA_FFDocView* pDocView =
186 (CXFA_FFDocView*)m_mapTypeToDocView.GetValueAt((void*)(uintptr_t)dwView); 186 (CXFA_FFDocView*)m_mapTypeToDocView.GetValueAt((void*)(uintptr_t)dwView);
187 if (!pDocView) { 187 if (!pDocView) {
188 pDocView = new CXFA_FFDocView(this); 188 pDocView = new CXFA_FFDocView(this);
189 m_mapTypeToDocView.SetAt((void*)(uintptr_t)dwView, pDocView); 189 m_mapTypeToDocView.SetAt((void*)(uintptr_t)dwView, pDocView);
190 } 190 }
191 return pDocView; 191 return pDocView;
192 } 192 }
193 CXFA_FFDocView* CXFA_FFDoc::GetDocView(IXFA_DocLayout* pLayout) { 193 CXFA_FFDocView* CXFA_FFDoc::GetDocView(IXFA_DocLayout* pLayout) {
194 FX_POSITION ps = m_mapTypeToDocView.GetStartPosition(); 194 FX_POSITION ps = m_mapTypeToDocView.GetStartPosition();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (pAcroForm == NULL) { 229 if (pAcroForm == NULL) {
230 return FALSE; 230 return FALSE;
231 } 231 }
232 CPDF_Object* pElementXFA = pAcroForm->GetElementValue("XFA"); 232 CPDF_Object* pElementXFA = pAcroForm->GetElementValue("XFA");
233 if (pElementXFA == NULL) { 233 if (pElementXFA == NULL) {
234 return FALSE; 234 return FALSE;
235 } 235 }
236 CFX_ArrayTemplate<CPDF_Stream*> xfaStreams; 236 CFX_ArrayTemplate<CPDF_Stream*> xfaStreams;
237 if (pElementXFA->IsArray()) { 237 if (pElementXFA->IsArray()) {
238 CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA; 238 CPDF_Array* pXFAArray = (CPDF_Array*)pElementXFA;
239 FX_DWORD count = pXFAArray->GetCount() / 2; 239 uint32_t count = pXFAArray->GetCount() / 2;
240 for (FX_DWORD i = 0; i < count; i++) { 240 for (uint32_t i = 0; i < count; i++) {
241 if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) 241 if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1))
242 xfaStreams.Add(pStream); 242 xfaStreams.Add(pStream);
243 } 243 }
244 } else if (pElementXFA->IsStream()) { 244 } else if (pElementXFA->IsStream()) {
245 xfaStreams.Add((CPDF_Stream*)pElementXFA); 245 xfaStreams.Add((CPDF_Stream*)pElementXFA);
246 } 246 }
247 if (xfaStreams.GetSize() < 1) { 247 if (xfaStreams.GetSize() < 1) {
248 return FALSE; 248 return FALSE;
249 } 249 }
250 IFX_FileRead* pFileRead = new CXFA_FileRead(xfaStreams); 250 IFX_FileRead* pFileRead = new CXFA_FileRead(xfaStreams);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 pImage->pDibSource = NULL; 300 pImage->pDibSource = NULL;
301 FX_Free(pImage); 301 FX_Free(pImage);
302 pImage = NULL; 302 pImage = NULL;
303 } 303 }
304 } 304 }
305 m_mapNamedImages.RemoveAll(); 305 m_mapNamedImages.RemoveAll();
306 IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); 306 IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
307 pNoteDriver->ClearEventTargets(FALSE); 307 pNoteDriver->ClearEventTargets(FALSE);
308 return TRUE; 308 return TRUE;
309 } 309 }
310 void CXFA_FFDoc::SetDocType(FX_DWORD dwType) { 310 void CXFA_FFDoc::SetDocType(uint32_t dwType) {
311 m_dwDocType = dwType; 311 m_dwDocType = dwType;
312 } 312 }
313 CPDF_Document* CXFA_FFDoc::GetPDFDoc() { 313 CPDF_Document* CXFA_FFDoc::GetPDFDoc() {
314 return m_pPDFDoc; 314 return m_pPDFDoc;
315 } 315 }
316 316
317 CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName, 317 CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
318 int32_t& iImageXDpi, 318 int32_t& iImageXDpi,
319 int32_t& iImageYDpi) { 319 int32_t& iImageYDpi) {
320 if (!m_pPDFDoc) 320 if (!m_pPDFDoc)
321 return nullptr; 321 return nullptr;
322 322
323 FX_DWORD dwHash = 323 uint32_t dwHash =
324 FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), FALSE); 324 FX_HashCode_String_GetW(wsName.GetPtr(), wsName.GetLength(), FALSE);
325 FX_IMAGEDIB_AND_DPI* imageDIBDpi = nullptr; 325 FX_IMAGEDIB_AND_DPI* imageDIBDpi = nullptr;
326 if (m_mapNamedImages.Lookup((void*)(uintptr_t)dwHash, (void*&)imageDIBDpi)) { 326 if (m_mapNamedImages.Lookup((void*)(uintptr_t)dwHash, (void*&)imageDIBDpi)) {
327 iImageXDpi = imageDIBDpi->iImageXDpi; 327 iImageXDpi = imageDIBDpi->iImageXDpi;
328 iImageYDpi = imageDIBDpi->iImageYDpi; 328 iImageYDpi = imageDIBDpi->iImageYDpi;
329 return static_cast<CFX_DIBitmap*>(imageDIBDpi->pDibSource); 329 return static_cast<CFX_DIBitmap*>(imageDIBDpi->pDibSource);
330 } 330 }
331 331
332 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); 332 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
333 if (!pRoot) 333 if (!pRoot)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi); 372 pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
373 imageDIBDpi->iImageXDpi = iImageXDpi; 373 imageDIBDpi->iImageXDpi = iImageXDpi;
374 imageDIBDpi->iImageYDpi = iImageYDpi; 374 imageDIBDpi->iImageYDpi = iImageYDpi;
375 pImageFileRead->Release(); 375 pImageFileRead->Release();
376 } 376 }
377 m_mapNamedImages.SetAt((void*)(uintptr_t)dwHash, imageDIBDpi); 377 m_mapNamedImages.SetAt((void*)(uintptr_t)dwHash, imageDIBDpi);
378 return (CFX_DIBitmap*)imageDIBDpi->pDibSource; 378 return (CFX_DIBitmap*)imageDIBDpi->pDibSource;
379 } 379 }
380 380
381 IFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) { 381 IFDE_XMLElement* CXFA_FFDoc::GetPackageData(const CFX_WideStringC& wsPackage) {
382 FX_DWORD packetHash = 382 uint32_t packetHash =
383 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); 383 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength());
384 CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); 384 CXFA_Node* pNode = ToNode(m_pDocument->GetXFAObject(packetHash));
385 if (!pNode) { 385 if (!pNode) {
386 return NULL; 386 return NULL;
387 } 387 }
388 IFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode(); 388 IFDE_XMLNode* pXMLNode = pNode->GetXMLMappingNode();
389 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) 389 return (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element)
390 ? (IFDE_XMLElement*)pXMLNode 390 ? (IFDE_XMLElement*)pXMLNode
391 : NULL; 391 : NULL;
392 } 392 }
393 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage, 393 FX_BOOL CXFA_FFDoc::SavePackage(const CFX_WideStringC& wsPackage,
394 IFX_FileWrite* pFile, 394 IFX_FileWrite* pFile,
395 IXFA_ChecksumContext* pCSContext) { 395 IXFA_ChecksumContext* pCSContext) {
396 IXFA_PacketExport* pExport = IXFA_PacketExport::Create(m_pDocument); 396 IXFA_PacketExport* pExport = IXFA_PacketExport::Create(m_pDocument);
397 if (!pExport) { 397 if (!pExport) {
398 return FALSE; 398 return FALSE;
399 } 399 }
400 FX_DWORD packetHash = 400 uint32_t packetHash =
401 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength()); 401 FX_HashCode_String_GetW(wsPackage.GetPtr(), wsPackage.GetLength());
402 CXFA_Node* pNode = NULL; 402 CXFA_Node* pNode = NULL;
403 if (packetHash == XFA_HASHCODE_Xfa) { 403 if (packetHash == XFA_HASHCODE_Xfa) {
404 pNode = m_pDocument->GetRoot(); 404 pNode = m_pDocument->GetRoot();
405 } else { 405 } else {
406 pNode = ToNode(m_pDocument->GetXFAObject(packetHash)); 406 pNode = ToNode(m_pDocument->GetXFAObject(packetHash));
407 } 407 }
408 FX_BOOL bFlags = FALSE; 408 FX_BOOL bFlags = FALSE;
409 if (pNode) { 409 if (pNode) {
410 CFX_ByteString bsChecksum; 410 CFX_ByteString bsChecksum;
(...skipping 11 matching lines...) Expand all
422 } 422 }
423 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) { 423 FX_BOOL CXFA_FFDoc::ImportData(IFX_FileRead* pStream, FX_BOOL bXDP) {
424 FX_BOOL bRet = FALSE; 424 FX_BOOL bRet = FALSE;
425 IXFA_PacketImport* pImport = IXFA_PacketImport::Create(m_pDocument); 425 IXFA_PacketImport* pImport = IXFA_PacketImport::Create(m_pDocument);
426 if (pImport) { 426 if (pImport) {
427 bRet = pImport->ImportData(pStream); 427 bRet = pImport->ImportData(pStream);
428 pImport->Release(); 428 pImport->Release();
429 } 429 }
430 return bRet; 430 return bRet;
431 } 431 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffchoicelist.cpp ('k') | xfa/fxfa/app/xfa_ffdochandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698