| 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/fpdfapi/fpdf_parser/include/cpdf_array.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 9 #include "core/fpdfdoc/doc_utils.h" | 9 #include "core/fpdfdoc/doc_utils.h" |
| 10 #include "core/include/fpdfdoc/fpdf_doc.h" | 10 #include "core/include/fpdfdoc/fpdf_doc.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 int& nIndex, | 83 int& nIndex, |
| 84 CPDF_Array** ppFind, | 84 CPDF_Array** ppFind, |
| 85 int nLevel = 0) { | 85 int nLevel = 0) { |
| 86 if (nLevel > nMaxRecursion) { | 86 if (nLevel > nMaxRecursion) { |
| 87 return NULL; | 87 return NULL; |
| 88 } | 88 } |
| 89 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); | 89 CPDF_Array* pLimits = pNode->GetArrayBy("Limits"); |
| 90 if (pLimits) { | 90 if (pLimits) { |
| 91 CFX_ByteString csLeft = pLimits->GetStringAt(0); | 91 CFX_ByteString csLeft = pLimits->GetStringAt(0); |
| 92 CFX_ByteString csRight = pLimits->GetStringAt(1); | 92 CFX_ByteString csRight = pLimits->GetStringAt(1); |
| 93 if (csLeft.Compare(csRight) > 0) { | 93 if (csLeft.Compare(csRight.AsByteStringC()) > 0) { |
| 94 CFX_ByteString csTmp = csRight; | 94 CFX_ByteString csTmp = csRight; |
| 95 csRight = csLeft; | 95 csRight = csLeft; |
| 96 csLeft = csTmp; | 96 csLeft = csTmp; |
| 97 } | 97 } |
| 98 if (csName.Compare(csLeft) < 0 || csName.Compare(csRight) > 0) { | 98 if (csName.Compare(csLeft.AsByteStringC()) < 0 || |
| 99 csName.Compare(csRight.AsByteStringC()) > 0) { |
| 99 return NULL; | 100 return NULL; |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 CPDF_Array* pNames = pNode->GetArrayBy("Names"); | 103 CPDF_Array* pNames = pNode->GetArrayBy("Names"); |
| 103 if (pNames) { | 104 if (pNames) { |
| 104 uint32_t dwCount = pNames->GetCount() / 2; | 105 uint32_t dwCount = pNames->GetCount() / 2; |
| 105 for (uint32_t i = 0; i < dwCount; i++) { | 106 for (uint32_t i = 0; i < dwCount; i++) { |
| 106 CFX_ByteString csValue = pNames->GetStringAt(i * 2); | 107 CFX_ByteString csValue = pNames->GetStringAt(i * 2); |
| 107 int32_t iCompare = csValue.Compare(csName); | 108 int32_t iCompare = csValue.Compare(csName.AsByteStringC()); |
| 108 if (iCompare <= 0) { | 109 if (iCompare <= 0) { |
| 109 if (ppFind) { | 110 if (ppFind) { |
| 110 *ppFind = pNames; | 111 *ppFind = pNames; |
| 111 } | 112 } |
| 112 if (iCompare < 0) { | 113 if (iCompare < 0) { |
| 113 continue; | 114 continue; |
| 114 } | 115 } |
| 115 } else { | 116 } else { |
| 116 break; | 117 break; |
| 117 } | 118 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 } | 494 } |
| 494 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); | 495 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); |
| 495 if (!pPDFRoot) { | 496 if (!pPDFRoot) { |
| 496 return -1; | 497 return -1; |
| 497 } | 498 } |
| 498 int nPages = m_pDocument->GetPageCount(); | 499 int nPages = m_pDocument->GetPageCount(); |
| 499 CFX_ByteString bsLbl; | 500 CFX_ByteString bsLbl; |
| 500 CFX_ByteString bsOrig = bsLabel; | 501 CFX_ByteString bsOrig = bsLabel; |
| 501 for (int i = 0; i < nPages; i++) { | 502 for (int i = 0; i < nPages; i++) { |
| 502 bsLbl = PDF_EncodeText(GetLabel(i)); | 503 bsLbl = PDF_EncodeText(GetLabel(i)); |
| 503 if (!bsLbl.Compare(bsOrig)) { | 504 if (!bsLbl.Compare(bsOrig.AsByteStringC())) { |
| 504 return i; | 505 return i; |
| 505 } | 506 } |
| 506 } | 507 } |
| 507 bsLbl = bsOrig; | 508 bsLbl = bsOrig; |
| 508 int nPage = FXSYS_atoi(bsLbl); | 509 int nPage = FXSYS_atoi(bsLbl); |
| 509 if (nPage > 0 && nPage <= nPages) { | 510 if (nPage > 0 && nPage <= nPages) { |
| 510 return nPage; | 511 return nPage; |
| 511 } | 512 } |
| 512 return -1; | 513 return -1; |
| 513 } | 514 } |
| 514 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { | 515 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { |
| 515 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr()); | 516 return GetPageByLabel(PDF_EncodeText(wsLabel.GetPtr()).AsByteStringC()); |
| 516 return GetPageByLabel(bsLabel); | |
| 517 } | 517 } |
| OLD | NEW |