From 8ef4ef26481d8ed80d33b898bcff829fa7c0999c Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Fri, 8 Jun 2018 20:39:04 +0000 Subject: Move getting the CPDF_CryptoHandler into CPDF_Creator::WriteStream() No reason to get it outside and pass it in. Change-Id: I75e3bbd361c04e195004d7c538145dfd56294816 Reviewed-on: https://pdfium-review.googlesource.com/34731 Commit-Queue: Henrique Nakashima Reviewed-by: Lei Zhang --- core/fpdfapi/edit/cpdf_creator.cpp | 11 +++++------ core/fpdfapi/edit/cpdf_creator.h | 4 +--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp index 60872c2059..ff8d4bb82f 100644 --- a/core/fpdfapi/edit/cpdf_creator.cpp +++ b/core/fpdfapi/edit/cpdf_creator.cpp @@ -151,9 +151,10 @@ CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc, CPDF_Creator::~CPDF_Creator() {} -bool CPDF_Creator::WriteStream(const CPDF_Object* pStream, - uint32_t objnum, - CPDF_CryptoHandler* pCrypto) { +bool CPDF_Creator::WriteStream(const CPDF_Object* pStream, uint32_t objnum) { + CPDF_CryptoHandler* pCrypto = + pStream != m_pMetadata ? GetCryptoHandler() : nullptr; + CPDF_FlateEncoder encoder(pStream->AsStream(), pStream != m_pMetadata); CPDF_Encryptor encryptor(pCrypto, objnum, encoder.GetSpan()); if (static_cast(encoder.GetDict()->GetIntegerFor("Length")) != @@ -183,9 +184,7 @@ bool CPDF_Creator::WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj) { return false; if (pObj->IsStream()) { - CPDF_CryptoHandler* pHandler = - pObj != m_pMetadata ? GetCryptoHandler() : nullptr; - if (!WriteStream(pObj, objnum, pHandler)) + if (!WriteStream(pObj, objnum)) return false; } else if (!WriteDirectObj(objnum, pObj, true)) { return false; diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h index af1a486d44..9c760edeae 100644 --- a/core/fpdfapi/edit/cpdf_creator.h +++ b/core/fpdfapi/edit/cpdf_creator.h @@ -55,9 +55,7 @@ class CPDF_Creator { bool WriteDirectObj(uint32_t objnum, const CPDF_Object* pObj, bool bEncrypt); bool WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj); - bool WriteStream(const CPDF_Object* pStream, - uint32_t objnum, - CPDF_CryptoHandler* pCrypto); + bool WriteStream(const CPDF_Object* pStream, uint32_t objnum); CPDF_CryptoHandler* GetCryptoHandler(); -- cgit v1.2.3