summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-25 16:18:40 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-25 16:18:40 +0000
commitcbf1550e48e300142a53f635daba3c1d8910add9 (patch)
tree71dca5ce8b3b5ac8a9f8ed6930601f3f0a272e0b /xfa/fxfa
parent4ba76201df61467928bba429ea1d8115e292072e (diff)
downloadpdfium-cbf1550e48e300142a53f635daba3c1d8910add9.tar.xz
[xfa] Generate CXFA_EventParam.newText dynamically
When an xfa.event is sent it is possible to change the selStart, selEnd and change values of the event. This should cause the value of newText to be changed as needed. This CL removes m_wsNewText from CXFA_EventParam and instead generates the new text based on the previous text, the selection and the change. Bug: 1066 Change-Id: I35d126fad9771c8980654a8af64d2b98989bff3f Reviewed-on: https://pdfium-review.googlesource.com/32970 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_eventparam.cpp6
-rw-r--r--xfa/fxfa/cxfa_eventparam.h3
-rw-r--r--xfa/fxfa/cxfa_ffcheckbutton.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffcombobox.cpp2
-rw-r--r--xfa/fxfa/cxfa_ffdatetimeedit.cpp2
-rw-r--r--xfa/fxfa/cxfa_fflistbox.cpp7
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp2
7 files changed, 10 insertions, 14 deletions
diff --git a/xfa/fxfa/cxfa_eventparam.cpp b/xfa/fxfa/cxfa_eventparam.cpp
index bd6742f4dd..4e3cae9d1d 100644
--- a/xfa/fxfa/cxfa_eventparam.cpp
+++ b/xfa/fxfa/cxfa_eventparam.cpp
@@ -33,7 +33,6 @@ void CXFA_EventParam::Reset() {
m_bKeyDown = false;
m_bModifier = false;
m_wsNewContentType.clear();
- m_wsNewText.clear();
m_wsPrevContentType.clear();
m_wsPrevText.clear();
m_bReenter = false;
@@ -44,3 +43,8 @@ void CXFA_EventParam::Reset() {
m_wsSoapFaultString.clear();
m_bIsFormReady = false;
}
+
+WideString CXFA_EventParam::GetNewText() const {
+ return m_wsPrevText.Left(m_iSelStart) + m_wsChange +
+ m_wsPrevText.Right(m_wsPrevText.GetLength() - m_iSelEnd);
+}
diff --git a/xfa/fxfa/cxfa_eventparam.h b/xfa/fxfa/cxfa_eventparam.h
index 210eeb515a..3fc5780008 100644
--- a/xfa/fxfa/cxfa_eventparam.h
+++ b/xfa/fxfa/cxfa_eventparam.h
@@ -67,12 +67,13 @@ class CXFA_EventParam {
WideString m_wsChange;
WideString m_wsFullText;
WideString m_wsNewContentType;
- WideString m_wsNewText;
WideString m_wsPrevContentType;
WideString m_wsPrevText;
WideString m_wsSoapFaultCode;
WideString m_wsSoapFaultString;
bool m_bIsFormReady;
+
+ WideString GetNewText() const;
};
#endif // XFA_FXFA_CXFA_EVENTPARAM_H_
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp
index c78fa1336d..289821f304 100644
--- a/xfa/fxfa/cxfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp
@@ -306,7 +306,7 @@ void CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) {
case CFWL_Event::Type::CheckStateChanged: {
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_Change;
- eParam.m_wsNewText = m_pNode->GetValue(XFA_VALUEPICTURE_Raw);
+ eParam.m_wsPrevText = m_pNode->GetValue(XFA_VALUEPICTURE_Raw);
CXFA_Node* exclNode = m_pNode->GetExclGroupIfExists();
if (ProcessCommittedData()) {
diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp
index e4de85c517..a150101efb 100644
--- a/xfa/fxfa/cxfa_ffcombobox.cpp
+++ b/xfa/fxfa/cxfa_ffcombobox.cpp
@@ -127,7 +127,7 @@ bool CXFA_FFComboBox::IsDataChanged() {
void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) {
pParam->m_eType = XFA_EVENT_Change;
pParam->m_pTarget = m_pNode.Get();
- pParam->m_wsNewText = ToComboBox(m_pNormalWidget.get())->GetEditText();
+ pParam->m_wsPrevText = ToComboBox(m_pNormalWidget.get())->GetEditText();
m_pNode->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, pParam);
}
diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
index 632924f1ab..f5531ffd66 100644
--- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp
+++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp
@@ -197,7 +197,7 @@ void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget,
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_Change;
eParam.m_pTarget = m_pNode.Get();
- eParam.m_wsNewText = m_pNode->GetValue(XFA_VALUEPICTURE_Raw);
+ eParam.m_wsPrevText = m_pNode->GetValue(XFA_VALUEPICTURE_Raw);
m_pNode->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, &eParam);
}
diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp
index 50f9d4a772..583efacdea 100644
--- a/xfa/fxfa/cxfa_fflistbox.cpp
+++ b/xfa/fxfa/cxfa_fflistbox.cpp
@@ -153,13 +153,6 @@ void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget) {
eParam.m_eType = XFA_EVENT_Change;
eParam.m_pTarget = m_pNode.Get();
eParam.m_wsPrevText = m_pNode->GetValue(XFA_VALUEPICTURE_Raw);
-
- auto* pListBox = ToListBox(m_pNormalWidget.get());
- int32_t iSels = pListBox->CountSelItems();
- if (iSels > 0) {
- CFWL_ListItem* item = pListBox->GetSelItem(0);
- eParam.m_wsNewText = item ? item->GetText() : L"";
- }
m_pNode->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, &eParam);
}
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index 520ed31ec5..02787d579b 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -307,7 +307,6 @@ void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget,
eParam.m_wsPrevText = wsPrevText;
if (m_pNode->GetFFWidgetType() == XFA_FFWidgetType::kDateTimeEdit) {
auto* pDateTime = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get());
- eParam.m_wsNewText = pDateTime->GetEditText();
if (pDateTime->HasSelection()) {
size_t count;
std::tie(eParam.m_iSelStart, count) = pDateTime->GetSelection();
@@ -315,7 +314,6 @@ void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget,
}
} else {
CFWL_Edit* pEdit = ToEdit(m_pNormalWidget.get());
- eParam.m_wsNewText = pEdit->GetText();
if (pEdit->HasSelection())
std::tie(eParam.m_iSelStart, eParam.m_iSelEnd) = pEdit->GetSelection();
}