From 5c09f4ca825652f910d3ff406fcbf64d25f56e23 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Fri, 4 Aug 2017 12:28:52 -0400 Subject: Remove CFX_ByteTextBuf from cpdfsdk_interform.cpp and others. New version of the CL that include fpdf_parser_utility.cpp where there is an overload for CFX_ByteTextBuf << CPDF_Object* used by CFDF_Document. Bug: pdfium:731 Change-Id: I54f4e9ee7e10e94388f6f6584f3999f43689e84c Reviewed-on: https://pdfium-review.googlesource.com/10170 Reviewed-by: Tom Sepez Commit-Queue: Henrique Nakashima --- core/fpdfapi/parser/cfdf_document.cpp | 9 ++++++--- core/fpdfapi/parser/cfdf_document.h | 2 +- core/fpdfapi/parser/fpdf_parser_utility.cpp | 5 +++-- core/fpdfapi/parser/fpdf_parser_utility.h | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'core/fpdfapi/parser') diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp index 85e2f6ef04..b00806967b 100644 --- a/core/fpdfapi/parser/cfdf_document.cpp +++ b/core/fpdfapi/parser/cfdf_document.cpp @@ -7,6 +7,7 @@ #include "core/fpdfapi/parser/cfdf_document.h" #include +#include #include #include "core/fpdfapi/edit/cpdf_creator.h" @@ -88,10 +89,11 @@ void CFDF_Document::ParseStream( } } -bool CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const { +CFX_ByteString CFDF_Document::WriteToString() const { if (!m_pRootDict) - return false; + return CFX_ByteString(); + std::ostringstream buf; buf << "%FDF-1.2\r\n"; for (const auto& pair : *this) buf << pair.first << " 0 obj\r\n" @@ -99,5 +101,6 @@ bool CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const { buf << "trailer\r\n<GetObjNum() << " 0 R>>\r\n%%EOF\r\n"; - return true; + + return CFX_ByteString(buf); } diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h index 9a13877544..45bf83d426 100644 --- a/core/fpdfapi/parser/cfdf_document.h +++ b/core/fpdfapi/parser/cfdf_document.h @@ -27,7 +27,7 @@ class CFDF_Document : public CPDF_IndirectObjectHolder { CFDF_Document(); ~CFDF_Document() override; - bool WriteBuf(CFX_ByteTextBuf& buf) const; + CFX_ByteString WriteToString() const; CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); } protected: diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp index 0c0ca6644f..7cea16569f 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp @@ -151,7 +151,7 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) { return res; } -CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) { +std::ostream& operator<<(std::ostream& buf, const CPDF_Object* pObj) { if (!pObj) { buf << " null"; return buf; @@ -211,7 +211,8 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) { buf << p->GetDict() << "stream\r\n"; auto pAcc = pdfium::MakeRetain(p); pAcc->LoadAllData(true); - buf.AppendBlock(pAcc->GetData(), pAcc->GetSize()); + buf.write(reinterpret_cast(pAcc->GetData()), + pAcc->GetSize()); buf << "\r\nendstream"; break; } diff --git a/core/fpdfapi/parser/fpdf_parser_utility.h b/core/fpdfapi/parser/fpdf_parser_utility.h index 5e764ad07b..47431e47dd 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.h +++ b/core/fpdfapi/parser/fpdf_parser_utility.h @@ -43,6 +43,6 @@ int32_t GetHeaderOffset(const CFX_RetainPtr& pFile); int32_t GetDirectInteger(CPDF_Dictionary* pDict, const CFX_ByteString& key); -CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj); +std::ostream& operator<<(std::ostream& buf, const CPDF_Object* pObj); #endif // CORE_FPDFAPI_PARSER_FPDF_PARSER_UTILITY_H_ -- cgit v1.2.3