summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-06-02 20:40:46 +0200
committerEike Rathke <erack@redhat.com>2016-06-02 20:41:44 +0200
commit020d395b59b4c631491ded910c0405584ef46e1c (patch)
tree57c8b56c60f8c81c63f6230b170ce619532f5b91
parente7418e96cee263a0a74027335d7f5a119bb43ce2 (diff)
preserve ISO date+time format when editing such values
Change-Id: I6dcbe6c9aeff87d735303713f328c84203f76b60
-rw-r--r--svl/source/numbers/zforlist.cxx43
1 files changed, 24 insertions, 19 deletions
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index df13480ff019..0747e0c2a326 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -1420,24 +1420,29 @@ sal_uInt32 SvNumberFormatter::GetEditFormat( double fNumber, sal_uInt32 nFIndex,
{
// #61619# always edit using 4-digit year
case css::util::NumberFormat::DATE :
- if (rtl::math::approxFloor( fNumber) != fNumber)
- nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
- // fdo#34977 preserve time when editing even if only date was
- // displayed.
- /* FIXME: in case an ISO 8601 format was used, editing should
- * also use such. Unfortunately we have no builtin combined
- * date+time ISO format defined. Needs also locale data work.
- * */
- else
{
// Preserve ISO 8601 format.
- if ( nFIndex == GetFormatIndex( NF_DATE_DIN_YYYYMMDD, eLang) ||
- nFIndex == GetFormatIndex( NF_DATE_DIN_YYMMDD, eLang) ||
- nFIndex == GetFormatIndex( NF_DATE_DIN_MMDD, eLang) ||
- (pFormat && pFormat->IsIso8601( 0 )))
- nKey = GetFormatIndex( NF_DATE_DIN_YYYYMMDD, eLang);
+ bool bIsoDate =
+ nFIndex == GetFormatIndex( NF_DATE_DIN_YYYYMMDD, eLang) ||
+ nFIndex == GetFormatIndex( NF_DATE_DIN_YYMMDD, eLang) ||
+ nFIndex == GetFormatIndex( NF_DATE_DIN_MMDD, eLang) ||
+ (pFormat && pFormat->IsIso8601( 0 ));
+ if (rtl::math::approxFloor( fNumber) != fNumber)
+ {
+ // fdo#34977 preserve time when editing even if only date was
+ // displayed.
+ if (bIsoDate)
+ nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang);
+ else
+ nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
+ }
else
- nKey = GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
+ {
+ if (bIsoDate)
+ nKey = GetFormatIndex( NF_DATE_ISO_YYYYMMDD, eLang);
+ else
+ nKey = GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
+ }
}
break;
case css::util::NumberFormat::TIME :
@@ -1458,10 +1463,10 @@ sal_uInt32 SvNumberFormatter::GetEditFormat( double fNumber, sal_uInt32 nFIndex,
nKey = GetStandardFormat( fNumber, nFIndex, eType, eLang );
break;
case css::util::NumberFormat::DATETIME :
- nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
- /* FIXME: in case an ISO 8601 format was used, editing should
- * also use such. Unfortunately we have no builtin combined
- * date+time ISO format defined. Needs also locale data work. */
+ if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang) || (pFormat && pFormat->IsIso8601( 0 )))
+ nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang );
+ else
+ nKey = GetFormatIndex( NF_DATETIME_SYS_DDMMYYYY_HHMMSS, eLang );
break;
default:
nKey = GetStandardFormat( fNumber, nFIndex, eType, eLang );