blob: 8b8fa4ed5b9b88a33f6e85008c616ca3c5d73b49 (
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
|
// 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_iconfit.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fxcrt/fx_string.h"
namespace {
constexpr float kDefaultPosition = 0.5f;
} // namespace
CPDF_IconFit::CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {}
CPDF_IconFit::CPDF_IconFit(const CPDF_IconFit& that) = default;
CPDF_IconFit::~CPDF_IconFit() = default;
CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() const {
if (!m_pDict)
return Always;
ByteString csSW = m_pDict->GetStringFor("SW", "A");
if (csSW == "B")
return Bigger;
if (csSW == "S")
return Smaller;
if (csSW == "N")
return Never;
return Always;
}
bool CPDF_IconFit::IsProportionalScale() const {
return !m_pDict || m_pDict->GetStringFor("S", "P") != "A";
}
CFX_PointF CPDF_IconFit::GetIconBottomLeftPosition() const {
float fLeft = kDefaultPosition;
float fBottom = kDefaultPosition;
if (!m_pDict)
return {fLeft, fBottom};
const CPDF_Array* pA = m_pDict->GetArrayFor("A");
if (!pA)
return {fLeft, fBottom};
size_t dwCount = pA->GetCount();
if (dwCount > 0)
fLeft = pA->GetNumberAt(0);
if (dwCount > 1)
fBottom = pA->GetNumberAt(1);
return {fLeft, fBottom};
}
bool CPDF_IconFit::GetFittingBounds() const {
return m_pDict && m_pDict->GetBooleanFor("FB", false);
}
|