From d39443e8a5ae8e189e272accc23c5e66d9f0bd8d Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Tue, 27 Jun 2017 16:13:17 -0400 Subject: Add overload for CPDF_Stream.SetData() that takes an ostringstream. Bug: pdfium:731 Change-Id: Ie65bafc644cff076b0d7aadcc5d0b0e33e2c199b Reviewed-on: https://pdfium-review.googlesource.com/7035 Commit-Queue: Henrique Nakashima Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_stream.cpp | 5 +++++ core/fpdfapi/parser/cpdf_stream.h | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp index 69a87e6d2e..ec12ac5080 100644 --- a/core/fpdfapi/parser/cpdf_stream.cpp +++ b/core/fpdfapi/parser/cpdf_stream.cpp @@ -110,6 +110,11 @@ void CPDF_Stream::SetData(const uint8_t* pData, uint32_t size) { m_pDict->RemoveFor("DecodeParms"); } +void CPDF_Stream::SetData(std::ostringstream* stream) { + SetData(reinterpret_cast(stream->str().c_str()), + stream->tellp()); +} + bool CPDF_Stream::ReadRawData(FX_FILESIZE offset, uint8_t* buf, uint32_t size) const { diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h index 82cc01aef3..d58f608f72 100644 --- a/core/fpdfapi/parser/cpdf_stream.h +++ b/core/fpdfapi/parser/cpdf_stream.h @@ -9,6 +9,7 @@ #include #include +#include #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_object.h" @@ -38,8 +39,9 @@ class CPDF_Stream : public CPDF_Object { uint32_t GetRawSize() const { return m_dwSize; } uint8_t* GetRawData() const { return m_pDataBuf.get(); } - // Does not takes onwership of |pData|, copies into internally-owned buffer. + // Does not takes ownership of |pData|, copies into internally-owned buffer. void SetData(const uint8_t* pData, uint32_t size); + void SetData(std::ostringstream* stream); void InitStream(const uint8_t* pData, uint32_t size, -- cgit v1.2.3