diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-05-10 13:54:54 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-10 19:40:30 +0000 |
commit | aa7022833db1a6e21b81fcca30b45ba652298f32 (patch) | |
tree | 2a24f3f64c57776b27155f742f77c8805aa5215f /core/fpdfapi/edit/cpdf_objectstream.cpp | |
parent | 2e2ee0e7f786dbc27a5b85b27d5e91e821069aea (diff) | |
download | pdfium-aa7022833db1a6e21b81fcca30b45ba652298f32.tar.xz |
Cleaning up Edit code
This Cl conslidates if statements, converts int returns to bools where
possible and various other cleanups in fpdfapi/edit.
Change-Id: Ia31ecc69843117eb5ebfff449a6046a267d08e89
Reviewed-on: https://pdfium-review.googlesource.com/5190
Reviewed-by: Nicolás Peña <npm@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.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/core/fpdfapi/edit/cpdf_objectstream.cpp b/core/fpdfapi/edit/cpdf_objectstream.cpp index fa0284433b..9b636f2e54 100644 --- a/core/fpdfapi/edit/cpdf_objectstream.cpp +++ b/core/fpdfapi/edit/cpdf_objectstream.cpp @@ -68,10 +68,9 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) { 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); - len = pFile->AppendDWord(iCount); + + len = pFile->AppendDWord(pdfium::CollectionSize<uint32_t>(m_Items)); if (len < 0) return -1; pCreator->IncrementOffset(len); @@ -80,9 +79,7 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) { return -1; len = pFile->AppendDWord(static_cast<uint32_t>(tempBuffer.GetLength())); - if (len < 0) - return -1; - if (pFile->AppendString("/Length ") < 0) + if (len < 0 || pFile->AppendString("/Length ") < 0) return -1; pCreator->IncrementOffset(len + 15); @@ -96,23 +93,23 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) { len = pFile->AppendDWord(encryptor.GetSize()); if (len < 0) return -1; - pCreator->IncrementOffset(len); + if (pFile->AppendString("/Filter /FlateDecode") < 0) return -1; - pCreator->IncrementOffset(20); + len = pFile->AppendString(">>stream\r\n"); - if (len < 0) + if (len < 0 || + pFile->AppendBlock(encryptor.GetData(), encryptor.GetSize()) < 0) { return -1; - if (pFile->AppendBlock(encryptor.GetData(), encryptor.GetSize()) < 0) - return -1; - + } pCreator->IncrementOffset(len + encryptor.GetSize()); + len = pFile->AppendString("\r\nendstream\r\nendobj\r\n"); if (len < 0) return -1; - pCreator->IncrementOffset(len); + return ObjOffset; } |