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 "core/include/fpdfapi/fpdf_parser.h" | 7 #include "core/include/fpdfapi/fpdf_parser.h" |
8 | 8 |
9 #include "core/include/fxcrt/fx_ext.h" | 9 #include "core/include/fxcrt/fx_ext.h" |
10 | 10 |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 FX_FLOAT PDF_ClipFloat(FX_FLOAT f) { | 405 FX_FLOAT PDF_ClipFloat(FX_FLOAT f) { |
406 if (f < 0) { | 406 if (f < 0) { |
407 return 0; | 407 return 0; |
408 } | 408 } |
409 if (f > 1.0f) { | 409 if (f > 1.0f) { |
410 return 1.0f; | 410 return 1.0f; |
411 } | 411 } |
412 return f; | 412 return f; |
413 } | 413 } |
414 static CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) { | 414 static CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) { |
415 CPDF_Array* pLimits = pNode->GetArray("Limits"); | 415 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); |
416 if (pLimits && | 416 if (pLimits && |
417 (num < pLimits->GetInteger(0) || num > pLimits->GetInteger(1))) { | 417 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { |
418 return NULL; | 418 return NULL; |
419 } | 419 } |
420 CPDF_Array* pNumbers = pNode->GetArray("Nums"); | 420 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); |
421 if (pNumbers) { | 421 if (pNumbers) { |
422 FX_DWORD dwCount = pNumbers->GetCount() / 2; | 422 FX_DWORD dwCount = pNumbers->GetCount() / 2; |
423 for (FX_DWORD i = 0; i < dwCount; i++) { | 423 for (FX_DWORD i = 0; i < dwCount; i++) { |
424 int index = pNumbers->GetInteger(i * 2); | 424 int index = pNumbers->GetIntegerAt(i * 2); |
425 if (num == index) { | 425 if (num == index) { |
426 return pNumbers->GetElementValue(i * 2 + 1); | 426 return pNumbers->GetElementValue(i * 2 + 1); |
427 } | 427 } |
428 if (index > num) { | 428 if (index > num) { |
429 break; | 429 break; |
430 } | 430 } |
431 } | 431 } |
432 return NULL; | 432 return NULL; |
433 } | 433 } |
434 CPDF_Array* pKids = pNode->GetArray("Kids"); | 434 CPDF_Array* pKids = pNode->GetArrayBy("Kids"); |
435 if (!pKids) { | 435 if (!pKids) { |
436 return NULL; | 436 return NULL; |
437 } | 437 } |
438 for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { | 438 for (FX_DWORD i = 0; i < pKids->GetCount(); i++) { |
439 CPDF_Dictionary* pKid = pKids->GetDict(i); | 439 CPDF_Dictionary* pKid = pKids->GetDictAt(i); |
440 if (!pKid) { | 440 if (!pKid) { |
441 continue; | 441 continue; |
442 } | 442 } |
443 CPDF_Object* pFound = SearchNumberNode(pKid, num); | 443 CPDF_Object* pFound = SearchNumberNode(pKid, num); |
444 if (pFound) { | 444 if (pFound) { |
445 return pFound; | 445 return pFound; |
446 } | 446 } |
447 } | 447 } |
448 return NULL; | 448 return NULL; |
449 } | 449 } |
450 CPDF_Object* CPDF_NumberTree::LookupValue(int num) { | 450 CPDF_Object* CPDF_NumberTree::LookupValue(int num) { |
451 return SearchNumberNode(m_pRoot, num); | 451 return SearchNumberNode(m_pRoot, num); |
452 } | 452 } |
OLD | NEW |