7#include "xfa/fxfa/cxfa_ffdatetimeedit.h"
9#include "core/fxcrt/cfx_datetime.h"
10#include "third_party/base/check.h"
11#include "xfa/fwl/cfwl_datetimepicker.h"
12#include "xfa/fwl/cfwl_eventselectchanged.h"
13#include "xfa/fwl/cfwl_notedriver.h"
14#include "xfa/fwl/cfwl_widget.h"
15#include "xfa/fxfa/cxfa_eventparam.h"
16#include "xfa/fxfa/cxfa_ffdoc.h"
17#include "xfa/fxfa/cxfa_ffdocview.h"
18#include "xfa/fxfa/parser/cxfa_localevalue.h"
19#include "xfa/fxfa/parser/cxfa_para.h"
20#include "xfa/fxfa/parser/cxfa_value.h"
21#include "xfa/fxfa/parser/xfa_utils.h"
28CFWL_DateTimePicker* CXFA_FFDateTimeEdit::GetPickerWidget() {
29 return static_cast<CFWL_DateTimePicker*>(GetNormalWidget());
39 CFWL_DateTimePicker* pPicker = GetPickerWidget();
46 CFWL_DateTimePicker* pWidget =
47 cppgc::MakeGarbageCollected<CFWL_DateTimePicker>(
48 GetFWLApp()->GetHeap()->GetAllocationHandle(), GetFWLApp());
52 CFWL_NoteDriver* pNoteDriver = pWidget
->GetFWLApp()->GetNoteDriver();
54 m_pOldDelegate = pWidget->GetDelegate();
59 WideString wsText = m_pNode->GetValue(XFA_ValuePicture::kDisplay);
62 CXFA_Value* value = m_pNode->GetFormValueIfExists();
85 CFWL_DateTimePicker* pPicker = GetPickerWidget();
91 dwExtendedStyle |= GetAlignment();
92 GetNormalWidget()->ModifyStyleExts(dwExtendedStyle, 0xFFFFFFFF);
94 uint32_t dwEditStyles = 0;
95 absl::optional<int32_t> numCells = m_pNode->GetNumberOfCells();
96 if (numCells.has_value() && numCells.value() > 0) {
98 pPicker->SetEditLimit(numCells.value());
100 if (!m_pNode->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive())
102 if (!m_pNode->IsHorizontalScrollPolicyOff())
108uint32_t CXFA_FFDateTimeEdit::GetAlignment() {
109 CXFA_Para* para = m_pNode->GetParaIfExists();
113 uint32_t dwExtendedStyle = 0;
143 return dwExtendedStyle;
147 CFWL_DateTimePicker* pPicker = GetPickerWidget();
148 if (!m_pNode->SetValue(XFA_ValuePicture::kEdit, pPicker->GetEditText()))
151 GetDoc()->GetDocView()->UpdateUIDisplay(m_pNode.Get(),
this);
156 if (!GetNormalWidget())
163 WideString wsText = m_pNode->GetValue(eType);
164 CFWL_DateTimePicker* pPicker = GetPickerWidget();
174 GetNormalWidget()->Update();
183 return m_pNode->GetValue(XFA_ValuePicture::kEdit) != wsText;
190 WideString wsPicture = m_pNode->GetPictureContent(XFA_ValuePicture::kEdit);
192 GetDoc()->GetXFADoc()->GetLocaleMgr());
196 date.FormatPatterns(wsDate, wsPicture, m_pNode->GetLocale(),
197 XFA_ValuePicture::kEdit);
199 CFWL_DateTimePicker* pPicker = GetPickerWidget();
202 GetDoc()->SetFocusWidget(
nullptr);
206 eParam.m_wsPrevText = m_pNode->GetValue(XFA_ValuePicture::kRaw);
207 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Change, &eParam);
212 auto* event =
static_cast<CFWL_EventSelectChanged*>(pEvent);
243 return GetPickerWidget()->GetEditTextLength() > 0;
247 return GetPickerWidget()->Copy();
250bool CXFA_FFDateTimeEdit::
Undo() {
254bool CXFA_FFDateTimeEdit::
Redo() {
259 return GetPickerWidget()->Cut();
262bool CXFA_FFDateTimeEdit::
Paste(
const WideString& wsPaste) {
263 return GetPickerWidget()
->Paste(wsPaste
);
#define FWL_STYLEEXT_DTP_EditVCenter
#define FWL_STYLEEXT_DTP_EditJustified
#define FWL_STYLEEXT_DTP_ShortDateFormat
#define FWL_STYLEEXT_DTP_EditHCenter
#define FWL_STYLEEXT_DTP_EditVFar
#define FWL_STYLEEXT_DTP_EditHNear
#define FWL_STYLEEXT_DTP_EditHFar
#define FWL_STYLEEXT_DTP_EditVNear
#define FWL_STYLEEXT_EDT_AutoHScroll
#define FWL_STYLEEXT_EDT_ReadOnly
#define FWL_STYLEEXT_EDT_CombText
CFX_RectF GetBBox() const
bool Paste(const WideString &wsPaste)
void SetCurSel(int32_t iYear, int32_t iMonth, int32_t iDay)
bool HasSelection() const
WideString GetEditText() const
void SetEditText(const WideString &wsText)
void ModifyEditStyleExts(uint32_t dwStyleExtsAdded, uint32_t dwStyleExtsRemoved)
void RegisterEventTarget(CFWL_Widget *pListener, CFWL_Widget *pEventSource)
CFX_DateTime(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond)
constexpr CFX_RectF()=default
bool Contains(const PointType &p) const
CXFA_EventParam(XFA_EVENTTYPE type)
bool IsDataChanged() override
bool LoadWidget() override
bool CommitData() override
bool Paste(const WideString &wsPaste) override
WideString GetText() override
CFX_RectF GetBBox(FocusOption focus) override
absl::optional< WideString > Copy() override
bool UpdateFWLData() override
bool PtInActiveRect(const CFX_PointF &point) override
void OnProcessEvent(CFWL_Event *pEvent) override
void UpdateWidgetProperty() override
CXFA_FFDateTimeEdit(CXFA_Node *pNode)
~CXFA_FFDateTimeEdit() override
void SelectAll() override
bool CanSelectAll() override
void OnSelectChanged(CFWL_Widget *pWidget, int32_t iYear, int32_t iMonth, int32_t iDay)
absl::optional< WideString > Cut() override
bool LoadWidget() override
void SetNormalWidget(CFWL_Widget *widget)
uint32_t UpdateUIProperty()
void OnProcessEvent(CFWL_Event *pEvent) override
CXFA_FFTextEdit(CXFA_Node *pNode)
bool SetDate(const CFX_DateTime &d)
CFX_DateTime GetDate() const
XFA_AttributeValue GetHorizontalAlign()
XFA_AttributeValue GetVerticalAlign()
XFA_Element GetChildValueClassID() const