blob: 312ef8734634167cf53f55b978549b692f27c1fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fpdfdoc/cpdf_dest.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_document.h"
namespace {
const FX_CHAR* const g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR",
"FitB", "FitBH", "FitBV", nullptr};
} // namespace
int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) {
CPDF_Array* pArray = ToArray(m_pObj);
if (!pArray)
return 0;
CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
if (!pPage)
return 0;
if (pPage->IsNumber())
return pPage->GetInteger();
if (!pPage->IsDictionary())
return 0;
return pDoc->GetPageIndex(pPage->GetObjNum());
}
uint32_t CPDF_Dest::GetPageObjNum() {
CPDF_Array* pArray = ToArray(m_pObj);
if (!pArray)
return 0;
CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
if (!pPage)
return 0;
if (pPage->IsNumber())
return pPage->GetInteger();
if (pPage->IsDictionary())
return pPage->GetObjNum();
return 0;
}
int CPDF_Dest::GetZoomMode() {
CPDF_Array* pArray = ToArray(m_pObj);
if (!pArray)
return 0;
CPDF_Object* pObj = pArray->GetDirectObjectAt(1);
if (!pObj)
return 0;
CFX_ByteString mode = pObj->GetString();
for (int i = 0; g_sZoomModes[i]; ++i) {
if (mode == g_sZoomModes[i])
return i + 1;
}
return 0;
}
FX_FLOAT CPDF_Dest::GetParam(int index) {
CPDF_Array* pArray = ToArray(m_pObj);
return pArray ? pArray->GetNumberAt(2 + index) : 0;
}
CFX_ByteString CPDF_Dest::GetRemoteName() {
return m_pObj ? m_pObj->GetString() : CFX_ByteString();
}
|