diff options
author | Lei Zhang <thestig@chromium.org> | 2018-05-24 01:36:40 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-24 01:36:40 +0000 |
commit | dbf13f6562a902df17f6e543d3be844ca82956e2 (patch) | |
tree | 7ba195555b7534e51708fd8d26000db0700b7cfe | |
parent | 7e33dbeec78dfa051df52619672133da6a799240 (diff) | |
download | pdfium-dbf13f6562a902df17f6e543d3be844ca82956e2.tar.xz |
Improve constness for more CPDF_Objects pointers.
Most of them can be marked const. A couple are marked non-const because
eventually something inside gets modified.
Change-Id: I5415ca8d1efdac451cde340272436cd1e6ec433f
Reviewed-on: https://pdfium-review.googlesource.com/32184
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r-- | core/fpdfdoc/cpdf_aaction.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_aaction.h | 6 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_iconfit.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/cfx_seekablemultistream.cpp | 4 | ||||
-rw-r--r-- | core/fxcrt/cfx_seekablemultistream.h | 3 | ||||
-rw-r--r-- | core/fxcrt/cfx_seekablemultistream_unittest.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/fpdf_save.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_icon.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.cpp | 14 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdoc.h | 2 |
10 files changed, 24 insertions, 23 deletions
diff --git a/core/fpdfdoc/cpdf_aaction.cpp b/core/fpdfdoc/cpdf_aaction.cpp index 2628ca009e..9a95340114 100644 --- a/core/fpdfdoc/cpdf_aaction.cpp +++ b/core/fpdfdoc/cpdf_aaction.cpp @@ -38,7 +38,7 @@ static_assert(FX_ArraySize(g_sAATypes) == CPDF_AAction::NumberOfActions, } // namespace -CPDF_AAction::CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {} +CPDF_AAction::CPDF_AAction(const CPDF_Dictionary* pDict) : m_pDict(pDict) {} CPDF_AAction::CPDF_AAction(const CPDF_AAction& that) = default; diff --git a/core/fpdfdoc/cpdf_aaction.h b/core/fpdfdoc/cpdf_aaction.h index a5b0d25525..11eca01f8f 100644 --- a/core/fpdfdoc/cpdf_aaction.h +++ b/core/fpdfdoc/cpdf_aaction.h @@ -38,16 +38,16 @@ class CPDF_AAction { NumberOfActions // Must be last. }; - explicit CPDF_AAction(CPDF_Dictionary* pDict); + explicit CPDF_AAction(const CPDF_Dictionary* pDict); CPDF_AAction(const CPDF_AAction& that); ~CPDF_AAction(); bool ActionExist(AActionType eType) const; CPDF_Action GetAction(AActionType eType) const; - CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } + const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } private: - UnownedPtr<CPDF_Dictionary> const m_pDict; + UnownedPtr<const CPDF_Dictionary> const m_pDict; }; #endif // CORE_FPDFDOC_CPDF_AACTION_H_ diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp index 20ed963e92..5b3deee93f 100644 --- a/core/fpdfdoc/cpdf_iconfit.cpp +++ b/core/fpdfdoc/cpdf_iconfit.cpp @@ -39,7 +39,7 @@ void CPDF_IconFit::GetIconPosition(float& fLeft, float& fBottom) { if (!m_pDict) return; - CPDF_Array* pA = m_pDict->GetArrayFor("A"); + const CPDF_Array* pA = m_pDict->GetArrayFor("A"); if (pA) { uint32_t dwCount = pA->GetCount(); if (dwCount > 0) diff --git a/core/fxcrt/cfx_seekablemultistream.cpp b/core/fxcrt/cfx_seekablemultistream.cpp index 92286b1939..24a29ee425 100644 --- a/core/fxcrt/cfx_seekablemultistream.cpp +++ b/core/fxcrt/cfx_seekablemultistream.cpp @@ -13,8 +13,8 @@ #include "third_party/base/stl_util.h" CFX_SeekableMultiStream::CFX_SeekableMultiStream( - const std::vector<CPDF_Stream*>& streams) { - for (CPDF_Stream* pStream : streams) { + const std::vector<const CPDF_Stream*>& streams) { + for (const CPDF_Stream* pStream : streams) { m_Data.push_back(pdfium::MakeRetain<CPDF_StreamAcc>(pStream)); m_Data.back()->LoadAllDataFiltered(); } diff --git a/core/fxcrt/cfx_seekablemultistream.h b/core/fxcrt/cfx_seekablemultistream.h index 9138d7c321..4bd26b9863 100644 --- a/core/fxcrt/cfx_seekablemultistream.h +++ b/core/fxcrt/cfx_seekablemultistream.h @@ -17,7 +17,8 @@ class CPDF_StreamAcc; class CFX_SeekableMultiStream : public IFX_SeekableStream { public: - explicit CFX_SeekableMultiStream(const std::vector<CPDF_Stream*>& streams); + explicit CFX_SeekableMultiStream( + const std::vector<const CPDF_Stream*>& streams); ~CFX_SeekableMultiStream() override; // IFX_SeekableReadStream diff --git a/core/fxcrt/cfx_seekablemultistream_unittest.cpp b/core/fxcrt/cfx_seekablemultistream_unittest.cpp index 89213b13af..89be1bd180 100644 --- a/core/fxcrt/cfx_seekablemultistream_unittest.cpp +++ b/core/fxcrt/cfx_seekablemultistream_unittest.cpp @@ -15,7 +15,7 @@ #include "third_party/base/ptr_util.h" TEST(CFX_SeekableMultiStreamTest, NoStreams) { - std::vector<CPDF_Stream*> streams; + std::vector<const CPDF_Stream*> streams; auto fileread = pdfium::MakeRetain<CFX_SeekableMultiStream>(streams); uint8_t output_buffer[16]; @@ -25,7 +25,7 @@ TEST(CFX_SeekableMultiStreamTest, NoStreams) { } TEST(CXFAFileReadTest, EmptyStreams) { - std::vector<CPDF_Stream*> streams; + std::vector<const CPDF_Stream*> streams; auto stream1 = pdfium::MakeUnique<CPDF_Stream>(); streams.push_back(stream1.get()); auto fileread = pdfium::MakeRetain<CFX_SeekableMultiStream>(streams); @@ -37,7 +37,7 @@ TEST(CXFAFileReadTest, EmptyStreams) { } TEST(CXFAFileReadTest, NormalStreams) { - std::vector<CPDF_Stream*> streams; + std::vector<const CPDF_Stream*> streams; auto stream1 = pdfium::MakeUnique<CPDF_Stream>(); auto stream2 = pdfium::MakeUnique<CPDF_Stream>(); auto stream3 = pdfium::MakeUnique<CPDF_Stream>(); diff --git a/fpdfsdk/fpdf_save.cpp b/fpdfsdk/fpdf_save.cpp index e4a1a607bb..6064a73629 100644 --- a/fpdfsdk/fpdf_save.cpp +++ b/fpdfsdk/fpdf_save.cpp @@ -59,7 +59,7 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext, if (!pPDFDocument) return false; - const CPDF_Dictionary* pRoot = pPDFDocument->GetRoot(); + CPDF_Dictionary* pRoot = pPDFDocument->GetRoot(); if (!pRoot) return false; @@ -80,7 +80,7 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext, int iDataSetsIndex = -1; int iLast = size - 2; for (int i = 0; i < size - 1; i++) { - CPDF_Object* pPDFObj = pArray->GetObjectAt(i); + const CPDF_Object* pPDFObj = pArray->GetObjectAt(i); if (!pPDFObj->IsString()) continue; if (pPDFObj->GetString() == "form") @@ -90,7 +90,6 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext, } CPDF_Stream* pFormStream = nullptr; - CPDF_Stream* pDataSetsStream = nullptr; if (iFormIndex != -1) { // Get form CPDF_Stream CPDF_Object* pFormPDFObj = pArray->GetObjectAt(iFormIndex); @@ -104,6 +103,7 @@ bool SaveXFADocumentData(CPDFXFA_Context* pContext, } } + CPDF_Stream* pDataSetsStream = nullptr; if (iDataSetsIndex != -1) { // Get datasets CPDF_Stream CPDF_Object* pDataSetsPDFObj = pArray->GetObjectAt(iDataSetsIndex); diff --git a/fpdfsdk/pwl/cpwl_icon.cpp b/fpdfsdk/pwl/cpwl_icon.cpp index 52a4464639..567a5786e6 100644 --- a/fpdfsdk/pwl/cpwl_icon.cpp +++ b/fpdfsdk/pwl/cpwl_icon.cpp @@ -49,7 +49,7 @@ std::pair<float, float> CPWL_Icon::GetIconPosition() { if (!m_pIconFit) return {0.0f, 0.0f}; - CPDF_Array* pA = + const CPDF_Array* pA = m_pIconFit->GetDict() ? m_pIconFit->GetDict()->GetArrayFor("A") : nullptr; if (!pA) return {0.0f, 0.0f}; diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp index bc4a939078..330572ff9c 100644 --- a/xfa/fxfa/cxfa_ffdoc.cpp +++ b/xfa/fxfa/cxfa_ffdoc.cpp @@ -44,12 +44,12 @@ CXFA_FFDoc::~CXFA_FFDoc() { CloseDoc(); } -bool CXFA_FFDoc::ParseDoc(CPDF_Object* pElementXFA) { - std::vector<CPDF_Stream*> xfaStreams; +bool CXFA_FFDoc::ParseDoc(const CPDF_Object* pElementXFA) { + std::vector<const CPDF_Stream*> xfaStreams; if (pElementXFA->IsArray()) { - CPDF_Array* pXFAArray = pElementXFA->AsArray(); + const CPDF_Array* pXFAArray = pElementXFA->AsArray(); for (size_t i = 0; i < pXFAArray->GetCount() / 2; i++) { - if (CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) + if (const CPDF_Stream* pStream = pXFAArray->GetStreamAt(i * 2 + 1)) xfaStreams.push_back(pStream); } } else if (pElementXFA->IsStream()) { @@ -99,11 +99,11 @@ bool CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { if (!pRoot) return false; - CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); + const CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm"); if (!pAcroForm) return false; - CPDF_Object* pElementXFA = pAcroForm->GetDirectObjectFor("XFA"); + const CPDF_Object* pElementXFA = pAcroForm->GetDirectObjectFor("XFA"); if (!pElementXFA) return false; @@ -183,7 +183,7 @@ RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage( return it->second.pDibSource.As<CFX_DIBitmap>(); } - const CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); + CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); if (!pRoot) return nullptr; diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h index 356a157437..88becb4071 100644 --- a/xfa/fxfa/cxfa_ffdoc.h +++ b/xfa/fxfa/cxfa_ffdoc.h @@ -81,7 +81,7 @@ class CXFA_FFDoc { const RetainPtr<IFX_SeekableStream>& pFile); private: - bool ParseDoc(CPDF_Object* pElementXFA); + bool ParseDoc(const CPDF_Object* pElementXFA); UnownedPtr<IXFA_DocEnvironment> const m_pDocEnvironment; UnownedPtr<CXFA_FFApp> const m_pApp; |