summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-08-30 14:19:26 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-08-30 22:17:09 +0000
commit0158106c1c77c6af4f7195d086cb0f2d129de838 (patch)
treeaed97db22abfaab6424378436c925a37d832c0e7 /fpdfsdk
parent4793f3474f2778dbbd225d797f011db0f45e0953 (diff)
downloadpdfium-0158106c1c77c6af4f7195d086cb0f2d129de838.tar.xz
Add truly const versions of CPDF_Document getters.
Instead of only having CPDF_Dictionary* GetRoot() const, provide const CPDF_Dictionary* GetRoot() const and CPDF_Dictionary* GetRoot(). Do the same for GetInfo(). Change-Id: I6eae1208d38327fcdc7d0cd75069a01c95f4a92a Reviewed-on: https://pdfium-review.googlesource.com/11671 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.cpp2
-rw-r--r--fpdfsdk/formfiller/cba_fontmap.cpp5
-rw-r--r--fpdfsdk/fpdf_ext.cpp4
-rw-r--r--fpdfsdk/fpdfdoc.cpp2
-rw-r--r--fpdfsdk/fpdfformfill.cpp2
-rw-r--r--fpdfsdk/fpdfsave.cpp2
-rw-r--r--fpdfsdk/fpdfview.cpp16
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp9
-rw-r--r--fpdfsdk/javascript/Document.cpp2
9 files changed, 23 insertions, 21 deletions
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index 0a8a59cfda..a258026a7d 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -593,7 +593,7 @@ bool CPDFSDK_FormFillEnvironment::ProcOpenAction() {
if (!m_pUnderlyingDoc)
return false;
- CPDF_Dictionary* pRoot = GetPDFDocument()->GetRoot();
+ const CPDF_Dictionary* pRoot = GetPDFDocument()->GetRoot();
if (!pRoot)
return false;
diff --git a/fpdfsdk/formfiller/cba_fontmap.cpp b/fpdfsdk/formfiller/cba_fontmap.cpp
index 577faf4b8f..c3ab2b8f56 100644
--- a/fpdfsdk/formfiller/cba_fontmap.cpp
+++ b/fpdfsdk/formfiller/cba_fontmap.cpp
@@ -89,7 +89,7 @@ CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString* sFontAlias,
return nullptr;
CPDF_Document* pDocument = GetDocument();
- CPDF_Dictionary* pRootDict = pDocument->GetRoot();
+ const CPDF_Dictionary* pRootDict = pDocument->GetRoot();
if (!pRootDict)
return nullptr;
@@ -198,7 +198,8 @@ CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString* sAlias) {
CPDF_Dictionary* pAcroFormDict = nullptr;
const bool bWidget = (m_pAnnotDict->GetStringFor("Subtype") == "Widget");
if (bWidget) {
- if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot())
+ const CPDF_Dictionary* pRootDict = m_pDocument->GetRoot();
+ if (pRootDict)
pAcroFormDict = pRootDict->GetDictFor("AcroForm");
}
diff --git a/fpdfsdk/fpdf_ext.cpp b/fpdfsdk/fpdf_ext.cpp
index 2284453d2d..c8a1b4b4f7 100644
--- a/fpdfsdk/fpdf_ext.cpp
+++ b/fpdfsdk/fpdf_ext.cpp
@@ -126,7 +126,7 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) {
return;
// Portfolios and Packages
- CPDF_Dictionary* pRootDict = pDoc->GetRoot();
+ const CPDF_Dictionary* pRootDict = pDoc->GetRoot();
if (pRootDict) {
CFX_ByteString cbString;
if (pRootDict->KeyExist("Collection")) {
@@ -174,7 +174,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFDoc_GetPageMode(FPDF_DOCUMENT document) {
if (!pDoc)
return PAGEMODE_UNKNOWN;
- CPDF_Dictionary* pRoot = pDoc->GetRoot();
+ const CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot)
return PAGEMODE_UNKNOWN;
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp
index 8f81b3a840..f73336a94f 100644
--- a/fpdfsdk/fpdfdoc.cpp
+++ b/fpdfsdk/fpdfdoc.cpp
@@ -387,7 +387,7 @@ FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetMetaText(FPDF_DOCUMENT document,
if (!pDoc)
return 0;
pDoc->LoadDocumentInfo();
- CPDF_Dictionary* pInfo = pDoc->GetInfo();
+ const CPDF_Dictionary* pInfo = pDoc->GetInfo();
if (!pInfo)
return 0;
CFX_WideString text = pInfo->GetUnicodeTextFor(tag);
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 6e142ed97c..b36c1dff23 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -721,7 +721,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
return;
CPDF_Document* pDoc = pFormFillEnv->GetPDFDocument();
- CPDF_Dictionary* pDict = pDoc->GetRoot();
+ const CPDF_Dictionary* pDict = pDoc->GetRoot();
if (!pDict)
return;
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 91f88503fc..455b5ba9ba 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -62,7 +62,7 @@ bool SaveXFADocumentData(
if (!pPDFDocument)
return false;
- CPDF_Dictionary* pRoot = pPDFDocument->GetRoot();
+ const CPDF_Dictionary* pRoot = pPDFDocument->GetRoot();
if (!pRoot)
return false;
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index bf8daad958..2bc229d14d 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -564,12 +564,12 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_HasXFAField(FPDF_DOCUMENT document,
if (!document)
return false;
- CPDF_Document* pdfDoc =
- (static_cast<CPDFXFA_Context*>(document))->GetPDFDoc();
- if (!pdfDoc)
+ const CPDF_Document* pDoc =
+ static_cast<CPDFXFA_Context*>(document)->GetPDFDoc();
+ if (!pDoc)
return false;
- CPDF_Dictionary* pRoot = pdfDoc->GetRoot();
+ const CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot)
return false;
@@ -587,7 +587,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_HasXFAField(FPDF_DOCUMENT document,
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_LoadXFA(FPDF_DOCUMENT document) {
- return document && (static_cast<CPDFXFA_Context*>(document))->LoadXFADoc();
+ return document && static_cast<CPDFXFA_Context*>(document)->LoadXFADoc();
}
#endif // PDF_ENABLE_XFA
@@ -640,7 +640,7 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_GetFileVersion(FPDF_DOCUMENT doc,
if (!pDoc)
return false;
- CPDF_Parser* pParser = pDoc->GetParser();
+ const CPDF_Parser* pParser = pDoc->GetParser();
if (!pParser)
return false;
@@ -1349,7 +1349,7 @@ FPDF_CountNamedDests(FPDF_DOCUMENT document) {
if (!pDoc)
return 0;
- CPDF_Dictionary* pRoot = pDoc->GetRoot();
+ const CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot)
return 0;
@@ -1445,7 +1445,7 @@ FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDF_GetNamedDest(FPDF_DOCUMENT document,
if (!pDoc)
return nullptr;
- CPDF_Dictionary* pRoot = pDoc->GetRoot();
+ const CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot)
return nullptr;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index c0c28db192..65379254f0 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -384,7 +384,7 @@ void CPDFXFA_DocEnvironment::GetTitle(CXFA_FFDoc* hDoc,
if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetPDFDoc())
return;
- CPDF_Dictionary* pInfoDict = m_pContext->GetPDFDoc()->GetInfo();
+ const CPDF_Dictionary* pInfoDict = m_pContext->GetPDFDoc()->GetInfo();
if (!pInfoDict)
return;
@@ -398,7 +398,8 @@ void CPDFXFA_DocEnvironment::SetTitle(CXFA_FFDoc* hDoc,
if (hDoc != m_pContext->GetXFADoc() || !m_pContext->GetPDFDoc())
return;
- if (CPDF_Dictionary* pInfoDict = m_pContext->GetPDFDoc()->GetInfo())
+ CPDF_Dictionary* pInfoDict = m_pContext->GetPDFDoc()->GetInfo();
+ if (pInfoDict)
pInfoDict->SetNewFor<CPDF_String>("Title", wsTitle);
}
@@ -449,7 +450,7 @@ void CPDFXFA_DocEnvironment::ExportData(CXFA_FFDoc* hDoc,
if (!m_pContext->GetPDFDoc())
return;
- CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
+ const CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
if (!pRoot)
return;
@@ -750,7 +751,7 @@ bool CPDFXFA_DocEnvironment::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
return false;
}
- CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
+ const CPDF_Dictionary* pRoot = m_pContext->GetPDFDoc()->GetRoot();
if (!pRoot) {
fileStream->Flush();
return false;
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index d8934a44f6..d5875aca69 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -754,7 +754,7 @@ bool Document::info(CJS_Runtime* pRuntime,
sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
return false;
}
- CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
+ const auto* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
return false;