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

Side by Side Diff: xfa/fwl/core/cfwl_edit.cpp

Issue 2467503003: Remove GetWidget() overrides (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « xfa/fwl/core/cfwl_edit.h ('k') | xfa/fwl/core/cfwl_listbox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "xfa/fwl/core/cfwl_edit.h" 7 #include "xfa/fwl/core/cfwl_edit.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 namespace {
13
14 IFWL_Edit* ToEdit(IFWL_Widget* widget) {
15 return static_cast<IFWL_Edit*>(widget);
16 }
17
18 const IFWL_Edit* ToEdit(const IFWL_Widget* widget) {
19 return static_cast<const IFWL_Edit*>(widget);
20 }
21
22 } // namespace
23
12 CFWL_Edit::CFWL_Edit(const IFWL_App* app) : CFWL_Widget(app) {} 24 CFWL_Edit::CFWL_Edit(const IFWL_App* app) : CFWL_Widget(app) {}
13 25
14 CFWL_Edit::~CFWL_Edit() {} 26 CFWL_Edit::~CFWL_Edit() {}
15 27
16 void CFWL_Edit::Initialize() { 28 void CFWL_Edit::Initialize() {
17 ASSERT(!m_pIface); 29 ASSERT(!m_pIface);
18 30
19 std::unique_ptr<IFWL_Edit> pEdit(new IFWL_Edit( 31 std::unique_ptr<IFWL_Edit> pEdit(new IFWL_Edit(
20 m_pApp, m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); 32 m_pApp, m_pProperties->MakeWidgetImpProperties(nullptr), nullptr));
21 pEdit->Initialize(); 33 pEdit->Initialize();
22 34
23 m_pIface = std::move(pEdit); 35 m_pIface = std::move(pEdit);
24 CFWL_Widget::Initialize(); 36 CFWL_Widget::Initialize();
25 } 37 }
26 38
27 IFWL_Edit* CFWL_Edit::GetWidget() {
28 return static_cast<IFWL_Edit*>(m_pIface.get());
29 }
30
31 const IFWL_Edit* CFWL_Edit::GetWidget() const {
32 return static_cast<IFWL_Edit*>(m_pIface.get());
33 }
34
35 FWL_Error CFWL_Edit::SetText(const CFX_WideString& wsText) { 39 FWL_Error CFWL_Edit::SetText(const CFX_WideString& wsText) {
36 if (!GetWidget()) 40 if (!GetWidget())
37 return FWL_Error::Indefinite; 41 return FWL_Error::Indefinite;
38 return GetWidget()->SetText(wsText); 42 return ToEdit(GetWidget())->SetText(wsText);
39 } 43 }
40 44
41 int32_t CFWL_Edit::GetTextLength() const { 45 int32_t CFWL_Edit::GetTextLength() const {
42 if (!GetWidget()) 46 if (!GetWidget())
43 return 0; 47 return 0;
44 return GetWidget()->GetTextLength(); 48 return ToEdit(GetWidget())->GetTextLength();
45 } 49 }
46 50
47 FWL_Error CFWL_Edit::GetText(CFX_WideString& wsText, 51 FWL_Error CFWL_Edit::GetText(CFX_WideString& wsText,
48 int32_t nStart, 52 int32_t nStart,
49 int32_t nCount) const { 53 int32_t nCount) const {
50 if (!GetWidget()) 54 if (!GetWidget())
51 return FWL_Error::Indefinite; 55 return FWL_Error::Indefinite;
52 return GetWidget()->GetText(wsText, nStart, nCount); 56 return ToEdit(GetWidget())->GetText(wsText, nStart, nCount);
53 } 57 }
54 58
55 FWL_Error CFWL_Edit::ClearText() { 59 FWL_Error CFWL_Edit::ClearText() {
56 if (!GetWidget()) 60 if (!GetWidget())
57 return FWL_Error::Indefinite; 61 return FWL_Error::Indefinite;
58 return GetWidget()->ClearText(); 62 return ToEdit(GetWidget())->ClearText();
59 } 63 }
60 64
61 int32_t CFWL_Edit::GetCaretPos() const { 65 int32_t CFWL_Edit::GetCaretPos() const {
62 if (!GetWidget()) 66 if (!GetWidget())
63 return -1; 67 return -1;
64 return GetWidget()->GetCaretPos(); 68 return ToEdit(GetWidget())->GetCaretPos();
65 } 69 }
66 70
67 int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { 71 int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) {
68 if (!GetWidget()) 72 if (!GetWidget())
69 return -1; 73 return -1;
70 return GetWidget()->SetCaretPos(nIndex, bBefore); 74 return ToEdit(GetWidget())->SetCaretPos(nIndex, bBefore);
71 } 75 }
72 76
73 int32_t CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { 77 int32_t CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) {
74 if (!GetWidget()) 78 if (!GetWidget())
75 return -1; 79 return -1;
76 GetWidget()->AddSelRange(nStart, nCount); 80 ToEdit(GetWidget())->AddSelRange(nStart, nCount);
77 int32_t pos = 0; 81 int32_t pos = 0;
78 int32_t sum = GetWidget()->GetTextLength(); 82 int32_t sum = ToEdit(GetWidget())->GetTextLength();
79 if (nCount == -1) { 83 if (nCount == -1) {
80 pos = sum; 84 pos = sum;
81 } else { 85 } else {
82 pos = nStart + nCount; 86 pos = nStart + nCount;
83 } 87 }
84 return GetWidget()->SetCaretPos(pos); 88 return ToEdit(GetWidget())->SetCaretPos(pos);
85 } 89 }
86 90
87 int32_t CFWL_Edit::CountSelRanges() { 91 int32_t CFWL_Edit::CountSelRanges() {
88 if (!GetWidget()) 92 if (!GetWidget())
89 return 0; 93 return 0;
90 return GetWidget()->CountSelRanges(); 94 return ToEdit(GetWidget())->CountSelRanges();
91 } 95 }
92 96
93 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { 97 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) {
94 if (!GetWidget()) 98 if (!GetWidget())
95 return 0; 99 return 0;
96 return GetWidget()->GetSelRange(nIndex, nStart); 100 return ToEdit(GetWidget())->GetSelRange(nIndex, nStart);
97 } 101 }
98 102
99 FWL_Error CFWL_Edit::ClearSelections() { 103 FWL_Error CFWL_Edit::ClearSelections() {
100 if (!GetWidget()) 104 if (!GetWidget())
101 return FWL_Error::Indefinite; 105 return FWL_Error::Indefinite;
102 return GetWidget()->ClearSelections(); 106 return ToEdit(GetWidget())->ClearSelections();
103 } 107 }
104 108
105 int32_t CFWL_Edit::GetLimit() { 109 int32_t CFWL_Edit::GetLimit() {
106 if (!GetWidget()) 110 if (!GetWidget())
107 return -1; 111 return -1;
108 return GetWidget()->GetLimit(); 112 return ToEdit(GetWidget())->GetLimit();
109 } 113 }
110 114
111 FWL_Error CFWL_Edit::SetLimit(int32_t nLimit) { 115 FWL_Error CFWL_Edit::SetLimit(int32_t nLimit) {
112 if (!GetWidget()) 116 if (!GetWidget())
113 return FWL_Error::Indefinite; 117 return FWL_Error::Indefinite;
114 return GetWidget()->SetLimit(nLimit); 118 return ToEdit(GetWidget())->SetLimit(nLimit);
115 } 119 }
116 120
117 FWL_Error CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { 121 FWL_Error CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) {
118 if (!GetWidget()) 122 if (!GetWidget())
119 return FWL_Error::Indefinite; 123 return FWL_Error::Indefinite;
120 return GetWidget()->SetAliasChar(wAlias); 124 return ToEdit(GetWidget())->SetAliasChar(wAlias);
121 } 125 }
122 126
123 FWL_Error CFWL_Edit::Insert(int32_t nStart, 127 FWL_Error CFWL_Edit::Insert(int32_t nStart,
124 const FX_WCHAR* lpText, 128 const FX_WCHAR* lpText,
125 int32_t nLen) { 129 int32_t nLen) {
126 if (!GetWidget()) 130 if (!GetWidget())
127 return FWL_Error::Indefinite; 131 return FWL_Error::Indefinite;
128 return GetWidget()->Insert(nStart, lpText, nLen); 132 return ToEdit(GetWidget())->Insert(nStart, lpText, nLen);
129 } 133 }
130 134
131 FWL_Error CFWL_Edit::DeleteSelections() { 135 FWL_Error CFWL_Edit::DeleteSelections() {
132 if (!GetWidget()) 136 if (!GetWidget())
133 return FWL_Error::Indefinite; 137 return FWL_Error::Indefinite;
134 return GetWidget()->DeleteSelections(); 138 return ToEdit(GetWidget())->DeleteSelections();
135 } 139 }
136 140
137 FWL_Error CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { 141 FWL_Error CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) {
138 if (!GetWidget()) 142 if (!GetWidget())
139 return FWL_Error::Indefinite; 143 return FWL_Error::Indefinite;
140 return GetWidget()->DeleteRange(nStart, nCount); 144 return ToEdit(GetWidget())->DeleteRange(nStart, nCount);
141 } 145 }
142 146
143 FWL_Error CFWL_Edit::Replace(int32_t nStart, 147 FWL_Error CFWL_Edit::Replace(int32_t nStart,
144 int32_t nLen, 148 int32_t nLen,
145 const CFX_WideStringC& wsReplace) { 149 const CFX_WideStringC& wsReplace) {
146 if (!GetWidget()) 150 if (!GetWidget())
147 return FWL_Error::Indefinite; 151 return FWL_Error::Indefinite;
148 return GetWidget()->Replace(nStart, nLen, wsReplace); 152 return ToEdit(GetWidget())->Replace(nStart, nLen, wsReplace);
149 } 153 }
150 154
151 FWL_Error CFWL_Edit::DoClipboard(int32_t iCmd) { 155 FWL_Error CFWL_Edit::DoClipboard(int32_t iCmd) {
152 if (!GetWidget()) 156 if (!GetWidget())
153 return FWL_Error::Indefinite; 157 return FWL_Error::Indefinite;
154 return GetWidget()->DoClipboard(iCmd); 158 return ToEdit(GetWidget())->DoClipboard(iCmd);
155 } 159 }
156 160
157 FX_BOOL CFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) { 161 FX_BOOL CFWL_Edit::Redo(const IFDE_TxtEdtDoRecord* pRecord) {
158 return GetWidget() && GetWidget()->Redo(pRecord); 162 return GetWidget() && ToEdit(GetWidget())->Redo(pRecord);
159 } 163 }
160 164
161 FX_BOOL CFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) { 165 FX_BOOL CFWL_Edit::Undo(const IFDE_TxtEdtDoRecord* pRecord) {
162 return GetWidget() && GetWidget()->Undo(pRecord); 166 return GetWidget() && ToEdit(GetWidget())->Undo(pRecord);
163 } 167 }
164 168
165 FWL_Error CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { 169 FWL_Error CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) {
166 if (!GetWidget()) 170 if (!GetWidget())
167 return FWL_Error::Indefinite; 171 return FWL_Error::Indefinite;
168 return GetWidget()->SetTabWidth(fTabWidth, bEquidistant); 172 return ToEdit(GetWidget())->SetTabWidth(fTabWidth, bEquidistant);
169 } 173 }
170 174
171 FWL_Error CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { 175 FWL_Error CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) {
172 if (iMin > iMax) { 176 if (iMin > iMax)
173 return FWL_Error::ParameterInvalid; 177 return FWL_Error::ParameterInvalid;
174 } 178 return ToEdit(GetWidget())->SetNumberRange(iMin, iMax);
175 return GetWidget()->SetNumberRange(iMin, iMax);
176 } 179 }
177 180
178 FWL_Error CFWL_Edit::SetBackColor(uint32_t dwColor) { 181 FWL_Error CFWL_Edit::SetBackColor(uint32_t dwColor) {
179 if (!GetWidget()) 182 if (!GetWidget())
180 return FWL_Error::Indefinite; 183 return FWL_Error::Indefinite;
181 return GetWidget()->SetBackgroundColor(dwColor); 184 return ToEdit(GetWidget())->SetBackgroundColor(dwColor);
182 } 185 }
183 186
184 FWL_Error CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { 187 FWL_Error CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) {
185 if (!GetWidget()) 188 if (!GetWidget())
186 return FWL_Error::Indefinite; 189 return FWL_Error::Indefinite;
187 return GetWidget()->SetFont(wsFont, fSize); 190 return ToEdit(GetWidget())->SetFont(wsFont, fSize);
188 } 191 }
189 192
190 FX_BOOL CFWL_Edit::CanUndo() { 193 FX_BOOL CFWL_Edit::CanUndo() {
191 return GetWidget()->CanUndo(); 194 return ToEdit(GetWidget())->CanUndo();
192 } 195 }
193 196
194 FX_BOOL CFWL_Edit::CanRedo() { 197 FX_BOOL CFWL_Edit::CanRedo() {
195 return GetWidget()->CanRedo(); 198 return ToEdit(GetWidget())->CanRedo();
196 } 199 }
197 200
198 FX_BOOL CFWL_Edit::Undo() { 201 FX_BOOL CFWL_Edit::Undo() {
199 return GetWidget()->Undo(); 202 return ToEdit(GetWidget())->Undo();
200 } 203 }
201 204
202 FX_BOOL CFWL_Edit::Redo() { 205 FX_BOOL CFWL_Edit::Redo() {
203 return GetWidget()->Undo(); 206 return ToEdit(GetWidget())->Undo();
204 } 207 }
205 208
206 FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) { 209 FX_BOOL CFWL_Edit::Copy(CFX_WideString& wsCopy) {
207 return GetWidget()->Copy(wsCopy); 210 return ToEdit(GetWidget())->Copy(wsCopy);
208 } 211 }
209 212
210 FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) { 213 FX_BOOL CFWL_Edit::Cut(CFX_WideString& wsCut) {
211 return GetWidget()->Cut(wsCut); 214 return ToEdit(GetWidget())->Cut(wsCut);
212 } 215 }
213 216
214 FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) { 217 FX_BOOL CFWL_Edit::Paste(const CFX_WideString& wsPaste) {
215 return GetWidget()->Paste(wsPaste); 218 return ToEdit(GetWidget())->Paste(wsPaste);
216 } 219 }
217 220
218 FX_BOOL CFWL_Edit::Delete() { 221 FX_BOOL CFWL_Edit::Delete() {
219 return GetWidget()->Delete(); 222 return ToEdit(GetWidget())->Delete();
220 } 223 }
221 224
222 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) { 225 void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
223 return GetWidget()->SetScrollOffset(fScrollOffset); 226 return ToEdit(GetWidget())->SetScrollOffset(fScrollOffset);
224 } 227 }
225 228
226 FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf, 229 FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf,
227 std::vector<CFX_ByteString>& sSuggest) { 230 std::vector<CFX_ByteString>& sSuggest) {
228 return GetWidget()->GetSuggestWords(pointf, sSuggest); 231 return ToEdit(GetWidget())->GetSuggestWords(pointf, sSuggest);
229 } 232 }
230 233
231 FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, 234 FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf,
232 const CFX_ByteStringC& bsReplace) { 235 const CFX_ByteStringC& bsReplace) {
233 return GetWidget()->ReplaceSpellCheckWord(pointf, bsReplace); 236 return ToEdit(GetWidget())->ReplaceSpellCheckWord(pointf, bsReplace);
234 } 237 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_edit.h ('k') | xfa/fwl/core/cfwl_listbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698