Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cpdf_apsettings.cpp
Go to the documentation of this file.
1
// Copyright 2016 The PDFium Authors
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/cpdf_apsettings.h"
8
9
#
include
<
algorithm
>
10
#
include
<
utility
>
11
12
#
include
"core/fpdfapi/parser/cpdf_array.h"
13
#
include
"core/fpdfapi/parser/cpdf_dictionary.h"
14
#
include
"core/fpdfapi/parser/cpdf_stream.h"
15
#
include
"core/fpdfdoc/cpdf_formcontrol.h"
16
17
CPDF_ApSettings
::
CPDF_ApSettings
(
RetainPtr
<
CPDF_Dictionary
> pDict)
18
:
m_pDict
(
std
::
move
(
pDict
)) {}
19
20
CPDF_ApSettings
::
CPDF_ApSettings
(
const
CPDF_ApSettings
& that) =
default
;
21
22
CPDF_ApSettings
::~
CPDF_ApSettings
() =
default
;
23
24
bool
CPDF_ApSettings
::
HasMKEntry
(
const
ByteString
& csEntry)
const
{
25
return
m_pDict && m_pDict->KeyExist(csEntry);
26
}
27
28
int
CPDF_ApSettings
::
GetRotation
()
const
{
29
return
m_pDict ? m_pDict->GetIntegerFor(
"R"
) : 0;
30
}
31
32
CFX_Color
::
TypeAndARGB
CPDF_ApSettings
::
GetColorARGB
(
33
const
ByteString
& csEntry)
const
{
34
if
(!m_pDict)
35
return
{
CFX_Color
::
Type
::
kTransparent
,
0
}
;
36
37
RetainPtr
<
const
CPDF_Array
> pEntry = m_pDict->GetArrayFor(csEntry);
38
if
(!pEntry)
39
return
{
CFX_Color
::
Type
::
kTransparent
,
0
}
;
40
41
const
size_t dwCount = pEntry->size();
42
if
(dwCount == 1) {
43
const
float
g = pEntry->GetFloatAt(0) * 255;
44
return
{
CFX_Color
::
Type
::
kGray
,
ArgbEncode
(
255
,
(
int
)g
,
(
int
)g
,
(
int
)g
)
}
;
45
}
46
if
(dwCount == 3) {
47
float
r = pEntry->GetFloatAt(0) * 255;
48
float
g = pEntry->GetFloatAt(1) * 255;
49
float
b = pEntry->GetFloatAt(2) * 255;
50
return
{
CFX_Color
::
Type
::
kRGB
,
ArgbEncode
(
255
,
(
int
)r
,
(
int
)g
,
(
int
)b
)
}
;
51
}
52
if
(dwCount == 4) {
53
float
c = pEntry->GetFloatAt(0);
54
float
m = pEntry->GetFloatAt(1);
55
float
y = pEntry->GetFloatAt(2);
56
float
k = pEntry->GetFloatAt(3);
57
float
r = (1.0f -
std
::min(1.0f, c + k)) * 255;
58
float
g = (1.0f -
std
::min(1.0f, m + k)) * 255;
59
float
b = (1.0f -
std
::min(1.0f, y + k)) * 255;
60
return
{
CFX_Color
::
Type
::
kCMYK
,
ArgbEncode
(
255
,
(
int
)r
,
(
int
)g
,
(
int
)b
)
}
;
61
}
62
return
{
CFX_Color
::
Type
::
kTransparent
,
0
}
;
63
}
64
65
float
CPDF_ApSettings
::
GetOriginalColorComponent
(
66
int
index,
67
const
ByteString
& csEntry)
const
{
68
if
(!m_pDict)
69
return
0;
70
71
RetainPtr
<
const
CPDF_Array
> pEntry = m_pDict->GetArrayFor(csEntry);
72
return
pEntry ? pEntry->GetFloatAt(index) : 0;
73
}
74
75
CFX_Color
CPDF_ApSettings
::
GetOriginalColor
(
const
ByteString
& csEntry)
const
{
76
if
(!m_pDict)
77
return
CFX_Color
(
)
;
78
79
RetainPtr
<
const
CPDF_Array
> pEntry = m_pDict->GetArrayFor(csEntry);
80
if
(!pEntry)
81
return
CFX_Color
(
)
;
82
83
size_t dwCount = pEntry->size();
84
if
(dwCount == 1) {
85
return
CFX_Color
(
CFX_Color
::
Type
::
kGray
, pEntry->GetFloatAt(0));
86
}
87
if
(dwCount == 3) {
88
return
CFX_Color
(
CFX_Color
::
Type
::
kRGB
, pEntry->GetFloatAt(0),
89
pEntry->GetFloatAt(1), pEntry->GetFloatAt(2));
90
}
91
if
(dwCount == 4) {
92
return
CFX_Color
(
CFX_Color
::
Type
::
kCMYK
, pEntry->GetFloatAt(0),
93
pEntry->GetFloatAt(1), pEntry->GetFloatAt(2),
94
pEntry->GetFloatAt(3));
95
}
96
return
CFX_Color
(
)
;
97
}
98
99
WideString
CPDF_ApSettings
::
GetCaption
(
const
ByteString
& csEntry)
const
{
100
return
m_pDict ? m_pDict->GetUnicodeTextFor(csEntry) : WideString();
101
}
102
103
RetainPtr
<CPDF_Stream>
CPDF_ApSettings
::
GetIcon
(
104
const
ByteString
& csEntry)
const
{
105
return
m_pDict ? m_pDict->GetMutableStreamFor(csEntry) :
nullptr
;
106
}
107
108
CPDF_IconFit
CPDF_ApSettings
::
GetIconFit
()
const
{
109
return
CPDF_IconFit(m_pDict ? m_pDict->GetDictFor(
"IF"
) :
nullptr
);
110
}
111
112
int
CPDF_ApSettings
::
GetTextPosition
()
const
{
113
return
m_pDict ? m_pDict->GetIntegerFor(
"TP"
,
TEXTPOS_CAPTION
)
114
:
TEXTPOS_CAPTION
;
115
}
ByteString
fxcrt::ByteString ByteString
Definition
bytestring.h:180
CPDF_ApSettings
Definition
cpdf_apsettings.h:28
CPDF_ApSettings::GetOriginalColor
CFX_Color GetOriginalColor(const ByteString &csEntry) const
Definition
cpdf_apsettings.cpp:75
CPDF_ApSettings::HasMKEntry
bool HasMKEntry(const ByteString &csEntry) const
Definition
cpdf_apsettings.cpp:24
CPDF_ApSettings::GetRotation
int GetRotation() const
Definition
cpdf_apsettings.cpp:28
CPDF_ApSettings::~CPDF_ApSettings
~CPDF_ApSettings()
CPDF_ApSettings::GetIcon
RetainPtr< CPDF_Stream > GetIcon(const ByteString &csEntry) const
Definition
cpdf_apsettings.cpp:103
CPDF_ApSettings::CPDF_ApSettings
CPDF_ApSettings(const CPDF_ApSettings &that)
CPDF_ApSettings::GetIconFit
CPDF_IconFit GetIconFit() const
Definition
cpdf_apsettings.cpp:108
CPDF_ApSettings::GetCaption
WideString GetCaption(const ByteString &csEntry) const
Definition
cpdf_apsettings.cpp:99
CPDF_ApSettings::GetOriginalColorComponent
float GetOriginalColorComponent(int index, const ByteString &csEntry) const
Definition
cpdf_apsettings.cpp:65
CPDF_ApSettings::GetColorARGB
CFX_Color::TypeAndARGB GetColorARGB(const ByteString &csEntry) const
Definition
cpdf_apsettings.cpp:32
CPDF_ApSettings::CPDF_ApSettings
CPDF_ApSettings(RetainPtr< CPDF_Dictionary > pDict)
Definition
cpdf_apsettings.cpp:17
CPDF_ApSettings::GetTextPosition
int GetTextPosition() const
Definition
cpdf_apsettings.cpp:112
CPDF_Array::const_iterator
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition
cpdf_array.h:29
CPDF_Dictionary::DictMap
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Definition
cpdf_dictionary.h:31
CPDF_IconFit
Definition
cpdf_iconfit.h:15
fxcrt::RetainPtr
Definition
retain_ptr.h:28
TEXTPOS_CAPTION
#define TEXTPOS_CAPTION
Definition
cpdf_apsettings.h:20
ArgbEncode
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition
fx_dib.h:188
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
CFX_Color::TypeAndARGB
Definition
cfx_color.h:16
CFX_Color::TypeAndARGB::TypeAndARGB
TypeAndARGB(CFX_Color::Type type_in, FX_ARGB argb_in)
Definition
cfx_color.h:17
CFX_Color
Definition
cfx_color.h:12
CFX_Color::Type
Type
Definition
cfx_color.h:14
CFX_Color::Type::kCMYK
@ kCMYK
Definition
cfx_color.h:14
CFX_Color::Type::kGray
@ kGray
Definition
cfx_color.h:14
CFX_Color::Type::kRGB
@ kRGB
Definition
cfx_color.h:14
CFX_Color::Type::kTransparent
@ kTransparent
Definition
cfx_color.h:14
CFX_Color::CFX_Color
constexpr CFX_Color(Type type=CFX_Color::Type::kTransparent, float color1=0.0f, float color2=0.0f, float color3=0.0f, float color4=0.0f)
Definition
cfx_color.h:27
WideString
fxcrt::WideString WideString
Definition
widestring.h:207
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfdoc
cpdf_apsettings.cpp
Generated on
for Qt by
1.18.0