Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
16
18
20 RetainPtr<const CPDF_Dictionary> pDict = GetViewerPreferences();
21 return pDict && pDict->GetByteStringFor("Direction") == "R2L";
22}
23
25 RetainPtr<const CPDF_Dictionary> pDict = GetViewerPreferences();
26 return !pDict || pDict->GetByteStringFor("PrintScaling") != "None";
27}
28
30 RetainPtr<const CPDF_Dictionary> pDict = GetViewerPreferences();
31 return pDict ? pDict->GetIntegerFor("NumCopies") : 1;
32}
33
35 RetainPtr<const CPDF_Dictionary> pDict = GetViewerPreferences();
36 return pDict ? pDict->GetArrayFor("PrintPageRange") : nullptr;
37}
38
39ByteString CPDF_ViewerPreferences::Duplex() const {
40 RetainPtr<const CPDF_Dictionary> pDict = GetViewerPreferences();
41 return pDict ? pDict->GetByteStringFor("Duplex") : ByteString("None");
42}
43
45 const ByteString& bsKey) const {
46 RetainPtr<const CPDF_Dictionary> pDict = GetViewerPreferences();
47 if (!pDict)
48 return absl::nullopt;
49
50 RetainPtr<const CPDF_Name> pName = ToName(pDict->GetObjectFor(bsKey));
51 if (!pName)
52 return absl::nullopt;
53
54 return pName->GetString();
55}
56
57RetainPtr<const CPDF_Dictionary> CPDF_ViewerPreferences::GetViewerPreferences()
58 const {
59 const CPDF_Dictionary* pDict = m_pDoc->GetRoot();
60 return pDict ? pDict->GetDictFor("ViewerPreferences") : nullptr;
61}
RetainPtr< const CPDF_Dictionary > GetDictFor(const ByteString &key) const
RetainPtr< const CPDF_Array > PrintPageRange() const
CPDF_ViewerPreferences(const CPDF_Document *pDoc)
absl::optional< ByteString > GenericName(const ByteString &bsKey) const
ByteString(const char *ptr)