summaryrefslogtreecommitdiff
path: root/core/fpdfapi/edit/cpdf_objectstream.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-05-09 15:13:48 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-05-09 19:28:48 +0000
commit6161445d85f28115519985e616039623b970b0a1 (patch)
treeea6f8d4f73499e6469f2fef1dd28e903c34009ce /core/fpdfapi/edit/cpdf_objectstream.cpp
parent808828cb7b5539ab9a3f52b67ada6f26fa3c9d51 (diff)
downloadpdfium-6161445d85f28115519985e616039623b970b0a1.tar.xz
Edit code cleanup
Minor cleans in the fpdfapi/edit code. Change-Id: I7bb2f4add7c6e84f072501035b1f77c218174cca Reviewed-on: https://pdfium-review.googlesource.com/5152 Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/edit/cpdf_objectstream.cpp')
-rw-r--r--core/fpdfapi/edit/cpdf_objectstream.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/core/fpdfapi/edit/cpdf_objectstream.cpp b/core/fpdfapi/edit/cpdf_objectstream.cpp
index e3f6e4c8e9..fa0284433b 100644
--- a/core/fpdfapi/edit/cpdf_objectstream.cpp
+++ b/core/fpdfapi/edit/cpdf_objectstream.cpp
@@ -47,6 +47,7 @@ void CPDF_ObjectStream::CompressIndirectObject(uint32_t dwObjNum,
FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) {
ASSERT(pCreator);
+
if (m_Items.empty())
return 0;
@@ -62,32 +63,38 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) {
int32_t len = pFile->AppendDWord(m_dwObjNum);
if (len < 0)
return -1;
-
pCreator->IncrementOffset(len);
- if ((len = pFile->AppendString(" 0 obj\r\n<</Type /ObjStm /N ")) < 0)
+
+ len = pFile->AppendString(" 0 obj\r\n<</Type /ObjStm /N ");
+ if (len < 0)
return -1;
pCreator->IncrementOffset(len);
uint32_t iCount = pdfium::CollectionSize<uint32_t>(m_Items);
- if ((len = pFile->AppendDWord(iCount)) < 0)
+ len = pFile->AppendDWord(iCount);
+ if (len < 0)
return -1;
-
pCreator->IncrementOffset(len);
+
if (pFile->AppendString("/First ") < 0)
return -1;
- if ((len = pFile->AppendDWord((uint32_t)tempBuffer.GetLength())) < 0)
+
+ len = pFile->AppendDWord(static_cast<uint32_t>(tempBuffer.GetLength()));
+ if (len < 0)
return -1;
if (pFile->AppendString("/Length ") < 0)
return -1;
-
pCreator->IncrementOffset(len + 15);
tempBuffer << m_Buffer;
+
CPDF_FlateEncoder encoder(tempBuffer.GetBuffer(), tempBuffer.GetLength(),
true, false);
CPDF_Encryptor encryptor(pCreator->GetCryptoHandler(), m_dwObjNum,
encoder.GetData(), encoder.GetSize());
- if ((len = pFile->AppendDWord(encryptor.GetSize())) < 0)
+
+ len = pFile->AppendDWord(encryptor.GetSize());
+ if (len < 0)
return -1;
pCreator->IncrementOffset(len);
@@ -95,13 +102,15 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) {
return -1;
pCreator->IncrementOffset(20);
- if ((len = pFile->AppendString(">>stream\r\n")) < 0)
+ len = pFile->AppendString(">>stream\r\n");
+ if (len < 0)
return -1;
if (pFile->AppendBlock(encryptor.GetData(), encryptor.GetSize()) < 0)
return -1;
pCreator->IncrementOffset(len + encryptor.GetSize());
- if ((len = pFile->AppendString("\r\nendstream\r\nendobj\r\n")) < 0)
+ len = pFile->AppendString("\r\nendstream\r\nendobj\r\n");
+ if (len < 0)
return -1;
pCreator->IncrementOffset(len);