summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-05-15 07:24:43 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2013-05-15 07:31:38 +0200
commit9c3420d18173fd6c9380cf8ff7e2a4ad886e9e0b (patch)
treeff37c0623e3f828a18223f4544722fd060ce225b /svtools
parent35fdbea1a112c0f0bf8ea6e9003cf0e13b9cd886 (diff)
svtools FormattedField: don't reparse value from text after ReFormat
If our format is lossy / not a bijection (as is e.g. our default date format, because of 2-digit year), then reparsing the string that came from the format leads to data loss (the value is changed to something else). The existing code tried to do that, by calling Modify() and then setting m_bValueDirty to false. However, this fails because listeners are called while m_bValueDirty is true. If any of them calls e.g. GetValue(), the reparse happens. Change-Id: I272f377927f83c71ede1eb80eafbc689f36fb17a
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/fmtfield.cxx26
1 files changed, 19 insertions, 7 deletions
diff --git a/svtools/source/control/fmtfield.cxx b/svtools/source/control/fmtfield.cxx
index 53ccc338e2a7..7e04e8ca54ec 100644
--- a/svtools/source/control/fmtfield.cxx
+++ b/svtools/source/control/fmtfield.cxx
@@ -487,13 +487,14 @@ void FormattedField::SetAutoColor(sal_Bool _bAutomatic)
}
//------------------------------------------------------------------------------
-void FormattedField::Modify()
+void FormattedField::impl_Modify(bool makeValueDirty)
{
DBG_CHKTHIS(FormattedField, NULL);
if (!IsStrictFormat())
{
- m_bValueDirty = sal_True;
+ if(makeValueDirty)
+ m_bValueDirty = sal_True;
SpinField::Modify();
return;
}
@@ -503,7 +504,8 @@ void FormattedField::Modify()
{
m_sLastValidText = sCheck;
m_aLastSelection = GetSelection();
- m_bValueDirty = sal_True;
+ if(makeValueDirty)
+ m_bValueDirty = sal_True;
}
else
{
@@ -514,6 +516,14 @@ void FormattedField::Modify()
}
//------------------------------------------------------------------------------
+void FormattedField::Modify()
+{
+ DBG_CHKTHIS(FormattedField, NULL);
+
+ impl_Modify();
+}
+
+//------------------------------------------------------------------------------
void FormattedField::ImplSetTextImpl(const OUString& rNew, Selection* pNewSel)
{
DBG_CHKTHIS(FormattedField, NULL);
@@ -789,10 +799,12 @@ void FormattedField::Commit()
// did the text change?
if ( GetText() != sOld )
- { // consider the field as modified
- Modify();
- // but we have the most recent value now
- m_bValueDirty = sal_False;
+ { // consider the field as modified,
+ // but we already have the most recent value;
+ // don't reparse it from the text
+ // (can lead to data loss when the format is lossy,
+ // as is e.g. our default date format: 2-digit year!)
+ impl_Modify(false);
}
}