summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-18 16:35:55 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-18 20:50:08 +0000
commitbf510b7c520bccbd2edf5bb3e2f91b125ebfd6d7 (patch)
tree6ffafd1e5fcc767f5a4160d290e0b5f72d2ce271 /xfa
parentfdf7d4092a5fa9c79bbb4a626a4d3d087053ae2c (diff)
downloadpdfium-bf510b7c520bccbd2edf5bb3e2f91b125ebfd6d7.tar.xz
Rename IFGAS_Stream to CFGAS_Stream
This CL replaces IFGAS_Stream with the only implementation CFGAS_Stream. The CreateReadStream and CreateWriteStream methods are removed in favour of calling MakeRetain directly. Change-Id: I882a89258f642e24fc3d631587db05652bd53ded Reviewed-on: https://pdfium-review.googlesource.com/4210 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp4
-rw-r--r--xfa/fde/cfde_txtedtengine.h2
-rw-r--r--xfa/fde/css/cfde_csstextbuf.cpp18
-rw-r--r--xfa/fde/css/cfde_csstextbuf.h6
-rw-r--r--xfa/fde/css/fde_css.h2
-rw-r--r--xfa/fde/xml/cfde_xmldoc.cpp2
-rw-r--r--xfa/fde/xml/cfde_xmldoc.h6
-rw-r--r--xfa/fde/xml/cfde_xmlnode.cpp2
-rw-r--r--xfa/fde/xml/cfde_xmlnode.h4
-rw-r--r--xfa/fde/xml/cfde_xmlparser.cpp2
-rw-r--r--xfa/fde/xml/cfde_xmlparser.h6
-rw-r--r--xfa/fde/xml/cfde_xmlsyntaxparser.cpp8
-rw-r--r--xfa/fde/xml/cfde_xmlsyntaxparser.h6
-rw-r--r--xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp77
-rw-r--r--xfa/fgas/crt/cfgas_stream.cpp (renamed from xfa/fgas/crt/ifgas_stream.cpp)105
-rw-r--r--xfa/fgas/crt/cfgas_stream.h54
-rw-r--r--xfa/fgas/crt/ifgas_stream.h44
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.h2
-rw-r--r--xfa/fgas/font/cfgas_gefont.h4
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.h4
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp9
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.h4
-rw-r--r--xfa/fxfa/parser/xfa_utils.h4
25 files changed, 155 insertions, 250 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 84aafed433..136735c16e 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -106,7 +106,7 @@ CFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) {
}
void CFDE_TxtEdtEngine::SetTextByStream(
- const CFX_RetainPtr<IFGAS_Stream>& pStream) {
+ const CFX_RetainPtr<CFGAS_Stream>& pStream) {
ResetEngine();
int32_t nIndex = 0;
if (pStream && pStream->GetLength()) {
@@ -118,7 +118,7 @@ void CFDE_TxtEdtEngine::SetTextByStream(
bool bPreIsCR = false;
if (bValid) {
int32_t nPos = pStream->GetBOMLength();
- pStream->Seek(FX_STREAMSEEK_Begin, nPos);
+ pStream->Seek(CFGAS_Stream::Pos::Begin, nPos);
int32_t nPlateSize = std::min(nStreamLength, m_pTxtBuf->GetChunkSize());
wchar_t* lpwstr = FX_Alloc(wchar_t, nPlateSize);
bool bEos = false;
diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index 020b8c93df..bbdef8fd7a 100644
--- a/xfa/fde/cfde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -31,7 +31,7 @@ class CFDE_TxtEdtEngine {
int32_t CountPages() const;
CFDE_TxtEdtPage* GetPage(int32_t nIndex);
- void SetTextByStream(const CFX_RetainPtr<IFGAS_Stream>& pStream);
+ void SetTextByStream(const CFX_RetainPtr<CFGAS_Stream>& pStream);
void SetText(const CFX_WideString& wsText);
int32_t GetTextLength() const;
CFX_WideString GetText(int32_t nStart, int32_t nCount) const;
diff --git a/xfa/fde/css/cfde_csstextbuf.cpp b/xfa/fde/css/cfde_csstextbuf.cpp
index 149ed31e98..2d8f93f2b3 100644
--- a/xfa/fde/css/cfde_csstextbuf.cpp
+++ b/xfa/fde/css/cfde_csstextbuf.cpp
@@ -41,24 +41,6 @@ bool CFDE_CSSTextBuf::EstimateSize(int32_t iAllocSize) {
return ExpandBuf(iAllocSize);
}
-int32_t CFDE_CSSTextBuf::LoadFromStream(
- const CFX_RetainPtr<IFGAS_Stream>& pTxtStream,
- int32_t iStreamOffset,
- int32_t iMaxChars,
- bool& bEOS) {
- ASSERT(iStreamOffset >= 0 && iMaxChars > 0);
- Clear();
- m_bExtBuf = false;
- if (!ExpandBuf(iMaxChars))
- return 0;
-
- if (pTxtStream->GetPosition() != iStreamOffset)
- pTxtStream->Seek(FX_STREAMSEEK_Begin, iStreamOffset);
-
- m_iDatLen = pTxtStream->ReadString(m_pBuffer, iMaxChars, &bEOS);
- return m_iDatLen;
-}
-
bool CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
if (m_bExtBuf)
return false;
diff --git a/xfa/fde/css/cfde_csstextbuf.h b/xfa/fde/css/cfde_csstextbuf.h
index 52c76210ce..43ff03aa07 100644
--- a/xfa/fde/css/cfde_csstextbuf.h
+++ b/xfa/fde/css/cfde_csstextbuf.h
@@ -10,7 +10,7 @@
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/fx_system.h"
-#include "xfa/fgas/crt/ifgas_stream.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
class CFDE_CSSTextBuf {
public:
@@ -19,10 +19,6 @@ class CFDE_CSSTextBuf {
bool AttachBuffer(const wchar_t* pBuffer, int32_t iBufLen);
bool EstimateSize(int32_t iAllocSize);
- int32_t LoadFromStream(const CFX_RetainPtr<IFGAS_Stream>& pTxtStream,
- int32_t iStreamOffset,
- int32_t iMaxChars,
- bool& bEOS);
bool AppendChar(wchar_t wch) {
if (m_iDatLen >= m_iBufLen && !ExpandBuf(m_iBufLen * 2))
return false;
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index ae4f36c93d..9e56fce59a 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -8,7 +8,7 @@
#define XFA_FDE_CSS_FDE_CSS_H_
#include "core/fxge/fx_dib.h"
-#include "xfa/fgas/crt/ifgas_stream.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
#include "xfa/fgas/font/cfgas_fontmgr.h"
enum FDE_CSSVALUETYPE {
diff --git a/xfa/fde/xml/cfde_xmldoc.cpp b/xfa/fde/xml/cfde_xmldoc.cpp
index 209ce9c68f..256164c5f8 100644
--- a/xfa/fde/xml/cfde_xmldoc.cpp
+++ b/xfa/fde/xml/cfde_xmldoc.cpp
@@ -47,7 +47,7 @@ void CFDE_XMLDoc::CloseXML() {
m_pXMLParser.reset();
}
-void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
+void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<CFGAS_Stream>& pXMLStream,
CFDE_XMLNode* pINode) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode;
switch (pNode->GetType()) {
diff --git a/xfa/fde/xml/cfde_xmldoc.h b/xfa/fde/xml/cfde_xmldoc.h
index 6143750428..b84c9c00a0 100644
--- a/xfa/fde/xml/cfde_xmldoc.h
+++ b/xfa/fde/xml/cfde_xmldoc.h
@@ -12,7 +12,7 @@
#include "core/fxcrt/cfx_retain_ptr.h"
#include "xfa/fde/xml/cfde_xmlnode.h"
#include "xfa/fde/xml/cfde_xmlparser.h"
-#include "xfa/fgas/crt/ifgas_stream.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
class CFDE_XMLDoc {
public:
@@ -24,14 +24,14 @@ class CFDE_XMLDoc {
void CloseXML();
CFDE_XMLNode* GetRoot() const { return m_pRoot.get(); }
- void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
+ void SaveXMLNode(const CFX_RetainPtr<CFGAS_Stream>& pXMLStream,
CFDE_XMLNode* pNode);
private:
int32_t m_iStatus;
std::unique_ptr<CFDE_XMLNode> m_pRoot;
std::unique_ptr<CFDE_XMLParser> m_pXMLParser;
- CFX_RetainPtr<IFGAS_Stream> m_pStream;
+ CFX_RetainPtr<CFGAS_Stream> m_pStream;
};
#endif // XFA_FDE_XML_CFDE_XMLDOC_H_
diff --git a/xfa/fde/xml/cfde_xmlnode.cpp b/xfa/fde/xml/cfde_xmlnode.cpp
index e4d7880cac..149d18c3d6 100644
--- a/xfa/fde/xml/cfde_xmlnode.cpp
+++ b/xfa/fde/xml/cfde_xmlnode.cpp
@@ -329,7 +329,7 @@ std::unique_ptr<CFDE_XMLNode> CFDE_XMLNode::Clone() {
return nullptr;
}
-void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream) {
+void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<CFGAS_Stream>& pXMLStream) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
switch (pNode->GetType()) {
case FDE_XMLNODE_Instruction: {
diff --git a/xfa/fde/xml/cfde_xmlnode.h b/xfa/fde/xml/cfde_xmlnode.h
index 3cfcd5c980..a04bd8c812 100644
--- a/xfa/fde/xml/cfde_xmlnode.h
+++ b/xfa/fde/xml/cfde_xmlnode.h
@@ -10,7 +10,7 @@
#include <memory>
#include "core/fxcrt/cfx_retain_ptr.h"
-#include "xfa/fgas/crt/ifgas_stream.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
enum FDE_XMLNODETYPE {
FDE_XMLNODE_Unknown = 0,
@@ -64,7 +64,7 @@ class CFDE_XMLNode {
bool InsertNodeItem(CFDE_XMLNode::NodeItem eItem, CFDE_XMLNode* pNode);
CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem);
- void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream);
+ void SaveXMLNode(const CFX_RetainPtr<CFGAS_Stream>& pXMLStream);
CFDE_XMLNode* m_pParent;
CFDE_XMLNode* m_pChild;
diff --git a/xfa/fde/xml/cfde_xmlparser.cpp b/xfa/fde/xml/cfde_xmlparser.cpp
index 5b8993de1b..c29dfc38ab 100644
--- a/xfa/fde/xml/cfde_xmlparser.cpp
+++ b/xfa/fde/xml/cfde_xmlparser.cpp
@@ -15,7 +15,7 @@
#include "xfa/fde/xml/cfde_xmltext.h"
CFDE_XMLParser::CFDE_XMLParser(CFDE_XMLNode* pParent,
- const CFX_RetainPtr<IFGAS_Stream>& pStream)
+ const CFX_RetainPtr<CFGAS_Stream>& pStream)
: m_nElementStart(0),
m_dwCheckStatus(0),
m_dwCurrentCheckStatus(0),
diff --git a/xfa/fde/xml/cfde_xmlparser.h b/xfa/fde/xml/cfde_xmlparser.h
index 42f590ce21..f1a7888fa7 100644
--- a/xfa/fde/xml/cfde_xmlparser.h
+++ b/xfa/fde/xml/cfde_xmlparser.h
@@ -16,13 +16,13 @@
class CFDE_XMLElement;
class CFDE_XMLNode;
-class IFGAS_Stream;
+class CFGAS_Stream;
class IFX_Pause;
class CFDE_XMLParser {
public:
CFDE_XMLParser(CFDE_XMLNode* pParent,
- const CFX_RetainPtr<IFGAS_Stream>& pStream);
+ const CFX_RetainPtr<CFGAS_Stream>& pStream);
~CFDE_XMLParser();
int32_t DoParser(IFX_Pause* pPause);
@@ -34,7 +34,7 @@ class CFDE_XMLParser {
uint16_t m_dwCurrentCheckStatus;
private:
- CFX_RetainPtr<IFGAS_Stream> m_pStream;
+ CFX_RetainPtr<CFGAS_Stream> m_pStream;
std::unique_ptr<CFDE_XMLSyntaxParser> m_pParser;
CFDE_XMLNode* m_pParent;
CFDE_XMLNode* m_pChild;
diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.cpp b/xfa/fde/xml/cfde_xmlsyntaxparser.cpp
index 78382058ec..10eefdc012 100644
--- a/xfa/fde/xml/cfde_xmlsyntaxparser.cpp
+++ b/xfa/fde/xml/cfde_xmlsyntaxparser.cpp
@@ -80,7 +80,7 @@ int32_t GetUTF8EncodeLength(const std::vector<wchar_t>& src,
} // namespace
CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser(
- const CFX_RetainPtr<IFGAS_Stream>& pStream)
+ const CFX_RetainPtr<CFGAS_Stream>& pStream)
: m_pStream(pStream),
m_iXMLPlaneSize(32 * 1024),
m_iCurrentPos(0),
@@ -144,9 +144,9 @@ FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() {
}
m_ParsedChars += m_End;
m_iParsedBytes = m_iCurrentPos;
- if (m_pStream->GetPosition() != m_iCurrentPos) {
- m_pStream->Seek(FX_STREAMSEEK_Begin, m_iCurrentPos);
- }
+ if (m_pStream->GetPosition() != m_iCurrentPos)
+ m_pStream->Seek(CFGAS_Stream::Pos::Begin, m_iCurrentPos);
+
m_iBufferChars =
m_pStream->ReadString(m_Buffer.data(), m_iXMLPlaneSize, &m_bEOS);
iPos = m_pStream->GetPosition();
diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.h b/xfa/fde/xml/cfde_xmlsyntaxparser.h
index f229cc02b1..aa4e91827e 100644
--- a/xfa/fde/xml/cfde_xmlsyntaxparser.h
+++ b/xfa/fde/xml/cfde_xmlsyntaxparser.h
@@ -14,7 +14,7 @@
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "xfa/fde/xml/cfde_xmlnode.h"
-#include "xfa/fgas/crt/ifgas_stream.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
enum class FDE_XmlSyntaxResult {
None,
@@ -36,7 +36,7 @@ enum class FDE_XmlSyntaxResult {
class CFDE_XMLSyntaxParser {
public:
- explicit CFDE_XMLSyntaxParser(const CFX_RetainPtr<IFGAS_Stream>& pStream);
+ explicit CFDE_XMLSyntaxParser(const CFX_RetainPtr<CFGAS_Stream>& pStream);
~CFDE_XMLSyntaxParser();
FDE_XmlSyntaxResult DoSyntaxParse();
@@ -97,7 +97,7 @@ class CFDE_XMLSyntaxParser {
void ParseTextChar(wchar_t ch);
- CFX_RetainPtr<IFGAS_Stream> m_pStream;
+ CFX_RetainPtr<CFGAS_Stream> m_pStream;
FX_STRSIZE m_iXMLPlaneSize;
int32_t m_iCurrentPos;
int32_t m_iCurrentNodeNum;
diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp b/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp
index a45bb1276a..aecb3ee39e 100644
--- a/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp
+++ b/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp
@@ -8,8 +8,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
#include "xfa/fgas/crt/fgas_codepage.h"
-#include "xfa/fgas/crt/ifgas_stream.h"
class CFDE_XMLSyntaxParserTest : public pdfium::FPDF_Test {};
@@ -28,9 +28,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CData) {
L" app.alert(\"Tclams\");\n"
L" ";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -76,9 +75,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CDataWithInnerScript) {
L" </script>\n"
L" ";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -113,9 +111,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, ArrowBangArrow) {
" <!>\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -148,9 +145,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, ArrowBangBracketArrow) {
" <![>\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -178,9 +174,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, IncompleteCData) {
" <![CDATA>\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -208,9 +203,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, UnClosedCData) {
" <![CDATA[\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -238,9 +232,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, EmptyCData) {
" <![CDATA[]]>\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -275,9 +268,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, Comment) {
" <!-- A Comment -->\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -309,9 +301,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, IncorrectCommentStart) {
" <!- A Comment -->\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -343,9 +334,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentEmpty) {
" <!---->\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -377,9 +367,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentThreeDash) {
" <!--->\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -405,9 +394,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentTwoDash) {
" <!-->\n"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -437,9 +425,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, Entities) {
"&#x0000000000000000000;"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -469,9 +456,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, EntityOverflowHex) {
"&#xafffffffffffffffffffffffffffffffff;"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
@@ -501,9 +487,8 @@ TEST_F(CFDE_XMLSyntaxParserTest, EntityOverflowDecimal) {
"&#29149102052342342134521341234512351234213452315;"
"</script>";
- CFX_RetainPtr<IFGAS_Stream> stream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)));
+ CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>(
+ reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input));
stream->SetCodePage(FX_CODEPAGE_UTF8);
CFDE_XMLSyntaxParser parser(stream);
diff --git a/xfa/fgas/crt/ifgas_stream.cpp b/xfa/fgas/crt/cfgas_stream.cpp
index 7a90626fe8..809c19bdae 100644
--- a/xfa/fgas/crt/ifgas_stream.cpp
+++ b/xfa/fgas/crt/cfgas_stream.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fgas/crt/ifgas_stream.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \
_FX_OS_ == _FX_WIN64_
@@ -12,6 +12,7 @@
#endif
#include <algorithm>
+#include <limits>
#include <memory>
#include <utility>
#include <vector>
@@ -23,39 +24,6 @@
namespace {
-class CFGAS_Stream : public IFGAS_Stream {
- public:
- template <typename T, typename... Args>
- friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
-
- // 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;
-
- private:
- CFGAS_Stream(const CFX_RetainPtr<IFX_SeekableStream>& stream,
- bool isWriteSteam);
- ~CFGAS_Stream() override;
-
- FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize);
- void WriteData(const CFX_WideStringC& str);
-
- uint16_t m_wCodePage;
- FX_STRSIZE m_wBOMLength;
- bool m_IsWriteStream;
- FX_FILESIZE m_iPosition;
- CFX_RetainPtr<IFX_SeekableStream> m_pStream;
-};
-
// Returns {src bytes consumed, dst bytes produced}.
std::pair<FX_STRSIZE, FX_STRSIZE> UTF8Decode(const char* pSrc,
FX_STRSIZE srcLen,
@@ -161,6 +129,8 @@ void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) {
}
}
+} // namespace
+
#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_
#define BOM_MASK 0x00FFFFFF
#define BOM_UTF8 0x00BFBBEF
@@ -190,7 +160,7 @@ CFGAS_Stream::CFGAS_Stream(const CFX_RetainPtr<IFX_SeekableStream>& stream,
}
FX_FILESIZE iPosition = GetPosition();
- Seek(FX_STREAMSEEK_Begin, 0);
+ Seek(CFGAS_Stream::Pos::Begin, 0);
uint32_t bom;
ReadData(reinterpret_cast<uint8_t*>(&bom), 3);
@@ -213,18 +183,21 @@ CFGAS_Stream::CFGAS_Stream(const CFX_RetainPtr<IFX_SeekableStream>& stream,
}
}
- Seek(FX_STREAMSEEK_Begin,
+ Seek(CFGAS_Stream::Pos::Begin,
std::max(static_cast<FX_FILESIZE>(m_wBOMLength), iPosition));
}
+CFGAS_Stream::CFGAS_Stream(uint8_t* data, FX_STRSIZE size)
+ : CFGAS_Stream(IFX_MemoryStream::Create(data, size), false) {}
+
CFGAS_Stream::~CFGAS_Stream() {}
-void CFGAS_Stream::Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) {
+void CFGAS_Stream::Seek(CFGAS_Stream::Pos eSeek, FX_FILESIZE iOffset) {
switch (eSeek) {
- case FX_STREAMSEEK_Begin:
+ case CFGAS_Stream::Pos::Begin:
m_iPosition = iOffset;
break;
- case FX_STREAMSEEK_Current:
+ case CFGAS_Stream::Pos::Current:
m_iPosition += iOffset;
break;
}
@@ -300,7 +273,7 @@ FX_STRSIZE CFGAS_Stream::ReadString(wchar_t* pStr,
FX_STRSIZE iSrc = 0;
std::tie(iSrc, iMaxLength) = UTF8Decode(
reinterpret_cast<const char*>(buf.data()), iLen, pStr, iMaxLength);
- Seek(FX_STREAMSEEK_Current, iSrc - iLen);
+ Seek(CFGAS_Stream::Pos::Current, iSrc - iLen);
} else {
iMaxLength = 0;
}
@@ -310,48 +283,22 @@ FX_STRSIZE CFGAS_Stream::ReadString(wchar_t* pStr,
return iMaxLength;
}
-void CFGAS_Stream::WriteData(const CFX_WideStringC& str) {
- if (!m_IsWriteStream || str.GetLength() == 0)
- return;
- if (m_pStream->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();
- }
-}
-
void CFGAS_Stream::WriteString(const CFX_WideStringC& str) {
- if (!m_IsWriteStream)
- return;
- if (str.GetLength() == 0)
+ if (!m_IsWriteStream || str.GetLength() == 0 ||
+ m_wCodePage != FX_CODEPAGE_UTF8) {
return;
- if (m_wCodePage != FX_CODEPAGE_UTF8)
+ }
+ if (!m_pStream->WriteBlock(str.c_str(), m_iPosition,
+ str.GetLength() * sizeof(wchar_t))) {
return;
+ }
- WriteData(str);
-}
-
-} // namespace
-
-// static
-CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateReadStream(
- const CFX_RetainPtr<IFX_SeekableStream>& pFileRead) {
- if (!pFileRead)
- return nullptr;
-
- return pdfium::MakeRetain<CFGAS_Stream>(pFileRead, false);
-}
-
-// static
-CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateWriteStream(
- const CFX_RetainPtr<IFX_SeekableStream>& pFileWrite) {
- if (!pFileWrite)
- return nullptr;
+ pdfium::base::CheckedNumeric<FX_STRSIZE> new_pos = m_iPosition;
+ new_pos += str.GetLength() * sizeof(wchar_t);
+ if (!new_pos.IsValid()) {
+ m_iPosition = std::numeric_limits<FX_STRSIZE>::max();
+ return;
+ }
- return pdfium::MakeRetain<CFGAS_Stream>(pFileWrite, true);
+ m_iPosition = new_pos.ValueOrDie();
}
diff --git a/xfa/fgas/crt/cfgas_stream.h b/xfa/fgas/crt/cfgas_stream.h
new file mode 100644
index 0000000000..5d2e5e6242
--- /dev/null
+++ b/xfa/fgas/crt/cfgas_stream.h
@@ -0,0 +1,54 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef XFA_FGAS_CRT_CFGAS_STREAM_H_
+#define XFA_FGAS_CRT_CFGAS_STREAM_H_
+
+#include <algorithm>
+
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/fx_stream.h"
+#include "core/fxcrt/fx_system.h"
+
+class CFGAS_Stream : public CFX_Retainable {
+ public:
+ enum class Pos {
+ Begin = 0,
+ Current,
+ };
+
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
+
+ FX_FILESIZE GetLength() const { return m_pStream->GetSize(); }
+ FX_FILESIZE GetPosition() { return m_iPosition; }
+ FX_STRSIZE GetBOMLength() const { return std::max(0, m_wBOMLength); }
+ bool IsEOF() const { return m_iPosition >= GetLength(); }
+
+ void Seek(CFGAS_Stream::Pos eSeek, FX_FILESIZE iOffset);
+ FX_STRSIZE ReadString(wchar_t* pStr, FX_STRSIZE iMaxLength, bool* bEOS);
+
+ void WriteString(const CFX_WideStringC& str);
+
+ uint16_t GetCodePage() const { return m_wCodePage; }
+ void SetCodePage(uint16_t wCodePage);
+
+ private:
+ CFGAS_Stream(const CFX_RetainPtr<IFX_SeekableStream>& stream,
+ bool isWriteSteam);
+ CFGAS_Stream(uint8_t* data, FX_STRSIZE size);
+ ~CFGAS_Stream() override;
+
+ FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize);
+
+ uint16_t m_wCodePage;
+ FX_STRSIZE m_wBOMLength;
+ bool m_IsWriteStream;
+ FX_FILESIZE m_iPosition;
+ CFX_RetainPtr<IFX_SeekableStream> m_pStream;
+};
+
+#endif // XFA_FGAS_CRT_CFGAS_STREAM_H_
diff --git a/xfa/fgas/crt/ifgas_stream.h b/xfa/fgas/crt/ifgas_stream.h
deleted file mode 100644
index acc9f1c4eb..0000000000
--- a/xfa/fgas/crt/ifgas_stream.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FGAS_CRT_IFGAS_STREAM_H_
-#define XFA_FGAS_CRT_IFGAS_STREAM_H_
-
-#include "core/fxcrt/cfx_retain_ptr.h"
-#include "core/fxcrt/fx_stream.h"
-#include "core/fxcrt/fx_system.h"
-
-enum FX_STREAMSEEK {
- FX_STREAMSEEK_Begin = 0,
- FX_STREAMSEEK_Current,
-};
-
-class IFGAS_Stream : public CFX_Retainable {
- public:
- static CFX_RetainPtr<IFGAS_Stream> CreateReadStream(
- const CFX_RetainPtr<IFX_SeekableStream>& pFileRead);
- static CFX_RetainPtr<IFGAS_Stream> CreateWriteStream(
- const CFX_RetainPtr<IFX_SeekableStream>& pFileWrite);
-
- virtual FX_FILESIZE GetLength() const = 0;
- virtual FX_FILESIZE GetPosition() = 0;
- virtual FX_STRSIZE GetBOMLength() const = 0;
-
- virtual void Seek(FX_STREAMSEEK eSeek, FX_FILESIZE iOffset) = 0;
-
- virtual FX_STRSIZE ReadString(wchar_t* pStr,
- FX_STRSIZE iMaxLength,
- bool* bEOS) = 0;
- virtual void WriteString(const CFX_WideStringC& str) = 0;
-
- virtual uint16_t GetCodePage() const = 0;
- virtual void SetCodePage(uint16_t wCodePage) = 0;
-
- protected:
- virtual bool IsEOF() const = 0;
-};
-
-#endif // XFA_FGAS_CRT_IFGAS_STREAM_H_
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index c0b59f4dd7..8a3705335e 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -18,7 +18,7 @@
#include "core/fxge/cfx_fontmapper.h"
#include "core/fxge/fx_freetype.h"
#include "core/fxge/ifx_systemfontinfo.h"
-#include "xfa/fgas/crt/ifgas_stream.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
#define FX_FONTSTYLE_Normal 0x00
#define FX_FONTSTYLE_FixedPitch 0x01
diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h
index 14029be1e0..6c9f2a168d 100644
--- a/xfa/fgas/font/cfgas_gefont.h
+++ b/xfa/fgas/font/cfgas_gefont.h
@@ -67,7 +67,7 @@ class CFGAS_GEFont : public CFX_Retainable {
uint32_t dwFontStyles,
uint16_t wCodePage);
bool LoadFontInternal(const uint8_t* pBuffer, int32_t length);
- bool LoadFontInternal(const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
+ bool LoadFontInternal(const CFX_RetainPtr<CFGAS_Stream>& pFontStream,
bool bSaveStream);
#endif
bool LoadFontInternal(CFX_Font* pExternalFont);
@@ -95,7 +95,7 @@ class CFGAS_GEFont : public CFX_Retainable {
CFX_RetainPtr<CFGAS_GEFont> m_pSrcFont; // Only set by ctor, so no cycles.
CFGAS_FontMgr* const m_pFontMgr;
bool m_bExternalFont;
- CFX_RetainPtr<IFGAS_Stream> m_pStream;
+ CFX_RetainPtr<CFGAS_Stream> m_pStream;
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
std::map<wchar_t, int32_t> m_CharWidthMap;
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 4e3b0b3ffa..442195b1dd 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -226,8 +226,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
CFX_RetainPtr<IFX_MemoryStream> pMemStream =
IFX_MemoryStream::Create(true);
- CFX_RetainPtr<IFGAS_Stream> pTempStream =
- IFGAS_Stream::CreateWriteStream(pMemStream);
+ auto pTempStream = pdfium::MakeRetain<CFGAS_Stream>(pMemStream, true);
pTempStream->SetCodePage(FX_CODEPAGE_UTF8);
pRichTextXML->SaveXMLNode(pTempStream);
@@ -343,8 +342,8 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
}
void RegenerateFormFile_Container(CXFA_Node* pNode,
- const CFX_RetainPtr<IFGAS_Stream>& pStream,
- bool bSaveXML = false) {
+ const CFX_RetainPtr<CFGAS_Stream>& pStream,
+ bool bSaveXML) {
XFA_Element eType = pNode->GetElementType();
if (eType == XFA_Element::Field || eType == XFA_Element::Draw ||
!pNode->IsContainerNode()) {
@@ -400,7 +399,7 @@ void RegenerateFormFile_Container(CXFA_Node* pNode,
void XFA_DataExporter_RegenerateFormFile(
CXFA_Node* pNode,
- const CFX_RetainPtr<IFGAS_Stream>& pStream,
+ const CFX_RetainPtr<CFGAS_Stream>& pStream,
const char* pChecksum,
bool bSaveXML) {
if (pNode->IsModelNode()) {
@@ -428,7 +427,7 @@ void XFA_DataExporter_RegenerateFormFile(
CXFA_Node* pChildNode = pNode->GetNodeItem(XFA_NODEITEM_FirstChild);
while (pChildNode) {
- RegenerateFormFile_Container(pChildNode, pStream);
+ RegenerateFormFile_Container(pChildNode, pStream, false);
pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling);
}
pStream->WriteString(L"</form\n>");
@@ -486,15 +485,12 @@ bool CXFA_DataExporter::Export(const CFX_RetainPtr<IFX_SeekableStream>& pWrite,
if (!pWrite)
return false;
- CFX_RetainPtr<IFGAS_Stream> pStream = IFGAS_Stream::CreateWriteStream(pWrite);
- if (!pStream)
- return false;
-
+ auto pStream = pdfium::MakeRetain<CFGAS_Stream>(pWrite, true);
pStream->SetCodePage(FX_CODEPAGE_UTF8);
return Export(pStream, pNode, dwFlag, pChecksum);
}
-bool CXFA_DataExporter::Export(const CFX_RetainPtr<IFGAS_Stream>& pStream,
+bool CXFA_DataExporter::Export(const CFX_RetainPtr<CFGAS_Stream>& pStream,
CXFA_Node* pNode,
uint32_t dwFlag,
const char* pChecksum) {
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.h b/xfa/fxfa/parser/cxfa_dataexporter.h
index 8f405b188d..c7e5c7b70b 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.h
+++ b/xfa/fxfa/parser/cxfa_dataexporter.h
@@ -13,7 +13,7 @@
class CXFA_Document;
class CXFA_Node;
class IFX_SeekableStream;
-class IFGAS_Stream;
+class CFGAS_Stream;
class CXFA_DataExporter {
public:
@@ -26,7 +26,7 @@ class CXFA_DataExporter {
const char* pChecksum);
private:
- bool Export(const CFX_RetainPtr<IFGAS_Stream>& pStream,
+ bool Export(const CFX_RetainPtr<CFGAS_Stream>& pStream,
CXFA_Node* pNode,
uint32_t dwFlag,
const char* pChecksum);
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 90e93fbda5..26dc6bd831 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1408,14 +1408,7 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
}
CFX_RetainPtr<IFX_MemoryStream> pMemoryStream =
IFX_MemoryStream::Create(true);
- CFX_RetainPtr<IFGAS_Stream> pStream =
- IFGAS_Stream::CreateWriteStream(pMemoryStream);
-
- if (!pStream) {
- pArguments->GetReturnValue()->SetString(
- bsXMLHeader.UTF8Encode().AsStringC());
- return;
- }
+ auto pStream = pdfium::MakeRetain<CFGAS_Stream>(pMemoryStream, true);
pStream->SetCodePage(FX_CODEPAGE_UTF8);
pStream->WriteString(bsXMLHeader.AsStringC());
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 1ebed10b4d..92196ec957 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -19,8 +19,8 @@
#include "xfa/fde/xml/cfde_xmlnode.h"
#include "xfa/fde/xml/cfde_xmlparser.h"
#include "xfa/fde/xml/cfde_xmltext.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
#include "xfa/fgas/crt/fgas_codepage.h"
-#include "xfa/fgas/crt/ifgas_stream.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -277,10 +277,7 @@ int32_t CXFA_SimpleParser::StartParse(
XFA_XDPPACKET ePacketID) {
CloseParser();
m_pFileRead = pStream;
- m_pStream = IFGAS_Stream::CreateReadStream(pStream);
- if (!m_pStream)
- return XFA_PARSESTATUS_StreamErr;
-
+ m_pStream = pdfium::MakeRetain<CFGAS_Stream>(pStream, false);
uint16_t wCodePage = m_pStream->GetCodePage();
if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE &&
wCodePage != FX_CODEPAGE_UTF8) {
@@ -322,9 +319,8 @@ CFDE_XMLNode* CXFA_SimpleParser::ParseXMLData(const CFX_ByteString& wsXML,
CloseParser();
m_pXMLDoc = pdfium::MakeUnique<CFDE_XMLDoc>();
- CFX_RetainPtr<IFGAS_Stream> pStream =
- IFGAS_Stream::CreateReadStream(IFX_MemoryStream::Create(
- const_cast<uint8_t*>(wsXML.raw_str()), wsXML.GetLength()));
+ auto pStream = pdfium::MakeRetain<CFGAS_Stream>(
+ const_cast<uint8_t*>(wsXML.raw_str()), wsXML.GetLength());
auto pParser =
pdfium::MakeUnique<CFDE_XMLParser>(m_pXMLDoc->GetRoot(), pStream);
pParser->m_dwCheckStatus = 0x03;
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h
index 7671e8d740..32b5518fab 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.h
+++ b/xfa/fxfa/parser/cxfa_simple_parser.h
@@ -19,7 +19,7 @@ class CFDE_XMLNode;
class CFDE_XMLParser;
class IFX_SeekableStream;
class IFX_Pause;
-class IFGAS_Stream;
+class CFGAS_Stream;
class CXFA_SimpleParser {
public:
@@ -78,7 +78,7 @@ class CXFA_SimpleParser {
CFDE_XMLParser* m_pXMLParser;
std::unique_ptr<CFDE_XMLDoc> m_pXMLDoc;
- CFX_RetainPtr<IFGAS_Stream> m_pStream;
+ CFX_RetainPtr<CFGAS_Stream> m_pStream;
CFX_RetainPtr<IFX_SeekableStream> m_pFileRead;
CXFA_Document* m_pFactory;
CXFA_Node* m_pRootNode;
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index 36d62c7602..ae51c8fdc6 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -7,7 +7,7 @@
#ifndef XFA_FXFA_PARSER_XFA_UTILS_H_
#define XFA_FXFA_PARSER_XFA_UTILS_H_
-#include "xfa/fgas/crt/ifgas_stream.h"
+#include "xfa/fgas/crt/cfgas_stream.h"
#include "xfa/fxfa/fxfa_basic.h"
class CFDE_XMLElement;
@@ -155,7 +155,7 @@ bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode);
void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode);
void XFA_DataExporter_RegenerateFormFile(
CXFA_Node* pNode,
- const CFX_RetainPtr<IFGAS_Stream>& pStream,
+ const CFX_RetainPtr<CFGAS_Stream>& pStream,
const char* pChecksum = nullptr,
bool bSaveXML = false);