OLD | NEW |
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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 return ((CFWL_Edit*)m_pNormalWidget)->Paste(wsPaste); | 325 return ((CFWL_Edit*)m_pNormalWidget)->Paste(wsPaste); |
326 } | 326 } |
327 FX_BOOL CXFA_FFTextEdit::SelectAll() { | 327 FX_BOOL CXFA_FFTextEdit::SelectAll() { |
328 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->GetTextLength(); | 328 int32_t nCount = ((CFWL_Edit*)m_pNormalWidget)->GetTextLength(); |
329 return ((CFWL_Edit*)m_pNormalWidget)->AddSelRange(0, nCount); | 329 return ((CFWL_Edit*)m_pNormalWidget)->AddSelRange(0, nCount); |
330 } | 330 } |
331 FX_BOOL CXFA_FFTextEdit::Delete() { | 331 FX_BOOL CXFA_FFTextEdit::Delete() { |
332 return ((CFWL_Edit*)m_pNormalWidget)->Delete(); | 332 return ((CFWL_Edit*)m_pNormalWidget)->Delete(); |
333 } | 333 } |
334 FX_BOOL CXFA_FFTextEdit::DeSelect() { | 334 FX_BOOL CXFA_FFTextEdit::DeSelect() { |
335 return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections(); | 335 return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections() == |
| 336 FWL_Error::Succeeded; |
336 } | 337 } |
337 FX_BOOL CXFA_FFTextEdit::GetSuggestWords( | 338 FX_BOOL CXFA_FFTextEdit::GetSuggestWords( |
338 CFX_PointF pointf, | 339 CFX_PointF pointf, |
339 std::vector<CFX_ByteString>& sSuggest) { | 340 std::vector<CFX_ByteString>& sSuggest) { |
340 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { | 341 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { |
341 return FALSE; | 342 return FALSE; |
342 } | 343 } |
343 FWLToClient(pointf.x, pointf.y); | 344 FWLToClient(pointf.x, pointf.y); |
344 return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest); | 345 return ((CFWL_Edit*)m_pNormalWidget)->GetSuggestWords(pointf, sSuggest); |
345 } | 346 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 std::vector<CFX_ByteString>& sSuggest) { | 398 std::vector<CFX_ByteString>& sSuggest) { |
398 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { | 399 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { |
399 return FALSE; | 400 return FALSE; |
400 } | 401 } |
401 return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest); | 402 return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest); |
402 } | 403 } |
403 int32_t CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { | 404 int32_t CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { |
404 return m_pOldDelegate->OnProcessMessage(pMessage); | 405 return m_pOldDelegate->OnProcessMessage(pMessage); |
405 } | 406 } |
406 | 407 |
407 FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { | 408 FWL_Error CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { |
408 CXFA_FFField::OnProcessEvent(pEvent); | 409 CXFA_FFField::OnProcessEvent(pEvent); |
409 switch (pEvent->GetClassID()) { | 410 switch (pEvent->GetClassID()) { |
410 case CFWL_EventType::TextChanged: { | 411 case CFWL_EventType::TextChanged: { |
411 CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; | 412 CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; |
412 CFX_WideString wsChange; | 413 CFX_WideString wsChange; |
413 OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); | 414 OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); |
414 break; | 415 break; |
415 } | 416 } |
416 case CFWL_EventType::TextFull: { | 417 case CFWL_EventType::TextFull: { |
417 OnTextFull(m_pNormalWidget->GetWidget()); | 418 OnTextFull(m_pNormalWidget->GetWidget()); |
(...skipping 10 matching lines...) Expand all Loading... |
428 event->bSuggestWords = GetSuggestWords(event->bsWord.AsStringC(), | 429 event->bSuggestWords = GetSuggestWords(event->bsWord.AsStringC(), |
429 event->bsArraySuggestWords); | 430 event->bsArraySuggestWords); |
430 break; | 431 break; |
431 } | 432 } |
432 default: | 433 default: |
433 break; | 434 break; |
434 } | 435 } |
435 return m_pOldDelegate->OnProcessEvent(pEvent); | 436 return m_pOldDelegate->OnProcessEvent(pEvent); |
436 } | 437 } |
437 | 438 |
438 FWL_ERR CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, | 439 FWL_Error CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, |
439 const CFX_Matrix* pMatrix) { | 440 const CFX_Matrix* pMatrix) { |
440 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 441 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
441 } | 442 } |
442 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, | 443 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, |
443 CXFA_WidgetAcc* pDataAcc) | 444 CXFA_WidgetAcc* pDataAcc) |
444 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 445 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
445 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} | 446 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} |
446 FX_BOOL CXFA_FFNumericEdit::LoadWidget() { | 447 FX_BOOL CXFA_FFNumericEdit::LoadWidget() { |
447 CFWL_Edit* pWidget = CFWL_Edit::Create(); | 448 CFWL_Edit* pWidget = CFWL_Edit::Create(); |
448 pWidget->Initialize(); | 449 pWidget->Initialize(); |
449 m_pNormalWidget = (CFWL_Widget*)pWidget; | 450 m_pNormalWidget = (CFWL_Widget*)pWidget; |
(...skipping 29 matching lines...) Expand all Loading... |
479 pWidget->SetLimit(iNumCells); | 480 pWidget->SetLimit(iNumCells); |
480 } | 481 } |
481 dwExtendedStyle |= GetAlignment(); | 482 dwExtendedStyle |= GetAlignment(); |
482 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || | 483 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || |
483 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { | 484 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { |
484 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; | 485 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; |
485 } | 486 } |
486 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 487 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
487 } | 488 } |
488 | 489 |
489 FWL_ERR CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { | 490 FWL_Error CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { |
490 if (pEvent->GetClassID() == CFWL_EventType::Validate) { | 491 if (pEvent->GetClassID() == CFWL_EventType::Validate) { |
491 CFWL_EvtEdtValidate* event = (CFWL_EvtEdtValidate*)pEvent; | 492 CFWL_EvtEdtValidate* event = (CFWL_EvtEdtValidate*)pEvent; |
492 CFX_WideString wsChange = event->wsInsert; | 493 CFX_WideString wsChange = event->wsInsert; |
493 event->bValidate = OnValidate(m_pNormalWidget->GetWidget(), wsChange); | 494 event->bValidate = OnValidate(m_pNormalWidget->GetWidget(), wsChange); |
494 return event->bValidate; | 495 return event->bValidate ? FWL_Error::Succeeded : FWL_Error::Indefinite; |
495 } | 496 } |
496 return CXFA_FFTextEdit::OnProcessEvent(pEvent); | 497 return CXFA_FFTextEdit::OnProcessEvent(pEvent); |
497 } | 498 } |
498 | 499 |
499 FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, | 500 FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, |
500 CFX_WideString& wsText) { | 501 CFX_WideString& wsText) { |
501 CFX_WideString wsPattern; | 502 CFX_WideString wsPattern; |
502 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); | 503 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); |
503 if (!wsPattern.IsEmpty()) { | 504 if (!wsPattern.IsEmpty()) { |
504 return TRUE; | 505 return TRUE; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 pDateTime->SetEditText(wsDate); | 782 pDateTime->SetEditText(wsDate); |
782 pDateTime->Update(); | 783 pDateTime->Update(); |
783 GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL); | 784 GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL); |
784 CXFA_EventParam eParam; | 785 CXFA_EventParam eParam; |
785 eParam.m_eType = XFA_EVENT_Change; | 786 eParam.m_eType = XFA_EVENT_Change; |
786 eParam.m_pTarget = m_pDataAcc; | 787 eParam.m_pTarget = m_pDataAcc; |
787 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); | 788 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); |
788 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); | 789 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |
789 } | 790 } |
790 | 791 |
791 FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { | 792 FWL_Error CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { |
792 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { | 793 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { |
793 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; | 794 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; |
794 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, | 795 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, |
795 event->iDay); | 796 event->iDay); |
796 return TRUE; | 797 return FWL_Error::Succeeded; |
797 } | 798 } |
798 return CXFA_FFTextEdit::OnProcessEvent(pEvent); | 799 return CXFA_FFTextEdit::OnProcessEvent(pEvent); |
799 } | 800 } |
OLD | NEW |