summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-02-22 18:52:06 +0100
committerEike Rathke <erack@redhat.com>2020-02-22 20:17:54 +0100
commit8453f6e5d1fd98700a37e30346a1af0daf8fb753 (patch)
tree9d5ee1a300bc922dd4c577365e598a2e7a814218 /svx
parent3ac9f491c20fb56c4544444d876687dd6d8de231 (diff)
Resolves: tdf#130563 Add predefined 4-digit year date+time format
Add a predefined NF_DATETIME_SYS_DDMMYYYY_HHMM format code with formatindex="50" to all locale data files, which shifts all reserved area internally generated built-in formats up by one. Reserved area was filled already so that boundary has to be increased as well. Add some flexibility for future additions by setting the new boundary to 65, free first format index to be used by additional locale data formats is 66 now. Adapt all locales to the new boundary. The existing predefined NF_DATETIME_SYSTEM_SHORT_HHMM format code with formatindex="46" mostly was and is used with 2-digit years (stemming back from the old binary format and Excel compatibility), some locales that don't use 2-digit years at all already defined it to 4-digit years. Keep those but move the default="true" attribute (if so) to the new "50" format. Modify populating the format list such that resulting duplicates will be suppressed there as well. Also try to match the new format in ODF import if a long year was requested with date+time. Finally set the new format as default for all *_IT locales. In future changing the default date+time format to 4-digit year is just a matter of moving the default="true" attribute to the new format. Change-Id: Ib16aa9fda0e71b2d03f78e3dd013785de03cd288 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89265 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'svx')
-rw-r--r--svx/source/items/numfmtsh.cxx72
1 files changed, 40 insertions, 32 deletions
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index 3a329b7181a4..e169319df799 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -661,41 +661,14 @@ short SvxNumberFormatShell::FillEListWithFormats_Impl(std::vector<OUString>& rLi
short SvxNumberFormatShell::FillEListWithDateTime_Impl(std::vector<OUString>& rList, short nSelPos,
bool bSuppressDuplicates)
{
- sal_uInt16 nMyType;
-
- sal_uInt32 nNFEntry;
- OUString aNewFormNInfo;
+ // Add first, so a NF_DATETIME_SYSTEM_SHORT_HHMM may be suppressed in
+ // locales that do not use 2-digit years there and this here is the
+ // default.
+ FillEListWithOneDateTime_Impl( rList, nSelPos, bSuppressDuplicates, NF_DATETIME_SYS_DDMMYYYY_HHMM);
for (long nIndex = NF_DATETIME_START; nIndex <= NF_DATETIME_END; ++nIndex)
{
- nNFEntry = pFormatter->GetFormatIndex(static_cast<NfIndexTableOffset>(nIndex), eCurLanguage);
-
- const SvNumberformat* pNumEntry = pFormatter->GetEntry(nNFEntry);
- if (pNumEntry != nullptr)
- {
- SvNumFormatType nMyCat = pNumEntry->GetMaskedType();
- CategoryToPos_Impl(nMyCat, nMyType);
- aNewFormNInfo = pNumEntry->GetFormatstring();
-
- if (nNFEntry == nCurFormatKey)
- {
- nSelPos = (!IsRemoved_Impl(nNFEntry)) ? aCurEntryList.size() : SELPOS_NONE;
- }
-
- if (!bSuppressDuplicates || IsEssentialFormat_Impl(nMyCat, nNFEntry)
- || std::find(rList.begin(), rList.end(), aNewFormNInfo) == rList.end())
- {
- // 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"
- && aNewFormNInfo != "YYYY-MM-DD\"T\"HH:MM:SS"))
- {
- rList.push_back(aNewFormNInfo);
- aCurEntryList.push_back(nNFEntry);
- }
- }
- }
+ FillEListWithOneDateTime_Impl( rList, nSelPos, bSuppressDuplicates, static_cast<NfIndexTableOffset>(nIndex));
}
// Always add the internally generated ISO formats.
@@ -705,6 +678,40 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl(std::vector<OUString>& rL
return nSelPos;
}
+void SvxNumberFormatShell::FillEListWithOneDateTime_Impl(std::vector<OUString>& rList, short & nSelPos,
+ bool bSuppressDuplicates, NfIndexTableOffset nOffset)
+{
+ sal_uInt32 nNFEntry = pFormatter->GetFormatIndex(nOffset, eCurLanguage);
+
+ const SvNumberformat* pNumEntry = pFormatter->GetEntry(nNFEntry);
+ if (pNumEntry == nullptr)
+ return;
+
+ SvNumFormatType nMyCat = pNumEntry->GetMaskedType();
+ sal_uInt16 nMyType;
+ CategoryToPos_Impl(nMyCat, nMyType);
+ OUString aNewFormNInfo = pNumEntry->GetFormatstring();
+
+ if (nNFEntry == nCurFormatKey)
+ {
+ nSelPos = (!IsRemoved_Impl(nNFEntry)) ? aCurEntryList.size() : SELPOS_NONE;
+ }
+
+ if (!bSuppressDuplicates || IsEssentialFormat_Impl(nMyCat, nNFEntry)
+ || std::find(rList.begin(), rList.end(), aNewFormNInfo) == rList.end())
+ {
+ // 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 after/below.
+ 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);
+ }
+ }
+}
+
bool SvxNumberFormatShell::IsEssentialFormat_Impl(SvNumFormatType eType, sal_uInt32 nKey)
{
if (nKey == nCurFormatKey)
@@ -719,6 +726,7 @@ bool SvxNumberFormatShell::IsEssentialFormat_Impl(SvNumFormatType eType, sal_uIn
case NF_TIME_HH_MMSS:
case NF_TIME_MMSS00:
case NF_TIME_HH_MMSS00:
+ case NF_DATETIME_SYS_DDMMYYYY_HHMM:
case NF_DATETIME_SYS_DDMMYYYY_HHMMSS:
case NF_DATETIME_ISO_YYYYMMDD_HHMMSS:
case NF_DATETIME_ISO_YYYYMMDDTHHMMSS: