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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 buf << "\r\nendstream"; | 356 buf << "\r\nendstream"; |
357 break; | 357 break; |
358 } | 358 } |
359 default: | 359 default: |
360 ASSERT(FALSE); | 360 ASSERT(FALSE); |
361 break; | 361 break; |
362 } | 362 } |
363 return buf; | 363 return buf; |
364 } | 364 } |
365 | 365 |
366 FX_FLOAT PDF_ClipFloat(FX_FLOAT f) { | |
367 if (f < 0) { | |
368 return 0; | |
369 } | |
370 if (f > 1.0f) { | |
371 return 1.0f; | |
372 } | |
373 return f; | |
374 } | |
375 | |
376 static CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) { | 366 static CPDF_Object* SearchNumberNode(CPDF_Dictionary* pNode, int num) { |
377 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); | 367 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); |
378 if (pLimits && | 368 if (pLimits && |
379 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { | 369 (num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) { |
380 return NULL; | 370 return NULL; |
381 } | 371 } |
382 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); | 372 CPDF_Array* pNumbers = pNode->GetArrayBy("Nums"); |
383 if (pNumbers) { | 373 if (pNumbers) { |
384 FX_DWORD dwCount = pNumbers->GetCount() / 2; | 374 FX_DWORD dwCount = pNumbers->GetCount() / 2; |
385 for (FX_DWORD i = 0; i < dwCount; i++) { | 375 for (FX_DWORD i = 0; i < dwCount; i++) { |
(...skipping 20 matching lines...) Expand all Loading... |
406 if (pFound) { | 396 if (pFound) { |
407 return pFound; | 397 return pFound; |
408 } | 398 } |
409 } | 399 } |
410 return NULL; | 400 return NULL; |
411 } | 401 } |
412 | 402 |
413 CPDF_Object* CPDF_NumberTree::LookupValue(int num) { | 403 CPDF_Object* CPDF_NumberTree::LookupValue(int num) { |
414 return SearchNumberNode(m_pRoot, num); | 404 return SearchNumberNode(m_pRoot, num); |
415 } | 405 } |
OLD | NEW |