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

Side by Side Diff: xfa/fxfa/app/xfa_fftextedit.cpp

Issue 2089443002: Convert XFA_ELEMENT to an enum class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More unknown checks Created 4 years, 6 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
« no previous file with comments | « xfa/fxfa/app/xfa_ffpageview.cpp ('k') | xfa/fxfa/app/xfa_ffwidget.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 "xfa/fxfa/app/xfa_fftextedit.h" 7 #include "xfa/fxfa/app/xfa_fftextedit.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoVScroll; 68 dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoVScroll;
69 } 69 }
70 } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) { 70 } else if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) {
71 dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; 71 dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll;
72 } 72 }
73 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || 73 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
74 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { 74 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
75 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; 75 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly;
76 dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine; 76 dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine;
77 } 77 }
78 XFA_ELEMENT eType = XFA_ELEMENT_UNKNOWN; 78 XFA_Element eType = XFA_Element::Unknown;
79 int32_t iMaxChars = m_pDataAcc->GetMaxChars(eType); 79 int32_t iMaxChars = m_pDataAcc->GetMaxChars(eType);
80 if (eType == XFA_ELEMENT_ExData) { 80 if (eType == XFA_Element::ExData) {
81 iMaxChars = 0; 81 iMaxChars = 0;
82 } 82 }
83 int32_t iNumCells = m_pDataAcc->GetNumberOfCells(); 83 int32_t iNumCells = m_pDataAcc->GetNumberOfCells();
84 if (iNumCells == 0) { 84 if (iNumCells == 0) {
85 dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; 85 dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText;
86 pWidget->SetLimit(iMaxChars > 0 ? iMaxChars : 1); 86 pWidget->SetLimit(iMaxChars > 0 ? iMaxChars : 1);
87 } else if (iNumCells > 0) { 87 } else if (iNumCells > 0) {
88 dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; 88 dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText;
89 pWidget->SetLimit(iNumCells); 89 pWidget->SetLimit(iNumCells);
90 } else { 90 } else {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText); 182 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsText);
183 if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) { 183 if (m_pDataAcc->SetValue(wsText, XFA_VALUEPICTURE_Edit)) {
184 m_pDataAcc->UpdateUIDisplay(this); 184 m_pDataAcc->UpdateUIDisplay(this);
185 return TRUE; 185 return TRUE;
186 } 186 }
187 ValidateNumberField(wsText); 187 ValidateNumberField(wsText);
188 return FALSE; 188 return FALSE;
189 } 189 }
190 void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { 190 void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) {
191 CXFA_WidgetAcc* pAcc = GetDataAcc(); 191 CXFA_WidgetAcc* pAcc = GetDataAcc();
192 if (pAcc && pAcc->GetUIType() == XFA_ELEMENT_NumericEdit) { 192 if (pAcc && pAcc->GetUIType() == XFA_Element::NumericEdit) {
193 IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider(); 193 IXFA_AppProvider* pAppProvider = GetApp()->GetAppProvider();
194 if (pAppProvider) { 194 if (pAppProvider) {
195 CFX_WideString wsTitle; 195 CFX_WideString wsTitle;
196 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle); 196 pAppProvider->LoadString(XFA_IDS_AppName, wsTitle);
197 CFX_WideString wsError; 197 CFX_WideString wsError;
198 pAppProvider->LoadString(XFA_IDS_ValidateNumberError, wsError); 198 pAppProvider->LoadString(XFA_IDS_ValidateNumberError, wsError);
199 CFX_WideString wsSomField; 199 CFX_WideString wsSomField;
200 pAcc->GetNode()->GetSOMExpression(wsSomField); 200 pAcc->GetNode()->GetSOMExpression(wsSomField);
201 CFX_WideString wsMessage; 201 CFX_WideString wsMessage;
202 wsMessage.Format(wsError.c_str(), wsText.c_str(), wsSomField.c_str()); 202 wsMessage.Format(wsError.c_str(), wsText.c_str(), wsSomField.c_str());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 246 }
247 FX_BOOL CXFA_FFTextEdit::UpdateFWLData() { 247 FX_BOOL CXFA_FFTextEdit::UpdateFWLData() {
248 if (!m_pNormalWidget) { 248 if (!m_pNormalWidget) {
249 return FALSE; 249 return FALSE;
250 } 250 }
251 XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; 251 XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display;
252 if (IsFocused()) { 252 if (IsFocused()) {
253 eType = XFA_VALUEPICTURE_Edit; 253 eType = XFA_VALUEPICTURE_Edit;
254 } 254 }
255 FX_BOOL bUpdate = FALSE; 255 FX_BOOL bUpdate = FALSE;
256 if (m_pDataAcc->GetUIType() == XFA_ELEMENT_TextEdit && 256 if (m_pDataAcc->GetUIType() == XFA_Element::TextEdit &&
257 m_pDataAcc->GetNumberOfCells() < 0) { 257 m_pDataAcc->GetNumberOfCells() < 0) {
258 XFA_ELEMENT elementType = XFA_ELEMENT_UNKNOWN; 258 XFA_Element elementType = XFA_Element::Unknown;
259 int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType); 259 int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType);
260 if (elementType == XFA_ELEMENT_ExData) { 260 if (elementType == XFA_Element::ExData) {
261 iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0; 261 iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0;
262 } 262 }
263 if (((CFWL_Edit*)m_pNormalWidget)->GetLimit() != iMaxChars) { 263 if (((CFWL_Edit*)m_pNormalWidget)->GetLimit() != iMaxChars) {
264 ((CFWL_Edit*)m_pNormalWidget)->SetLimit(iMaxChars); 264 ((CFWL_Edit*)m_pNormalWidget)->SetLimit(iMaxChars);
265 bUpdate = TRUE; 265 bUpdate = TRUE;
266 } 266 }
267 } 267 }
268 if (m_pDataAcc->GetUIType() == XFA_ELEMENT_Barcode) { 268 if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) {
269 int32_t nDataLen = 0; 269 int32_t nDataLen = 0;
270 if (eType == XFA_VALUEPICTURE_Edit) 270 if (eType == XFA_VALUEPICTURE_Edit)
271 m_pDataAcc->GetBarcodeAttribute_DataLength(nDataLen); 271 m_pDataAcc->GetBarcodeAttribute_DataLength(nDataLen);
272 static_cast<CFWL_Edit*>(m_pNormalWidget)->SetLimit(nDataLen); 272 static_cast<CFWL_Edit*>(m_pNormalWidget)->SetLimit(nDataLen);
273 bUpdate = TRUE; 273 bUpdate = TRUE;
274 } 274 }
275 CFX_WideString wsText; 275 CFX_WideString wsText;
276 m_pDataAcc->GetValue(wsText, eType); 276 m_pDataAcc->GetValue(wsText, eType);
277 CFX_WideString wsOldText; 277 CFX_WideString wsOldText;
278 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText); 278 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 FX_BOOL CXFA_FFTextEdit::Delete() { 330 FX_BOOL CXFA_FFTextEdit::Delete() {
331 return ((CFWL_Edit*)m_pNormalWidget)->Delete(); 331 return ((CFWL_Edit*)m_pNormalWidget)->Delete();
332 } 332 }
333 FX_BOOL CXFA_FFTextEdit::DeSelect() { 333 FX_BOOL CXFA_FFTextEdit::DeSelect() {
334 return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections() == 334 return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections() ==
335 FWL_Error::Succeeded; 335 FWL_Error::Succeeded;
336 } 336 }
337 FX_BOOL CXFA_FFTextEdit::GetSuggestWords( 337 FX_BOOL CXFA_FFTextEdit::GetSuggestWords(
338 CFX_PointF pointf, 338 CFX_PointF pointf,
339 std::vector<CFX_ByteString>& sSuggest) { 339 std::vector<CFX_ByteString>& sSuggest) {
340 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { 340 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) {
341 return FALSE; 341 return FALSE;
342 } 342 }
343 FWLToClient(pointf.x, pointf.y); 343 FWLToClient(pointf.x, pointf.y);
344 return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest); 344 return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest);
345 } 345 }
346 FX_BOOL CXFA_FFTextEdit::ReplaceSpellCheckWord( 346 FX_BOOL CXFA_FFTextEdit::ReplaceSpellCheckWord(
347 CFX_PointF pointf, 347 CFX_PointF pointf,
348 const CFX_ByteStringC& bsReplace) { 348 const CFX_ByteStringC& bsReplace) {
349 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { 349 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) {
350 return FALSE; 350 return FALSE;
351 } 351 }
352 FWLToClient(pointf.x, pointf.y); 352 FWLToClient(pointf.x, pointf.y);
353 return ((CFWL_Edit*)m_pNormalWidget) 353 return ((CFWL_Edit*)m_pNormalWidget)
354 ->ReplaceSpellCheckWord(pointf, bsReplace); 354 ->ReplaceSpellCheckWord(pointf, bsReplace);
355 } 355 }
356 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, 356 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget,
357 const CFX_WideString& wsChanged, 357 const CFX_WideString& wsChanged,
358 const CFX_WideString& wsPrevText) { 358 const CFX_WideString& wsPrevText) {
359 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; 359 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged;
360 CXFA_EventParam eParam; 360 CXFA_EventParam eParam;
361 eParam.m_eType = XFA_EVENT_Change; 361 eParam.m_eType = XFA_EVENT_Change;
362 eParam.m_wsChange = wsChanged; 362 eParam.m_wsChange = wsChanged;
363 eParam.m_pTarget = m_pDataAcc; 363 eParam.m_pTarget = m_pDataAcc;
364 eParam.m_wsPrevText = wsPrevText; 364 eParam.m_wsPrevText = wsPrevText;
365 CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget); 365 CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget);
366 if (m_pDataAcc->GetUIType() == XFA_ELEMENT_DateTimeEdit) { 366 if (m_pDataAcc->GetUIType() == XFA_Element::DateTimeEdit) {
367 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit; 367 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)pEdit;
368 pDateTime->GetEditText(eParam.m_wsNewText); 368 pDateTime->GetEditText(eParam.m_wsNewText);
369 int32_t iSels = pDateTime->CountSelRanges(); 369 int32_t iSels = pDateTime->CountSelRanges();
370 if (iSels) { 370 if (iSels) {
371 eParam.m_iSelEnd = pDateTime->GetSelRange(0, eParam.m_iSelStart); 371 eParam.m_iSelEnd = pDateTime->GetSelRange(0, eParam.m_iSelStart);
372 } 372 }
373 } else { 373 } else {
374 pEdit->GetText(eParam.m_wsNewText); 374 pEdit->GetText(eParam.m_wsNewText);
375 int32_t iSels = pEdit->CountSelRanges(); 375 int32_t iSels = pEdit->CountSelRanges();
376 if (iSels) { 376 if (iSels) {
377 eParam.m_iSelEnd = pEdit->GetSelRange(0, eParam.m_iSelStart); 377 eParam.m_iSelEnd = pEdit->GetSelRange(0, eParam.m_iSelStart);
378 } 378 }
379 } 379 }
380 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); 380 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam);
381 } 381 }
382 void CXFA_FFTextEdit::OnTextFull(IFWL_Widget* pWidget) { 382 void CXFA_FFTextEdit::OnTextFull(IFWL_Widget* pWidget) {
383 CXFA_EventParam eParam; 383 CXFA_EventParam eParam;
384 eParam.m_eType = XFA_EVENT_Full; 384 eParam.m_eType = XFA_EVENT_Full;
385 eParam.m_pTarget = m_pDataAcc; 385 eParam.m_pTarget = m_pDataAcc;
386 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam); 386 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Full, &eParam);
387 } 387 }
388 388
389 FX_BOOL CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) { 389 FX_BOOL CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) {
390 if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { 390 if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit) {
391 return TRUE; 391 return TRUE;
392 } 392 }
393 return GetDoc()->GetDocProvider()->CheckWord(GetDoc(), sWord); 393 return GetDoc()->GetDocProvider()->CheckWord(GetDoc(), sWord);
394 } 394 }
395 FX_BOOL CXFA_FFTextEdit::GetSuggestWords( 395 FX_BOOL CXFA_FFTextEdit::GetSuggestWords(
396 const CFX_ByteStringC& sWord, 396 const CFX_ByteStringC& sWord,
397 std::vector<CFX_ByteString>& sSuggest) { 397 std::vector<CFX_ByteString>& sSuggest) {
398 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { 398 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) {
399 return FALSE; 399 return FALSE;
400 } 400 }
401 return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest); 401 return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest);
402 } 402 }
403 403
404 void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { 404 void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) {
405 m_pOldDelegate->OnProcessMessage(pMessage); 405 m_pOldDelegate->OnProcessMessage(pMessage);
406 } 406 }
407 407
408 void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { 408 void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); 593 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget();
594 CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); 594 CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
595 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); 595 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
596 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); 596 m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
597 m_pNormalWidget->LockUpdate(); 597 m_pNormalWidget->LockUpdate();
598 CFX_WideString wsText; 598 CFX_WideString wsText;
599 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); 599 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display);
600 pWidget->SetEditText(wsText); 600 pWidget->SetEditText(wsText);
601 if (CXFA_Value value = m_pDataAcc->GetFormValue()) { 601 if (CXFA_Value value = m_pDataAcc->GetFormValue()) {
602 switch (value.GetChildValueClassID()) { 602 switch (value.GetChildValueClassID()) {
603 case XFA_ELEMENT_Date: { 603 case XFA_Element::Date: {
604 if (!wsText.IsEmpty()) { 604 if (!wsText.IsEmpty()) {
605 CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); 605 CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc);
606 CFX_Unitime date = lcValue.GetDate(); 606 CFX_Unitime date = lcValue.GetDate();
607 if ((FX_UNITIME)date != 0) { 607 if ((FX_UNITIME)date != 0) {
608 pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); 608 pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay());
609 } 609 }
610 } 610 }
611 } break; 611 } break;
612 default: 612 default:
613 break; 613 break;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 792
793 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { 793 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) {
794 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { 794 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) {
795 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; 795 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent;
796 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, 796 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth,
797 event->iDay); 797 event->iDay);
798 return; 798 return;
799 } 799 }
800 CXFA_FFTextEdit::OnProcessEvent(pEvent); 800 CXFA_FFTextEdit::OnProcessEvent(pEvent);
801 } 801 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffpageview.cpp ('k') | xfa/fxfa/app/xfa_ffwidget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698