| 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 "../../include/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 8 const int nMaxRecursion = 32; | 8 const int nMaxRecursion = 32; |
| 9 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) | 9 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) |
| 10 { | 10 { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 return NULL; | 243 return NULL; |
| 244 } | 244 } |
| 245 if (pValue->GetType() == PDFOBJ_ARRAY) { | 245 if (pValue->GetType() == PDFOBJ_ARRAY) { |
| 246 return (CPDF_Array*)pValue; | 246 return (CPDF_Array*)pValue; |
| 247 } | 247 } |
| 248 if (pValue->GetType() == PDFOBJ_DICTIONARY) { | 248 if (pValue->GetType() == PDFOBJ_DICTIONARY) { |
| 249 return ((CPDF_Dictionary*)pValue)->GetArray(FX_BSTRC("D")); | 249 return ((CPDF_Dictionary*)pValue)->GetArray(FX_BSTRC("D")); |
| 250 } | 250 } |
| 251 return NULL; | 251 return NULL; |
| 252 } | 252 } |
| 253 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || _FXM_PLATFORM_ == _FXM_PLATFORM_
WINDOWS_ |
| 253 static CFX_WideString ChangeSlashToPlatform(FX_LPCWSTR str) | 254 static CFX_WideString ChangeSlashToPlatform(FX_LPCWSTR str) |
| 254 { | 255 { |
| 255 CFX_WideString result; | 256 CFX_WideString result; |
| 256 while (*str) { | 257 while (*str) { |
| 257 if (*str == '/') { | 258 if (*str == '/') { |
| 258 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 259 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 259 result += ':'; | 260 result += ':'; |
| 260 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 261 #else |
| 261 result += '\\'; | 262 result += '\\'; |
| 262 #else | |
| 263 result += *str; | |
| 264 #endif | 263 #endif |
| 265 } else { | 264 } else { |
| 266 result += *str; | 265 result += *str; |
| 267 } | 266 } |
| 268 str++; | 267 str++; |
| 269 } | 268 } |
| 270 return result; | 269 return result; |
| 271 } | 270 } |
| 271 static CFX_WideString ChangeSlashToPDF(FX_LPCWSTR str) |
| 272 { |
| 273 CFX_WideString result; |
| 274 while (*str) { |
| 275 if (*str == '\\' || *str == ':') { |
| 276 result += '/'; |
| 277 } else { |
| 278 result += *str; |
| 279 } |
| 280 str++; |
| 281 } |
| 282 return result; |
| 283 } |
| 284 #endif |
| 272 static CFX_WideString FILESPEC_DecodeFileName(FX_WSTR filepath) | 285 static CFX_WideString FILESPEC_DecodeFileName(FX_WSTR filepath) |
| 273 { | 286 { |
| 274 if (filepath.GetLength() <= 1) { | 287 if (filepath.GetLength() <= 1) { |
| 275 return CFX_WideString(); | 288 return CFX_WideString(); |
| 276 } | 289 } |
| 277 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 290 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 278 if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) { | 291 if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) { |
| 279 return ChangeSlashToPlatform(filepath.GetPtr() + 1); | 292 return ChangeSlashToPlatform(filepath.GetPtr() + 1); |
| 280 } | 293 } |
| 281 return ChangeSlashToPlatform(filepath.GetPtr()); | 294 return ChangeSlashToPlatform(filepath.GetPtr()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 FX_BOOL CPDF_FileSpec::IsURL() const | 355 FX_BOOL CPDF_FileSpec::IsURL() const |
| 343 { | 356 { |
| 344 if (m_pObj == NULL) { | 357 if (m_pObj == NULL) { |
| 345 return FALSE; | 358 return FALSE; |
| 346 } | 359 } |
| 347 if (m_pObj->GetType() != PDFOBJ_DICTIONARY) { | 360 if (m_pObj->GetType() != PDFOBJ_DICTIONARY) { |
| 348 return FALSE; | 361 return FALSE; |
| 349 } | 362 } |
| 350 return ((CPDF_Dictionary*)m_pObj)->GetString(FX_BSTRC("FS")) == FX_BSTRC("UR
L"); | 363 return ((CPDF_Dictionary*)m_pObj)->GetString(FX_BSTRC("FS")) == FX_BSTRC("UR
L"); |
| 351 } | 364 } |
| 352 static CFX_WideString ChangeSlashToPDF(FX_LPCWSTR str) | |
| 353 { | |
| 354 CFX_WideString result; | |
| 355 while (*str) { | |
| 356 if (*str == '\\' || *str == ':') { | |
| 357 result += '/'; | |
| 358 } else { | |
| 359 result += *str; | |
| 360 } | |
| 361 str++; | |
| 362 } | |
| 363 return result; | |
| 364 } | |
| 365 CFX_WideString FILESPEC_EncodeFileName(FX_WSTR filepath) | 365 CFX_WideString FILESPEC_EncodeFileName(FX_WSTR filepath) |
| 366 { | 366 { |
| 367 if (filepath.GetLength() <= 1) { | 367 if (filepath.GetLength() <= 1) { |
| 368 return CFX_WideString(); | 368 return CFX_WideString(); |
| 369 } | 369 } |
| 370 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 370 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 371 if (filepath.GetAt(1) == ':') { | 371 if (filepath.GetAt(1) == ':') { |
| 372 CFX_WideString result; | 372 CFX_WideString result; |
| 373 result = '/'; | 373 result = '/'; |
| 374 result += filepath.GetAt(0); | 374 result += filepath.GetAt(0); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 if (nPage > 0 && nPage <= nPages) { | 563 if (nPage > 0 && nPage <= nPages) { |
| 564 return nPage; | 564 return nPage; |
| 565 } | 565 } |
| 566 return -1; | 566 return -1; |
| 567 } | 567 } |
| 568 FX_INT32 CPDF_PageLabel::GetPageByLabel(FX_WSTR wsLabel) const | 568 FX_INT32 CPDF_PageLabel::GetPageByLabel(FX_WSTR wsLabel) const |
| 569 { | 569 { |
| 570 CFX_ByteString bsLabel = PDF_EncodeText((CFX_WideString)wsLabel); | 570 CFX_ByteString bsLabel = PDF_EncodeText((CFX_WideString)wsLabel); |
| 571 return GetPageByLabel(bsLabel); | 571 return GetPageByLabel(bsLabel); |
| 572 } | 572 } |
| OLD | NEW |