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

Side by Side Diff: core/fpdfdoc/doc_utils.cpp

Issue 1832173003: Remove FX_DWORD from core/ and delete definition (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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 | « core/fpdfdoc/doc_utils.h ('k') | core/fpdfdoc/doc_vt.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 <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 10 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h"
14 #include "core/fpdfdoc/doc_utils.h" 14 #include "core/fpdfdoc/doc_utils.h"
15 #include "core/include/fpdfdoc/fpdf_doc.h" 15 #include "core/include/fpdfdoc/fpdf_doc.h"
16 #include "core/include/fxge/fx_font.h" 16 #include "core/include/fxge/fx_font.h"
17 17
18 namespace { 18 namespace {
19 19
20 const int FPDFDOC_UTILS_MAXRECURSION = 32; 20 const int FPDFDOC_UTILS_MAXRECURSION = 32;
21 21
22 CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { 22 CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) {
23 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); 23 CPDF_Array* pLimits = pNode->GetArrayBy("Limits");
24 if (pLimits && 24 if (pLimits &&
25 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { 25 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) {
26 return NULL; 26 return NULL;
27 } 27 }
28 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); 28 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums");
29 if (pNumbers) { 29 if (pNumbers) {
30 FX_DWORD dwCount = pNumbers->GetCount() / 2; 30 uint32_t dwCount = pNumbers->GetCount() / 2;
31 for (FX_DWORD i = 0; i < dwCount; i++) { 31 for (uint32_t i = 0; i < dwCount; i++) {
32 int index = pNumbers->GetIntegerAt(i * 2); 32 int index = pNumbers->GetIntegerAt(i * 2);
33 if (num == index) { 33 if (num == index) {
34 return pNumbers->GetElementValue(i * 2 + 1); 34 return pNumbers->GetElementValue(i * 2 + 1);
35 } 35 }
36 if (index > num) { 36 if (index > num) {
37 break; 37 break;
38 } 38 }
39 } 39 }
40 return NULL; 40 return NULL;
41 } 41 }
42 CPDF_Array* pKids = pNode->GetArrayBy("Kids"); 42 CPDF_Array* pKids = pNode->GetArrayBy("Kids");
43 if (!pKids) { 43 if (!pKids) {
44 return NULL; 44 return NULL;
45 } 45 }
46 for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { 46 for (uint32_t i = 0; i < pKids->GetCount(); i++) {
47 CPDF_Dictionary* pKid = pKids->GetDictAt(i); 47 CPDF_Dictionary* pKid = pKids->GetDictAt(i);
48 if (!pKid) { 48 if (!pKid) {
49 continue; 49 continue;
50 } 50 }
51 CPDF_Object* pFound = SearchNumberNode(pKid, num); 51 CPDF_Object* pFound = SearchNumberNode(pKid, num);
52 if (pFound) { 52 if (pFound) {
53 return pFound; 53 return pFound;
54 } 54 }
55 } 55 }
56 return NULL; 56 return NULL;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 tm.Set(f[0], f[1], f[2], f[3], f[4], f[5]); 267 tm.Set(f[0], f[1], f[2], f[3], f[4], f[5]);
268 } 268 }
269 return tm; 269 return tm;
270 } 270 }
271 void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { 271 void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
272 if (!pDocument) { 272 if (!pDocument) {
273 return; 273 return;
274 } 274 }
275 if (!pFormDict) { 275 if (!pFormDict) {
276 pFormDict = new CPDF_Dictionary; 276 pFormDict = new CPDF_Dictionary;
277 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pFormDict); 277 uint32_t dwObjNum = pDocument->AddIndirectObject(pFormDict);
278 CPDF_Dictionary* pRoot = pDocument->GetRoot(); 278 CPDF_Dictionary* pRoot = pDocument->GetRoot();
279 pRoot->SetAtReference("AcroForm", pDocument, dwObjNum); 279 pRoot->SetAtReference("AcroForm", pDocument, dwObjNum);
280 } 280 }
281 CFX_ByteString csDA; 281 CFX_ByteString csDA;
282 if (!pFormDict->KeyExist("DR")) { 282 if (!pFormDict->KeyExist("DR")) {
283 CPDF_Font* pFont = NULL; 283 CPDF_Font* pFont = NULL;
284 CFX_ByteString csBaseName, csDefault; 284 CFX_ByteString csBaseName, csDefault;
285 uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); 285 uint8_t charSet = CPDF_InterForm::GetNativeCharSet();
286 pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); 286 pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica");
287 if (pFont) { 287 if (pFont) {
(...skipping 16 matching lines...) Expand all
304 } 304 }
305 } 305 }
306 if (!csDA.IsEmpty()) { 306 if (!csDA.IsEmpty()) {
307 csDA += " "; 307 csDA += " ";
308 } 308 }
309 csDA += "0 g"; 309 csDA += "0 g";
310 if (!pFormDict->KeyExist("DA")) { 310 if (!pFormDict->KeyExist("DA")) {
311 pFormDict->SetAtString("DA", csDA); 311 pFormDict->SetAtString("DA", csDA);
312 } 312 }
313 } 313 }
314 FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) { 314 uint32_t CountInterFormFonts(CPDF_Dictionary* pFormDict) {
315 if (!pFormDict) { 315 if (!pFormDict) {
316 return 0; 316 return 0;
317 } 317 }
318 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); 318 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR");
319 if (!pDR) { 319 if (!pDR) {
320 return 0; 320 return 0;
321 } 321 }
322 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); 322 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font");
323 if (!pFonts) { 323 if (!pFonts) {
324 return 0; 324 return 0;
325 } 325 }
326 FX_DWORD dwCount = 0; 326 uint32_t dwCount = 0;
327 for (const auto& it : *pFonts) { 327 for (const auto& it : *pFonts) {
328 CPDF_Object* pObj = it.second; 328 CPDF_Object* pObj = it.second;
329 if (!pObj) { 329 if (!pObj) {
330 continue; 330 continue;
331 } 331 }
332 if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) { 332 if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) {
333 if (pDirect->GetStringBy("Type") == "Font") { 333 if (pDirect->GetStringBy("Type") == "Font") {
334 dwCount++; 334 dwCount++;
335 } 335 }
336 } 336 }
337 } 337 }
338 return dwCount; 338 return dwCount;
339 } 339 }
340 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, 340 CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
341 CPDF_Document* pDocument, 341 CPDF_Document* pDocument,
342 FX_DWORD index, 342 uint32_t index,
343 CFX_ByteString& csNameTag) { 343 CFX_ByteString& csNameTag) {
344 if (!pFormDict) { 344 if (!pFormDict) {
345 return NULL; 345 return NULL;
346 } 346 }
347 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR"); 347 CPDF_Dictionary* pDR = pFormDict->GetDictBy("DR");
348 if (!pDR) { 348 if (!pDR) {
349 return NULL; 349 return NULL;
350 } 350 }
351 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font"); 351 CPDF_Dictionary* pFonts = pDR->GetDictBy("Font");
352 if (!pFonts) { 352 if (!pFonts) {
353 return NULL; 353 return NULL;
354 } 354 }
355 FX_DWORD dwCount = 0; 355 uint32_t dwCount = 0;
356 for (const auto& it : *pFonts) { 356 for (const auto& it : *pFonts) {
357 const CFX_ByteString& csKey = it.first; 357 const CFX_ByteString& csKey = it.first;
358 CPDF_Object* pObj = it.second; 358 CPDF_Object* pObj = it.second;
359 if (!pObj) { 359 if (!pObj) {
360 continue; 360 continue;
361 } 361 }
362 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); 362 CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
363 if (!pElement) 363 if (!pElement)
364 continue; 364 continue;
365 if (pElement->GetStringBy("Type") != "Font") 365 if (pElement->GetStringBy("Type") != "Font")
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 } 701 }
702 return m_pDict->GetStringBy("S", "P") != "A"; 702 return m_pDict->GetStringBy("S", "P") != "A";
703 } 703 }
704 void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { 704 void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
705 fLeft = fBottom = 0.5; 705 fLeft = fBottom = 0.5;
706 if (!m_pDict) { 706 if (!m_pDict) {
707 return; 707 return;
708 } 708 }
709 CPDF_Array* pA = m_pDict->GetArrayBy("A"); 709 CPDF_Array* pA = m_pDict->GetArrayBy("A");
710 if (pA) { 710 if (pA) {
711 FX_DWORD dwCount = pA->GetCount(); 711 uint32_t dwCount = pA->GetCount();
712 if (dwCount > 0) { 712 if (dwCount > 0) {
713 fLeft = pA->GetNumberAt(0); 713 fLeft = pA->GetNumberAt(0);
714 } 714 }
715 if (dwCount > 1) { 715 if (dwCount > 1) {
716 fBottom = pA->GetNumberAt(1); 716 fBottom = pA->GetNumberAt(1);
717 } 717 }
718 } 718 }
719 } 719 }
720 FX_BOOL CPDF_IconFit::GetFittingBounds() { 720 FX_BOOL CPDF_IconFit::GetFittingBounds() {
721 if (!m_pDict) { 721 if (!m_pDict) {
(...skipping 24 matching lines...) Expand all
746 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); 746 CPDF_Object* pAttr = pFieldDict->GetElementValue(name);
747 if (pAttr) { 747 if (pAttr) {
748 return pAttr; 748 return pAttr;
749 } 749 }
750 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent"); 750 CPDF_Dictionary* pParent = pFieldDict->GetDictBy("Parent");
751 if (!pParent) { 751 if (!pParent) {
752 return NULL; 752 return NULL;
753 } 753 }
754 return FPDF_GetFieldAttr(pParent, name, nLevel + 1); 754 return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
755 } 755 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_utils.h ('k') | core/fpdfdoc/doc_vt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698