summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_view.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 /fpdfsdk/fpdf_view.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 'fpdfsdk/fpdf_view.cpp')
-rw-r--r--fpdfsdk/fpdf_view.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 22cb62ea6e..6c4ad6020e 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -243,11 +243,11 @@ FPDF_EXPORT int FPDF_CALLCONV FPDF_GetFormType(FPDF_DOCUMENT document) {
if (!pRoot)
return FORMTYPE_NONE;
- CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
+ const CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
if (!pAcroForm)
return FORMTYPE_NONE;
- CPDF_Object* pXFA = pAcroForm->GetObjectFor("XFA");
+ const CPDF_Object* pXFA = pAcroForm->GetObjectFor("XFA");
if (!pXFA)
return FORMTYPE_ACRO_FORM;
@@ -978,7 +978,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document) {
- CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ const CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return true;
CPDF_ViewerPreferences viewRef(pDoc);
@@ -987,7 +987,7 @@ FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document) {
FPDF_EXPORT int FPDF_CALLCONV
FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document) {
- CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ const CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return 1;
CPDF_ViewerPreferences viewRef(pDoc);
@@ -996,7 +996,7 @@ FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document) {
FPDF_EXPORT FPDF_PAGERANGE FPDF_CALLCONV
FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document) {
- CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ const CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
CPDF_ViewerPreferences viewRef(pDoc);
@@ -1020,7 +1020,7 @@ FPDF_VIEWERREF_GetPrintPageRangeElement(FPDF_PAGERANGE pagerange,
FPDF_EXPORT FPDF_DUPLEXTYPE FPDF_CALLCONV
FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document) {
- CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ const CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return DuplexUndefined;
CPDF_ViewerPreferences viewRef(pDoc);
@@ -1039,18 +1039,18 @@ FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
FPDF_BYTESTRING key,
char* buffer,
unsigned long length) {
- CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ const CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return 0;
CPDF_ViewerPreferences viewRef(pDoc);
- ByteString bsVal;
- if (!viewRef.GenericName(key, &bsVal))
+ Optional<ByteString> bsVal = viewRef.GenericName(key);
+ if (!bsVal)
return 0;
- unsigned long dwStringLen = bsVal.GetLength() + 1;
+ unsigned long dwStringLen = bsVal->GetLength() + 1;
if (buffer && length >= dwStringLen)
- memcpy(buffer, bsVal.c_str(), dwStringLen);
+ memcpy(buffer, bsVal->c_str(), dwStringLen);
return dwStringLen;
}
@@ -1066,7 +1066,7 @@ FPDF_CountNamedDests(FPDF_DOCUMENT document) {
CPDF_NameTree nameTree(pDoc, "Dests");
pdfium::base::CheckedNumeric<FPDF_DWORD> count = nameTree.GetCount();
- CPDF_Dictionary* pDest = pRoot->GetDictFor("Dests");
+ const CPDF_Dictionary* pDest = pRoot->GetDictFor("Dests");
if (pDest)
count += pDest->GetCount();
@@ -1161,7 +1161,7 @@ FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document,
CPDF_NameTree nameTree(pDoc, "Dests");
int count = nameTree.GetCount();
if (index >= count) {
- CPDF_Dictionary* pDest = pRoot->GetDictFor("Dests");
+ const CPDF_Dictionary* pDest = pRoot->GetDictFor("Dests");
if (!pDest)
return nullptr;