diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-04-19 08:58:54 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-19 13:16:57 +0000 |
commit | 3b71d26f092ebc86ca9177fbbe89d83caa67ae1b (patch) | |
tree | a81ab092972ab8a2ce474d8d53984bfe9b6887a8 /xfa/fde/xml | |
parent | 5af27b63bf94e7f60212f6759c8342ce02da5ad2 (diff) | |
download | pdfium-3b71d26f092ebc86ca9177fbbe89d83caa67ae1b.tar.xz |
Move CFGAS_Stream to CFX_SeekableStreamProxy
This CL moves the FGAS stream code into core/fxcrt and renames to
CFX_SeekableStreamProxy.
Change-Id: I6641fe0cca45a128ef3ec281b0b40f8d60296387
Reviewed-on: https://pdfium-review.googlesource.com/4311
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'xfa/fde/xml')
-rw-r--r-- | xfa/fde/xml/cfde_xmldoc.cpp | 7 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xmldoc.h | 6 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xmlnode.cpp | 5 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xmlnode.h | 4 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xmlparser.cpp | 5 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xmlparser.h | 6 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xmlsyntaxparser.cpp | 4 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xmlsyntaxparser.h | 7 | ||||
-rw-r--r-- | xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp | 79 |
9 files changed, 71 insertions, 52 deletions
diff --git a/xfa/fde/xml/cfde_xmldoc.cpp b/xfa/fde/xml/cfde_xmldoc.cpp index 256164c5f8..fa44472098 100644 --- a/xfa/fde/xml/cfde_xmldoc.cpp +++ b/xfa/fde/xml/cfde_xmldoc.cpp @@ -9,6 +9,7 @@ #include <utility> #include <vector> +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fde/xml/cfde_xmlchardata.h" @@ -16,7 +17,6 @@ #include "xfa/fde/xml/cfde_xmlinstruction.h" #include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fde/xml/cfde_xmltext.h" -#include "xfa/fgas/crt/fgas_codepage.h" CFDE_XMLDoc::CFDE_XMLDoc() : m_iStatus(0), m_pRoot(pdfium::MakeUnique<CFDE_XMLNode>()) { @@ -47,8 +47,9 @@ void CFDE_XMLDoc::CloseXML() { m_pXMLParser.reset(); } -void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<CFGAS_Stream>& pXMLStream, - CFDE_XMLNode* pINode) { +void CFDE_XMLDoc::SaveXMLNode( + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pXMLStream, + CFDE_XMLNode* pINode) { CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode; switch (pNode->GetType()) { case FDE_XMLNODE_Instruction: { diff --git a/xfa/fde/xml/cfde_xmldoc.h b/xfa/fde/xml/cfde_xmldoc.h index b84c9c00a0..c9c7db41b7 100644 --- a/xfa/fde/xml/cfde_xmldoc.h +++ b/xfa/fde/xml/cfde_xmldoc.h @@ -10,9 +10,9 @@ #include <memory> #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fde/xml/cfde_xmlparser.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<CFGAS_Stream>& pXMLStream, + void SaveXMLNode(const CFX_RetainPtr<CFX_SeekableStreamProxy>& 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<CFGAS_Stream> m_pStream; + CFX_RetainPtr<CFX_SeekableStreamProxy> 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 149d18c3d6..c81de7623a 100644 --- a/xfa/fde/xml/cfde_xmlnode.cpp +++ b/xfa/fde/xml/cfde_xmlnode.cpp @@ -8,12 +8,12 @@ #include <vector> +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/stl_util.h" #include "xfa/fde/xml/cfde_xmlchardata.h" #include "xfa/fde/xml/cfde_xmlelement.h" #include "xfa/fde/xml/cfde_xmlinstruction.h" #include "xfa/fde/xml/cfde_xmltext.h" -#include "xfa/fgas/crt/fgas_codepage.h" CFDE_XMLNode::CFDE_XMLNode() : m_pParent(nullptr), @@ -329,7 +329,8 @@ std::unique_ptr<CFDE_XMLNode> CFDE_XMLNode::Clone() { return nullptr; } -void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<CFGAS_Stream>& pXMLStream) { +void CFDE_XMLNode::SaveXMLNode( + const CFX_RetainPtr<CFX_SeekableStreamProxy>& 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 a04bd8c812..71e1a712e0 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/cfgas_stream.h" +#include "core/fxcrt/cfx_seekablestreamproxy.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<CFGAS_Stream>& pXMLStream); + void SaveXMLNode(const CFX_RetainPtr<CFX_SeekableStreamProxy>& 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 c29dfc38ab..c8b300f81d 100644 --- a/xfa/fde/xml/cfde_xmlparser.cpp +++ b/xfa/fde/xml/cfde_xmlparser.cpp @@ -14,8 +14,9 @@ #include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fde/xml/cfde_xmltext.h" -CFDE_XMLParser::CFDE_XMLParser(CFDE_XMLNode* pParent, - const CFX_RetainPtr<CFGAS_Stream>& pStream) +CFDE_XMLParser::CFDE_XMLParser( + CFDE_XMLNode* pParent, + const CFX_RetainPtr<CFX_SeekableStreamProxy>& 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 f1a7888fa7..14b2127068 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 CFGAS_Stream; +class CFX_SeekableStreamProxy; class IFX_Pause; class CFDE_XMLParser { public: CFDE_XMLParser(CFDE_XMLNode* pParent, - const CFX_RetainPtr<CFGAS_Stream>& pStream); + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream); ~CFDE_XMLParser(); int32_t DoParser(IFX_Pause* pPause); @@ -34,7 +34,7 @@ class CFDE_XMLParser { uint16_t m_dwCurrentCheckStatus; private: - CFX_RetainPtr<CFGAS_Stream> m_pStream; + CFX_RetainPtr<CFX_SeekableStreamProxy> 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 10eefdc012..5d671bb39a 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<CFGAS_Stream>& pStream) + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream) : m_pStream(pStream), m_iXMLPlaneSize(32 * 1024), m_iCurrentPos(0), @@ -145,7 +145,7 @@ FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() { m_ParsedChars += m_End; m_iParsedBytes = m_iCurrentPos; if (m_pStream->GetPosition() != m_iCurrentPos) - m_pStream->Seek(CFGAS_Stream::Pos::Begin, m_iCurrentPos); + m_pStream->Seek(CFX_SeekableStreamProxy::Pos::Begin, m_iCurrentPos); m_iBufferChars = m_pStream->ReadString(m_Buffer.data(), m_iXMLPlaneSize, &m_bEOS); diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.h b/xfa/fde/xml/cfde_xmlsyntaxparser.h index aa4e91827e..8b6c9ac8b5 100644 --- a/xfa/fde/xml/cfde_xmlsyntaxparser.h +++ b/xfa/fde/xml/cfde_xmlsyntaxparser.h @@ -12,9 +12,9 @@ #include "core/fxcrt/cfx_blockbuffer.h" #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_string.h" #include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fgas/crt/cfgas_stream.h" enum class FDE_XmlSyntaxResult { None, @@ -36,7 +36,8 @@ enum class FDE_XmlSyntaxResult { class CFDE_XMLSyntaxParser { public: - explicit CFDE_XMLSyntaxParser(const CFX_RetainPtr<CFGAS_Stream>& pStream); + explicit CFDE_XMLSyntaxParser( + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream); ~CFDE_XMLSyntaxParser(); FDE_XmlSyntaxResult DoSyntaxParse(); @@ -97,7 +98,7 @@ class CFDE_XMLSyntaxParser { void ParseTextChar(wchar_t ch); - CFX_RetainPtr<CFGAS_Stream> m_pStream; + CFX_RetainPtr<CFX_SeekableStreamProxy> 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 aecb3ee39e..45ad3bb2f0 100644 --- a/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp +++ b/xfa/fde/xml/cfde_xmlsyntaxparser_unittest.cpp @@ -6,10 +6,10 @@ #include <memory> +#include "core/fxcrt/cfx_seekablestreamproxy.h" +#include "core/fxcrt/fx_codepage.h" #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" class CFDE_XMLSyntaxParserTest : public pdfium::FPDF_Test {}; @@ -28,8 +28,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, CData) { L" app.alert(\"Tclams\");\n" L" "; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -75,8 +76,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, CDataWithInnerScript) { L" </script>\n" L" "; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -111,8 +113,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, ArrowBangArrow) { " <!>\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -145,8 +148,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, ArrowBangBracketArrow) { " <![>\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -174,8 +178,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, IncompleteCData) { " <![CDATA>\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -203,8 +208,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, UnClosedCData) { " <![CDATA[\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -232,8 +238,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, EmptyCData) { " <![CDATA[]]>\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -268,8 +275,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, Comment) { " <!-- A Comment -->\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -301,8 +309,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, IncorrectCommentStart) { " <!- A Comment -->\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -334,8 +343,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentEmpty) { " <!---->\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -367,8 +377,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentThreeDash) { " <!--->\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -394,8 +405,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, CommentTwoDash) { " <!-->\n" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -425,8 +437,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, Entities) { "�" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -456,8 +469,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, EntityOverflowHex) { "�" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); @@ -487,8 +501,9 @@ TEST_F(CFDE_XMLSyntaxParserTest, EntityOverflowDecimal) { "�" "</script>"; - CFX_RetainPtr<CFGAS_Stream> stream = pdfium::MakeRetain<CFGAS_Stream>( - reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); + CFX_RetainPtr<CFX_SeekableStreamProxy> stream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>( + reinterpret_cast<uint8_t*>(const_cast<char*>(input)), strlen(input)); stream->SetCodePage(FX_CODEPAGE_UTF8); CFDE_XMLSyntaxParser parser(stream); |