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

Side by Side Diff: xfa/src/fwl/src/lightwidget/edit.cpp

Issue 1508883003: Replace more static casts in FWL (part 3) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years 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
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 "../../../foxitlib.h" 7 #include "../../../foxitlib.h"
8 CFWL_Edit* CFWL_Edit::Create() { 8 CFWL_Edit* CFWL_Edit::Create() {
9 return new CFWL_Edit; 9 return new CFWL_Edit;
10 } 10 }
11 FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) { 11 FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) {
12 if (m_pIface) 12 if (m_pIface)
13 return FWL_ERR_Indefinite; 13 return FWL_ERR_Indefinite;
14 if (pProperties) { 14 if (pProperties) {
15 *m_pProperties = *pProperties; 15 *m_pProperties = *pProperties;
16 } 16 }
17 m_pIface = IFWL_Edit::Create(); 17 IFWL_Edit* pEdit = IFWL_Edit::Create();
18 FWL_ERR ret = 18 m_pIface = pEdit;
19 ((IFWL_Edit*)m_pIface) 19 FWL_ERR ret = pEdit->Initialize(
20 ->Initialize(m_pProperties->MakeWidgetImpProperties(nullptr), 20 m_pProperties->MakeWidgetImpProperties(nullptr), nullptr);
21 nullptr);
22 if (ret == FWL_ERR_Succeeded) { 21 if (ret == FWL_ERR_Succeeded) {
23 CFWL_Widget::Initialize(); 22 CFWL_Widget::Initialize();
24 } 23 }
25 return ret; 24 return ret;
26 } 25 }
27 FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) { 26 FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) {
28 if (!m_pIface) 27 if (!m_pIface)
29 return FWL_ERR_Indefinite; 28 return FWL_ERR_Indefinite;
30 return ((IFWL_Edit*)m_pIface)->SetText(wsText); 29 return static_cast<IFWL_Edit*>(m_pIface)->SetText(wsText);
31 } 30 }
32 int32_t CFWL_Edit::GetTextLength() const { 31 int32_t CFWL_Edit::GetTextLength() const {
33 if (!m_pIface) 32 if (!m_pIface)
34 return 0; 33 return 0;
35 return ((IFWL_Edit*)m_pIface)->GetTextLength(); 34 return static_cast<IFWL_Edit*>(m_pIface)->GetTextLength();
36 } 35 }
37 FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText, 36 FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText,
38 int32_t nStart, 37 int32_t nStart,
39 int32_t nCount) const { 38 int32_t nCount) const {
40 if (!m_pIface) 39 if (!m_pIface)
41 return FWL_ERR_Indefinite; 40 return FWL_ERR_Indefinite;
42 return ((IFWL_Edit*)m_pIface)->GetText(wsText, nStart, nCount); 41 return static_cast<IFWL_Edit*>(m_pIface)->GetText(wsText, nStart, nCount);
43 } 42 }
44 FWL_ERR CFWL_Edit::ClearText() { 43 FWL_ERR CFWL_Edit::ClearText() {
45 if (!m_pIface) 44 if (!m_pIface)
46 return FWL_ERR_Indefinite; 45 return FWL_ERR_Indefinite;
47 return ((IFWL_Edit*)m_pIface)->ClearText(); 46 return static_cast<IFWL_Edit*>(m_pIface)->ClearText();
48 } 47 }
49 int32_t CFWL_Edit::GetCaretPos() const { 48 int32_t CFWL_Edit::GetCaretPos() const {
50 if (!m_pIface) 49 if (!m_pIface)
51 return -1; 50 return -1;
52 return ((IFWL_Edit*)m_pIface)->GetCaretPos(); 51 return static_cast<IFWL_Edit*>(m_pIface)->GetCaretPos();
53 } 52 }
54 int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { 53 int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
55 if (!m_pIface) 54 if (!m_pIface)
56 return -1; 55 return -1;
57 return ((IFWL_Edit*)m_pIface)->SetCaretPos(nIndex, bBefore); 56 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(nIndex, bBefore);
58 } 57 }
59 FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { 58 FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
60 if (!m_pIface) 59 if (!m_pIface)
61 return FWL_ERR_Indefinite; 60 return FWL_ERR_Indefinite;
62 ((IFWL_Edit*)m_pIface)->AddSelRange(nStart, nCount); 61 static_cast<IFWL_Edit*>(m_pIface)->AddSelRange(nStart, nCount);
63 int32_t pos = 0; 62 int32_t pos = 0;
64 int32_t sum = ((IFWL_Edit*)m_pIface)->GetTextLength(); 63 int32_t sum = static_cast<IFWL_Edit*>(m_pIface)->GetTextLength();
65 if (nCount == -1) { 64 if (nCount == -1) {
66 pos = sum; 65 pos = sum;
67 } else { 66 } else {
68 pos = nStart + nCount; 67 pos = nStart + nCount;
69 } 68 }
70 return ((IFWL_Edit*)m_pIface)->SetCaretPos(pos); 69 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(pos);
71 } 70 }
72 int32_t CFWL_Edit::CountSelRanges() { 71 int32_t CFWL_Edit::CountSelRanges() {
73 if (!m_pIface) 72 if (!m_pIface)
74 return 0; 73 return 0;
75 return ((IFWL_Edit*)m_pIface)->CountSelRanges(); 74 return static_cast<IFWL_Edit*>(m_pIface)->CountSelRanges();
76 } 75 }
77 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { 76 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) {
78 if (!m_pIface) 77 if (!m_pIface)
79 return 0; 78 return 0;
80 return ((IFWL_Edit*)m_pIface)->GetSelRange(nIndex, nStart); 79 return static_cast<IFWL_Edit*>(m_pIface)->GetSelRange(nIndex, nStart);
81 } 80 }
82 FWL_ERR CFWL_Edit::ClearSelections() { 81 FWL_ERR CFWL_Edit::ClearSelections() {
83 if (!m_pIface) 82 if (!m_pIface)
84 return FWL_ERR_Indefinite; 83 return FWL_ERR_Indefinite;
85 return ((IFWL_Edit*)m_pIface)->ClearSelections(); 84 return static_cast<IFWL_Edit*>(m_pIface)->ClearSelections();
86 } 85 }
87 int32_t CFWL_Edit::GetLimit() { 86 int32_t CFWL_Edit::GetLimit() {
88 if (!m_pIface) 87 if (!m_pIface)
89 return -1; 88 return -1;
90 return ((IFWL_Edit*)m_pIface)->GetLimit(); 89 return static_cast<IFWL_Edit*>(m_pIface)->GetLimit();
91 } 90 }
92 FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) { 91 FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) {
93 if (!m_pIface) 92 if (!m_pIface)
94 return FWL_ERR_Indefinite; 93 return FWL_ERR_Indefinite;
95 return ((IFWL_Edit*)m_pIface)->SetLimit(nLimit); 94 return static_cast<IFWL_Edit*>(m_pIface)->SetLimit(nLimit);
96 } 95 }
97 FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { 96 FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
98 if (!m_pIface) 97 if (!m_pIface)
99 return FWL_ERR_Indefinite; 98 return FWL_ERR_Indefinite;
100 return ((IFWL_Edit*)m_pIface)->SetAliasChar(wAlias); 99 return static_cast<IFWL_Edit*>(m_pIface)->SetAliasChar(wAlias);
101 } 100 }
102 FWL_ERR CFWL_Edit::SetFormatString(const CFX_WideString& wsFormat) { 101 FWL_ERR CFWL_Edit::SetFormatString(const CFX_WideString& wsFormat) {
103 if (!m_pIface) 102 if (!m_pIface)
104 return FWL_ERR_Indefinite; 103 return FWL_ERR_Indefinite;
105 return ((IFWL_Edit*)m_pIface)->SetFormatString(wsFormat); 104 return static_cast<IFWL_Edit*>(m_pIface)->SetFormatString(wsFormat);
106 } 105 }
107 FWL_ERR CFWL_Edit::Insert(int32_t nStart, 106 FWL_ERR CFWL_Edit::Insert(int32_t nStart,
108 const FX_WCHAR* lpText, 107 const FX_WCHAR* lpText,
109 int32_t nLen) { 108 int32_t nLen) {
110 if (!m_pIface) 109 if (!m_pIface)
111 return FWL_ERR_Indefinite; 110 return FWL_ERR_Indefinite;
112 return ((IFWL_Edit*)m_pIface)->Insert(nStart, lpText, nLen); 111 return static_cast<IFWL_Edit*>(m_pIface)->Insert(nStart, lpText, nLen);
113 } 112 }
114 FWL_ERR CFWL_Edit::DeleteSelections() { 113 FWL_ERR CFWL_Edit::DeleteSelections() {
115 if (!m_pIface) 114 if (!m_pIface)
116 return FWL_ERR_Indefinite; 115 return FWL_ERR_Indefinite;
117 return ((IFWL_Edit*)m_pIface)->DeleteSelections(); 116 return static_cast<IFWL_Edit*>(m_pIface)->DeleteSelections();
118 } 117 }
119 FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { 118 FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
120 if (!m_pIface) 119 if (!m_pIface)
121 return FWL_ERR_Indefinite; 120 return FWL_ERR_Indefinite;
122 return ((IFWL_Edit*)m_pIface)->DeleteRange(nStart, nCount); 121 return static_cast<IFWL_Edit*>(m_pIface)->DeleteRange(nStart, nCount);
123 } 122 }
124 FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { 123 FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) {
125 if (!m_pIface) 124 if (!m_pIface)
126 return FWL_ERR_Indefinite; 125 return FWL_ERR_Indefinite;
127 return ((IFWL_Edit*)m_pIface)->ReplaceSelections(wsReplace); 126 return static_cast<IFWL_Edit*>(m_pIface)->ReplaceSelections(wsReplace);
128 } 127 }
129 FWL_ERR CFWL_Edit::Replace(int32_t nStart, 128 FWL_ERR CFWL_Edit::Replace(int32_t nStart,
130 int32_t nLen, 129 int32_t nLen,
131 const CFX_WideStringC& wsReplace) { 130 const CFX_WideStringC& wsReplace) {
132 if (!m_pIface) 131 if (!m_pIface)
133 return FWL_ERR_Indefinite; 132 return FWL_ERR_Indefinite;
134 return ((IFWL_Edit*)m_pIface)->Replace(nStart, nLen, wsReplace); 133 return static_cast<IFWL_Edit*>(m_pIface)->Replace(nStart, nLen, wsReplace);
135 } 134 }
136 FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) { 135 FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) {
137 if (!m_pIface) 136 if (!m_pIface)
138 return FWL_ERR_Indefinite; 137 return FWL_ERR_Indefinite;
139 return ((IFWL_Edit*)m_pIface)->DoClipboard(iCmd); 138 return static_cast<IFWL_Edit*>(m_pIface)->DoClipboard(iCmd);
140 } 139 }
141 FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) { 140 FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) {
142 if (!m_pIface) 141 if (!m_pIface)
143 return FALSE; 142 return FALSE;
144 return ((IFWL_Edit*)m_pIface)->Redo(bsRecord); 143 return static_cast<IFWL_Edit*>(m_pIface)->Redo(bsRecord);
145 } 144 }
146 FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) { 145 FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) {
147 if (!m_pIface) 146 if (!m_pIface)
148 return FALSE; 147 return FALSE;
149 return ((IFWL_Edit*)m_pIface)->Undo(bsRecord); 148 return static_cast<IFWL_Edit*>(m_pIface)->Undo(bsRecord);
150 } 149 }
151 FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { 150 FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
152 if (!m_pIface) 151 if (!m_pIface)
153 return FWL_ERR_Indefinite; 152 return FWL_ERR_Indefinite;
154 return ((IFWL_Edit*)m_pIface)->SetTabWidth(fTabWidth, bEquidistant); 153 return static_cast<IFWL_Edit*>(m_pIface)
154 ->SetTabWidth(fTabWidth, bEquidistant);
155 } 155 }
156 FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { 156 FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
157 if (iMin > iMax) { 157 if (iMin > iMax) {
158 return FWL_ERR_Parameter_Invalid; 158 return FWL_ERR_Parameter_Invalid;
159 } 159 }
160 return ((IFWL_Edit*)m_pIface)->SetNumberRange(iMin, iMax); 160 return static_cast<IFWL_Edit*>(m_pIface)->SetNumberRange(iMin, iMax);
161 } 161 }
162 FWL_ERR CFWL_Edit::SetBackColor(FX_DWORD dwColor) { 162 FWL_ERR CFWL_Edit::SetBackColor(FX_DWORD dwColor) {
163 if (!m_pIface) 163 if (!m_pIface)
164 return FWL_ERR_Indefinite; 164 return FWL_ERR_Indefinite;
165 return ((IFWL_Edit*)m_pIface)->SetBackColor(dwColor); 165 return static_cast<IFWL_Edit*>(m_pIface)->SetBackColor(dwColor);
166 } 166 }
167 FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { 167 FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
168 if (!m_pIface) 168 if (!m_pIface)
169 return FWL_ERR_Indefinite; 169 return FWL_ERR_Indefinite;
170 return ((IFWL_Edit*)m_pIface)->SetFont(wsFont, fSize); 170 return static_cast<IFWL_Edit*>(m_pIface)->SetFont(wsFont, fSize);
171 } 171 }
172 FX_BOOL CFWL_Edit::CanUndo() { 172 FX_BOOL CFWL_Edit::CanUndo() {
173 return ((IFWL_Edit*)m_pIface)->CanUndo(); 173 return static_cast<IFWL_Edit*>(m_pIface)->CanUndo();
174 } 174 }
175 FX_BOOL CFWL_Edit::CanRedo() { 175 FX_BOOL CFWL_Edit::CanRedo() {
176 return ((IFWL_Edit*)m_pIface)->CanRedo(); 176 return static_cast<IFWL_Edit*>(m_pIface)->CanRedo();
177 } 177 }
178 FX_BOOL CFWL_Edit::Undo() { 178 FX_BOOL CFWL_Edit::Undo() {
179 return ((IFWL_Edit*)m_pIface)->Undo(); 179 return static_cast<IFWL_Edit*>(m_pIface)->Undo();
180 } 180 }
181 FX_BOOL CFWL_Edit::Redo() { 181 FX_BOOL CFWL_Edit::Redo() {
182 return ((IFWL_Edit*)m_pIface)->Undo(); 182 return static_cast<IFWL_Edit*>(m_pIface)->Undo();
183 } 183 }
184 FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) { 184 FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) {
185 return ((IFWL_Edit*)m_pIface)->Copy(wsCopy); 185 return static_cast<IFWL_Edit*>(m_pIface)->Copy(wsCopy);
186 } 186 }
187 FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) { 187 FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) {
188 return ((IFWL_Edit*)m_pIface)->Cut(wsCut); 188 return static_cast<IFWL_Edit*>(m_pIface)->Cut(wsCut);
189 } 189 }
190 FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) { 190 FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) {
191 return ((IFWL_Edit*)m_pIface)->Paste(wsPaste); 191 return static_cast<IFWL_Edit*>(m_pIface)->Paste(wsPaste);
192 } 192 }
193 FX_BOOL CFWL_Edit::Delete() { 193 FX_BOOL CFWL_Edit::Delete() {
194 return ((IFWL_Edit*)m_pIface)->Delete(); 194 return static_cast<IFWL_Edit*>(m_pIface)->Delete();
195 } 195 }
196 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { 196 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
197 return ((IFWL_Edit*)m_pIface)->SetScrollOffset(fScrollOffset); 197 return static_cast<IFWL_Edit*>(m_pIface)->SetScrollOffset(fScrollOffset);
198 } 198 }
199 FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf, 199 FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf,
200 CFX_ByteStringArray& sSuggest) { 200 CFX_ByteStringArray& sSuggest) {
201 return ((IFWL_Edit*)m_pIface)->GetSuggestWords(pointf, sSuggest); 201 return static_cast<IFWL_Edit*>(m_pIface)->GetSuggestWords(pointf, sSuggest);
202 } 202 }
203 FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, 203 FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf,
204 const CFX_ByteStringC& bsReplace) { 204 const CFX_ByteStringC& bsReplace) {
205 return ((IFWL_Edit*)m_pIface)->ReplaceSpellCheckWord(pointf, bsReplace); 205 return static_cast<IFWL_Edit*>(m_pIface)
206 ->ReplaceSpellCheckWord(pointf, bsReplace);
206 } 207 }
207 CFWL_Edit::CFWL_Edit() {} 208 CFWL_Edit::CFWL_Edit() {}
208 CFWL_Edit::~CFWL_Edit() {} 209 CFWL_Edit::~CFWL_Edit() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698