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

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

Issue 2491103002: IFWL method and param cleanup (Closed)
Patch Set: Review feedback 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/fxfa/app/xfa_fftextedit.h ('k') | no next file » | 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText); 282 ((CFWL_Edit*)m_pNormalWidget)->GetText(wsOldText);
283 if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) { 283 if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) {
284 ((CFWL_Edit*)m_pNormalWidget)->SetText(wsText); 284 ((CFWL_Edit*)m_pNormalWidget)->SetText(wsText);
285 bUpdate = true; 285 bUpdate = true;
286 } 286 }
287 if (bUpdate) { 287 if (bUpdate) {
288 m_pNormalWidget->Update(); 288 m_pNormalWidget->Update();
289 } 289 }
290 return true; 290 return true;
291 } 291 }
292 bool CXFA_FFTextEdit::CanUndo() {
293 return ((CFWL_Edit*)m_pNormalWidget)->CanUndo();
294 }
295 bool CXFA_FFTextEdit::CanRedo() {
296 return ((CFWL_Edit*)m_pNormalWidget)->CanRedo();
297 }
298 bool CXFA_FFTextEdit::Undo() {
299 return ((CFWL_Edit*)m_pNormalWidget)->Undo();
300 }
301 bool CXFA_FFTextEdit::Redo() {
302 return ((CFWL_Edit*)m_pNormalWidget)->Redo();
303 }
304 bool CXFA_FFTextEdit::CanCopy() {
305 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges();
306 return nCount > 0;
307 }
308 bool CXFA_FFTextEdit::CanCut() {
309 if (m_pNormalWidget->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly) {
310 return false;
311 }
312 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->CountSelRanges();
313 return nCount > 0;
314 }
315 bool CXFA_FFTextEdit::CanPaste() {
316 return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open;
317 }
318 bool CXFA_FFTextEdit::CanSelectAll() {
319 return ((CFWL_Edit*)m_pNormalWidget)->GetTextLength() > 0;
320 }
321 bool CXFA_FFTextEdit::Copy(CFX_WideString& wsCopy) {
322 return ((CFWL_Edit*)m_pNormalWidget)->Copy(wsCopy);
323 }
324 bool CXFA_FFTextEdit::Cut(CFX_WideString& wsCut) {
325 return ((CFWL_Edit*)m_pNormalWidget)->Cut(wsCut);
326 }
327 bool CXFA_FFTextEdit::Paste(const CFX_WideString& wsPaste) {
328 return ((CFWL_Edit*)m_pNormalWidget)->Paste(wsPaste);
329 }
330 bool CXFA_FFTextEdit::SelectAll() {
331 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->GetTextLength();
332 return ((CFWL_Edit*)m_pNormalWidget)->AddSelRange(0, nCount) >= 0;
333 }
334 bool CXFA_FFTextEdit::Delete() {
335 return ((CFWL_Edit*)m_pNormalWidget)->Delete();
336 }
337 bool CXFA_FFTextEdit::DeSelect() {
338 return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections() ==
339 FWL_Error::Succeeded;
340 }
341 bool CXFA_FFTextEdit::GetSuggestWords(CFX_PointF pointf,
342 std::vector<CFX_ByteString>& sSuggest) {
343 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) {
344 return false;
345 }
346 FWLToClient(pointf.x, pointf.y);
347 return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest);
348 }
349 bool CXFA_FFTextEdit::ReplaceSpellCheckWord(CFX_PointF pointf,
350 const CFX_ByteStringC& bsReplace) {
351 if (m_pDataAcc->GetUIType() != XFA_Element::TextEdit) {
352 return false;
353 }
354 FWLToClient(pointf.x, pointf.y);
355 return ((CFWL_Edit*)m_pNormalWidget)
356 ->ReplaceSpellCheckWord(pointf, bsReplace);
357 }
358 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, 292 void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget,
359 const CFX_WideString& wsChanged, 293 const CFX_WideString& wsChanged,
360 const CFX_WideString& wsPrevText) { 294 const CFX_WideString& wsPrevText) {
361 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; 295 m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged;
362 CXFA_EventParam eParam; 296 CXFA_EventParam eParam;
363 eParam.m_eType = XFA_EVENT_Change; 297 eParam.m_eType = XFA_EVENT_Change;
364 eParam.m_wsChange = wsChanged; 298 eParam.m_wsChange = wsChanged;
365 eParam.m_pTarget = m_pDataAcc; 299 eParam.m_pTarget = m_pDataAcc;
366 eParam.m_wsPrevText = wsPrevText; 300 eParam.m_wsPrevText = wsPrevText;
367 CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget); 301 CFWL_Edit* pEdit = ((CFWL_Edit*)m_pNormalWidget);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 case CFWL_EventType::TextFull: { 344 case CFWL_EventType::TextFull: {
411 OnTextFull(m_pNormalWidget->GetWidget()); 345 OnTextFull(m_pNormalWidget->GetWidget());
412 break; 346 break;
413 } 347 }
414 case CFWL_EventType::CheckWord: { 348 case CFWL_EventType::CheckWord: {
415 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); 349 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged");
416 CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; 350 CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent;
417 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); 351 event->bCheckWord = CheckWord(event->bsWord.AsStringC());
418 break; 352 break;
419 } 353 }
420 case CFWL_EventType::GetSuggestedWords: {
421 CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent;
422 event->bSuggestWords = false;
423 break;
424 }
425 default: 354 default:
426 break; 355 break;
427 } 356 }
428 m_pOldDelegate->OnProcessEvent(pEvent); 357 m_pOldDelegate->OnProcessEvent(pEvent);
429 } 358 }
430 359
431 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, 360 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics,
432 const CFX_Matrix* pMatrix) { 361 const CFX_Matrix* pMatrix) {
433 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); 362 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
434 } 363 }
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 bool CXFA_FFDateTimeEdit::IsDataChanged() { 648 bool CXFA_FFDateTimeEdit::IsDataChanged() {
720 if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) { 649 if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) {
721 return true; 650 return true;
722 } 651 }
723 CFX_WideString wsText; 652 CFX_WideString wsText;
724 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText); 653 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetEditText(wsText);
725 CFX_WideString wsOldValue; 654 CFX_WideString wsOldValue;
726 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit); 655 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Edit);
727 return wsOldValue != wsText; 656 return wsOldValue != wsText;
728 } 657 }
729 bool CXFA_FFDateTimeEdit::CanUndo() { 658
730 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanUndo();
731 }
732 bool CXFA_FFDateTimeEdit::CanRedo() {
733 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanRedo();
734 }
735 bool CXFA_FFDateTimeEdit::Undo() {
736 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Undo();
737 }
738 bool CXFA_FFDateTimeEdit::Redo() {
739 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Redo();
740 }
741 bool CXFA_FFDateTimeEdit::CanCopy() {
742 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCopy();
743 }
744 bool CXFA_FFDateTimeEdit::CanCut() {
745 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) {
746 return false;
747 }
748 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanCut();
749 }
750 bool CXFA_FFDateTimeEdit::CanPaste() {
751 return m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open;
752 }
753 bool CXFA_FFDateTimeEdit::CanSelectAll() {
754 return ((CFWL_DateTimePicker*)m_pNormalWidget)->CanSelectAll();
755 }
756 bool CXFA_FFDateTimeEdit::Copy(CFX_WideString& wsCopy) {
757 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Copy(wsCopy);
758 }
759 bool CXFA_FFDateTimeEdit::Cut(CFX_WideString& wsCut) {
760 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Cut(wsCut);
761 }
762 bool CXFA_FFDateTimeEdit::Paste(const CFX_WideString& wsPaste) {
763 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Paste(wsPaste);
764 }
765 bool CXFA_FFDateTimeEdit::SelectAll() {
766 return ((CFWL_DateTimePicker*)m_pNormalWidget)->SelectAll();
767 }
768 bool CXFA_FFDateTimeEdit::Delete() {
769 return ((CFWL_DateTimePicker*)m_pNormalWidget)->Delete();
770 }
771 bool CXFA_FFDateTimeEdit::DeSelect() {
772 return ((CFWL_DateTimePicker*)m_pNormalWidget)->DeSelect();
773 }
774 void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget, 659 void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget,
775 int32_t iYear, 660 int32_t iYear,
776 int32_t iMonth, 661 int32_t iMonth,
777 int32_t iDay) { 662 int32_t iDay) {
778 CFX_WideString wsPicture; 663 CFX_WideString wsPicture;
779 m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); 664 m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit);
780 CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); 665 CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr());
781 CFX_Unitime dt; 666 CFX_Unitime dt;
782 dt.Set(iYear, iMonth, iDay); 667 dt.Set(iYear, iMonth, iDay);
783 date.SetDate(dt); 668 date.SetDate(dt);
(...skipping 13 matching lines...) Expand all
797 682
798 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { 683 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) {
799 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { 684 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) {
800 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; 685 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent;
801 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, 686 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth,
802 event->iDay); 687 event->iDay);
803 return; 688 return;
804 } 689 }
805 CXFA_FFTextEdit::OnProcessEvent(pEvent); 690 CXFA_FFTextEdit::OnProcessEvent(pEvent);
806 } 691 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_fftextedit.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698