| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 return result; | 281 return result; |
| 282 } | 282 } |
| 283 #endif // _FXM_PLATFORM_APPLE_ || _FXM_PLATFORM_WINDOWS_ | 283 #endif // _FXM_PLATFORM_APPLE_ || _FXM_PLATFORM_WINDOWS_ |
| 284 | 284 |
| 285 CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideStringC& filepath) { | 285 CFX_WideString CPDF_FileSpec::DecodeFileName(const CFX_WideStringC& filepath) { |
| 286 if (filepath.GetLength() <= 1) | 286 if (filepath.GetLength() <= 1) |
| 287 return CFX_WideString(); | 287 return CFX_WideString(); |
| 288 | 288 |
| 289 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 289 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 290 if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) | 290 if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) |
| 291 return ChangeSlashToPlatform(filepath.GetPtr() + 1); | 291 return ChangeSlashToPlatform(filepath.raw_str() + 1); |
| 292 return ChangeSlashToPlatform(filepath.GetPtr()); | 292 return ChangeSlashToPlatform(filepath.raw_str()); |
| 293 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 293 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 294 if (filepath.GetAt(0) != '/') | 294 if (filepath.GetAt(0) != '/') |
| 295 return ChangeSlashToPlatform(filepath.GetPtr()); | 295 return ChangeSlashToPlatform(filepath.raw_str()); |
| 296 if (filepath.GetAt(1) == '/') | 296 if (filepath.GetAt(1) == '/') |
| 297 return ChangeSlashToPlatform(filepath.GetPtr() + 1); | 297 return ChangeSlashToPlatform(filepath.raw_str() + 1); |
| 298 if (filepath.GetAt(2) == '/') { | 298 if (filepath.GetAt(2) == '/') { |
| 299 CFX_WideString result; | 299 CFX_WideString result; |
| 300 result += filepath.GetAt(1); | 300 result += filepath.GetAt(1); |
| 301 result += ':'; | 301 result += ':'; |
| 302 result += ChangeSlashToPlatform(filepath.GetPtr() + 2); | 302 result += ChangeSlashToPlatform(filepath.raw_str() + 2); |
| 303 return result; | 303 return result; |
| 304 } | 304 } |
| 305 CFX_WideString result; | 305 CFX_WideString result; |
| 306 result += '\\'; | 306 result += '\\'; |
| 307 result += ChangeSlashToPlatform(filepath.GetPtr()); | 307 result += ChangeSlashToPlatform(filepath.raw_str()); |
| 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()) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 return CFX_WideString(); | 349 return CFX_WideString(); |
| 350 } | 350 } |
| 351 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 351 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 352 if (filepath.GetAt(1) == ':') { | 352 if (filepath.GetAt(1) == ':') { |
| 353 CFX_WideString result; | 353 CFX_WideString result; |
| 354 result = '/'; | 354 result = '/'; |
| 355 result += filepath.GetAt(0); | 355 result += filepath.GetAt(0); |
| 356 if (filepath.GetAt(2) != '\\') { | 356 if (filepath.GetAt(2) != '\\') { |
| 357 result += '/'; | 357 result += '/'; |
| 358 } | 358 } |
| 359 result += ChangeSlashToPDF(filepath.GetPtr() + 2); | 359 result += ChangeSlashToPDF(filepath.raw_str() + 2); |
| 360 return result; | 360 return result; |
| 361 } | 361 } |
| 362 if (filepath.GetAt(0) == '\\' && filepath.GetAt(1) == '\\') { | 362 if (filepath.GetAt(0) == '\\' && filepath.GetAt(1) == '\\') { |
| 363 return ChangeSlashToPDF(filepath.GetPtr() + 1); | 363 return ChangeSlashToPDF(filepath.raw_str() + 1); |
| 364 } | 364 } |
| 365 if (filepath.GetAt(0) == '\\') { | 365 if (filepath.GetAt(0) == '\\') { |
| 366 CFX_WideString result; | 366 CFX_WideString result; |
| 367 result = '/'; | 367 result = '/'; |
| 368 result += ChangeSlashToPDF(filepath.GetPtr()); | 368 result += ChangeSlashToPDF(filepath.raw_str()); |
| 369 return result; | 369 return result; |
| 370 } | 370 } |
| 371 return ChangeSlashToPDF(filepath.GetPtr()); | 371 return ChangeSlashToPDF(filepath.raw_str()); |
| 372 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 372 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 373 if (filepath.Left(sizeof("Mac") - 1) == FX_WSTRC(L"Mac")) { | 373 if (filepath.Left(sizeof("Mac") - 1) == FX_WSTRC(L"Mac")) { |
| 374 CFX_WideString result; | 374 CFX_WideString result; |
| 375 result = '/'; | 375 result = '/'; |
| 376 result += ChangeSlashToPDF(filepath.GetPtr()); | 376 result += ChangeSlashToPDF(filepath.raw_str()); |
| 377 return result; | 377 return result; |
| 378 } | 378 } |
| 379 return ChangeSlashToPDF(filepath.GetPtr()); | 379 return ChangeSlashToPDF(filepath.raw_str()); |
| 380 #else | 380 #else |
| 381 return filepath; | 381 return filepath; |
| 382 #endif | 382 #endif |
| 383 } | 383 } |
| 384 | 384 |
| 385 void CPDF_FileSpec::SetFileName(const CFX_WideStringC& wsFileName) { | 385 void CPDF_FileSpec::SetFileName(const CFX_WideStringC& wsFileName) { |
| 386 if (!m_pObj) | 386 if (!m_pObj) |
| 387 return; | 387 return; |
| 388 | 388 |
| 389 CFX_WideString wsStr = EncodeFileName(wsFileName); | 389 CFX_WideString wsStr = EncodeFileName(wsFileName); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 } | 506 } |
| 507 } | 507 } |
| 508 bsLbl = bsOrig; | 508 bsLbl = bsOrig; |
| 509 int nPage = FXSYS_atoi(bsLbl); | 509 int nPage = FXSYS_atoi(bsLbl); |
| 510 if (nPage > 0 && nPage <= nPages) { | 510 if (nPage > 0 && nPage <= nPages) { |
| 511 return nPage; | 511 return nPage; |
| 512 } | 512 } |
| 513 return -1; | 513 return -1; |
| 514 } | 514 } |
| 515 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { | 515 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { |
| 516 return GetPageByLabel(PDF_EncodeText(wsLabel.GetPtr()).AsByteStringC()); | 516 return GetPageByLabel(PDF_EncodeText(wsLabel.raw_str()).AsByteStringC()); |
| 517 } | 517 } |
| OLD | NEW |