summaryrefslogtreecommitdiff
path: root/xfa/fde
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde')
-rw-r--r--xfa/fde/xml/cfx_saxreader.cpp37
-rw-r--r--xfa/fde/xml/cfx_saxreader.h9
2 files changed, 26 insertions, 20 deletions
diff --git a/xfa/fde/xml/cfx_saxreader.cpp b/xfa/fde/xml/cfx_saxreader.cpp
index b4d48d2937..458bed52d6 100644
--- a/xfa/fde/xml/cfx_saxreader.cpp
+++ b/xfa/fde/xml/cfx_saxreader.cpp
@@ -63,32 +63,34 @@ static const FX_SAXReader_LPFParse
} // namespace
CFX_SAXFile::CFX_SAXFile()
- : m_pFile(nullptr),
- m_dwStart(0),
+ : m_dwStart(0),
m_dwEnd(0),
m_dwCur(0),
m_pBuf(nullptr),
m_dwBufSize(0),
m_dwBufIndex(0) {}
-bool CFX_SAXFile::StartFile(IFX_SeekableReadStream* pFile,
+
+CFX_SAXFile::~CFX_SAXFile() {}
+
+bool CFX_SAXFile::StartFile(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile,
uint32_t dwStart,
uint32_t dwLen) {
ASSERT(!m_pFile && pFile);
uint32_t dwSize = pFile->GetSize();
- if (dwStart >= dwSize) {
+ if (dwStart >= dwSize)
return false;
- }
- if (dwLen == static_cast<uint32_t>(-1) || dwStart + dwLen > dwSize) {
+
+ if (dwLen == static_cast<uint32_t>(-1) || dwStart + dwLen > dwSize)
dwLen = dwSize - dwStart;
- }
- if (dwLen == 0) {
+
+ if (dwLen == 0)
return false;
- }
+
m_dwBufSize = std::min(dwLen, kSaxFileBufSize);
m_pBuf = FX_Alloc(uint8_t, m_dwBufSize);
- if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize)) {
+ if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize))
return false;
- }
+
m_dwStart = dwStart;
m_dwEnd = dwStart + dwLen;
m_dwCur = dwStart;
@@ -214,15 +216,16 @@ bool CFX_SAXReader::SkipSpace(uint8_t ch) {
return (m_dwParseMode & CFX_SaxParseMode_NotSkipSpace) == 0 && ch < 0x21;
}
-int32_t CFX_SAXReader::StartParse(IFX_SeekableReadStream* pFile,
- uint32_t dwStart,
- uint32_t dwLen,
- uint32_t dwParseMode) {
+int32_t CFX_SAXReader::StartParse(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFile,
+ uint32_t dwStart,
+ uint32_t dwLen,
+ uint32_t dwParseMode) {
m_iState = -1;
Reset();
- if (!m_File.StartFile(pFile, dwStart, dwLen)) {
+ if (!m_File.StartFile(pFile, dwStart, dwLen))
return -1;
- }
+
m_iState = 0;
m_eMode = CFX_SaxMode::Text;
m_ePrevMode = CFX_SaxMode::Text;
diff --git a/xfa/fde/xml/cfx_saxreader.h b/xfa/fde/xml/cfx_saxreader.h
index 667813cf76..8e06d9bb48 100644
--- a/xfa/fde/xml/cfx_saxreader.h
+++ b/xfa/fde/xml/cfx_saxreader.h
@@ -38,12 +38,15 @@ class CFX_SAXItem {
class CFX_SAXFile {
public:
CFX_SAXFile();
- bool StartFile(IFX_SeekableReadStream* pFile,
+ ~CFX_SAXFile();
+
+ bool StartFile(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile,
uint32_t dwStart,
uint32_t dwLen);
bool ReadNextBlock();
void Reset();
- IFX_SeekableReadStream* m_pFile;
+
+ CFX_RetainPtr<IFX_SeekableReadStream> m_pFile;
uint32_t m_dwStart;
uint32_t m_dwEnd;
uint32_t m_dwCur;
@@ -72,7 +75,7 @@ class CFX_SAXReader {
CFX_SAXReader();
~CFX_SAXReader();
- int32_t StartParse(IFX_SeekableReadStream* pFile,
+ int32_t StartParse(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile,
uint32_t dwStart = 0,
uint32_t dwLen = -1,
uint32_t dwParseMode = 0);