OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fde/xml/cfx_saxreader.h" | 7 #include "xfa/fde/xml/cfx_saxreader.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } // namespace | 63 } // namespace |
64 | 64 |
65 CFX_SAXFile::CFX_SAXFile() | 65 CFX_SAXFile::CFX_SAXFile() |
66 : m_pFile(nullptr), | 66 : m_pFile(nullptr), |
67 m_dwStart(0), | 67 m_dwStart(0), |
68 m_dwEnd(0), | 68 m_dwEnd(0), |
69 m_dwCur(0), | 69 m_dwCur(0), |
70 m_pBuf(nullptr), | 70 m_pBuf(nullptr), |
71 m_dwBufSize(0), | 71 m_dwBufSize(0), |
72 m_dwBufIndex(0) {} | 72 m_dwBufIndex(0) {} |
73 FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile, | 73 FX_BOOL CFX_SAXFile::StartFile(IFX_SeekableReadStream* pFile, |
74 uint32_t dwStart, | 74 uint32_t dwStart, |
75 uint32_t dwLen) { | 75 uint32_t dwLen) { |
76 ASSERT(!m_pFile && pFile); | 76 ASSERT(!m_pFile && pFile); |
77 uint32_t dwSize = pFile->GetSize(); | 77 uint32_t dwSize = pFile->GetSize(); |
78 if (dwStart >= dwSize) { | 78 if (dwStart >= dwSize) { |
79 return FALSE; | 79 return FALSE; |
80 } | 80 } |
81 if (dwLen == static_cast<uint32_t>(-1) || dwStart + dwLen > dwSize) { | 81 if (dwLen == static_cast<uint32_t>(-1) || dwStart + dwLen > dwSize) { |
82 dwLen = dwSize - dwStart; | 82 dwLen = dwSize - dwStart; |
83 } | 83 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } else { | 207 } else { |
208 m_iNameSize += 1024 * 1024; | 208 m_iNameSize += 1024 * 1024; |
209 } | 209 } |
210 m_pszName = (uint8_t*)FX_Realloc(uint8_t, m_pszName, m_iNameSize); | 210 m_pszName = (uint8_t*)FX_Realloc(uint8_t, m_pszName, m_iNameSize); |
211 } | 211 } |
212 | 212 |
213 FX_BOOL CFX_SAXReader::SkipSpace(uint8_t ch) { | 213 FX_BOOL CFX_SAXReader::SkipSpace(uint8_t ch) { |
214 return (m_dwParseMode & CFX_SaxParseMode_NotSkipSpace) == 0 && ch < 0x21; | 214 return (m_dwParseMode & CFX_SaxParseMode_NotSkipSpace) == 0 && ch < 0x21; |
215 } | 215 } |
216 | 216 |
217 int32_t CFX_SAXReader::StartParse(IFX_FileRead* pFile, | 217 int32_t CFX_SAXReader::StartParse(IFX_SeekableReadStream* pFile, |
218 uint32_t dwStart, | 218 uint32_t dwStart, |
219 uint32_t dwLen, | 219 uint32_t dwLen, |
220 uint32_t dwParseMode) { | 220 uint32_t dwParseMode) { |
221 m_iState = -1; | 221 m_iState = -1; |
222 Reset(); | 222 Reset(); |
223 if (!m_File.StartFile(pFile, dwStart, dwLen)) { | 223 if (!m_File.StartFile(pFile, dwStart, dwLen)) { |
224 return -1; | 224 return -1; |
225 } | 225 } |
226 m_iState = 0; | 226 m_iState = 0; |
227 m_eMode = CFX_SaxMode::Text; | 227 m_eMode = CFX_SaxMode::Text; |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 CFX_SAXItem* pItem = GetCurrentItem(); | 727 CFX_SAXItem* pItem = GetCurrentItem(); |
728 if (!pItem) | 728 if (!pItem) |
729 return; | 729 return; |
730 | 730 |
731 pItem->m_bSkip = TRUE; | 731 pItem->m_bSkip = TRUE; |
732 } | 732 } |
733 | 733 |
734 void CFX_SAXReader::SetHandler(CXFA_SAXReaderHandler* pHandler) { | 734 void CFX_SAXReader::SetHandler(CXFA_SAXReaderHandler* pHandler) { |
735 m_pHandler = pHandler; | 735 m_pHandler = pHandler; |
736 } | 736 } |
OLD | NEW |