[Libreoffice-commits] .: svl/source
Eike Rathke
erack at kemper.freedesktop.org
Fri Aug 5 11:06:35 PDT 2011
svl/source/numbers/zforlist.cxx | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
New commits:
commit 59005c9c8e553b1458430d0a2726d966cf80a0f3
Author: Eike Rathke <erack at erack.de>
Date: Fri Aug 5 16:30:19 2011 +0200
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.
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 59bbe87..1772a58 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 );
More information about the Libreoffice-commits
mailing list