summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fgas/crt/ifgas_stream.cpp367
-rw-r--r--xfa/fgas/crt/ifgas_stream.h4
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp19
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h8
-rw-r--r--xfa/fxfa/cxfa_fileread.cpp25
-rw-r--r--xfa/fxfa/cxfa_fileread.h7
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp11
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.h6
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.h4
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.h4
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.h6
14 files changed, 194 insertions, 273 deletions
diff --git a/xfa/fgas/crt/ifgas_stream.cpp b/xfa/fgas/crt/ifgas_stream.cpp
index 41913b28b6..3f5069e4bb 100644
--- a/xfa/fgas/crt/ifgas_stream.cpp
+++ b/xfa/fgas/crt/ifgas_stream.cpp
@@ -23,91 +23,64 @@
namespace {
-class IFGAS_StreamImp {
+class CFGAS_Stream : public IFGAS_Stream {
public:
- virtual ~IFGAS_StreamImp() {}
-
- virtual FX_FILESIZE GetLength() const = 0;
- virtual FX_FILESIZE GetPosition() = 0;
-
- virtual void Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) = 0;
- virtual bool IsEOF() const = 0;
-
- virtual FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize) = 0;
- virtual void WriteData(const CFX_WideStringC& str) = 0;
+ // IFGAS_Stream
+ FX_FILESIZE GetLength() const override { return m_pStream->GetSize(); }
+ FX_FILESIZE GetPosition() override { return m_iPosition; }
+ FX_STRSIZE GetBOMLength() const override { return std::max(0, m_wBOMLength); }
+ FX_STRSIZE ReadString(wchar_t* pStr,
+ FX_STRSIZE iMaxLength,
+ bool* bEOS) override;
+ void Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) override;
+ bool IsEOF() const override { return m_iPosition >= GetLength(); }
+ void WriteString(const CFX_WideStringC& str) override;
+ uint16_t GetCodePage() const override { return m_wCodePage; }
+ void SetCodePage(uint16_t wCodePage) override;
protected:
- IFGAS_StreamImp();
-};
-
-class CFGAS_FileReadStreamImp : public IFGAS_StreamImp {
- public:
- explicit CFGAS_FileReadStreamImp(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead);
- ~CFGAS_FileReadStreamImp() override {}
+ CFGAS_Stream(const CFX_RetainPtr<IFX_SeekableStream>& stream,
+ bool isWriteSteam);
+ ~CFGAS_Stream() override;
- // IFGAS_StreamImp:
- FX_FILESIZE GetLength() const override;
- FX_FILESIZE GetPosition() override { return m_iPosition; }
- void Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) override;
- bool IsEOF() const override;
- FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize) override;
- void WriteData(const CFX_WideStringC& str) override {}
+ virtual FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize) {
+ return 0;
+ }
+ virtual void WriteData(const CFX_WideStringC& str) {}
- private:
- CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
+ uint16_t m_wCodePage;
+ FX_STRSIZE m_wBOMLength;
+ bool m_IsWriteStream;
FX_FILESIZE m_iPosition;
+ CFX_RetainPtr<IFX_SeekableStream> m_pStream;
};
-class CFGAS_FileWriteStreamImp : public IFGAS_StreamImp {
+class CFGAS_FileReadStreamImp : public CFGAS_Stream {
public:
- CFGAS_FileWriteStreamImp(
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite);
- ~CFGAS_FileWriteStreamImp() override {}
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
- // IFGAS_StreamImp:
- FX_FILESIZE GetLength() const override;
- FX_FILESIZE GetPosition() override { return m_iPosition; }
- void Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) override;
- bool IsEOF() const override;
- FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize) override {
- return 0;
- }
- void WriteData(const CFX_WideStringC& str) override;
+ // CFGAS_Stream:
+ FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize) override;
private:
- CFX_RetainPtr<IFX_SeekableWriteStream> m_pFileWrite;
- FX_FILESIZE m_iPosition;
+ explicit CFGAS_FileReadStreamImp(
+ const CFX_RetainPtr<IFX_SeekableStream>& pFileRead);
+ ~CFGAS_FileReadStreamImp() override {}
};
-class CFGAS_TextStream : public IFGAS_Stream {
+class CFGAS_FileWriteStreamImp : public CFGAS_Stream {
public:
template <typename T, typename... Args>
friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
- // IFGAS_Stream
- FX_FILESIZE GetLength() const override;
- FX_FILESIZE GetPosition() override;
- FX_STRSIZE GetBOMLength() const override;
- void Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) override;
- bool IsEOF() const override;
- FX_STRSIZE ReadString(wchar_t* pStr,
- FX_STRSIZE iMaxLength,
- bool* bEOS) override;
- void WriteString(const CFX_WideStringC& str) override;
- uint16_t GetCodePage() const override;
- void SetCodePage(uint16_t wCodePage) override;
+ // CFGAS_Stream:
+ void WriteData(const CFX_WideStringC& str) override;
private:
- CFGAS_TextStream(std::unique_ptr<IFGAS_StreamImp> imp, bool isWriteSteam);
- ~CFGAS_TextStream() override;
-
- void InitStream();
-
- uint16_t m_wCodePage;
- FX_STRSIZE m_wBOMLength;
- bool m_IsWriteStream;
- std::unique_ptr<IFGAS_StreamImp> m_pStreamImp;
+ explicit CFGAS_FileWriteStreamImp(
+ const CFX_RetainPtr<IFX_SeekableStream>& pFileWrite);
+ ~CFGAS_FileWriteStreamImp() override {}
};
class CFGAS_WideStringReadStream : public IFGAS_Stream {
@@ -116,16 +89,20 @@ class CFGAS_WideStringReadStream : public IFGAS_Stream {
friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
// IFGAS_Stream
- FX_FILESIZE GetLength() const override;
- FX_FILESIZE GetPosition() override;
+ 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;
+ 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;
+ uint16_t GetCodePage() const override {
+ return sizeof(wchar_t) == 2 ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE;
+ }
void SetCodePage(uint16_t wCodePage) override {}
private:
@@ -228,7 +205,7 @@ void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) {
wch = (wch >> 8) | (wch << 8);
wch &= 0x00FF;
*pStr = wch;
- pStr++;
+ ++pStr;
}
return;
}
@@ -237,117 +214,10 @@ void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) {
wch = static_cast<uint16_t>(*pStr);
wch = (wch >> 8) | (wch << 8);
*pStr = wch;
- pStr++;
+ ++pStr;
}
}
-IFGAS_StreamImp::IFGAS_StreamImp() {}
-
-CFGAS_FileReadStreamImp::CFGAS_FileReadStreamImp(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead)
- : m_pFileRead(pFileRead), m_iPosition(0) {
- ASSERT(m_pFileRead);
-}
-
-FX_FILESIZE CFGAS_FileReadStreamImp::GetLength() const {
- return m_pFileRead->GetSize();
-}
-
-void CFGAS_FileReadStreamImp::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<FX_FILESIZE>(0),
- m_pFileRead->GetSize());
-}
-
-bool CFGAS_FileReadStreamImp::IsEOF() const {
- return m_iPosition >= m_pFileRead->GetSize();
-}
-
-FX_STRSIZE CFGAS_FileReadStreamImp::ReadData(uint8_t* pBuffer,
- FX_STRSIZE iBufferSize) {
- ASSERT(pBuffer && iBufferSize > 0);
-
- iBufferSize =
- std::min(iBufferSize,
- static_cast<FX_STRSIZE>(m_pFileRead->GetSize() - m_iPosition));
- if (iBufferSize <= 0)
- return 0;
-
- if (m_pFileRead->ReadBlock(pBuffer, m_iPosition, iBufferSize)) {
- pdfium::base::CheckedNumeric<FX_FILESIZE> new_pos = m_iPosition;
- new_pos += iBufferSize;
- if (!new_pos.IsValid())
- return 0;
-
- m_iPosition = new_pos.ValueOrDie();
- return iBufferSize;
- }
- return 0;
-}
-
-CFGAS_FileWriteStreamImp::CFGAS_FileWriteStreamImp(
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite)
- : m_pFileWrite(pFileWrite), m_iPosition(m_pFileWrite->GetSize()) {
- ASSERT(m_pFileWrite);
-}
-
-FX_FILESIZE CFGAS_FileWriteStreamImp::GetLength() const {
- return m_pFileWrite->GetSize();
-}
-
-void CFGAS_FileWriteStreamImp::Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) {
- FX_FILESIZE iLength = GetLength();
- 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<FX_FILESIZE>(0), iLength);
-}
-
-bool CFGAS_FileWriteStreamImp::IsEOF() const {
- return m_iPosition >= GetLength();
-}
-
-void CFGAS_FileWriteStreamImp::WriteData(const CFX_WideStringC& str) {
- if (str.GetLength() == 0)
- return;
-
- if (m_pFileWrite->WriteBlock(str.c_str(), m_iPosition,
- str.GetLength() * sizeof(wchar_t))) {
- pdfium::base::CheckedNumeric<FX_STRSIZE> new_pos = m_iPosition;
- new_pos += str.GetLength() * sizeof(wchar_t);
- // TODO(dsinclair): Not sure what to do if we over flow ....
- if (!new_pos.IsValid())
- return;
-
- m_iPosition = new_pos.ValueOrDie();
- }
-}
-
-CFGAS_TextStream::CFGAS_TextStream(std::unique_ptr<IFGAS_StreamImp> imp,
- bool isWriteStream)
- : m_wCodePage(FX_CODEPAGE_DefANSI),
- m_wBOMLength(0),
- m_IsWriteStream(isWriteStream),
- m_pStreamImp(std::move(imp)) {
- ASSERT(m_pStreamImp);
- InitStream();
-}
-
-CFGAS_TextStream::~CFGAS_TextStream() {}
-
#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_
#define BOM_MASK 0x00FFFFFF
#define BOM_UTF8 0x00BFBBEF
@@ -362,12 +232,14 @@ CFGAS_TextStream::~CFGAS_TextStream() {}
#define BOM_UTF16_LE 0xFFFE0000
#endif // _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_
-void CFGAS_TextStream::InitStream() {
- FX_FILESIZE iPosition = m_pStreamImp->GetPosition();
- m_pStreamImp->Seek(FX_STREAMSEEK_Begin, 0);
+CFGAS_FileReadStreamImp::CFGAS_FileReadStreamImp(
+ const CFX_RetainPtr<IFX_SeekableStream>& pFileRead)
+ : CFGAS_Stream(pFileRead, false) {
+ FX_FILESIZE iPosition = GetPosition();
+ Seek(FX_STREAMSEEK_Begin, 0);
uint32_t bom;
- m_pStreamImp->ReadData(reinterpret_cast<uint8_t*>(&bom), 3);
+ ReadData(reinterpret_cast<uint8_t*>(&bom), 3);
bom &= BOM_MASK;
if (bom == BOM_UTF8) {
@@ -387,46 +259,88 @@ void CFGAS_TextStream::InitStream() {
}
}
- m_pStreamImp->Seek(
- FX_STREAMSEEK_Begin,
- std::max(static_cast<FX_FILESIZE>(m_wBOMLength), iPosition));
+ Seek(FX_STREAMSEEK_Begin,
+ std::max(static_cast<FX_FILESIZE>(m_wBOMLength), iPosition));
}
-FX_FILESIZE CFGAS_TextStream::GetLength() const {
- return m_pStreamImp->GetLength();
-}
+FX_STRSIZE CFGAS_FileReadStreamImp::ReadData(uint8_t* pBuffer,
+ FX_STRSIZE iBufferSize) {
+ ASSERT(pBuffer && iBufferSize > 0);
+
+ iBufferSize = std::min(
+ iBufferSize, static_cast<FX_STRSIZE>(m_pStream->GetSize() - m_iPosition));
+ if (iBufferSize <= 0)
+ return 0;
-void CFGAS_TextStream::Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) {
- m_pStreamImp->Seek(eSeek, iOffset);
+ if (m_pStream->ReadBlock(pBuffer, m_iPosition, iBufferSize)) {
+ pdfium::base::CheckedNumeric<FX_FILESIZE> new_pos = m_iPosition;
+ new_pos += iBufferSize;
+ if (!new_pos.IsValid())
+ return 0;
+
+ m_iPosition = new_pos.ValueOrDie();
+ return iBufferSize;
+ }
+ return 0;
}
-FX_FILESIZE CFGAS_TextStream::GetPosition() {
- return m_pStreamImp->GetPosition();
+CFGAS_FileWriteStreamImp::CFGAS_FileWriteStreamImp(
+ const CFX_RetainPtr<IFX_SeekableStream>& pFileWrite)
+ : CFGAS_Stream(pFileWrite, true) {
+ m_iPosition = m_pStream->GetSize();
}
-bool CFGAS_TextStream::IsEOF() const {
- return m_pStreamImp->IsEOF();
+void CFGAS_FileWriteStreamImp::WriteData(const CFX_WideStringC& str) {
+ if (str.GetLength() == 0)
+ return;
+
+ if (!m_pStream->WriteBlock(str.c_str(), m_iPosition,
+ str.GetLength() * sizeof(wchar_t)))
+ return;
+
+ pdfium::base::CheckedNumeric<FX_STRSIZE> new_pos = m_iPosition;
+ new_pos += str.GetLength() * sizeof(wchar_t);
+ // TODO(dsinclair): Not sure what to do if we over flow ....
+ if (!new_pos.IsValid())
+ return;
+
+ m_iPosition = new_pos.ValueOrDie();
}
-FX_STRSIZE CFGAS_TextStream::GetBOMLength() const {
- if (m_wBOMLength < 1)
- return 0;
- return m_wBOMLength;
+CFGAS_Stream::CFGAS_Stream(const CFX_RetainPtr<IFX_SeekableStream>& stream,
+ bool isWriteStream)
+ : m_wCodePage(FX_CODEPAGE_DefANSI),
+ m_wBOMLength(0),
+ m_IsWriteStream(isWriteStream),
+ m_iPosition(0),
+ m_pStream(stream) {
+ ASSERT(m_pStream);
}
-uint16_t CFGAS_TextStream::GetCodePage() const {
- return m_wCodePage;
+CFGAS_Stream::~CFGAS_Stream() {}
+
+void CFGAS_Stream::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<FX_FILESIZE>(0), GetLength());
}
-void CFGAS_TextStream::SetCodePage(uint16_t wCodePage) {
+void CFGAS_Stream::SetCodePage(uint16_t wCodePage) {
if (m_wBOMLength > 0)
return;
m_wCodePage = wCodePage;
}
-FX_STRSIZE CFGAS_TextStream::ReadString(wchar_t* pStr,
- FX_STRSIZE iMaxLength,
- bool* bEOS) {
+FX_STRSIZE CFGAS_Stream::ReadString(wchar_t* pStr,
+ FX_STRSIZE iMaxLength,
+ bool* bEOS) {
ASSERT(pStr && iMaxLength > 0);
if (m_IsWriteStream)
@@ -435,8 +349,7 @@ FX_STRSIZE CFGAS_TextStream::ReadString(wchar_t* pStr,
if (m_wCodePage == FX_CODEPAGE_UTF16LE ||
m_wCodePage == FX_CODEPAGE_UTF16BE) {
FX_FILESIZE iBytes = iMaxLength * 2;
- FX_STRSIZE iLen =
- m_pStreamImp->ReadData(reinterpret_cast<uint8_t*>(pStr), iBytes);
+ FX_STRSIZE iLen = ReadData(reinterpret_cast<uint8_t*>(pStr), iBytes);
iMaxLength = iLen / 2;
if (sizeof(wchar_t) > 2)
UTF16ToWChar(pStr, iMaxLength);
@@ -450,31 +363,31 @@ FX_STRSIZE CFGAS_TextStream::ReadString(wchar_t* pStr,
#endif
} else {
- FX_FILESIZE pos = m_pStreamImp->GetPosition();
- FX_STRSIZE iBytes = std::min(
- iMaxLength, static_cast<FX_STRSIZE>(m_pStreamImp->GetLength() - pos));
+ FX_FILESIZE pos = GetPosition();
+ FX_STRSIZE iBytes =
+ std::min(iMaxLength, static_cast<FX_STRSIZE>(GetLength() - pos));
if (iBytes > 0) {
std::vector<uint8_t> buf(iBytes);
- FX_STRSIZE iLen = m_pStreamImp->ReadData(buf.data(), iBytes);
+ FX_STRSIZE iLen = ReadData(buf.data(), iBytes);
if (m_wCodePage != FX_CODEPAGE_UTF8)
return -1;
FX_STRSIZE iSrc = 0;
std::tie(iSrc, iMaxLength) = UTF8Decode(
reinterpret_cast<const char*>(buf.data()), iLen, pStr, iMaxLength);
- m_pStreamImp->Seek(FX_STREAMSEEK_Current, iSrc - iLen);
+ Seek(FX_STREAMSEEK_Current, iSrc - iLen);
} else {
iMaxLength = 0;
}
}
- *bEOS = m_pStreamImp->IsEOF();
+ *bEOS = IsEOF();
return iMaxLength;
}
-void CFGAS_TextStream::WriteString(const CFX_WideStringC& str) {
+void CFGAS_Stream::WriteString(const CFX_WideStringC& str) {
if (!m_IsWriteStream)
return;
if (str.GetLength() == 0)
@@ -482,7 +395,7 @@ void CFGAS_TextStream::WriteString(const CFX_WideStringC& str) {
if (m_wCodePage != FX_CODEPAGE_UTF8)
return;
- m_pStreamImp->WriteData(str);
+ WriteData(str);
}
CFGAS_WideStringReadStream::CFGAS_WideStringReadStream(
@@ -491,10 +404,6 @@ CFGAS_WideStringReadStream::CFGAS_WideStringReadStream(
CFGAS_WideStringReadStream::~CFGAS_WideStringReadStream() {}
-FX_FILESIZE CFGAS_WideStringReadStream::GetLength() const {
- return m_wsBuffer.GetLength() * sizeof(wchar_t);
-}
-
void CFGAS_WideStringReadStream::Seek(FX_STREAMSEEK eSeek,
FX_FILESIZE iOffset) {
switch (eSeek) {
@@ -509,14 +418,6 @@ void CFGAS_WideStringReadStream::Seek(FX_STREAMSEEK eSeek,
static_cast<FX_FILESIZE>(m_wsBuffer.GetLength()));
}
-FX_FILESIZE CFGAS_WideStringReadStream::GetPosition() {
- return m_iPosition * sizeof(wchar_t);
-}
-
-bool CFGAS_WideStringReadStream::IsEOF() const {
- return m_iPosition >= m_wsBuffer.GetLength();
-}
-
FX_STRSIZE CFGAS_WideStringReadStream::ReadString(wchar_t* pStr,
FX_STRSIZE iMaxLength,
bool* bEOS) {
@@ -532,30 +433,24 @@ FX_STRSIZE CFGAS_WideStringReadStream::ReadString(wchar_t* pStr,
return iMaxLength;
}
-uint16_t CFGAS_WideStringReadStream::GetCodePage() const {
- return (sizeof(wchar_t) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE;
-}
-
} // namespace
// static
CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateReadStream(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead) {
+ const CFX_RetainPtr<IFX_SeekableStream>& pFileRead) {
if (!pFileRead)
return nullptr;
- return pdfium::MakeRetain<CFGAS_TextStream>(
- pdfium::MakeUnique<CFGAS_FileReadStreamImp>(pFileRead), false);
+ return pdfium::MakeRetain<CFGAS_FileReadStreamImp>(pFileRead);
}
// static
CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateWriteStream(
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite) {
+ const CFX_RetainPtr<IFX_SeekableStream>& pFileWrite) {
if (!pFileWrite)
return nullptr;
- return pdfium::MakeRetain<CFGAS_TextStream>(
- pdfium::MakeUnique<CFGAS_FileWriteStreamImp>(pFileWrite), true);
+ return pdfium::MakeRetain<CFGAS_FileWriteStreamImp>(pFileWrite);
}
// static
diff --git a/xfa/fgas/crt/ifgas_stream.h b/xfa/fgas/crt/ifgas_stream.h
index be42fe5ca3..620a023dd8 100644
--- a/xfa/fgas/crt/ifgas_stream.h
+++ b/xfa/fgas/crt/ifgas_stream.h
@@ -19,9 +19,9 @@ enum FX_STREAMSEEK {
class IFGAS_Stream : public CFX_Retainable {
public:
static CFX_RetainPtr<IFGAS_Stream> CreateReadStream(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead);
+ const CFX_RetainPtr<IFX_SeekableStream>& pFileRead);
static CFX_RetainPtr<IFGAS_Stream> CreateWriteStream(
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite);
+ const CFX_RetainPtr<IFX_SeekableStream>& pFileWrite);
static CFX_RetainPtr<IFGAS_Stream> CreateWideStringReadStream(
const CFX_WideString& buffer);
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 2bbdfa1b9c..3565370bde 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -281,7 +281,7 @@ CXFA_FFDocView* CXFA_FFDoc::GetDocView() {
return m_DocView.get();
}
-bool CXFA_FFDoc::OpenDoc(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream) {
+bool CXFA_FFDoc::OpenDoc(const CFX_RetainPtr<IFX_SeekableStream>& pStream) {
m_pStream = pStream;
return true;
}
@@ -389,9 +389,8 @@ CFX_RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(
auto pAcc = pdfium::MakeRetain<CPDF_StreamAcc>(pStream);
pAcc->LoadAllData();
- CFX_RetainPtr<IFX_SeekableReadStream> pImageFileRead =
- IFX_MemoryStream::Create(const_cast<uint8_t*>(pAcc->GetData()),
- pAcc->GetSize());
+ CFX_RetainPtr<IFX_SeekableStream> pImageFileRead = IFX_MemoryStream::Create(
+ const_cast<uint8_t*>(pAcc->GetData()), pAcc->GetSize());
CFX_RetainPtr<CFX_DIBitmap> pDibSource = XFA_LoadImageFromBuffer(
pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
@@ -399,10 +398,9 @@ CFX_RetainPtr<CFX_DIBitmap> CXFA_FFDoc::GetPDFNamedImage(
return pDibSource;
}
-bool CXFA_FFDoc::SavePackage(
- XFA_HashCode code,
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pFile,
- CFX_ChecksumContext* pCSContext) {
+bool CXFA_FFDoc::SavePackage(XFA_HashCode code,
+ const CFX_RetainPtr<IFX_SeekableStream>& pFile,
+ CFX_ChecksumContext* pCSContext) {
CXFA_Document* doc = m_pDocumentParser->GetDocument();
auto pExport = pdfium::MakeUnique<CXFA_DataExporter>(doc);
CXFA_Node* pNode = code == XFA_HASHCODE_Xfa ? doc->GetRoot()
@@ -418,9 +416,8 @@ bool CXFA_FFDoc::SavePackage(
pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr);
}
-bool CXFA_FFDoc::ImportData(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
- bool bXDP) {
+bool CXFA_FFDoc::ImportData(const CFX_RetainPtr<IFX_SeekableStream>& pStream,
+ bool bXDP) {
auto importer =
pdfium::MakeUnique<CXFA_DataImporter>(m_pDocumentParser->GetDocument());
return importer->ImportData(pStream);
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index 0bba956f14..c5822e3577 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -58,7 +58,7 @@ class CXFA_FFDoc {
CXFA_FFDocView* CreateDocView();
- bool OpenDoc(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream);
+ bool OpenDoc(const CFX_RetainPtr<IFX_SeekableStream>& pStream);
bool OpenDoc(CPDF_Document* pPDFDoc);
bool CloseDoc();
@@ -72,15 +72,15 @@ class CXFA_FFDoc {
int32_t& iImageYDpi);
bool SavePackage(XFA_HashCode code,
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pFile,
+ const CFX_RetainPtr<IFX_SeekableStream>& pFile,
CFX_ChecksumContext* pCSContext);
- bool ImportData(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ bool ImportData(const CFX_RetainPtr<IFX_SeekableStream>& pStream,
bool bXDP = true);
private:
IXFA_DocEnvironment* const m_pDocEnvironment;
std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser;
- CFX_RetainPtr<IFX_SeekableReadStream> m_pStream;
+ CFX_RetainPtr<IFX_SeekableStream> m_pStream;
CXFA_FFApp* m_pApp;
std::unique_ptr<CXFA_FFNotify> m_pNotify;
CPDF_Document* m_pPDFDoc;
diff --git a/xfa/fxfa/cxfa_fileread.cpp b/xfa/fxfa/cxfa_fileread.cpp
index e2ecad2e93..acd81a2232 100644
--- a/xfa/fxfa/cxfa_fileread.cpp
+++ b/xfa/fxfa/cxfa_fileread.cpp
@@ -54,3 +54,28 @@ bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
}
return false;
}
+
+size_t CXFA_FileRead::ReadBlock(void* buffer, size_t size) {
+ ASSERT(false);
+ return 0;
+}
+
+FX_FILESIZE CXFA_FileRead::GetPosition() {
+ return 0;
+}
+
+bool CXFA_FileRead::IsEOF() {
+ return false;
+}
+
+bool CXFA_FileRead::Flush() {
+ ASSERT(false);
+ return false;
+}
+
+bool CXFA_FileRead::WriteBlock(const void* pData,
+ FX_FILESIZE offset,
+ size_t size) {
+ ASSERT(false);
+ return false;
+}
diff --git a/xfa/fxfa/cxfa_fileread.h b/xfa/fxfa/cxfa_fileread.h
index 0c3348b8d5..2dba4d23df 100644
--- a/xfa/fxfa/cxfa_fileread.h
+++ b/xfa/fxfa/cxfa_fileread.h
@@ -15,14 +15,19 @@
class CPDF_Stream;
class CPDF_StreamAcc;
-class CXFA_FileRead : public IFX_SeekableReadStream {
+class CXFA_FileRead : public IFX_SeekableStream {
public:
explicit CXFA_FileRead(const std::vector<CPDF_Stream*>& streams);
~CXFA_FileRead() override;
// IFX_SeekableReadStream
+ FX_FILESIZE GetPosition() override;
FX_FILESIZE GetSize() override;
bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ size_t ReadBlock(void* buffer, size_t size) override;
+ bool IsEOF() override;
+ bool Flush() override;
+ bool WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) override;
private:
std::vector<CFX_RetainPtr<CPDF_StreamAcc>> m_Data;
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 3976fd6912..4e3b0b3ffa 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -474,15 +474,14 @@ CXFA_DataExporter::CXFA_DataExporter(CXFA_Document* pDocument)
}
bool CXFA_DataExporter::Export(
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite) {
+ const CFX_RetainPtr<IFX_SeekableStream>& pWrite) {
return Export(pWrite, m_pDocument->GetRoot(), 0, nullptr);
}
-bool CXFA_DataExporter::Export(
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite,
- CXFA_Node* pNode,
- uint32_t dwFlag,
- const char* pChecksum) {
+bool CXFA_DataExporter::Export(const CFX_RetainPtr<IFX_SeekableStream>& pWrite,
+ CXFA_Node* pNode,
+ uint32_t dwFlag,
+ const char* pChecksum) {
ASSERT(pWrite);
if (!pWrite)
return false;
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.h b/xfa/fxfa/parser/cxfa_dataexporter.h
index ac441ca21d..8f405b188d 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.h
+++ b/xfa/fxfa/parser/cxfa_dataexporter.h
@@ -12,15 +12,15 @@
class CXFA_Document;
class CXFA_Node;
-class IFX_SeekableWriteStream;
+class IFX_SeekableStream;
class IFGAS_Stream;
class CXFA_DataExporter {
public:
explicit CXFA_DataExporter(CXFA_Document* pDocument);
- bool Export(const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite);
- bool Export(const CFX_RetainPtr<IFX_SeekableWriteStream>& pWrite,
+ bool Export(const CFX_RetainPtr<IFX_SeekableStream>& pWrite);
+ bool Export(const CFX_RetainPtr<IFX_SeekableStream>& pWrite,
CXFA_Node* pNode,
uint32_t dwFlag,
const char* pChecksum);
diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp
index 200841f5cb..d87d0914e4 100644
--- a/xfa/fxfa/parser/cxfa_dataimporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp
@@ -23,7 +23,7 @@ CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument)
}
bool CXFA_DataImporter::ImportData(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pDataDocument) {
+ const CFX_RetainPtr<IFX_SeekableStream>& pDataDocument) {
auto pDataDocumentParser =
pdfium::MakeUnique<CXFA_SimpleParser>(m_pDocument, false);
if (pDataDocumentParser->StartParse(pDataDocument, XFA_XDPPACKET_Datasets) !=
diff --git a/xfa/fxfa/parser/cxfa_dataimporter.h b/xfa/fxfa/parser/cxfa_dataimporter.h
index 4e8bdda314..e76475cd1e 100644
--- a/xfa/fxfa/parser/cxfa_dataimporter.h
+++ b/xfa/fxfa/parser/cxfa_dataimporter.h
@@ -11,13 +11,13 @@
#include "core/fxcrt/fx_system.h"
class CXFA_Document;
-class IFX_SeekableReadStream;
+class IFX_SeekableStream;
class CXFA_DataImporter {
public:
explicit CXFA_DataImporter(CXFA_Document* pDocument);
- bool ImportData(const CFX_RetainPtr<IFX_SeekableReadStream>& pDataDocument);
+ bool ImportData(const CFX_RetainPtr<IFX_SeekableStream>& pDataDocument);
private:
CXFA_Document* const m_pDocument;
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index b855513f52..a6860d6b52 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -18,7 +18,7 @@ CXFA_DocumentParser::~CXFA_DocumentParser() {
}
int32_t CXFA_DocumentParser::StartParse(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ const CFX_RetainPtr<IFX_SeekableStream>& pStream,
XFA_XDPPACKET ePacketID) {
m_pDocument.reset();
m_nodeParser.CloseParser();
diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h
index 9a219f74c1..90bd47f829 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.h
+++ b/xfa/fxfa/parser/cxfa_document_parser.h
@@ -15,7 +15,7 @@ class CFDE_XMLDoc;
class CXFA_Document;
class CXFA_FFNotify;
class CXFA_Notify;
-class IFX_SeekableReadStream;
+class IFX_SeekableStream;
class IFX_Pause;
class CXFA_DocumentParser {
@@ -23,7 +23,7 @@ class CXFA_DocumentParser {
explicit CXFA_DocumentParser(CXFA_FFNotify* pNotify);
~CXFA_DocumentParser();
- int32_t StartParse(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ int32_t StartParse(const CFX_RetainPtr<IFX_SeekableStream>& pStream,
XFA_XDPPACKET ePacketID);
int32_t DoParse(IFX_Pause* pPause);
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index cce4b68a27..806e5445a0 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -273,7 +273,7 @@ void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) {
}
int32_t CXFA_SimpleParser::StartParse(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ const CFX_RetainPtr<IFX_SeekableStream>& pStream,
XFA_XDPPACKET ePacketID) {
CloseParser();
m_pFileRead = pStream;
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h
index a9bcec2139..ccb258a7d4 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.h
+++ b/xfa/fxfa/parser/cxfa_simple_parser.h
@@ -17,7 +17,7 @@ class CFDE_XMLDoc;
class CFDE_XMLInstruction;
class CFDE_XMLNode;
class CFDE_XMLParser;
-class IFX_SeekableReadStream;
+class IFX_SeekableStream;
class IFX_Pause;
class IFGAS_Stream;
@@ -26,7 +26,7 @@ class CXFA_SimpleParser {
CXFA_SimpleParser(CXFA_Document* pFactory, bool bDocumentParser);
~CXFA_SimpleParser();
- int32_t StartParse(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ int32_t StartParse(const CFX_RetainPtr<IFX_SeekableStream>& pStream,
XFA_XDPPACKET ePacketID);
int32_t DoParse(IFX_Pause* pPause);
int32_t ParseXMLData(const CFX_WideString& wsXML,
@@ -81,7 +81,7 @@ class CXFA_SimpleParser {
CFDE_XMLParser* m_pXMLParser;
std::unique_ptr<CFDE_XMLDoc> m_pXMLDoc;
CFX_RetainPtr<IFGAS_Stream> m_pStream;
- CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
+ CFX_RetainPtr<IFX_SeekableStream> m_pFileRead;
CXFA_Document* m_pFactory;
CXFA_Node* m_pRootNode;
XFA_XDPPACKET m_ePacketID;