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 if (m_pObj == NULL || m_pObj->GetType() != PDFOBJ_ARRAY) { | 10 if (m_pObj == NULL || m_pObj->GetType() != PDFOBJ_ARRAY) { |
11 return 0; | 11 return 0; |
12 } | 12 } |
13 CPDF_Object* pPage = ((CPDF_Array*)m_pObj)->GetElementValue(0); | 13 CPDF_Object* pPage = ((CPDF_Array*)m_pObj)->GetElementValue(0); |
14 if (pPage == NULL) { | 14 if (!pPage) |
15 return 0; | 15 return 0; |
16 } | 16 if (pPage->IsNumber()) |
17 if (pPage->GetType() == PDFOBJ_NUMBER) { | |
18 return pPage->GetInteger(); | 17 return pPage->GetInteger(); |
19 } | 18 if (!pPage->IsDictionary()) |
20 if (!pPage->IsDictionary()) { | |
21 return 0; | 19 return 0; |
22 } | |
23 return pDoc->GetPageIndex(pPage->GetObjNum()); | 20 return pDoc->GetPageIndex(pPage->GetObjNum()); |
24 } | 21 } |
25 FX_DWORD CPDF_Dest::GetPageObjNum() { | 22 FX_DWORD CPDF_Dest::GetPageObjNum() { |
26 if (m_pObj == NULL || m_pObj->GetType() != PDFOBJ_ARRAY) { | 23 if (m_pObj == NULL || m_pObj->GetType() != PDFOBJ_ARRAY) { |
27 return 0; | 24 return 0; |
28 } | 25 } |
29 CPDF_Object* pPage = ((CPDF_Array*)m_pObj)->GetElementValue(0); | 26 CPDF_Object* pPage = ((CPDF_Array*)m_pObj)->GetElementValue(0); |
30 if (pPage == NULL) { | 27 if (!pPage) |
31 return 0; | 28 return 0; |
32 } | 29 if (pPage->IsNumber()) |
33 if (pPage->GetType() == PDFOBJ_NUMBER) { | |
34 return pPage->GetInteger(); | 30 return pPage->GetInteger(); |
35 } | 31 if (pPage->IsDictionary()) |
36 if (pPage->IsDictionary()) { | |
37 return pPage->GetObjNum(); | 32 return pPage->GetObjNum(); |
38 } | |
39 return 0; | 33 return 0; |
40 } | 34 } |
41 const FX_CHAR* g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR", | 35 const FX_CHAR* g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR", |
42 "FitB", "FitBH", "FitBV", ""}; | 36 "FitB", "FitBH", "FitBV", ""}; |
43 int CPDF_Dest::GetZoomMode() { | 37 int CPDF_Dest::GetZoomMode() { |
44 if (m_pObj == NULL || m_pObj->GetType() != PDFOBJ_ARRAY) { | 38 if (m_pObj == NULL || m_pObj->GetType() != PDFOBJ_ARRAY) { |
45 return 0; | 39 return 0; |
46 } | 40 } |
47 CFX_ByteString mode; | 41 CFX_ByteString mode; |
48 CPDF_Object* pObj = ((CPDF_Array*)m_pObj)->GetElementValue(1); | 42 CPDF_Object* pObj = ((CPDF_Array*)m_pObj)->GetElementValue(1); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 int nPage = FXSYS_atoi(bsLbl); | 537 int nPage = FXSYS_atoi(bsLbl); |
544 if (nPage > 0 && nPage <= nPages) { | 538 if (nPage > 0 && nPage <= nPages) { |
545 return nPage; | 539 return nPage; |
546 } | 540 } |
547 return -1; | 541 return -1; |
548 } | 542 } |
549 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { | 543 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { |
550 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr()); | 544 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr()); |
551 return GetPageByLabel(bsLabel); | 545 return GetPageByLabel(bsLabel); |
552 } | 546 } |
OLD | NEW |