Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: core/fpdfdoc/doc_basic.cpp

Issue 1817283002: Make predefined character table slightly smaller. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/doc_action.cpp ('k') | core/include/fpdfapi/fpdf_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 11
12 namespace {
13
12 const int nMaxRecursion = 32; 14 const int nMaxRecursion = 32;
15 const FX_CHAR* const g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR",
16 "FitB", "FitBH", "FitBV", nullptr};
17
18 } // namespace
19
13 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) { 20 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) {
14 CPDF_Array* pArray = ToArray(m_pObj); 21 CPDF_Array* pArray = ToArray(m_pObj);
15 if (!pArray) 22 if (!pArray)
16 return 0; 23 return 0;
17 24
18 CPDF_Object* pPage = pArray->GetElementValue(0); 25 CPDF_Object* pPage = pArray->GetElementValue(0);
19 if (!pPage) 26 if (!pPage)
20 return 0; 27 return 0;
21 if (pPage->IsNumber()) 28 if (pPage->IsNumber())
22 return pPage->GetInteger(); 29 return pPage->GetInteger();
23 if (!pPage->IsDictionary()) 30 if (!pPage->IsDictionary())
24 return 0; 31 return 0;
25 return pDoc->GetPageIndex(pPage->GetObjNum()); 32 return pDoc->GetPageIndex(pPage->GetObjNum());
26 } 33 }
27 FX_DWORD CPDF_Dest::GetPageObjNum() { 34 FX_DWORD CPDF_Dest::GetPageObjNum() {
28 CPDF_Array* pArray = ToArray(m_pObj); 35 CPDF_Array* pArray = ToArray(m_pObj);
29 if (!pArray) 36 if (!pArray)
30 return 0; 37 return 0;
31 38
32 CPDF_Object* pPage = pArray->GetElementValue(0); 39 CPDF_Object* pPage = pArray->GetElementValue(0);
33 if (!pPage) 40 if (!pPage)
34 return 0; 41 return 0;
35 if (pPage->IsNumber()) 42 if (pPage->IsNumber())
36 return pPage->GetInteger(); 43 return pPage->GetInteger();
37 if (pPage->IsDictionary()) 44 if (pPage->IsDictionary())
38 return pPage->GetObjNum(); 45 return pPage->GetObjNum();
39 return 0; 46 return 0;
40 } 47 }
41 const FX_CHAR* g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR", 48
42 "FitB", "FitBH", "FitBV", ""};
43 int CPDF_Dest::GetZoomMode() { 49 int CPDF_Dest::GetZoomMode() {
44 CPDF_Array* pArray = ToArray(m_pObj); 50 CPDF_Array* pArray = ToArray(m_pObj);
45 if (!pArray) 51 if (!pArray)
46 return 0; 52 return 0;
47 53
48 CFX_ByteString mode;
49 CPDF_Object* pObj = pArray->GetElementValue(1); 54 CPDF_Object* pObj = pArray->GetElementValue(1);
50 mode = pObj ? pObj->GetString() : CFX_ByteString(); 55 if (!pObj)
51 int i = 0; 56 return 0;
52 while (g_sZoomModes[i][0] != '\0') { 57
53 if (mode == g_sZoomModes[i]) { 58 CFX_ByteString mode = pObj->GetString();
59 for (int i = 0; g_sZoomModes[i]; ++i) {
60 if (mode == g_sZoomModes[i])
54 return i + 1; 61 return i + 1;
55 }
56 i++;
57 } 62 }
63
58 return 0; 64 return 0;
59 } 65 }
66
60 FX_FLOAT CPDF_Dest::GetParam(int index) { 67 FX_FLOAT CPDF_Dest::GetParam(int index) {
61 CPDF_Array* pArray = ToArray(m_pObj); 68 CPDF_Array* pArray = ToArray(m_pObj);
62 return pArray ? pArray->GetNumberAt(2 + index) : 0; 69 return pArray ? pArray->GetNumberAt(2 + index) : 0;
63 } 70 }
64 CFX_ByteString CPDF_Dest::GetRemoteName() { 71 CFX_ByteString CPDF_Dest::GetRemoteName() {
65 return m_pObj ? m_pObj->GetString() : CFX_ByteString(); 72 return m_pObj ? m_pObj->GetString() : CFX_ByteString();
66 } 73 }
67 CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc, 74 CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc,
68 const CFX_ByteStringC& category) { 75 const CFX_ByteStringC& category) {
69 if (pDoc->GetRoot() && pDoc->GetRoot()->GetDictBy("Names")) 76 if (pDoc->GetRoot() && pDoc->GetRoot()->GetDictBy("Names"))
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 int nPage = FXSYS_atoi(bsLbl); 508 int nPage = FXSYS_atoi(bsLbl);
502 if (nPage > 0 && nPage <= nPages) { 509 if (nPage > 0 && nPage <= nPages) {
503 return nPage; 510 return nPage;
504 } 511 }
505 return -1; 512 return -1;
506 } 513 }
507 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const { 514 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_WideStringC& wsLabel) const {
508 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr()); 515 CFX_ByteString bsLabel = PDF_EncodeText(wsLabel.GetPtr());
509 return GetPageByLabel(bsLabel); 516 return GetPageByLabel(bsLabel);
510 } 517 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_action.cpp ('k') | core/include/fpdfapi/fpdf_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698