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_viewerpreferences.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_viewerpreferences.h"
8
9
#
include
"core/fpdfapi/parser/cpdf_array.h"
10
#
include
"core/fpdfapi/parser/cpdf_dictionary.h"
11
#
include
"core/fpdfapi/parser/cpdf_document.h"
12
#
include
"core/fpdfapi/parser/cpdf_name.h"
13
14
CPDF_ViewerPreferences
::
CPDF_ViewerPreferences
(
const
CPDF_Document
* pDoc)
15
:
m_pDoc
(
pDoc
) {}
16
17
CPDF_ViewerPreferences
::~
CPDF_ViewerPreferences
() =
default
;
18
19
bool
CPDF_ViewerPreferences
::
IsDirectionR2L
()
const
{
20
RetainPtr
<
const
CPDF_Dictionary
> pDict = GetViewerPreferences();
21
return
pDict && pDict->GetByteStringFor(
"Direction"
) ==
"R2L"
;
22
}
23
24
bool
CPDF_ViewerPreferences
::
PrintScaling
()
const
{
25
RetainPtr
<
const
CPDF_Dictionary
> pDict = GetViewerPreferences();
26
return
!pDict || pDict->GetByteStringFor(
"PrintScaling"
) !=
"None"
;
27
}
28
29
int32_t
CPDF_ViewerPreferences
::
NumCopies
()
const
{
30
RetainPtr
<
const
CPDF_Dictionary
> pDict = GetViewerPreferences();
31
return
pDict ? pDict->GetIntegerFor(
"NumCopies"
) : 1;
32
}
33
34
RetainPtr
<
const
CPDF_Array
>
CPDF_ViewerPreferences
::
PrintPageRange
()
const
{
35
RetainPtr
<
const
CPDF_Dictionary
> pDict = GetViewerPreferences();
36
return
pDict ? pDict->GetArrayFor(
"PrintPageRange"
) :
nullptr
;
37
}
38
39
ByteString
CPDF_ViewerPreferences
::
Duplex
()
const
{
40
RetainPtr
<
const
CPDF_Dictionary
> pDict = GetViewerPreferences();
41
return
pDict ? pDict->GetByteStringFor(
"Duplex"
) :
ByteString
(
"None"
)
;
42
}
43
44
std
::optional<
ByteString
>
CPDF_ViewerPreferences
::
GenericName
(
45
const
ByteString
& bsKey)
const
{
46
RetainPtr
<
const
CPDF_Dictionary
> pDict = GetViewerPreferences();
47
if
(!pDict)
48
return
std
::nullopt;
49
50
RetainPtr
<
const
CPDF_Name> pName = ToName(pDict->GetObjectFor(bsKey));
51
if
(!pName)
52
return
std
::nullopt;
53
54
return
pName->GetString();
55
}
56
57
RetainPtr
<
const
CPDF_Dictionary
>
CPDF_ViewerPreferences
::GetViewerPreferences()
58
const
{
59
const
CPDF_Dictionary
* pDict = m_pDoc->GetRoot();
60
return
pDict ? pDict
->
GetDictFor
(
"ViewerPreferences"
) :
nullptr
;
61
}
ByteString
fxcrt::ByteString ByteString
Definition
bytestring.h:180
CPDF_Array::const_iterator
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition
cpdf_array.h:29
CPDF_Dictionary::GetDictFor
RetainPtr< const CPDF_Dictionary > GetDictFor(const ByteString &key) const
Definition
cpdf_dictionary.cpp:163
CPDF_Dictionary::DictMap
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Definition
cpdf_dictionary.h:31
CPDF_Document
Definition
cpdf_document.h:29
CPDF_ViewerPreferences
Definition
cpdf_viewerpreferences.h:22
CPDF_ViewerPreferences::GenericName
std::optional< ByteString > GenericName(const ByteString &bsKey) const
Definition
cpdf_viewerpreferences.cpp:44
CPDF_ViewerPreferences::IsDirectionR2L
bool IsDirectionR2L() const
Definition
cpdf_viewerpreferences.cpp:19
CPDF_ViewerPreferences::PrintPageRange
RetainPtr< const CPDF_Array > PrintPageRange() const
Definition
cpdf_viewerpreferences.cpp:34
CPDF_ViewerPreferences::NumCopies
int32_t NumCopies() const
Definition
cpdf_viewerpreferences.cpp:29
CPDF_ViewerPreferences::CPDF_ViewerPreferences
CPDF_ViewerPreferences(const CPDF_Document *pDoc)
Definition
cpdf_viewerpreferences.cpp:14
CPDF_ViewerPreferences::Duplex
ByteString Duplex() const
Definition
cpdf_viewerpreferences.cpp:39
CPDF_ViewerPreferences::~CPDF_ViewerPreferences
~CPDF_ViewerPreferences()
CPDF_ViewerPreferences::PrintScaling
bool PrintScaling() const
Definition
cpdf_viewerpreferences.cpp:24
fxcrt::ByteString::ByteString
ByteString(const char *ptr)
Definition
bytestring.cpp:103
fxcrt::RetainPtr
Definition
retain_ptr.h:28
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfdoc
cpdf_viewerpreferences.cpp
Generated on
for Qt by
1.18.0