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

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

Issue 1977093002: Make CFX_ByteString(const CFX_ByteStringC&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nit Created 4 years, 7 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_action.cpp ('k') | core/fpdfdoc/doc_bookmark.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 "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/fpdfdoc/include/fpdf_doc.h" 10 #include "core/fpdfdoc/include/fpdf_doc.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 int nLabelNum = nPage - n + pLabel->GetIntegerBy("St", 1); 493 int nLabelNum = nPage - n + pLabel->GetIntegerBy("St", 1);
494 CFX_WideString wsNumPortion = 494 CFX_WideString wsNumPortion =
495 _GetLabelNumPortion(nLabelNum, bsNumberingStyle); 495 _GetLabelNumPortion(nLabelNum, bsNumberingStyle);
496 wsLabel += wsNumPortion; 496 wsLabel += wsNumPortion;
497 return wsLabel; 497 return wsLabel;
498 } 498 }
499 } 499 }
500 wsLabel.Format(L"%d", nPage + 1); 500 wsLabel.Format(L"%d", nPage + 1);
501 return wsLabel; 501 return wsLabel;
502 } 502 }
503
503 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const { 504 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
504 if (!m_pDocument) { 505 if (!m_pDocument)
505 return -1; 506 return -1;
507
508 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
509 if (!pPDFRoot)
510 return -1;
511
512 int nPages = m_pDocument->GetPageCount();
513 for (int i = 0; i < nPages; i++) {
514 if (PDF_EncodeText(GetLabel(i)).Compare(bsLabel))
515 return i;
506 } 516 }
507 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); 517
508 if (!pPDFRoot) { 518 int nPage = FXSYS_atoi(CFX_ByteString(bsLabel).c_str()); // NUL terminate.
509 return -1; 519 return nPage > 0 && nPage <= nPages ? nPage : -1;
510 }
511 int nPages = m_pDocument->GetPageCount();
512 CFX_ByteString bsLbl;
513 CFX_ByteString bsOrig = bsLabel;
514 for (int i = 0; i < nPages; i++) {
515 bsLbl = PDF_EncodeText(GetLabel(i));
516 if (!bsLbl.Compare(bsOrig.AsStringC())) {
517 return i;
518 }
519 }
520 bsLbl = bsOrig;
521 int nPage = FXSYS_atoi(bsLbl.c_str());
522 if (nPage > 0 && nPage <= nPages) {
523 return nPage;
524 }
525 return -1;
526 } 520 }
521
527 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { 522 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
528 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC()); 523 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC());
529 } 524 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_action.cpp ('k') | core/fpdfdoc/doc_bookmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698