OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/fpdfdoc/cpdf_pagelabel.h" | 7 #include "core/fpdfdoc/cpdf_pagelabel.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 | 115 |
116 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { | 116 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { |
117 if (!m_pDocument) | 117 if (!m_pDocument) |
118 return -1; | 118 return -1; |
119 | 119 |
120 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); | 120 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); |
121 if (!pPDFRoot) | 121 if (!pPDFRoot) |
122 return -1; | 122 return -1; |
123 | 123 |
| 124 // TOOD(dsinclair): Verify this works for XFA pages. |
124 int nPages = m_pDocument->GetPageCount(); | 125 int nPages = m_pDocument->GetPageCount(); |
125 for (int i = 0; i < nPages; i++) { | 126 for (int i = 0; i < nPages; i++) { |
126 if (PDF_EncodeText(GetLabel(i)).Compare(bsLabel)) | 127 if (PDF_EncodeText(GetLabel(i)).Compare(bsLabel)) |
127 return i; | 128 return i; |
128 } | 129 } |
129 | 130 |
130 int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate. | 131 int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate. |
131 return nPage > 0 && nPage <= nPages ? nPage : -1; | 132 return nPage > 0 && nPage <= nPages ? nPage : -1; |
132 } | 133 } |
133 | 134 |
134 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { | 135 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { |
135 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC()); | 136 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC()); |
136 } | 137 } |
OLD | NEW |