| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/fxfa/parser/cxfa_widetextread.h" | 7 #include "xfa/fxfa/parser/cxfa_widetextread.h" |
| 8 | 8 |
| 9 #include "core/fxcrt/fx_ext.h" | 9 #include "core/fxcrt/fx_ext.h" |
| 10 #include "xfa/fgas/crt/fgas_codepage.h" | 10 #include "xfa/fgas/crt/fgas_codepage.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 break; | 43 break; |
| 44 } | 44 } |
| 45 m_iPosition = std::min(std::max(0, m_iPosition), m_wsBuffer.GetLength()); | 45 m_iPosition = std::min(std::max(0, m_iPosition), m_wsBuffer.GetLength()); |
| 46 return GetPosition(); | 46 return GetPosition(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 int32_t CXFA_WideTextRead::GetPosition() { | 49 int32_t CXFA_WideTextRead::GetPosition() { |
| 50 return m_iPosition * sizeof(FX_WCHAR); | 50 return m_iPosition * sizeof(FX_WCHAR); |
| 51 } | 51 } |
| 52 | 52 |
| 53 FX_BOOL CXFA_WideTextRead::IsEOF() const { | 53 bool CXFA_WideTextRead::IsEOF() const { |
| 54 return m_iPosition >= m_wsBuffer.GetLength(); | 54 return m_iPosition >= m_wsBuffer.GetLength(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 int32_t CXFA_WideTextRead::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { | 57 int32_t CXFA_WideTextRead::ReadData(uint8_t* pBuffer, int32_t iBufferSize) { |
| 58 return 0; | 58 return 0; |
| 59 } | 59 } |
| 60 | 60 |
| 61 int32_t CXFA_WideTextRead::ReadString(FX_WCHAR* pStr, | 61 int32_t CXFA_WideTextRead::ReadString(FX_WCHAR* pStr, |
| 62 int32_t iMaxLength, | 62 int32_t iMaxLength, |
| 63 FX_BOOL& bEOS) { | 63 bool& bEOS) { |
| 64 iMaxLength = std::min(iMaxLength, m_wsBuffer.GetLength() - m_iPosition); | 64 iMaxLength = std::min(iMaxLength, m_wsBuffer.GetLength() - m_iPosition); |
| 65 if (iMaxLength == 0) | 65 if (iMaxLength == 0) |
| 66 return 0; | 66 return 0; |
| 67 | 67 |
| 68 FXSYS_wcsncpy(pStr, m_wsBuffer.c_str() + m_iPosition, iMaxLength); | 68 FXSYS_wcsncpy(pStr, m_wsBuffer.c_str() + m_iPosition, iMaxLength); |
| 69 m_iPosition += iMaxLength; | 69 m_iPosition += iMaxLength; |
| 70 bEOS = IsEOF(); | 70 bEOS = IsEOF(); |
| 71 return iMaxLength; | 71 return iMaxLength; |
| 72 } | 72 } |
| 73 | 73 |
| 74 int32_t CXFA_WideTextRead::WriteData(const uint8_t* pBuffer, | 74 int32_t CXFA_WideTextRead::WriteData(const uint8_t* pBuffer, |
| 75 int32_t iBufferSize) { | 75 int32_t iBufferSize) { |
| 76 return 0; | 76 return 0; |
| 77 } | 77 } |
| 78 | 78 |
| 79 int32_t CXFA_WideTextRead::WriteString(const FX_WCHAR* pStr, int32_t iLength) { | 79 int32_t CXFA_WideTextRead::WriteString(const FX_WCHAR* pStr, int32_t iLength) { |
| 80 return 0; | 80 return 0; |
| 81 } | 81 } |
| 82 | 82 |
| 83 FX_BOOL CXFA_WideTextRead::SetLength(int32_t iLength) { | 83 bool CXFA_WideTextRead::SetLength(int32_t iLength) { |
| 84 return FALSE; | 84 return false; |
| 85 } | 85 } |
| 86 | 86 |
| 87 int32_t CXFA_WideTextRead::GetBOM(uint8_t bom[4]) const { | 87 int32_t CXFA_WideTextRead::GetBOM(uint8_t bom[4]) const { |
| 88 return 0; | 88 return 0; |
| 89 } | 89 } |
| 90 | 90 |
| 91 uint16_t CXFA_WideTextRead::GetCodePage() const { | 91 uint16_t CXFA_WideTextRead::GetCodePage() const { |
| 92 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; | 92 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; |
| 93 } | 93 } |
| 94 | 94 |
| 95 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) { | 95 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) { |
| 96 return GetCodePage(); | 96 return GetCodePage(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 IFX_Stream* CXFA_WideTextRead::CreateSharedStream(uint32_t dwAccess, | 99 IFX_Stream* CXFA_WideTextRead::CreateSharedStream(uint32_t dwAccess, |
| 100 int32_t iOffset, | 100 int32_t iOffset, |
| 101 int32_t iLength) { | 101 int32_t iLength) { |
| 102 return nullptr; | 102 return nullptr; |
| 103 } | 103 } |
| 104 | 104 |
| 105 CFX_WideString CXFA_WideTextRead::GetSrcText() const { | 105 CFX_WideString CXFA_WideTextRead::GetSrcText() const { |
| 106 return m_wsBuffer; | 106 return m_wsBuffer; |
| 107 } | 107 } |
| OLD | NEW |