summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_viewerpreferences.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-05-08 19:26:37 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-08 19:26:37 +0000
commit55bbb0a2e7a95bf2c08cbd1d7f1563aec7e5b97d (patch)
tree547f7890311e47df663676299d587fef7236aecb /core/fpdfdoc/cpdf_viewerpreferences.cpp
parent9c6204fc6c23ab35ec234781df182da570f6faef (diff)
downloadpdfium-55bbb0a2e7a95bf2c08cbd1d7f1563aec7e5b97d.tar.xz
Mark CPDF_Object pointers as const in CPDF_ViewerPreferences.
Work up the short call stack and mark FPDF_PAGERANGE as an opaque const pointer. Also fix CPDF_ViewerPreferences::GenericName() to return an optional string. Change-Id: I2356d38888fcff8d4da37dd3efc17b284ff90485 Reviewed-on: https://pdfium-review.googlesource.com/32174 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_viewerpreferences.cpp')
-rw-r--r--core/fpdfdoc/cpdf_viewerpreferences.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/core/fpdfdoc/cpdf_viewerpreferences.cpp b/core/fpdfdoc/cpdf_viewerpreferences.cpp
index e7fb1416a8..3359d6344f 100644
--- a/core/fpdfdoc/cpdf_viewerpreferences.cpp
+++ b/core/fpdfdoc/cpdf_viewerpreferences.cpp
@@ -9,52 +9,50 @@
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_name.h"
-CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc)
+CPDF_ViewerPreferences::CPDF_ViewerPreferences(const CPDF_Document* pDoc)
: m_pDoc(pDoc) {}
CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {}
bool CPDF_ViewerPreferences::IsDirectionR2L() const {
- CPDF_Dictionary* pDict = GetViewerPreferences();
+ const CPDF_Dictionary* pDict = GetViewerPreferences();
return pDict ? pDict->GetStringFor("Direction") == "R2L" : false;
}
bool CPDF_ViewerPreferences::PrintScaling() const {
- CPDF_Dictionary* pDict = GetViewerPreferences();
+ const CPDF_Dictionary* pDict = GetViewerPreferences();
return pDict ? pDict->GetStringFor("PrintScaling") != "None" : true;
}
int32_t CPDF_ViewerPreferences::NumCopies() const {
- CPDF_Dictionary* pDict = GetViewerPreferences();
+ const CPDF_Dictionary* pDict = GetViewerPreferences();
return pDict ? pDict->GetIntegerFor("NumCopies") : 1;
}
-CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const {
- CPDF_Dictionary* pDict = GetViewerPreferences();
+const CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const {
+ const CPDF_Dictionary* pDict = GetViewerPreferences();
return pDict ? pDict->GetArrayFor("PrintPageRange") : nullptr;
}
ByteString CPDF_ViewerPreferences::Duplex() const {
- CPDF_Dictionary* pDict = GetViewerPreferences();
+ const CPDF_Dictionary* pDict = GetViewerPreferences();
return pDict ? pDict->GetStringFor("Duplex") : ByteString("None");
}
-bool CPDF_ViewerPreferences::GenericName(const ByteString& bsKey,
- ByteString* bsVal) const {
- ASSERT(bsVal);
- CPDF_Dictionary* pDict = GetViewerPreferences();
+Optional<ByteString> CPDF_ViewerPreferences::GenericName(
+ const ByteString& bsKey) const {
+ const CPDF_Dictionary* pDict = GetViewerPreferences();
if (!pDict)
- return false;
+ return {};
const CPDF_Name* pName = ToName(pDict->GetObjectFor(bsKey));
if (!pName)
- return false;
+ return {};
- *bsVal = pName->GetString();
- return true;
+ return pName->GetString();
}
-CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const {
+const CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const {
const CPDF_Dictionary* pDict = m_pDoc->GetRoot();
return pDict ? pDict->GetDictFor("ViewerPreferences") : nullptr;
}