Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: xfa/fxfa/parser/cxfa_widetextread.cpp

Issue 2165993002: Move xfa_basic_imp to cxfa_widetextread. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Really fix it .... Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/fxfa/parser/cxfa_widetextread.h"
8
9 #include "core/fxcrt/include/fx_ext.h"
10 #include "xfa/fgas/crt/fgas_codepage.h"
11
12 CXFA_WideTextRead::CXFA_WideTextRead(const CFX_WideString& wsBuffer)
13 : m_wsBuffer(wsBuffer), m_iPosition(0), m_iRefCount(1) {}
14
15 void CXFA_WideTextRead::Release() {
16 if (--m_iRefCount < 1)
17 delete this;
18 }
19
20 IFX_Stream* CXFA_WideTextRead::Retain() {
21 m_iRefCount++;
22 return this;
23 }
24
25 uint32_t CXFA_WideTextRead::GetAccessModes() const {
26 return FX_STREAMACCESS_Read | FX_STREAMACCESS_Text;
27 }
28
29 int32_t CXFA_WideTextRead::GetLength() const {
30 return m_wsBuffer.GetLength() * sizeof(FX_WCHAR);
31 }
32
33 int32_t CXFA_WideTextRead::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) {
34 switch (eSeek) {
35 case FX_STREAMSEEK_Begin:
36 m_iPosition = iOffset;
37 break;
38 case FX_STREAMSEEK_Current:
39 m_iPosition += iOffset;
40 break;
41 case FX_STREAMSEEK_End:
42 m_iPosition = m_wsBuffer.GetLength() + iOffset;
43 break;
44 }
45 if (m_iPosition < 0)
Lei Zhang 2016/07/20 20:54:33 std::min / max
dsinclair 2016/07/21 13:34:24 Done.
46 m_iPosition = 0;
47 if (m_iPosition > m_wsBuffer.GetLength())
48 m_iPosition = m_wsBuffer.GetLength();
49
50 return GetPosition();
51 }
52
53 int32_t CXFA_WideTextRead::GetPosition() {
54 return m_iPosition * sizeof(FX_WCHAR);
55 }
56
57 FX_BOOL CXFA_WideTextRead::IsEOF() const {
58 return m_iPosition >= m_wsBuffer.GetLength();
59 }
60
61 int32_t CXFA_WideTextRead::ReadData(uint8_t* pBuffer, int32_t iBufferSize) {
62 return 0;
63 }
64
65 int32_t CXFA_WideTextRead::ReadString(FX_WCHAR* pStr,
66 int32_t iMaxLength,
67 FX_BOOL& bEOS) {
68 iMaxLength = std::min(iMaxLength, m_wsBuffer.GetLength() - m_iPosition);
69 if (iMaxLength == 0)
70 return 0;
71
72 FXSYS_wcsncpy(pStr, m_wsBuffer.c_str() + m_iPosition, iMaxLength);
73 m_iPosition += iMaxLength;
74 bEOS = IsEOF();
75 return iMaxLength;
76 }
77
78 int32_t CXFA_WideTextRead::WriteData(const uint8_t* pBuffer,
79 int32_t iBufferSize) {
80 return 0;
81 }
82
83 int32_t CXFA_WideTextRead::WriteString(const FX_WCHAR* pStr, int32_t iLength) {
84 return 0;
85 }
86
87 FX_BOOL CXFA_WideTextRead::SetLength(int32_t iLength) {
88 return FALSE;
89 }
90
91 int32_t CXFA_WideTextRead::GetBOM(uint8_t bom[4]) const {
92 return 0;
93 }
94
95 uint16_t CXFA_WideTextRead::GetCodePage() const {
96 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE;
97 }
98
99 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) {
100 return GetCodePage();
101 }
102
103 IFX_Stream* CXFA_WideTextRead::CreateSharedStream(uint32_t dwAccess,
104 int32_t iOffset,
105 int32_t iLength) {
106 return nullptr;
107 }
108
109 void CXFA_WideTextRead::Lock() {}
Lei Zhang 2016/07/20 20:54:33 Hmm. :)
dsinclair 2016/07/21 13:34:24 Removed. I'd assumed it was an override, but looks
110
111 void CXFA_WideTextRead::Unlock() {}
112
113 CFX_WideString CXFA_WideTextRead::GetSrcText() const {
114 return m_wsBuffer;
115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698