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

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

Issue 2187073005: Splitting fpdfdoc/doc_* part II. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@fpdf_doc_III
Patch Set: Rebase to master Created 4 years, 4 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/clines.cpp ('k') | core/fpdfdoc/cpdf_filespec.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/fpdfdoc/include/cpdf_dest.h"
8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
11
12 namespace {
13
14 const FX_CHAR* const g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR",
15 "FitB", "FitBH", "FitBV", nullptr};
16
17 } // namespace
18
19 int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) {
20 CPDF_Array* pArray = ToArray(m_pObj);
21 if (!pArray)
22 return 0;
23
24 CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
25 if (!pPage)
26 return 0;
27 if (pPage->IsNumber())
28 return pPage->GetInteger();
29 if (!pPage->IsDictionary())
30 return 0;
31 return pDoc->GetPageIndex(pPage->GetObjNum());
32 }
33
34 uint32_t CPDF_Dest::GetPageObjNum() {
35 CPDF_Array* pArray = ToArray(m_pObj);
36 if (!pArray)
37 return 0;
38
39 CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
40 if (!pPage)
41 return 0;
42 if (pPage->IsNumber())
43 return pPage->GetInteger();
44 if (pPage->IsDictionary())
45 return pPage->GetObjNum();
46 return 0;
47 }
48
49 int CPDF_Dest::GetZoomMode() {
50 CPDF_Array* pArray = ToArray(m_pObj);
51 if (!pArray)
52 return 0;
53
54 CPDF_Object* pObj = pArray->GetDirectObjectAt(1);
55 if (!pObj)
56 return 0;
57
58 CFX_ByteString mode = pObj->GetString();
59 for (int i = 0; g_sZoomModes[i]; ++i) {
60 if (mode == g_sZoomModes[i])
61 return i + 1;
62 }
63
64 return 0;
65 }
66
67 FX_FLOAT CPDF_Dest::GetParam(int index) {
68 CPDF_Array* pArray = ToArray(m_pObj);
69 return pArray ? pArray->GetNumberAt(2 + index) : 0;
70 }
71
72 CFX_ByteString CPDF_Dest::GetRemoteName() {
73 return m_pObj ? m_pObj->GetString() : CFX_ByteString();
74 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/clines.cpp ('k') | core/fpdfdoc/cpdf_filespec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698