Chromium Code Reviews| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 return result; | 308 return result; |
| 309 #else | 309 #else |
| 310 return filepath; | 310 return filepath; |
| 311 #endif | 311 #endif |
| 312 } | 312 } |
| 313 | 313 |
| 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->GetStringBy("F")); | 318 *csFileName = |
| 319 CFX_WideString::FromLocal(pDict->GetStringBy("F").AsByteStringC()); | |
|
Lei Zhang
2016/04/07 19:21:59
Use GetConstStringBy() instead?
Tom Sepez
2016/04/08 15:47:29
Done.
| |
| 319 } | 320 } |
| 320 if (pDict->GetStringBy("FS") == "URL") | 321 if (pDict->GetStringBy("FS") == "URL") |
| 321 return true; | 322 return true; |
| 322 if (csFileName->IsEmpty()) { | 323 if (csFileName->IsEmpty()) { |
| 323 if (pDict->KeyExist("DOS")) { | 324 if (pDict->KeyExist("DOS")) { |
| 324 *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("DOS")); | 325 *csFileName = CFX_WideString::FromLocal( |
| 326 pDict->GetStringBy("DOS").AsByteStringC()); | |
| 325 } else if (pDict->KeyExist("Mac")) { | 327 } else if (pDict->KeyExist("Mac")) { |
| 326 *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("Mac")); | 328 *csFileName = CFX_WideString::FromLocal( |
| 329 pDict->GetStringBy("Mac").AsByteStringC()); | |
| 327 } else if (pDict->KeyExist("Unix")) { | 330 } else if (pDict->KeyExist("Unix")) { |
| 328 *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("Unix")); | 331 *csFileName = CFX_WideString::FromLocal( |
| 332 pDict->GetStringBy("Unix").AsByteStringC()); | |
| 329 } else { | 333 } else { |
| 330 return false; | 334 return false; |
| 331 } | 335 } |
| 332 } | 336 } |
| 333 } else if (m_pObj->IsString()) { | 337 } else if (m_pObj->IsString()) { |
| 334 *csFileName = CFX_WideString::FromLocal(m_pObj->GetString()); | 338 *csFileName = |
| 339 CFX_WideString::FromLocal(m_pObj->GetString().AsByteStringC()); | |
| 335 } else { | 340 } else { |
| 336 return false; | 341 return false; |
| 337 } | 342 } |
| 338 *csFileName = DecodeFileName(csFileName->AsWideStringC()); | 343 *csFileName = DecodeFileName(csFileName->AsWideStringC()); |
| 339 return true; | 344 return true; |
| 340 } | 345 } |
| 341 | 346 |
| 342 CPDF_FileSpec::CPDF_FileSpec() { | 347 CPDF_FileSpec::CPDF_FileSpec() { |
| 343 m_pObj = new CPDF_Dictionary; | 348 m_pObj = new CPDF_Dictionary; |
| 344 m_pObj->AsDictionary()->SetAtName("Type", "Filespec"); | 349 m_pObj->AsDictionary()->SetAtName("Type", "Filespec"); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 bsLbl = bsOrig; | 513 bsLbl = bsOrig; |
| 509 int nPage = FXSYS_atoi(bsLbl); | 514 int nPage = FXSYS_atoi(bsLbl); |
| 510 if (nPage > 0 && nPage <= nPages) { | 515 if (nPage > 0 && nPage <= nPages) { |
| 511 return nPage; | 516 return nPage; |
| 512 } | 517 } |
| 513 return -1; | 518 return -1; |
| 514 } | 519 } |
| 515 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { | 520 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { |
| 516 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsByteStringC()); | 521 return GetPageByLabel(PDF_EncodeText(wsLabel.c_str()).AsByteStringC()); |
| 517 } | 522 } |
| OLD | NEW |