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

Side by Side Diff: fpdfsdk/formfiller/cffl_textfield.cpp

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. 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 | « fpdfsdk/formfiller/cffl_textfield.h ('k') | fpdfsdk/fpdf_dataavail.cpp » ('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 "fpdfsdk/formfiller/cffl_textfield.h" 7 #include "fpdfsdk/formfiller/cffl_textfield.h"
8 8
9 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" 9 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
10 #include "fpdfsdk/cpdfsdk_widget.h" 10 #include "fpdfsdk/cpdfsdk_widget.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 pWnd->SetAlignFormatV(PEAV_CENTER); 98 pWnd->SetAlignFormatV(PEAV_CENTER);
99 } else { 99 } else {
100 pWnd->SetLimitChar(nMaxLen); 100 pWnd->SetLimitChar(nMaxLen);
101 } 101 }
102 } 102 }
103 103
104 pWnd->SetText(swValue); 104 pWnd->SetText(swValue);
105 return pWnd; 105 return pWnd;
106 } 106 }
107 107
108 FX_BOOL CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot, 108 bool CFFL_TextField::OnChar(CPDFSDK_Annot* pAnnot,
109 uint32_t nChar, 109 uint32_t nChar,
110 uint32_t nFlags) { 110 uint32_t nFlags) {
111 switch (nChar) { 111 switch (nChar) {
112 case FWL_VKEY_Return: 112 case FWL_VKEY_Return:
113 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE)) { 113 if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE)) {
114 CPDFSDK_PageView* pPageView = GetCurPageView(true); 114 CPDFSDK_PageView* pPageView = GetCurPageView(true);
115 ASSERT(pPageView); 115 ASSERT(pPageView);
116 m_bValid = !m_bValid; 116 m_bValid = !m_bValid;
117 CFX_FloatRect rcAnnot = pAnnot->GetRect(); 117 CFX_FloatRect rcAnnot = pAnnot->GetRect();
118 m_pFormFillEnv->Invalidate(pAnnot->GetUnderlyingPage(), rcAnnot.left, 118 m_pFormFillEnv->Invalidate(pAnnot->GetUnderlyingPage(), rcAnnot.left,
119 rcAnnot.top, rcAnnot.right, rcAnnot.bottom); 119 rcAnnot.top, rcAnnot.right, rcAnnot.bottom);
120 120
121 if (m_bValid) { 121 if (m_bValid) {
122 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) 122 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true))
123 pWnd->SetFocus(); 123 pWnd->SetFocus();
124 } else { 124 } else {
125 if (CommitData(pPageView, nFlags)) { 125 if (CommitData(pPageView, nFlags)) {
126 DestroyPDFWindow(pPageView); 126 DestroyPDFWindow(pPageView);
127 return TRUE; 127 return true;
128 } 128 }
129 return FALSE; 129 return false;
130 } 130 }
131 } 131 }
132 break; 132 break;
133 case FWL_VKEY_Escape: { 133 case FWL_VKEY_Escape: {
134 CPDFSDK_PageView* pPageView = GetCurPageView(true); 134 CPDFSDK_PageView* pPageView = GetCurPageView(true);
135 ASSERT(pPageView); 135 ASSERT(pPageView);
136 EscapeFiller(pPageView, TRUE); 136 EscapeFiller(pPageView, true);
137 return TRUE; 137 return true;
138 } 138 }
139 } 139 }
140 140
141 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); 141 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
142 } 142 }
143 143
144 FX_BOOL CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView) { 144 bool CFFL_TextField::IsDataChanged(CPDFSDK_PageView* pPageView) {
145 if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) 145 if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, false))
146 return pEdit->GetText() != m_pWidget->GetValue(); 146 return pEdit->GetText() != m_pWidget->GetValue();
147 147
148 return FALSE; 148 return false;
149 } 149 }
150 150
151 void CFFL_TextField::SaveData(CPDFSDK_PageView* pPageView) { 151 void CFFL_TextField::SaveData(CPDFSDK_PageView* pPageView) {
152 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { 152 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, false)) {
153 CFX_WideString sOldValue = m_pWidget->GetValue(); 153 CFX_WideString sOldValue = m_pWidget->GetValue();
154 CFX_WideString sNewValue = pWnd->GetText(); 154 CFX_WideString sNewValue = pWnd->GetText();
155 155
156 m_pWidget->SetValue(sNewValue, FALSE); 156 m_pWidget->SetValue(sNewValue, false);
157 m_pWidget->ResetFieldAppearance(TRUE); 157 m_pWidget->ResetFieldAppearance(true);
158 m_pWidget->UpdateField(); 158 m_pWidget->UpdateField();
159 SetChangeMark(); 159 SetChangeMark();
160 } 160 }
161 } 161 }
162 162
163 void CFFL_TextField::GetActionData(CPDFSDK_PageView* pPageView, 163 void CFFL_TextField::GetActionData(CPDFSDK_PageView* pPageView,
164 CPDF_AAction::AActionType type, 164 CPDF_AAction::AActionType type,
165 PDFSDK_FieldAction& fa) { 165 PDFSDK_FieldAction& fa) {
166 switch (type) { 166 switch (type) {
167 case CPDF_AAction::KeyStroke: 167 case CPDF_AAction::KeyStroke:
168 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { 168 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, false)) {
169 fa.bFieldFull = pWnd->IsTextFull(); 169 fa.bFieldFull = pWnd->IsTextFull();
170 170
171 fa.sValue = pWnd->GetText(); 171 fa.sValue = pWnd->GetText();
172 172
173 if (fa.bFieldFull) { 173 if (fa.bFieldFull) {
174 fa.sChange = L""; 174 fa.sChange = L"";
175 fa.sChangeEx = L""; 175 fa.sChangeEx = L"";
176 } 176 }
177 } 177 }
178 break; 178 break;
179 case CPDF_AAction::Validate: 179 case CPDF_AAction::Validate:
180 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { 180 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, false)) {
181 fa.sValue = pWnd->GetText(); 181 fa.sValue = pWnd->GetText();
182 } 182 }
183 break; 183 break;
184 case CPDF_AAction::LoseFocus: 184 case CPDF_AAction::LoseFocus:
185 case CPDF_AAction::GetFocus: 185 case CPDF_AAction::GetFocus:
186 fa.sValue = m_pWidget->GetValue(); 186 fa.sValue = m_pWidget->GetValue();
187 break; 187 break;
188 default: 188 default:
189 break; 189 break;
190 } 190 }
191 } 191 }
192 192
193 void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView, 193 void CFFL_TextField::SetActionData(CPDFSDK_PageView* pPageView,
194 CPDF_AAction::AActionType type, 194 CPDF_AAction::AActionType type,
195 const PDFSDK_FieldAction& fa) { 195 const PDFSDK_FieldAction& fa) {
196 switch (type) { 196 switch (type) {
197 case CPDF_AAction::KeyStroke: 197 case CPDF_AAction::KeyStroke:
198 if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { 198 if (CPWL_Edit* pEdit = (CPWL_Edit*)GetPDFWindow(pPageView, false)) {
199 pEdit->SetFocus(); 199 pEdit->SetFocus();
200 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); 200 pEdit->SetSel(fa.nSelStart, fa.nSelEnd);
201 pEdit->ReplaceSel(fa.sChange); 201 pEdit->ReplaceSel(fa.sChange);
202 } 202 }
203 break; 203 break;
204 default: 204 default:
205 break; 205 break;
206 } 206 }
207 } 207 }
208 208
209 FX_BOOL CFFL_TextField::IsActionDataChanged(CPDF_AAction::AActionType type, 209 bool CFFL_TextField::IsActionDataChanged(CPDF_AAction::AActionType type,
210 const PDFSDK_FieldAction& faOld, 210 const PDFSDK_FieldAction& faOld,
211 const PDFSDK_FieldAction& faNew) { 211 const PDFSDK_FieldAction& faNew) {
212 switch (type) { 212 switch (type) {
213 case CPDF_AAction::KeyStroke: 213 case CPDF_AAction::KeyStroke:
214 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) || 214 return (!faOld.bFieldFull && faOld.nSelEnd != faNew.nSelEnd) ||
215 faOld.nSelStart != faNew.nSelStart || 215 faOld.nSelStart != faNew.nSelStart ||
216 faOld.sChange != faNew.sChange; 216 faOld.sChange != faNew.sChange;
217 default: 217 default:
218 break; 218 break;
219 } 219 }
220 220
221 return FALSE; 221 return false;
222 } 222 }
223 223
224 void CFFL_TextField::SaveState(CPDFSDK_PageView* pPageView) { 224 void CFFL_TextField::SaveState(CPDFSDK_PageView* pPageView) {
225 ASSERT(pPageView); 225 ASSERT(pPageView);
226 226
227 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { 227 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, false)) {
228 pWnd->GetSel(m_State.nStart, m_State.nEnd); 228 pWnd->GetSel(m_State.nStart, m_State.nEnd);
229 m_State.sValue = pWnd->GetText(); 229 m_State.sValue = pWnd->GetText();
230 } 230 }
231 } 231 }
232 232
233 void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView) { 233 void CFFL_TextField::RestoreState(CPDFSDK_PageView* pPageView) {
234 ASSERT(pPageView); 234 ASSERT(pPageView);
235 235
236 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, TRUE)) { 236 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, true)) {
237 pWnd->SetText(m_State.sValue); 237 pWnd->SetText(m_State.sValue);
238 pWnd->SetSel(m_State.nStart, m_State.nEnd); 238 pWnd->SetSel(m_State.nStart, m_State.nEnd);
239 } 239 }
240 } 240 }
241 241
242 CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView, 242 CPWL_Wnd* CFFL_TextField::ResetPDFWindow(CPDFSDK_PageView* pPageView,
243 FX_BOOL bRestoreValue) { 243 bool bRestoreValue) {
244 if (bRestoreValue) 244 if (bRestoreValue)
245 SaveState(pPageView); 245 SaveState(pPageView);
246 246
247 DestroyPDFWindow(pPageView); 247 DestroyPDFWindow(pPageView);
248 248
249 CPWL_Wnd* pRet = nullptr; 249 CPWL_Wnd* pRet = nullptr;
250 250
251 if (bRestoreValue) { 251 if (bRestoreValue) {
252 RestoreState(pPageView); 252 RestoreState(pPageView);
253 pRet = GetPDFWindow(pPageView, FALSE); 253 pRet = GetPDFWindow(pPageView, false);
254 } else { 254 } else {
255 pRet = GetPDFWindow(pPageView, TRUE); 255 pRet = GetPDFWindow(pPageView, true);
256 } 256 }
257 257
258 m_pWidget->UpdateField(); 258 m_pWidget->UpdateField();
259 259
260 return pRet; 260 return pRet;
261 } 261 }
262 262
263 #ifdef PDF_ENABLE_XFA 263 #ifdef PDF_ENABLE_XFA
264 FX_BOOL CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) { 264 bool CFFL_TextField::IsFieldFull(CPDFSDK_PageView* pPageView) {
265 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, FALSE)) { 265 if (CPWL_Edit* pWnd = (CPWL_Edit*)GetPDFWindow(pPageView, false)) {
266 return pWnd->IsTextFull(); 266 return pWnd->IsTextFull();
267 } 267 }
268 268
269 return FALSE; 269 return false;
270 } 270 }
271 #endif // PDF_ENABLE_XFA 271 #endif // PDF_ENABLE_XFA
272 272
273 void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) { 273 void CFFL_TextField::OnSetFocus(CPWL_Wnd* pWnd) {
274 ASSERT(m_pFormFillEnv); 274 ASSERT(m_pFormFillEnv);
275 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) { 275 if (pWnd->GetClassName() == PWL_CLASSNAME_EDIT) {
276 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; 276 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd;
277 pEdit->SetCharSet(FXFONT_GB2312_CHARSET); 277 pEdit->SetCharSet(FXFONT_GB2312_CHARSET);
278 pEdit->SetCodePage(936); 278 pEdit->SetCodePage(936);
279 279
280 pEdit->SetReadyToInput(); 280 pEdit->SetReadyToInput();
281 CFX_WideString wsText = pEdit->GetText(); 281 CFX_WideString wsText = pEdit->GetText();
282 int nCharacters = wsText.GetLength(); 282 int nCharacters = wsText.GetLength();
283 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode(); 283 CFX_ByteString bsUTFText = wsText.UTF16LE_Encode();
284 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str(); 284 unsigned short* pBuffer = (unsigned short*)bsUTFText.c_str();
285 m_pFormFillEnv->OnSetFieldInputFocus(pBuffer, nCharacters, TRUE); 285 m_pFormFillEnv->OnSetFieldInputFocus(pBuffer, nCharacters, true);
286 } 286 }
287 } 287 }
OLDNEW
« no previous file with comments | « fpdfsdk/formfiller/cffl_textfield.h ('k') | fpdfsdk/fpdf_dataavail.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698