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

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

Issue 1862123003: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, fix new usage. Created 4 years, 8 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_annot.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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.AsByteStringC()) > 0) { 93 if (csLeft.Compare(csRight.AsStringC()) > 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.AsByteStringC()) < 0 || 98 if (csName.Compare(csLeft.AsStringC()) < 0 ||
99 csName.Compare(csRight.AsByteStringC()) > 0) { 99 csName.Compare(csRight.AsStringC()) > 0) {
100 return NULL; 100 return NULL;
101 } 101 }
102 } 102 }
103 CPDF_Array* pNames = pNode->GetArrayBy("Names"); 103 CPDF_Array* pNames = pNode->GetArrayBy("Names");
104 if (pNames) { 104 if (pNames) {
105 uint32_t dwCount = pNames->GetCount() / 2; 105 uint32_t dwCount = pNames->GetCount() / 2;
106 for (uint32_t i = 0; i < dwCount; i++) { 106 for (uint32_t i = 0; i < dwCount; i++) {
107 CFX_ByteString csValue = pNames->GetStringAt(i * 2); 107 CFX_ByteString csValue = pNames->GetStringAt(i * 2);
108 int32_t iCompare = csValue.Compare(csName.AsByteStringC()); 108 int32_t iCompare = csValue.Compare(csName.AsStringC());
109 if (iCompare <= 0) { 109 if (iCompare <= 0) {
110 if (ppFind) { 110 if (ppFind) {
111 *ppFind = pNames; 111 *ppFind = pNames;
112 } 112 }
113 if (iCompare < 0) { 113 if (iCompare < 0) {
114 continue; 114 continue;
115 } 115 }
116 } else { 116 } else {
117 break; 117 break;
118 } 118 }
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const { 314 bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const {
315 if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { 315 if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) {
316 *csFileName = pDict->GetUnicodeTextBy("UF"); 316 *csFileName = pDict->GetUnicodeTextBy("UF");
317 if (csFileName->IsEmpty()) { 317 if (csFileName->IsEmpty()) {
318 *csFileName = CFX_WideString::FromLocal(pDict->GetConstStringBy("F")); 318 *csFileName = CFX_WideString::FromLocal(pDict->GetConstStringBy("F"));
319 } 319 }
320 if (pDict->GetStringBy("FS") == "URL") 320 if (pDict->GetStringBy("FS") == "URL")
321 return true; 321 return true;
322 if (csFileName->IsEmpty()) { 322 if (csFileName->IsEmpty()) {
323 if (pDict->KeyExist("DOS")) { 323 if (pDict->KeyExist("DOS")) {
324 *csFileName = CFX_WideString::FromLocal( 324 *csFileName =
325 pDict->GetStringBy("DOS").AsByteStringC()); 325 CFX_WideString::FromLocal(pDict->GetStringBy("DOS").AsStringC());
326 } else if (pDict->KeyExist("Mac")) { 326 } else if (pDict->KeyExist("Mac")) {
327 *csFileName = CFX_WideString::FromLocal( 327 *csFileName =
328 pDict->GetStringBy("Mac").AsByteStringC()); 328 CFX_WideString::FromLocal(pDict->GetStringBy("Mac").AsStringC());
329 } else if (pDict->KeyExist("Unix")) { 329 } else if (pDict->KeyExist("Unix")) {
330 *csFileName = CFX_WideString::FromLocal( 330 *csFileName =
331 pDict->GetStringBy("Unix").AsByteStringC()); 331 CFX_WideString::FromLocal(pDict->GetStringBy("Unix").AsStringC());
332 } else { 332 } else {
333 return false; 333 return false;
334 } 334 }
335 } 335 }
336 } else if (m_pObj->IsString()) { 336 } else if (m_pObj->IsString()) {
337 *csFileName = 337 *csFileName = CFX_WideString::FromLocal(m_pObj->GetString().AsStringC());
338 CFX_WideString::FromLocal(m_pObj->GetString().AsByteStringC());
339 } else { 338 } else {
340 return false; 339 return false;
341 } 340 }
342 *csFileName = DecodeFileName(csFileName->AsWideStringC()); 341 *csFileName = DecodeFileName(csFileName->AsStringC());
343 return true; 342 return true;
344 } 343 }
345 344
346 CPDF_FileSpec::CPDF_FileSpec() { 345 CPDF_FileSpec::CPDF_FileSpec() {
347 m_pObj = new CPDF_Dictionary; 346 m_pObj = new CPDF_Dictionary;
348 m_pObj->AsDictionary()->SetAtName("Type", "Filespec"); 347 m_pObj->AsDictionary()->SetAtName("Type", "Filespec");
349 } 348 }
350 349
351 CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) { 350 CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) {
352 if (filepath.GetLength() <= 1) { 351 if (filepath.GetLength() <= 1) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 497 }
499 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot(); 498 CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
500 if (!pPDFRoot) { 499 if (!pPDFRoot) {
501 return -1; 500 return -1;
502 } 501 }
503 int nPages = m_pDocument->GetPageCount(); 502 int nPages = m_pDocument->GetPageCount();
504 CFX_ByteString bsLbl; 503 CFX_ByteString bsLbl;
505 CFX_ByteString bsOrig = bsLabel; 504 CFX_ByteString bsOrig = bsLabel;
506 for (int i = 0; i < nPages; i++) { 505 for (int i = 0; i < nPages; i++) {
507 bsLbl = PDF_EncodeText(GetLabel(i)); 506 bsLbl = PDF_EncodeText(GetLabel(i));
508 if (!bsLbl.Compare(bsOrig.AsByteStringC())) { 507 if (!bsLbl.Compare(bsOrig.AsStringC())) {
509 return i; 508 return i;
510 } 509 }
511 } 510 }
512 bsLbl = bsOrig; 511 bsLbl = bsOrig;
513 int nPage = FXSYS_atoi(bsLbl); 512 int nPage = FXSYS_atoi(bsLbl);
514 if (nPage > 0 && nPage <= nPages) { 513 if (nPage > 0 && nPage <= nPages) {
515 return nPage; 514 return nPage;
516 } 515 }
517 return -1; 516 return -1;
518 } 517 }
519 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { 518 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
520 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsByteStringC()); 519 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsStringC());
521 } 520 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_annot.cpp ('k') | core/fpdfdoc/doc_bookmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698