summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@erack.de>2011-08-05 16:30:19 +0200
committerEike Rathke <erack@erack.de>2011-08-05 20:05:28 +0200
commit59005c9c8e553b1458430d0a2726d966cf80a0f3 (patch)
tree4d7929f3382b2de0a2cc76068973077a825048a1
parent2cdd1d4272fb75d19c7e5e459e6b5dd8eb61297e (diff)
fdo#34977 preserve time when editing even if only date was displayed
* For date formats choose the datetime format when editing a value with a time fraction. * When editing time formats choose the time format only if 0>=value<1, choose the duration format when editing a value that may represent a duration, i.e. is <0 or >=1, and absolute value is less than 32k hours. If greater than 32k hours choose the datetime format.
-rw-r--r--svl/source/numbers/zforlist.cxx26
1 files changed, 24 insertions, 2 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 59bbe8737a..1772a58668 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1525,9 +1525,31 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
}
sal_uInt32 nKey = nFIndex;
switch ( eType )
- { // #61619# immer vierstelliges Jahr editieren
+ { // #61619# always edit using 4-digit year
case NUMBERFORMAT_DATE :
- nKey = GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
+ if (::rtl::math::approxFloor( fOutNumber) != fOutNumber)
+ nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
+ // fdo#34977 preserve time when editing even if only date was
+ // displayed.
+ else
+ nKey = GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
+ break;
+ case NUMBERFORMAT_TIME :
+ if (fOutNumber < 0.0 || fOutNumber >= 1.0)
+ {
+ /* XXX NOTE: this is a purely arbitrary value within the limits
+ * of a signed 16-bit. 32k hours are 3.7 years ... or
+ * 1903-09-26 if date. */
+ if (fabs( fOutNumber) * 24 < 0x7fff)
+ nKey = GetFormatIndex( NF_TIME_HH_MMSS, eLang );
+ // Preserve duration, use [HH]:MM:SS instead of time.
+ else
+ nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
+ // Assume that a large value is a datetime with only time
+ // displayed.
+ }
+ else
+ nKey = GetStandardFormat( fOutNumber, nFIndex, eType, eLang );
break;
case NUMBERFORMAT_DATETIME :
nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );