include/svl/zforlist.hxx | 3 ++- svl/source/numbers/zforlist.cxx | 22 +++++++++++++++++++--- svx/source/items/numfmtsh.cxx | 8 +++++--- 3 files changed, 26 insertions(+), 7 deletions(-)
New commits: commit 4ffb036fd5858c1acee9930e8f03d8b8a0d88730 Author: Eike Rathke <er...@redhat.com> AuthorDate: Mon Aug 19 17:05:15 2019 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Mon Aug 19 18:31:08 2019 +0200 Resolves: tdf#72040 add predefined ISO 8601 date+time format with "T" Still missing is selecting the format if such input is detected, but if applied it is preserved as edit format when editing the value. Change-Id: Ic36a643bb90ac897a303d5d59782aa4b297a56ea Reviewed-on: https://gerrit.libreoffice.org/77732 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index 032809b8f82e..2d52ce4322b5 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -243,11 +243,12 @@ 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_YYYYMMDDTHHMMSS, // 1997-10-08T01:23:45 ISO // XXX When adding values here, follow the comment above about // svx/source/items/numfmtsh.cxx - NF_INDEX_TABLE_ENTRIES // == 58, reserved up to #59 to not be used in i18npool locale data. + NF_INDEX_TABLE_ENTRIES // == 59, reserved up to #59 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/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index e862b45f5db4..6d8a906a0038 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -156,7 +156,8 @@ static sal_uInt32 const indexTable[NF_INDEX_TABLE_ENTRIES] = { ZF_STANDARD_FRACTION + 6, // NF_FRACTION_16 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 + 2, // NF_DATETIME_ISO_YYYYMMDD_HHMMSS + ZF_STANDARD_DATETIME + 3 // NF_DATETIME_ISO_YYYYMMDDTHHMMSS }; /** @@ -1507,7 +1508,9 @@ sal_uInt32 SvNumberFormatter::GetEditFormat( double fNumber, sal_uInt32 nFIndex, nKey = GetTimeFormat( fNumber, eLang, true); break; case SvNumFormatType::DATETIME : - if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDD_HHMMSS, eLang) || (pFormat && pFormat->IsIso8601( 0 ))) + if (nFIndex == GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS, eLang)) + nKey = GetFormatIndex( NF_DATETIME_ISO_YYYYMMDDTHHMMSS, eLang ); + else 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 ); @@ -2649,7 +2652,7 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio OUStringBuffer aBuf; aSingleFormatCode.Usage = i18n::KNumberFormatUsage::DATE_TIME; - // YYYY-MM-DD HH:MM:SS ISO + // YYYY-MM-DD HH:MM:SS ISO (with blank instead of 'T') aBuf.append( rKeyword[NF_KEY_YYYY]).append('-'). append( rKeyword[NF_KEY_MM]).append('-'). append( rKeyword[NF_KEY_DD]).append(' '). @@ -2660,6 +2663,19 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio ImpInsertFormat( aSingleFormatCode, CLOffset + ZF_STANDARD_DATETIME+2 /* NF_DATETIME_ISO_YYYYMMDD_HHMMSS */ ); + // YYYY-MM-DD"T"HH:MM:SS ISO + aBuf.append( rKeyword[NF_KEY_YYYY]).append('-'). + append( rKeyword[NF_KEY_MM]).append('-'). + append( rKeyword[NF_KEY_DD]).append("\"T\""). + append( rKeyword[NF_KEY_HH]).append(':'). + append( rKeyword[NF_KEY_MMI]).append(':'). + append( rKeyword[NF_KEY_SS]); + aSingleFormatCode.Code = aBuf.makeStringAndClear(); + SvNumberformat* pFormat = ImpInsertFormat( aSingleFormatCode, + CLOffset + ZF_STANDARD_DATETIME+3 /* NF_DATETIME_ISO_YYYYMMDDTHHMMSS */ ); + assert(pFormat); + pFormat->SetComment("ISO 8601"); // not to be localized + // Scientific number aFormatSeq = xNFC->getAllFormatCode( i18n::KNumberFormatUsage::SCIENTIFIC_NUMBER, aLocale ); diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx index 85c051fbc226..8f39c009351f 100644 --- a/svx/source/items/numfmtsh.cxx +++ b/svx/source/items/numfmtsh.cxx @@ -688,7 +688,8 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl(std::vector<OUString>& rL // Ugly hack to suppress an ISO date+time format that is the // default date+time format of the locale and identical to the // internally generated one to be added below. - if (!bSuppressDuplicates || aNewFormNInfo != "YYYY-MM-DD HH:MM:SS") + if (!bSuppressDuplicates || (aNewFormNInfo != "YYYY-MM-DD HH:MM:SS" + && aNewFormNInfo != "YYYY-MM-DD\"T\"HH:MM:SS")) { rList.push_back(aNewFormNInfo); aCurEntryList.push_back(nNFEntry); @@ -697,9 +698,9 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl(std::vector<OUString>& rL } } - // Always add the internally generated ISO format. + // Always add the internally generated ISO formats. nSelPos = FillEListWithFormats_Impl(rList, nSelPos, NF_DATETIME_ISO_YYYYMMDD_HHMMSS, - NF_DATETIME_ISO_YYYYMMDD_HHMMSS, false); + NF_DATETIME_ISO_YYYYMMDDTHHMMSS, false); return nSelPos; } @@ -720,6 +721,7 @@ bool SvxNumberFormatShell::IsEssentialFormat_Impl(SvNumFormatType eType, sal_uIn case NF_TIME_HH_MMSS00: case NF_DATETIME_SYS_DDMMYYYY_HHMMSS: case NF_DATETIME_ISO_YYYYMMDD_HHMMSS: + case NF_DATETIME_ISO_YYYYMMDDTHHMMSS: return true; default: break; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits