diff options
author | Eike Rathke <erack@erack.de> | 2011-08-05 16:30:19 +0200 |
---|---|---|
committer | Eike Rathke <erack@erack.de> | 2011-08-05 20:05:28 +0200 |
commit | 15d51584a1564a270dc976caf8f2c04bf5a068ea (patch) | |
tree | fa3e3f534c304dead6377cba44842cea7790d7fe /svl/source | |
parent | dc665255c188207908a3932354cf87a6428dc675 (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.
Diffstat (limited to 'svl/source')
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index e2ffa24fcd35..bb12e31875bf 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 ); |