From fdf7d4092a5fa9c79bbb4a626a4d3d087053ae2c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 18 Apr 2017 15:25:58 -0400 Subject: Remove IFGAS_Stream::CreateWideStringReadStream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl removes the wide string read stream and passes through a memory stream as needed. The callers were updated to pass the correct types. Change-Id: I8e2660859a85e38ed1c3f4c596ef7c8242762084 Reviewed-on: https://pdfium-review.googlesource.com/4172 Commit-Queue: dsinclair Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña --- xfa/fgas/crt/ifgas_stream.cpp | 71 ------------------------------------------- xfa/fgas/crt/ifgas_stream.h | 2 -- 2 files changed, 73 deletions(-) (limited to 'xfa/fgas/crt') diff --git a/xfa/fgas/crt/ifgas_stream.cpp b/xfa/fgas/crt/ifgas_stream.cpp index 06ab46551d..7a90626fe8 100644 --- a/xfa/fgas/crt/ifgas_stream.cpp +++ b/xfa/fgas/crt/ifgas_stream.cpp @@ -56,36 +56,6 @@ class CFGAS_Stream : public IFGAS_Stream { CFX_RetainPtr m_pStream; }; -class CFGAS_WideStringReadStream : public IFGAS_Stream { - public: - template - friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); - - // IFGAS_Stream - FX_FILESIZE GetLength() const override { - return m_wsBuffer.GetLength() * sizeof(wchar_t); - } - FX_FILESIZE GetPosition() override { return m_iPosition * sizeof(wchar_t); } - FX_STRSIZE GetBOMLength() const override { return 0; } - void Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) override; - bool IsEOF() const override { return m_iPosition >= m_wsBuffer.GetLength(); } - FX_STRSIZE ReadString(wchar_t* pStr, - FX_STRSIZE iMaxLength, - bool* bEOS) override; - void WriteString(const CFX_WideStringC& str) override {} - uint16_t GetCodePage() const override { - return sizeof(wchar_t) == 2 ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; - } - void SetCodePage(uint16_t wCodePage) override {} - - private: - explicit CFGAS_WideStringReadStream(const CFX_WideString& wsBuffer); - ~CFGAS_WideStringReadStream() override; - - CFX_WideString m_wsBuffer; - FX_FILESIZE m_iPosition; -}; - // Returns {src bytes consumed, dst bytes produced}. std::pair UTF8Decode(const char* pSrc, FX_STRSIZE srcLen, @@ -366,41 +336,6 @@ void CFGAS_Stream::WriteString(const CFX_WideStringC& str) { WriteData(str); } -CFGAS_WideStringReadStream::CFGAS_WideStringReadStream( - const CFX_WideString& wsBuffer) - : m_wsBuffer(wsBuffer), m_iPosition(0) {} - -CFGAS_WideStringReadStream::~CFGAS_WideStringReadStream() {} - -void CFGAS_WideStringReadStream::Seek(FX_STREAMSEEK eSeek, - FX_FILESIZE iOffset) { - switch (eSeek) { - case FX_STREAMSEEK_Begin: - m_iPosition = iOffset; - break; - case FX_STREAMSEEK_Current: - m_iPosition += iOffset; - break; - } - m_iPosition = pdfium::clamp(m_iPosition, static_cast(0), - static_cast(m_wsBuffer.GetLength())); -} - -FX_STRSIZE CFGAS_WideStringReadStream::ReadString(wchar_t* pStr, - FX_STRSIZE iMaxLength, - bool* bEOS) { - iMaxLength = - std::min(iMaxLength, - static_cast(m_wsBuffer.GetLength() - m_iPosition)); - if (iMaxLength == 0) - return 0; - - FXSYS_wcsncpy(pStr, m_wsBuffer.c_str() + m_iPosition, iMaxLength); - m_iPosition += iMaxLength; - *bEOS = IsEOF(); - return iMaxLength; -} - } // namespace // static @@ -420,9 +355,3 @@ CFX_RetainPtr IFGAS_Stream::CreateWriteStream( return pdfium::MakeRetain(pFileWrite, true); } - -// static -CFX_RetainPtr IFGAS_Stream::CreateWideStringReadStream( - const CFX_WideString& buffer) { - return pdfium::MakeRetain(buffer); -} diff --git a/xfa/fgas/crt/ifgas_stream.h b/xfa/fgas/crt/ifgas_stream.h index 620a023dd8..acc9f1c4eb 100644 --- a/xfa/fgas/crt/ifgas_stream.h +++ b/xfa/fgas/crt/ifgas_stream.h @@ -22,8 +22,6 @@ class IFGAS_Stream : public CFX_Retainable { const CFX_RetainPtr& pFileRead); static CFX_RetainPtr CreateWriteStream( const CFX_RetainPtr& pFileWrite); - static CFX_RetainPtr CreateWideStringReadStream( - const CFX_WideString& buffer); virtual FX_FILESIZE GetLength() const = 0; virtual FX_FILESIZE GetPosition() = 0; -- cgit v1.2.3