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 | |
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')
32 files changed, 116 insertions, 587 deletions
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 136735c16e..762c16f4c9 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<CFGAS_Stream>& pStream) { + const CFX_RetainPtr<CFX_SeekableStreamProxy>& 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(CFGAS_Stream::Pos::Begin, nPos); + pStream->Seek(CFX_SeekableStreamProxy::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 bbdef8fd7a..4a54c6df98 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<CFGAS_Stream>& pStream); + void SetTextByStream(const CFX_RetainPtr<CFX_SeekableStreamProxy>& 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_cssstylesheet.cpp b/xfa/fde/css/cfde_cssstylesheet.cpp index 175289be11..c16e25156c 100644 --- a/xfa/fde/css/cfde_cssstylesheet.cpp +++ b/xfa/fde/css/cfde_cssstylesheet.cpp @@ -8,12 +8,12 @@ #include <utility> +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fde/css/cfde_cssdeclaration.h" #include "xfa/fde/css/cfde_cssstylerule.h" #include "xfa/fde/css/fde_cssdatatable.h" -#include "xfa/fgas/crt/fgas_codepage.h" CFDE_CSSStyleSheet::CFDE_CSSStyleSheet() {} diff --git a/xfa/fde/css/cfde_csssyntaxparser.cpp b/xfa/fde/css/cfde_csssyntaxparser.cpp index 9c45422ebb..ac1abcc665 100644 --- a/xfa/fde/css/cfde_csssyntaxparser.cpp +++ b/xfa/fde/css/cfde_csssyntaxparser.cpp @@ -8,9 +8,9 @@ #include <algorithm> +#include "core/fxcrt/fx_codepage.h" #include "xfa/fde/css/cfde_cssdeclaration.h" #include "xfa/fde/css/fde_cssdatatable.h" -#include "xfa/fgas/crt/fgas_codepage.h" namespace { diff --git a/xfa/fde/css/cfde_csstextbuf.h b/xfa/fde/css/cfde_csstextbuf.h index 43ff03aa07..71c76f3361 100644 --- a/xfa/fde/css/cfde_csstextbuf.h +++ b/xfa/fde/css/cfde_csstextbuf.h @@ -8,9 +8,9 @@ #define XFA_FDE_CSS_CFDE_CSSTEXTBUF_H_ #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_memory.h" #include "core/fxcrt/fx_system.h" -#include "xfa/fgas/crt/cfgas_stream.h" class CFDE_CSSTextBuf { public: diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h index 9e56fce59a..ac44e30175 100644 --- a/xfa/fde/css/fde_css.h +++ b/xfa/fde/css/fde_css.h @@ -7,8 +7,8 @@ #ifndef XFA_FDE_CSS_FDE_CSS_H_ #define XFA_FDE_CSS_FDE_CSS_H_ +#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxge/fx_dib.h" -#include "xfa/fgas/crt/cfgas_stream.h" #include "xfa/fgas/font/cfgas_fontmgr.h" enum FDE_CSSVALUETYPE { diff --git a/xfa/fde/css/fde_cssdatatable.cpp b/xfa/fde/css/fde_cssdatatable.cpp index d61c610fe9..5fa9cf0dc9 100644 --- a/xfa/fde/css/fde_cssdatatable.cpp +++ b/xfa/fde/css/fde_cssdatatable.cpp @@ -8,10 +8,10 @@ #include <utility> +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_ext.h" #include "xfa/fde/css/cfde_cssstyleselector.h" #include "xfa/fde/css/cfde_cssvaluelistparser.h" -#include "xfa/fgas/crt/fgas_codepage.h" static const FDE_CSSPropertyTable g_FDE_CSSProperties[] = { {FDE_CSSProperty::BorderLeft, L"border-left", 0x04080036, 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); diff --git a/xfa/fgas/crt/cfgas_stream.cpp b/xfa/fgas/crt/cfgas_stream.cpp deleted file mode 100644 index 809c19bdae..0000000000 --- a/xfa/fgas/crt/cfgas_stream.cpp +++ /dev/null @@ -1,304 +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 - -#include "xfa/fgas/crt/cfgas_stream.h" - -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ - _FX_OS_ == _FX_WIN64_ -#include <io.h> -#endif - -#include <algorithm> -#include <limits> -#include <memory> -#include <utility> -#include <vector> - -#include "core/fxcrt/fx_ext.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fgas/crt/fgas_codepage.h" - -namespace { - -// Returns {src bytes consumed, dst bytes produced}. -std::pair<FX_STRSIZE, FX_STRSIZE> UTF8Decode(const char* pSrc, - FX_STRSIZE srcLen, - wchar_t* pDst, - FX_STRSIZE dstLen) { - ASSERT(pDst && dstLen > 0); - - if (srcLen < 1) - return {0, 0}; - - uint32_t dwCode = 0; - int32_t iPending = 0; - FX_STRSIZE iSrcNum = 0; - FX_STRSIZE iDstNum = 0; - FX_STRSIZE iIndex = 0; - int32_t k = 1; - while (iIndex < srcLen) { - uint8_t byte = static_cast<uint8_t>(*(pSrc + iIndex)); - if (byte < 0x80) { - iPending = 0; - k = 1; - iDstNum++; - iSrcNum += k; - *pDst++ = byte; - if (iDstNum >= dstLen) - break; - } else if (byte < 0xc0) { - if (iPending < 1) - break; - - iPending--; - dwCode |= (byte & 0x3f) << (iPending * 6); - if (iPending == 0) { - iDstNum++; - iSrcNum += k; - *pDst++ = dwCode; - if (iDstNum >= dstLen) - break; - } - } else if (byte < 0xe0) { - iPending = 1; - k = 2; - dwCode = (byte & 0x1f) << 6; - } else if (byte < 0xf0) { - iPending = 2; - k = 3; - dwCode = (byte & 0x0f) << 12; - } else if (byte < 0xf8) { - iPending = 3; - k = 4; - dwCode = (byte & 0x07) << 18; - } else if (byte < 0xfc) { - iPending = 4; - k = 5; - dwCode = (byte & 0x03) << 24; - } else if (byte < 0xfe) { - iPending = 5; - k = 6; - dwCode = (byte & 0x01) << 30; - } else { - break; - } - iIndex++; - } - return {iSrcNum, iDstNum}; -} - -void UTF16ToWChar(void* pBuffer, FX_STRSIZE iLength) { - ASSERT(pBuffer && iLength > 0); - - if (sizeof(wchar_t) == 2) - return; - - uint16_t* pSrc = static_cast<uint16_t*>(pBuffer); - wchar_t* pDst = static_cast<wchar_t*>(pBuffer); - while (--iLength >= 0) - pDst[iLength] = static_cast<wchar_t>(pSrc[iLength]); -} - -void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) { - ASSERT(pStr); - - if (iLength < 0) - iLength = FXSYS_wcslen(pStr); - - uint16_t wch; - if (sizeof(wchar_t) > 2) { - while (iLength-- > 0) { - wch = static_cast<uint16_t>(*pStr); - wch = (wch >> 8) | (wch << 8); - wch &= 0x00FF; - *pStr = wch; - ++pStr; - } - return; - } - - while (iLength-- > 0) { - wch = static_cast<uint16_t>(*pStr); - wch = (wch >> 8) | (wch << 8); - *pStr = wch; - ++pStr; - } -} - -} // namespace - -#if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ -#define BOM_MASK 0x00FFFFFF -#define BOM_UTF8 0x00BFBBEF -#define BOM_UTF16_MASK 0x0000FFFF -#define BOM_UTF16_BE 0x0000FFFE -#define BOM_UTF16_LE 0x0000FEFF -#else -#define BOM_MASK 0xFFFFFF00 -#define BOM_UTF8 0xEFBBBF00 -#define BOM_UTF16_MASK 0xFFFF0000 -#define BOM_UTF16_BE 0xFEFF0000 -#define BOM_UTF16_LE 0xFFFE0000 -#endif // _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ - -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); - - if (isWriteStream) { - m_iPosition = m_pStream->GetSize(); - return; - } - - FX_FILESIZE iPosition = GetPosition(); - Seek(CFGAS_Stream::Pos::Begin, 0); - - uint32_t bom; - ReadData(reinterpret_cast<uint8_t*>(&bom), 3); - - bom &= BOM_MASK; - if (bom == BOM_UTF8) { - m_wBOMLength = 3; - m_wCodePage = FX_CODEPAGE_UTF8; - } else { - bom &= BOM_UTF16_MASK; - if (bom == BOM_UTF16_BE) { - m_wBOMLength = 2; - m_wCodePage = FX_CODEPAGE_UTF16BE; - } else if (bom == BOM_UTF16_LE) { - m_wBOMLength = 2; - m_wCodePage = FX_CODEPAGE_UTF16LE; - } else { - m_wBOMLength = 0; - m_wCodePage = FXSYS_GetACP(); - } - } - - 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(CFGAS_Stream::Pos eSeek, FX_FILESIZE iOffset) { - switch (eSeek) { - case CFGAS_Stream::Pos::Begin: - m_iPosition = iOffset; - break; - case CFGAS_Stream::Pos::Current: - m_iPosition += iOffset; - break; - } - m_iPosition = - pdfium::clamp(m_iPosition, static_cast<FX_FILESIZE>(0), GetLength()); -} - -void CFGAS_Stream::SetCodePage(uint16_t wCodePage) { - if (m_wBOMLength > 0) - return; - m_wCodePage = wCodePage; -} - -FX_STRSIZE CFGAS_Stream::ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize) { - ASSERT(pBuffer && iBufferSize > 0); - - if (m_IsWriteStream) - return -1; - - iBufferSize = std::min( - iBufferSize, static_cast<FX_STRSIZE>(m_pStream->GetSize() - m_iPosition)); - if (iBufferSize <= 0) - return 0; - - 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_STRSIZE CFGAS_Stream::ReadString(wchar_t* pStr, - FX_STRSIZE iMaxLength, - bool* bEOS) { - ASSERT(pStr && iMaxLength > 0); - - if (m_IsWriteStream) - return -1; - - if (m_wCodePage == FX_CODEPAGE_UTF16LE || - m_wCodePage == FX_CODEPAGE_UTF16BE) { - FX_FILESIZE iBytes = iMaxLength * 2; - FX_STRSIZE iLen = ReadData(reinterpret_cast<uint8_t*>(pStr), iBytes); - iMaxLength = iLen / 2; - if (sizeof(wchar_t) > 2) - UTF16ToWChar(pStr, iMaxLength); - -#if _FX_ENDIAN_ == _FX_BIG_ENDIAN_ - if (m_wCodePage == FX_CODEPAGE_UTF16LE) - SwapByteOrder(pStr, iMaxLength); -#else - if (m_wCodePage == FX_CODEPAGE_UTF16BE) - SwapByteOrder(pStr, iMaxLength); -#endif - - } else { - 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 = 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); - Seek(CFGAS_Stream::Pos::Current, iSrc - iLen); - } else { - iMaxLength = 0; - } - } - - *bEOS = IsEOF(); - return iMaxLength; -} - -void CFGAS_Stream::WriteString(const CFX_WideStringC& str) { - if (!m_IsWriteStream || str.GetLength() == 0 || - m_wCodePage != FX_CODEPAGE_UTF8) { - 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); - if (!new_pos.IsValid()) { - m_iPosition = std::numeric_limits<FX_STRSIZE>::max(); - return; - } - - m_iPosition = new_pos.ValueOrDie(); -} diff --git a/xfa/fgas/crt/cfgas_stream.h b/xfa/fgas/crt/cfgas_stream.h deleted file mode 100644 index 5d2e5e6242..0000000000 --- a/xfa/fgas/crt/cfgas_stream.h +++ /dev/null @@ -1,54 +0,0 @@ -// 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/fgas_codepage.h b/xfa/fgas/crt/fgas_codepage.h deleted file mode 100644 index 17813595e6..0000000000 --- a/xfa/fgas/crt/fgas_codepage.h +++ /dev/null @@ -1,137 +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_FGAS_CODEPAGE_H_ -#define XFA_FGAS_CRT_FGAS_CODEPAGE_H_ - -#include "core/fxcrt/fx_basic.h" - -#define FX_CODEPAGE_DefANSI 0 -#define FX_CODEPAGE_DefOEM 1 -#define FX_CODEPAGE_DefMAC 2 -#define FX_CODEPAGE_Thread 3 -#define FX_CODEPAGE_Symbol 42 -#define FX_CODEPAGE_MSDOS_US 437 -#define FX_CODEPAGE_Arabic_ASMO708 708 -#define FX_CODEPAGE_Arabic_ASMO449Plus 709 -#define FX_CODEPAGE_Arabic_Transparent 710 -#define FX_CODEPAGE_Arabic_NafithaEnhanced 711 -#define FX_CODEPAGE_Arabic_TransparentASMO 720 -#define FX_CODEPAGE_MSDOS_Greek1 737 -#define FX_CODEPAGE_MSDOS_Baltic 775 -#define FX_CODEPAGE_MSWin31_WesternEuropean 819 -#define FX_CODEPAGE_MSDOS_WesternEuropean 850 -#define FX_CODEPAGE_MSDOS_EasternEuropean 852 -#define FX_CODEPAGE_MSDOS_Latin3 853 -#define FX_CODEPAGE_MSDOS_Cyrillic 855 -#define FX_CODEPAGE_MSDOS_Turkish 857 -#define FX_CODEPAGE_MSDOS_Latin1Euro 858 -#define FX_CODEPAGE_MSDOS_Portuguese 860 -#define FX_CODEPAGE_MSDOS_Icelandic 861 -#define FX_CODEPAGE_MSDOS_Hebrew 862 -#define FX_CODEPAGE_MSDOS_FrenchCanadian 863 -#define FX_CODEPAGE_MSDOS_Arabic 864 -#define FX_CODEPAGE_MSDOS_Norwegian 865 -#define FX_CODEPAGE_MSDOS_Russian 866 -#define FX_CODEPAGE_MSDOS_Greek2 869 -#define FX_CODEPAGE_MSDOS_Thai 874 -#define FX_CODEPAGE_MSDOS_KamenickyCS 895 -#define FX_CODEPAGE_ShiftJIS 932 -#define FX_CODEPAGE_ChineseSimplified 936 -#define FX_CODEPAGE_Korean 949 -#define FX_CODEPAGE_ChineseTraditional 950 -#define FX_CODEPAGE_UTF16LE 1200 -#define FX_CODEPAGE_UTF16BE 1201 -#define FX_CODEPAGE_MSWin_EasternEuropean 1250 -#define FX_CODEPAGE_MSWin_Cyrillic 1251 -#define FX_CODEPAGE_MSWin_WesternEuropean 1252 -#define FX_CODEPAGE_MSWin_Greek 1253 -#define FX_CODEPAGE_MSWin_Turkish 1254 -#define FX_CODEPAGE_MSWin_Hebrew 1255 -#define FX_CODEPAGE_MSWin_Arabic 1256 -#define FX_CODEPAGE_MSWin_Baltic 1257 -#define FX_CODEPAGE_MSWin_Vietnamese 1258 -#define FX_CODEPAGE_Johab 1361 -#define FX_CODEPAGE_MAC_Roman 10000 -#define FX_CODEPAGE_MAC_ShiftJIS 10001 -#define FX_CODEPAGE_MAC_ChineseTraditional 10002 -#define FX_CODEPAGE_MAC_Korean 10003 -#define FX_CODEPAGE_MAC_Arabic 10004 -#define FX_CODEPAGE_MAC_Hebrew 10005 -#define FX_CODEPAGE_MAC_Greek 10006 -#define FX_CODEPAGE_MAC_Cyrillic 10007 -#define FX_CODEPAGE_MAC_ChineseSimplified 10008 -#define FX_CODEPAGE_MAC_Thai 10021 -#define FX_CODEPAGE_MAC_EasternEuropean 10029 -#define FX_CODEPAGE_MAC_Turkish 10081 -#define FX_CODEPAGE_UTF32LE 12000 -#define FX_CODEPAGE_UTF32BE 12001 -#define FX_CODEPAGE_ISO8859_1 28591 -#define FX_CODEPAGE_ISO8859_2 28592 -#define FX_CODEPAGE_ISO8859_3 28593 -#define FX_CODEPAGE_ISO8859_4 28594 -#define FX_CODEPAGE_ISO8859_5 28595 -#define FX_CODEPAGE_ISO8859_6 28596 -#define FX_CODEPAGE_ISO8859_7 28597 -#define FX_CODEPAGE_ISO8859_8 28598 -#define FX_CODEPAGE_ISO8859_9 28599 -#define FX_CODEPAGE_ISO8859_10 28600 -#define FX_CODEPAGE_ISO8859_11 28601 -#define FX_CODEPAGE_ISO8859_12 28602 -#define FX_CODEPAGE_ISO8859_13 28603 -#define FX_CODEPAGE_ISO8859_14 28604 -#define FX_CODEPAGE_ISO8859_15 28605 -#define FX_CODEPAGE_ISO8859_16 28606 -#define FX_CODEPAGE_ISCII_Devanagari 57002 -#define FX_CODEPAGE_ISCII_Bengali 57003 -#define FX_CODEPAGE_ISCII_Tamil 57004 -#define FX_CODEPAGE_ISCII_Telugu 57005 -#define FX_CODEPAGE_ISCII_Assamese 57006 -#define FX_CODEPAGE_ISCII_Oriya 57007 -#define FX_CODEPAGE_ISCII_Kannada 57008 -#define FX_CODEPAGE_ISCII_Malayalam 57009 -#define FX_CODEPAGE_ISCII_Gujarati 57010 -#define FX_CODEPAGE_ISCII_Punjabi 57011 -#define FX_CODEPAGE_UTF7 65000 -#define FX_CODEPAGE_UTF8 65001 - -#define FX_CHARSET_ANSI 0 -#define FX_CHARSET_Default 1 -#define FX_CHARSET_Symbol 2 -#define FX_CHARSET_MAC_Roman 77 -#define FX_CHARSET_MAC_ShiftJIS 78 -#define FX_CHARSET_MAC_Korean 79 -#define FX_CHARSET_MAC_ChineseSimplified 80 -#define FX_CHARSET_MAC_ChineseTriditional 81 -#define FX_CHARSET_MAC_Johab 82 -#define FX_CHARSET_MAC_Hebrew 83 -#define FX_CHARSET_MAC_Arabic 84 -#define FX_CHARSET_MAC_Greek 85 -#define FX_CHARSET_MAC_Turkish 86 -#define FX_CHARSET_MAC_Thai 87 -#define FX_CHARSET_MAC_EasternEuropean 88 -#define FX_CHARSET_MAC_Cyrillic 89 -#define FX_CHARSET_ShiftJIS 128 -#define FX_CHARSET_Korean 129 -#define FX_CHARSET_Johab 130 -#define FX_CHARSET_ChineseSimplified 134 -#define FX_CHARSET_ChineseTriditional 136 -#define FX_CHARSET_MSWin_Greek 161 -#define FX_CHARSET_MSWin_Turkish 162 -#define FX_CHARSET_MSWin_Vietnamese 163 -#define FX_CHARSET_MSWin_Hebrew 177 -#define FX_CHARSET_MSWin_Arabic 178 -#define FX_CHARSET_ArabicTraditional 179 -#define FX_CHARSET_ArabicUser 180 -#define FX_CHARSET_HebrewUser 181 -#define FX_CHARSET_MSWin_Baltic 186 -#define FX_CHARSET_MSWin_Cyrillic 204 -#define FX_CHARSET_Thai 222 -#define FX_CHARSET_MSWin_EasterEuropean 238 -#define FX_CHARSET_US 254 -#define FX_CHARSET_OEM 255 - -#endif // XFA_FGAS_CRT_FGAS_CODEPAGE_H_ diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 8cd799e37a..d1c4b3d580 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -10,6 +10,7 @@ #include <memory> #include <utility> +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_stream.h" #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/cfx_fontmgr.h" @@ -17,7 +18,6 @@ #include "core/fxge/ifx_systemfontinfo.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -#include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fgas/font/fgas_fontutils.h" diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h index 8a3705335e..cca999a869 100644 --- a/xfa/fgas/font/cfgas_fontmgr.h +++ b/xfa/fgas/font/cfgas_fontmgr.h @@ -14,11 +14,11 @@ #include <vector> #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_seekablestreamproxy.h" #include "core/fxcrt/fx_ext.h" #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/fx_freetype.h" #include "core/fxge/ifx_systemfontinfo.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.cpp b/xfa/fgas/font/cfgas_gefont.cpp index fdeb2ce533..ab773698e7 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -9,11 +9,11 @@ #include <memory> #include <utility> +#include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_substfont.h" #include "core/fxge/cfx_unicodeencoding.h" #include "core/fxge/cfx_unicodeencodingex.h" #include "third_party/base/ptr_util.h" -#include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fgas/font/fgas_fontutils.h" #include "xfa/fxfa/cxfa_fontmgr.h" diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h index 6c9f2a168d..ba2e6e69a5 100644 --- a/xfa/fgas/font/cfgas_gefont.h +++ b/xfa/fgas/font/cfgas_gefont.h @@ -67,8 +67,9 @@ 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<CFGAS_Stream>& pFontStream, - bool bSaveStream); + bool LoadFontInternal( + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pFontStream, + bool bSaveStream); #endif bool LoadFontInternal(CFX_Font* pExternalFont); bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont); @@ -95,7 +96,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<CFGAS_Stream> m_pStream; + CFX_RetainPtr<CFX_SeekableStreamProxy> 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/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp index 4dc599cd4b..f5673de56b 100644 --- a/xfa/fgas/font/fgas_fontutils.cpp +++ b/xfa/fgas/font/fgas_fontutils.cpp @@ -6,8 +6,8 @@ #include "xfa/fgas/font/fgas_fontutils.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_ext.h" -#include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fgas/font/cfgas_fontmgr.h" namespace { diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp index 6f394dd5e2..1243f5b7ea 100644 --- a/xfa/fxfa/app/cxfa_textparser.cpp +++ b/xfa/fxfa/app/cxfa_textparser.cpp @@ -10,6 +10,7 @@ #include <utility> #include <vector> +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/ptr_util.h" #include "xfa/fde/css/cfde_csscomputedstyle.h" #include "xfa/fde/css/cfde_cssstyleselector.h" @@ -17,7 +18,6 @@ #include "xfa/fde/css/fde_css.h" #include "xfa/fde/xml/cfde_xmlelement.h" #include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fxfa/app/cxfa_csstagprovider.h" #include "xfa/fxfa/app/cxfa_textparsecontext.h" diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index 629cd509e8..9af45e62df 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -6,8 +6,8 @@ #include "xfa/fxfa/app/xfa_fwltheme.h" +#include "core/fxcrt/fx_codepage.h" #include "xfa/fde/cfde_textout.h" -#include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fwl/cfwl_barcode.h" #include "xfa/fwl/cfwl_caret.h" diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index 442195b1dd..c1eda8d9e6 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -9,11 +9,11 @@ #include <vector> #include "core/fxcrt/fx_basic.h" +#include "core/fxcrt/fx_codepage.h" #include "third_party/base/stl_util.h" #include "xfa/fde/xml/cfde_xmldoc.h" #include "xfa/fde/xml/cfde_xmlelement.h" #include "xfa/fde/xml/cfde_xmlnode.h" -#include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_widgetdata.h" @@ -226,7 +226,8 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, CFX_RetainPtr<IFX_MemoryStream> pMemStream = IFX_MemoryStream::Create(true); - auto pTempStream = pdfium::MakeRetain<CFGAS_Stream>(pMemStream, true); + auto pTempStream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>(pMemStream, true); pTempStream->SetCodePage(FX_CODEPAGE_UTF8); pRichTextXML->SaveXMLNode(pTempStream); @@ -341,9 +342,10 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode, } } -void RegenerateFormFile_Container(CXFA_Node* pNode, - const CFX_RetainPtr<CFGAS_Stream>& pStream, - bool bSaveXML) { +void RegenerateFormFile_Container( + CXFA_Node* pNode, + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream, + bool bSaveXML) { XFA_Element eType = pNode->GetElementType(); if (eType == XFA_Element::Field || eType == XFA_Element::Draw || !pNode->IsContainerNode()) { @@ -399,7 +401,7 @@ void RegenerateFormFile_Container(CXFA_Node* pNode, void XFA_DataExporter_RegenerateFormFile( CXFA_Node* pNode, - const CFX_RetainPtr<CFGAS_Stream>& pStream, + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream, const char* pChecksum, bool bSaveXML) { if (pNode->IsModelNode()) { @@ -485,15 +487,16 @@ bool CXFA_DataExporter::Export(const CFX_RetainPtr<IFX_SeekableStream>& pWrite, if (!pWrite) return false; - auto pStream = pdfium::MakeRetain<CFGAS_Stream>(pWrite, true); + auto pStream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(pWrite, true); pStream->SetCodePage(FX_CODEPAGE_UTF8); return Export(pStream, pNode, dwFlag, pChecksum); } -bool CXFA_DataExporter::Export(const CFX_RetainPtr<CFGAS_Stream>& pStream, - CXFA_Node* pNode, - uint32_t dwFlag, - const char* pChecksum) { +bool CXFA_DataExporter::Export( + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream, + CXFA_Node* pNode, + uint32_t dwFlag, + const char* pChecksum) { CFDE_XMLDoc* pXMLDoc = m_pDocument->GetXMLDoc(); if (pNode->IsModelNode()) { switch (pNode->GetPacketID()) { diff --git a/xfa/fxfa/parser/cxfa_dataexporter.h b/xfa/fxfa/parser/cxfa_dataexporter.h index c7e5c7b70b..cd949be964 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 CFGAS_Stream; +class CFX_SeekableStreamProxy; class CXFA_DataExporter { public: @@ -26,7 +26,7 @@ class CXFA_DataExporter { const char* pChecksum); private: - bool Export(const CFX_RetainPtr<CFGAS_Stream>& pStream, + bool Export(const CFX_RetainPtr<CFX_SeekableStreamProxy>& 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 26dc6bd831..83c05d1269 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -13,6 +13,7 @@ #include <vector> #include "core/fxcrt/cfx_decimal.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_ext.h" #include "fxjs/cfxjse_value.h" #include "third_party/base/ptr_util.h" @@ -20,7 +21,6 @@ #include "xfa/fde/xml/cfde_xmlelement.h" #include "xfa/fde/xml/cfde_xmlnode.h" #include "xfa/fde/xml/cfde_xmltext.h" -#include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffwidget.h" @@ -1408,7 +1408,8 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { } CFX_RetainPtr<IFX_MemoryStream> pMemoryStream = IFX_MemoryStream::Create(true); - auto pStream = pdfium::MakeRetain<CFGAS_Stream>(pMemoryStream, true); + auto pStream = + pdfium::MakeRetain<CFX_SeekableStreamProxy>(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 92196ec957..642b7641bd 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -10,6 +10,8 @@ #include <vector> #include "core/fxcrt/cfx_checksumcontext.h" +#include "core/fxcrt/cfx_seekablestreamproxy.h" +#include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_ext.h" #include "third_party/base/ptr_util.h" #include "xfa/fde/xml/cfde_xmlchardata.h" @@ -19,8 +21,6 @@ #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/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -277,7 +277,7 @@ int32_t CXFA_SimpleParser::StartParse( XFA_XDPPACKET ePacketID) { CloseParser(); m_pFileRead = pStream; - m_pStream = pdfium::MakeRetain<CFGAS_Stream>(pStream, false); + m_pStream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(pStream, false); uint16_t wCodePage = m_pStream->GetCodePage(); if (wCodePage != FX_CODEPAGE_UTF16LE && wCodePage != FX_CODEPAGE_UTF16BE && wCodePage != FX_CODEPAGE_UTF8) { @@ -319,7 +319,7 @@ CFDE_XMLNode* CXFA_SimpleParser::ParseXMLData(const CFX_ByteString& wsXML, CloseParser(); m_pXMLDoc = pdfium::MakeUnique<CFDE_XMLDoc>(); - auto pStream = pdfium::MakeRetain<CFGAS_Stream>( + auto pStream = pdfium::MakeRetain<CFX_SeekableStreamProxy>( const_cast<uint8_t*>(wsXML.raw_str()), wsXML.GetLength()); auto pParser = pdfium::MakeUnique<CFDE_XMLParser>(m_pXMLDoc->GetRoot(), pStream); diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h index 32b5518fab..88a7679e74 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 CFGAS_Stream; +class CFX_SeekableStreamProxy; class CXFA_SimpleParser { public: @@ -78,7 +78,7 @@ class CXFA_SimpleParser { CFDE_XMLParser* m_pXMLParser; std::unique_ptr<CFDE_XMLDoc> m_pXMLDoc; - CFX_RetainPtr<CFGAS_Stream> m_pStream; + CFX_RetainPtr<CFX_SeekableStreamProxy> 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 ae51c8fdc6..80f6d096ed 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/cfgas_stream.h" +#include "core/fxcrt/cfx_seekablestreamproxy.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<CFGAS_Stream>& pStream, + const CFX_RetainPtr<CFX_SeekableStreamProxy>& pStream, const char* pChecksum = nullptr, bool bSaveXML = false); |