7#include "xfa/fxfa/cxfa_fftextedit.h"
11#include "third_party/base/check.h"
12#include "xfa/fwl/cfwl_datetimepicker.h"
13#include "xfa/fwl/cfwl_edit.h"
14#include "xfa/fwl/cfwl_eventtextwillchange.h"
15#include "xfa/fwl/cfwl_messagekillfocus.h"
16#include "xfa/fwl/cfwl_messagesetfocus.h"
17#include "xfa/fwl/cfwl_notedriver.h"
18#include "xfa/fxfa/cxfa_eventparam.h"
19#include "xfa/fxfa/cxfa_ffapp.h"
20#include "xfa/fxfa/cxfa_ffdoc.h"
21#include "xfa/fxfa/cxfa_ffdocview.h"
22#include "xfa/fxfa/parser/cxfa_barcode.h"
23#include "xfa/fxfa/parser/cxfa_node.h"
24#include "xfa/fxfa/parser/cxfa_para.h"
39 if (GetNormalWidget()) {
40 CFWL_NoteDriver* pNoteDriver =
41 GetNormalWidget()->GetFWLApp()->GetNoteDriver();
47 CXFA_FFField::Trace(visitor);
48 visitor->Trace(m_pOldDelegate);
54 CFWL_Edit* pFWLEdit = cppgc::MakeGarbageCollected<CFWL_Edit>(
55 GetFWLApp()->GetHeap()->GetAllocationHandle(), GetFWLApp(),
56 CFWL_Widget::Properties(),
nullptr);
60 CFWL_NoteDriver* pNoteDriver = pFWLEdit
->GetFWLApp()->GetNoteDriver();
62 m_pOldDelegate = pFWLEdit->GetDelegate();
68 pFWLEdit->SetText(m_pNode->GetValue(XFA_ValuePicture::kDisplay));
75 CFWL_Edit* pWidget = ToEdit(GetNormalWidget());
80 uint32_t dwExtendedStyle =
83 if (m_pNode->IsMultiLine()) {
85 if (!m_pNode->IsVerticalScrollPolicyOff()) {
89 }
else if (!m_pNode->IsHorizontalScrollPolicyOff()) {
92 if (!m_pNode->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) {
99 std::tie(eType, iMaxChars) = m_pNode->GetMaxChars();
103 absl::optional<int32_t> numCells = m_pNode->GetNumberOfCells();
104 if (!numCells.has_value()) {
106 }
else if (numCells == 0) {
111 pWidget->SetLimit(numCells.value());
115 GetNormalWidget()->ModifyStyles(dwStyle, 0xFFFFFFFF);
116 GetNormalWidget()->ModifyStyleExts(dwExtendedStyle, 0xFFFFFFFF);
121 const CFX_PointF& point,
123 if (command == CFWL_MessageMouse::MouseCommand::kRightButtonDown &&
124 !m_pNode->IsOpenAccess()) {
134 const CFX_PointF& point) {
141 CFWL_MessageMouse msg(GetNormalWidget(),
149 const CFX_PointF& point) {
156 CFWL_MessageMouse msg(
nullptr,
164 const CFX_PointF& point) {
168 GetDoc()->PopupMenu(
this, point);
182 CFWL_MessageSetFocus msg(GetNormalWidget());
188 CFWL_MessageKillFocus msg(GetNormalWidget());
205 WideString wsText = ToEdit(GetNormalWidget())->GetText();
206 if (m_pNode->SetValue(XFA_ValuePicture::kEdit, wsText)) {
207 GetDoc()->GetDocView()->UpdateUIDisplay(m_pNode.Get(),
this);
210 ValidateNumberField(wsText);
222 WideString wsSomField =
GetNode()->GetSOMExpression();
224 wsText + WideString
::FromASCII(
" can not contain ") + wsSomField
,
235 CXFA_Para* para = m_pNode->GetParaIfExists();
239 uint32_t dwExtendedStyle = 0;
269 return dwExtendedStyle;
273 CFWL_Edit* pEdit = ToEdit(GetNormalWidget());
281 bool bUpdate =
false;
282 if (m_pNode->GetFFWidgetType() == XFA_FFWidgetType::kTextEdit &&
283 !m_pNode->GetNumberOfCells().has_value()) {
286 std::tie(elementType, iMaxChars) = m_pNode->GetMaxChars();
293 }
else if (m_pNode->GetFFWidgetType() == XFA_FFWidgetType::kBarcode) {
294 int32_t nDataLen = 0;
296 nDataLen =
static_cast<CXFA_Barcode*>(m_pNode->GetUIChildNode())
304 WideString wsText = m_pNode->GetValue(eType);
311 GetNormalWidget()->Update();
317 CFWL_EventTextWillChange* event) {
323 eParam
.m_iSelStart =
static_cast<int32_t>(event->GetSelectionStart());
324 eParam
.m_iSelEnd =
static_cast<int32_t>(event->GetSelectionEnd());
325 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Change, &eParam);
331 event->SetSelectionStart(
static_cast<size_t>(eParam
.m_iSelStart));
332 event->SetSelectionEnd(
static_cast<size_t>(eParam
.m_iSelEnd));
337 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Full, &eParam);
341 m_pOldDelegate->OnProcessMessage(pMessage);
349 static_cast<CFWL_EventTextWillChange*>(pEvent)
);
357 m_pOldDelegate->OnProcessEvent(pEvent);
362 m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
366 return ToEdit(GetNormalWidget())->CanUndo();
370 return ToEdit(GetNormalWidget())->CanRedo();
374 return ToEdit(GetNormalWidget())->HasSelection();
380 return ToEdit(GetNormalWidget())->HasSelection();
384 return !(ToEdit(GetNormalWidget())->GetStyleExts() &
389 return ToEdit(GetNormalWidget())->GetTextLength() > 0;
393 return ToEdit(GetNormalWidget())->Undo();
397 return ToEdit(GetNormalWidget())->Redo();
401 return ToEdit(GetNormalWidget())->Copy();
405 return ToEdit(GetNormalWidget())->Cut();
409 return ToEdit(GetNormalWidget())->Paste(wsPaste);
413 ToEdit(GetNormalWidget())->SelectAll();
417 ToEdit(GetNormalWidget())->ClearText();
421 ToEdit(GetNormalWidget())->ClearSelection();
425 return ToEdit(GetNormalWidget())->GetText();
429 return FormFieldType::kXFA_TextField;
#define FWL_STYLEEXT_EDT_MultiLine
#define FWL_STYLEEXT_EDT_HFar
#define FWL_STYLEEXT_EDT_ShowScrollbarFocus
#define FWL_STYLEEXT_EDT_WantReturn
#define FWL_STYLEEXT_EDT_VNear
#define FWL_STYLEEXT_EDT_VCenter
#define FWL_STYLEEXT_EDT_OuterScrollbar
#define FWL_STYLEEXT_EDT_AutoHScroll
#define FWL_STYLEEXT_EDT_ReadOnly
#define FWL_STYLEEXT_EDT_VFar
#define FWL_STYLEEXT_EDT_AutoVScroll
#define FWL_STYLEEXT_EDT_HNear
#define FWL_STYLEEXT_EDT_Justified
#define FWL_STYLEEXT_EDT_CombText
#define FWL_STYLEEXT_EDT_HCenter
void SetLimit(int32_t nLimit)
WideString GetText() const
virtual void SetTextSkipNotify(const WideString &wsText)
WideString GetPreviousText() const
void SetCancelled(bool cancelled)
void SetChangeText(const WideString &change_text)
WideString GetChangeText() const
void UnregisterEventTarget(CFWL_Widget *pListener)
void RegisterEventTarget(CFWL_Widget *pListener, CFWL_Widget *pEventSource)
CXFA_EventParam(XFA_EVENTTYPE type)
virtual WideString GetAppTitle() const =0
virtual int32_t MsgBox(const WideString &wsMessage, const WideString &wsTitle, uint32_t dwIconType, uint32_t dwButtonType)=0
CXFA_FFField(CXFA_Node *pNode)
CFX_PointF FWLToClient(const CFX_PointF &point)
bool ProcessCommittedData()
bool LoadWidget() override
void SetEditScrollOffset()
bool OnRButtonUp(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
void SetNormalWidget(CFWL_Widget *widget)
bool PtInActiveRect(const CFX_PointF &point) override
void OnProcessEvent(CFWL_Event *pEvent) override
uint32_t UpdateUIProperty()
void SendMessageToFWLWidget(CFWL_Message *pMessage)
bool OnKillFocus(CXFA_FFWidget *pNewWidget) override
void OnProcessEvent(CFWL_Event *pEvent) override
void OnTextWillChange(CFWL_Widget *pWidget, CFWL_EventTextWillChange *change)
void SelectAll() override
bool OnLButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void OnProcessMessage(CFWL_Message *pMessage) override
bool CanSelectAll() override
bool OnRButtonUp(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
~CXFA_FFTextEdit() override
absl::optional< WideString > Cut() override
bool CommitData() override
bool OnSetFocus(CXFA_FFWidget *pOldWidget) override
bool AcceptsFocusOnButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point, CFWL_MessageMouse::MouseCommand command) override
bool UpdateFWLData() override
bool LoadWidget() override
bool Paste(const WideString &wsPaste) override
CXFA_FFTextEdit(CXFA_Node *pNode)
void UpdateWidgetProperty() override
absl::optional< WideString > Copy() override
void OnTextFull(CFWL_Widget *pWidget)
FormFieldType GetFormFieldType() override
bool OnRButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
bool IsDataChanged() override
WideString GetText() override
XFA_AttributeValue GetHorizontalAlign()
XFA_AttributeValue GetVerticalAlign()
bool operator!=(const WideString &other) const
static WideString FromASCII(ByteStringView str)