summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2018-04-17 18:23:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-17 18:23:49 +0000
commitbddc60d0977068fbe89a1dad403f2e6ddd7ff1a1 (patch)
tree1769780973bd083f4598baed4d54a200737805fa
parentffdae5fceb4e0b37bc649d99d12c15ccd6ae1b9e (diff)
downloadpdfium-bddc60d0977068fbe89a1dad403f2e6ddd7ff1a1.tar.xz
Remove write abilities from CFX_SeekableStreamProxy
This CL removes the abliity to write to the seekable stream proxy class. Change-Id: I0eda2619714df190d326c23dfdcd4527d4312779 Reviewed-on: https://pdfium-review.googlesource.com/30853 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.cpp37
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.h6
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp3
3 files changed, 5 insertions, 41 deletions
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp
index 989c440db1..44a212d867 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -134,20 +134,13 @@ void SwapByteOrder(wchar_t* pStr, size_t iLength) {
#define BOM_UTF16_LE 0x0000FEFF
CFX_SeekableStreamProxy::CFX_SeekableStreamProxy(
- const RetainPtr<IFX_SeekableStream>& stream,
- bool isWriteStream)
- : m_IsWriteStream(isWriteStream),
- m_wCodePage(FX_CODEPAGE_DefANSI),
+ const RetainPtr<IFX_SeekableStream>& stream)
+ : m_wCodePage(FX_CODEPAGE_DefANSI),
m_wBOMLength(0),
m_iPosition(0),
m_pStream(stream) {
ASSERT(m_pStream);
- if (isWriteStream) {
- m_iPosition = m_pStream->GetSize();
- return;
- }
-
Seek(From::Begin, 0);
uint32_t bom = 0;
@@ -176,8 +169,7 @@ CFX_SeekableStreamProxy::CFX_SeekableStreamProxy(
CFX_SeekableStreamProxy::CFX_SeekableStreamProxy(uint8_t* data, size_t size)
: CFX_SeekableStreamProxy(
- pdfium::MakeRetain<CFX_MemoryStream>(data, size, false),
- false) {}
+ pdfium::MakeRetain<CFX_MemoryStream>(data, size, false)) {}
CFX_SeekableStreamProxy::~CFX_SeekableStreamProxy() {}
@@ -206,9 +198,6 @@ void CFX_SeekableStreamProxy::SetCodePage(uint16_t wCodePage) {
size_t CFX_SeekableStreamProxy::ReadData(uint8_t* pBuffer, size_t iBufferSize) {
ASSERT(pBuffer && iBufferSize > 0);
- if (m_IsWriteStream)
- return 0;
-
iBufferSize =
std::min(iBufferSize, static_cast<size_t>(GetLength() - m_iPosition));
if (iBufferSize <= 0)
@@ -229,9 +218,6 @@ size_t CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
if (!pStr || iMaxLength == 0)
return 0;
- if (m_IsWriteStream)
- return 0;
-
if (m_wCodePage == FX_CODEPAGE_UTF16LE ||
m_wCodePage == FX_CODEPAGE_UTF16BE) {
size_t iBytes = iMaxLength * 2;
@@ -267,20 +253,3 @@ size_t CFX_SeekableStreamProxy::ReadString(wchar_t* pStr,
*bEOS = IsEOF();
return iMaxLength;
}
-
-void CFX_SeekableStreamProxy::WriteString(const WideStringView& str) {
- if (!m_IsWriteStream || str.GetLength() == 0 ||
- m_wCodePage != FX_CODEPAGE_UTF8) {
- return;
- }
- if (!m_pStream->WriteBlock(str.unterminated_c_str(), m_iPosition,
- str.GetLength() * sizeof(wchar_t))) {
- return;
- }
-
- pdfium::base::CheckedNumeric<FX_FILESIZE> new_pos = m_iPosition;
- new_pos += str.GetLength() * sizeof(wchar_t);
- m_iPosition = new_pos.ValueOrDefault(std::numeric_limits<FX_FILESIZE>::max());
- m_iPosition =
- pdfium::clamp(m_iPosition, static_cast<FX_FILESIZE>(0), GetLength());
-}
diff --git a/core/fxcrt/cfx_seekablestreamproxy.h b/core/fxcrt/cfx_seekablestreamproxy.h
index c25ab3c9b6..451f7769c2 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.h
+++ b/core/fxcrt/cfx_seekablestreamproxy.h
@@ -31,20 +31,16 @@ class CFX_SeekableStreamProxy : public Retainable {
void Seek(From eSeek, FX_FILESIZE iOffset);
size_t ReadString(wchar_t* pStr, size_t iMaxLength, bool* bEOS);
- void WriteString(const WideStringView& str);
-
uint16_t GetCodePage() const { return m_wCodePage; }
void SetCodePage(uint16_t wCodePage);
private:
- CFX_SeekableStreamProxy(const RetainPtr<IFX_SeekableStream>& stream,
- bool isWriteSteam);
+ explicit CFX_SeekableStreamProxy(const RetainPtr<IFX_SeekableStream>& stream);
CFX_SeekableStreamProxy(uint8_t* data, size_t size);
~CFX_SeekableStreamProxy() override;
size_t ReadData(uint8_t* pBuffer, size_t iBufferSize);
- bool m_IsWriteStream;
uint16_t m_wCodePage;
size_t m_wBOMLength;
FX_FILESIZE m_iPosition;
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 32bcba0609..f52d52ff3c 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -329,8 +329,7 @@ CXFA_DocumentParser::~CXFA_DocumentParser() {}
bool CXFA_DocumentParser::Parse(const RetainPtr<IFX_SeekableStream>& pStream,
XFA_PacketType ePacketID) {
- auto pStreamProxy =
- pdfium::MakeRetain<CFX_SeekableStreamProxy>(pStream, false);
+ auto pStreamProxy = pdfium::MakeRetain<CFX_SeekableStreamProxy>(pStream);
uint16_t wCodePage = pStreamProxy->GetCodePage();
if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
wCodePage != FX_CODEPAGE_UTF8) {