[Libreoffice-commits] core.git: include/svl svl/qa svl/source svx/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 23 08:28:43 UTC 2021


 include/svl/zforlist.hxx        |    5 +++--
 svl/qa/unit/svl.cxx             |    3 ++-
 svl/source/numbers/zforlist.cxx |   25 +++++++++++++++++++++----
 svx/source/items/numfmtsh.cxx   |    1 +
 4 files changed, 27 insertions(+), 7 deletions(-)

New commits:
commit cda7dff78a113a18cdcc23274454cfef982a17c2
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Thu Sep 23 01:20:57 2021 +0200
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Thu Sep 23 10:28:11 2021 +0200

    Add not-quite-ISO date+time with space and milliseconds and locale's separator
    
    NF_DATETIME_ISO_YYYYMMDD_HHMMSS000
    YYYY-MM-DD HH:MM:SS.000
    
    Users may expect to see that if they enter such, instead of the
    real ISO 8601 "T" format.
    
    Change-Id: Iad81750d1c74eedd8d4360163b29ecac98ef6824
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122502
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index 59b748e4381e..9836f5047542 100644
--- a/include/svl/zforlist.hxx
+++ b/include/svl/zforlist.hxx
@@ -246,13 +246,14 @@ enum NfIndexTableOffset
     NF_FRACTION_100,                        // # ??/100
 
     NF_DATETIME_ISO_YYYYMMDD_HHMMSS,        // 1997-10-08 01:23:45          ISO (with blank instead of T)
+    NF_DATETIME_ISO_YYYYMMDD_HHMMSS000,     // 1997-10-08 01:23:45.678      not quite ISO with locale's separator
     NF_DATETIME_ISO_YYYYMMDDTHHMMSS,        // 1997-10-08T01:23:45          ISO
-    NF_DATETIME_ISO_YYYYMMDDTHHMMSS000,     // 1997-10-08T01:23:45,678      ISO with milliseconds
+    NF_DATETIME_ISO_YYYYMMDDTHHMMSS000,     // 1997-10-08T01:23:45,678      ISO with milliseconds and ',' or '.'
 
     // XXX When adding values here, follow the comment above about
     // svx/source/items/numfmtsh.cxx
 
-    NF_INDEX_TABLE_ENTRIES                  // == 61, reserved to not be used in i18npool locale data.
+    NF_INDEX_TABLE_ENTRIES                  // == 62, reserved to not be used in i18npool locale data.
 
     // XXX Adding values above may increment the reserved area that can't be
     // used by i18npool's locale data FormatCode definitions, see the
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 155fc9cbf1da..075515bca512 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -232,6 +232,7 @@ void Test::testNumberFormat()
 
     const char* pDateTimeExt2[] = {
         "YYYY-MM-DD HH:MM:SS",
+        "YYYY-MM-DD HH:MM:SS.000",
         "YYYY-MM-DD\"T\"HH:MM:SS",
         "YYYY-MM-DD\"T\"HH:MM:SS.000",
         nullptr
@@ -265,7 +266,7 @@ void Test::testNumberFormat()
         { NF_TEXT, NF_TEXT, 1, pText },
         { NF_DATETIME_SYS_DDMMYYYY_HHMM, NF_DATETIME_SYS_DDMMYYYY_HHMM, 1, pDateTimeExt1 },
         { NF_FRACTION_3D, NF_FRACTION_100, 7, pFractionExt },
-        { NF_DATETIME_ISO_YYYYMMDD_HHMMSS, NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, 3, pDateTimeExt2 }
+        { NF_DATETIME_ISO_YYYYMMDD_HHMMSS, NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, 4, pDateTimeExt2 }
     };
 
     SvNumberFormatter aFormatter(m_xContext, eLang);
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index dca678d81abd..ae6710ee18f1 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -169,6 +169,7 @@ sal_uInt32 const indexTable[NF_INDEX_TABLE_ENTRIES] = {
     ZF_STANDARD_FRACTION + 7, // NF_FRACTION_10
     ZF_STANDARD_FRACTION + 8, // NF_FRACTION_100
     ZF_STANDARD_DATETIME + 2, // NF_DATETIME_ISO_YYYYMMDD_HHMMSS
+    ZF_STANDARD_DATETIME + 6, // NF_DATETIME_ISO_YYYYMMDD_HHMMSS000
     ZF_STANDARD_DATETIME + 3, // NF_DATETIME_ISO_YYYYMMDDTHHMMSS
     ZF_STANDARD_DATETIME + 5  // NF_DATETIME_ISO_YYYYMMDDTHHMMSS000
 };
@@ -1281,9 +1282,8 @@ bool SvNumberFormatter::IsNumberFormat(const OUString& sString,
             }
             else if (pStringScanner->CanForceToIso8601( DateOrder::Invalid))
             {
-                /* TODO: add a millisecond format with space instead of 'T'? */
                 if (pStringScanner->GetDecPos())
-                    F_Index = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, ActLnge );
+                    F_Index = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS000, ActLnge );
                 else
                     F_Index = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, ActLnge );
             }
@@ -1649,6 +1649,8 @@ sal_uInt32 SvNumberFormatter::GetEditFormat( double fNumber, sal_uInt32 nFIndex,
             nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS, eLang );
         else if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, eLang))
             nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS000, eLang );
+        else if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS000, eLang))
+            nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS000, eLang );
         else if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang) || (pFormat && pFormat->IsIso8601( 0 )))
             nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang );
         else
@@ -2887,8 +2889,23 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio
         rKeyword[NF_KEY_HH] + ":" +
         rKeyword[NF_KEY_MMI] + ":" +
         rKeyword[NF_KEY_SS];
-    ImpInsertFormat( aSingleFormatCode,
+    SvNumberformat* pFormat = ImpInsertFormat( aSingleFormatCode,
                      CLOffset + ZF_STANDARD_DATETIME+2 /* NF_DATETIME_ISO_YYYYMMDD_HHMMSS */ );
+    assert(pFormat);
+
+    // YYYY-MM-DD HH:MM:SS,000   ISO (with blank instead of 'T') and
+    // milliseconds and locale's time decimal separator
+    aSingleFormatCode.Code =
+        rKeyword[NF_KEY_YYYY] + "-" +
+        rKeyword[NF_KEY_MM] + "-" +
+        rKeyword[NF_KEY_DD] + " " +
+        rKeyword[NF_KEY_HH] + ":" +
+        rKeyword[NF_KEY_MMI] + ":" +
+        rKeyword[NF_KEY_SS] + GetLocaleData()->getTime100SecSep() +
+        "000";
+    pFormat = ImpInsertFormat( aSingleFormatCode,
+                     CLOffset + ZF_STANDARD_DATETIME+6 /* NF_DATETIME_ISO_YYYYMMDD_HHMMSS000 */ );
+    assert(pFormat);
 
     // YYYY-MM-DD"T"HH:MM:SS   ISO
     aSingleFormatCode.Code =
@@ -2898,7 +2915,7 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio
         rKeyword[NF_KEY_HH] + ":" +
         rKeyword[NF_KEY_MMI] + ":" +
         rKeyword[NF_KEY_SS];
-    SvNumberformat* pFormat = ImpInsertFormat( aSingleFormatCode,
+    pFormat = ImpInsertFormat( aSingleFormatCode,
                      CLOffset + ZF_STANDARD_DATETIME+3 /* NF_DATETIME_ISO_YYYYMMDDTHHMMSS */ );
     assert(pFormat);
     pFormat->SetComment("ISO 8601");    // not to be localized
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index 30f76ab3afb9..e3c4b0fe7e4e 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -719,6 +719,7 @@ bool SvxNumberFormatShell::IsEssentialFormat_Impl(SvNumFormatType eType, sal_uIn
         case NF_DATETIME_SYS_DDMMYYYY_HHMM:
         case NF_DATETIME_SYS_DDMMYYYY_HHMMSS:
         case NF_DATETIME_ISO_YYYYMMDD_HHMMSS:
+        case NF_DATETIME_ISO_YYYYMMDD_HHMMSS000:
         case NF_DATETIME_ISO_YYYYMMDDTHHMMSS:
         case NF_DATETIME_ISO_YYYYMMDDTHHMMSS000:
             return true;


More information about the Libreoffice-commits mailing list