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 #elif _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
261 result += '\\'; | 262 result += '\\'; |
262 #else | 263 #else |
263 result += *str; | 264 result += *str; |
264 #endif | 265 #endif |
265 } else { | 266 } else { |
266 result += *str; | 267 result += *str; |
267 } | 268 } |
268 str++; | 269 str++; |
269 } | 270 } |
270 return result; | 271 return result; |
271 } | 272 } |
| 273 static CFX_WideString ChangeSlashToPDF(FX_LPCWSTR str) |
| 274 { |
| 275 CFX_WideString result; |
| 276 while (*str) { |
| 277 if (*str == '\\' || *str == ':') { |
| 278 result += '/'; |
| 279 } else { |
| 280 result += *str; |
| 281 } |
| 282 str++; |
| 283 } |
| 284 return result; |
| 285 } |
| 286 #endif |
272 static CFX_WideString FILESPEC_DecodeFileName(FX_WSTR filepath) | 287 static CFX_WideString FILESPEC_DecodeFileName(FX_WSTR filepath) |
273 { | 288 { |
274 if (filepath.GetLength() <= 1) { | 289 if (filepath.GetLength() <= 1) { |
275 return CFX_WideString(); | 290 return CFX_WideString(); |
276 } | 291 } |
277 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 292 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
278 if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) { | 293 if (filepath.Left(sizeof("/Mac") - 1) == CFX_WideStringC(L"/Mac")) { |
279 return ChangeSlashToPlatform(filepath.GetPtr() + 1); | 294 return ChangeSlashToPlatform(filepath.GetPtr() + 1); |
280 } | 295 } |
281 return ChangeSlashToPlatform(filepath.GetPtr()); | 296 return ChangeSlashToPlatform(filepath.GetPtr()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 FX_BOOL CPDF_FileSpec::IsURL() const | 357 FX_BOOL CPDF_FileSpec::IsURL() const |
343 { | 358 { |
344 if (m_pObj == NULL) { | 359 if (m_pObj == NULL) { |
345 return FALSE; | 360 return FALSE; |
346 } | 361 } |
347 if (m_pObj->GetType() != PDFOBJ_DICTIONARY) { | 362 if (m_pObj->GetType() != PDFOBJ_DICTIONARY) { |
348 return FALSE; | 363 return FALSE; |
349 } | 364 } |
350 return ((CPDF_Dictionary*)m_pObj)->GetString(FX_BSTRC("FS")) == FX_BSTRC("UR
L"); | 365 return ((CPDF_Dictionary*)m_pObj)->GetString(FX_BSTRC("FS")) == FX_BSTRC("UR
L"); |
351 } | 366 } |
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) | 367 CFX_WideString FILESPEC_EncodeFileName(FX_WSTR filepath) |
366 { | 368 { |
367 if (filepath.GetLength() <= 1) { | 369 if (filepath.GetLength() <= 1) { |
368 return CFX_WideString(); | 370 return CFX_WideString(); |
369 } | 371 } |
370 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 372 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
371 if (filepath.GetAt(1) == ':') { | 373 if (filepath.GetAt(1) == ':') { |
372 CFX_WideString result; | 374 CFX_WideString result; |
373 result = '/'; | 375 result = '/'; |
374 result += filepath.GetAt(0); | 376 result += filepath.GetAt(0); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 if (nPage > 0 && nPage <= nPages) { | 565 if (nPage > 0 && nPage <= nPages) { |
564 return nPage; | 566 return nPage; |
565 } | 567 } |
566 return -1; | 568 return -1; |
567 } | 569 } |
568 FX_INT32 CPDF_PageLabel::GetPageByLabel(FX_WSTR wsLabel) const | 570 FX_INT32 CPDF_PageLabel::GetPageByLabel(FX_WSTR wsLabel) const |
569 { | 571 { |
570 CFX_ByteString bsLabel = PDF_EncodeText((CFX_WideString)wsLabel); | 572 CFX_ByteString bsLabel = PDF_EncodeText((CFX_WideString)wsLabel); |
571 return GetPageByLabel(bsLabel); | 573 return GetPageByLabel(bsLabel); |
572 } | 574 } |
OLD | NEW |