summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-02-22 20:59:17 +0100
committerEike Rathke <erack@redhat.com>2020-02-22 22:12:31 +0100
commit8a1d66a27428359e853a20acf0f308e4fcdda692 (patch)
treea28bc31d2ce0b6191b206d7ede1863d0d8187c8d /svx
parent8453f6e5d1fd98700a37e30346a1af0daf8fb753 (diff)
Factor out FillEListWithOneFormat_Impl()
... from almost identical FillEListWithFormats_Impl(). Change-Id: Id0443b40a2acfdfee24426fa0672f711889f3e2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89286 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'svx')
-rw-r--r--svx/source/items/numfmtsh.cxx64
1 files changed, 19 insertions, 45 deletions
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index e169319df799..ade17b02af62 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -622,37 +622,9 @@ short SvxNumberFormatShell::FillEListWithFormats_Impl(std::vector<OUString>& rLi
* the list position of the current format. If the list is empty
* or if there is no current format, SELPOS_NONE is delivered.
*/
- sal_uInt16 nMyType;
-
- sal_uInt32 nNFEntry;
- OUString aNewFormNInfo;
-
- long nIndex;
-
- for (nIndex = eOffsetStart; nIndex <= eOffsetEnd; nIndex++)
+ for (long nIndex = eOffsetStart; nIndex <= eOffsetEnd; ++nIndex)
{
- nNFEntry = pFormatter->GetFormatIndex(static_cast<NfIndexTableOffset>(nIndex), eCurLanguage);
-
- const SvNumberformat* pNumEntry = pFormatter->GetEntry(nNFEntry);
-
- if (pNumEntry == nullptr)
- continue;
-
- 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())
- {
- rList.push_back(aNewFormNInfo);
- aCurEntryList.push_back(nNFEntry);
- }
+ FillEListWithOneFormat_Impl( rList, nSelPos, bSuppressDuplicates, static_cast<NfIndexTableOffset>(nIndex), false);
}
return nSelPos;
@@ -661,14 +633,16 @@ short SvxNumberFormatShell::FillEListWithFormats_Impl(std::vector<OUString>& rLi
short SvxNumberFormatShell::FillEListWithDateTime_Impl(std::vector<OUString>& rList, short nSelPos,
bool bSuppressDuplicates)
{
+ // Append a list of date+time formats.
+
// 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);
+ FillEListWithOneFormat_Impl( rList, nSelPos, bSuppressDuplicates, NF_DATETIME_SYS_DDMMYYYY_HHMM, true);
for (long nIndex = NF_DATETIME_START; nIndex <= NF_DATETIME_END; ++nIndex)
{
- FillEListWithOneDateTime_Impl( rList, nSelPos, bSuppressDuplicates, static_cast<NfIndexTableOffset>(nIndex));
+ FillEListWithOneFormat_Impl( rList, nSelPos, bSuppressDuplicates, static_cast<NfIndexTableOffset>(nIndex), true);
}
// Always add the internally generated ISO formats.
@@ -678,8 +652,9 @@ short SvxNumberFormatShell::FillEListWithDateTime_Impl(std::vector<OUString>& rL
return nSelPos;
}
-void SvxNumberFormatShell::FillEListWithOneDateTime_Impl(std::vector<OUString>& rList, short & nSelPos,
- bool bSuppressDuplicates, NfIndexTableOffset nOffset)
+void SvxNumberFormatShell::FillEListWithOneFormat_Impl(std::vector<OUString>& rList, short & nSelPos,
+ bool bSuppressDuplicates, NfIndexTableOffset nOffset,
+ bool bSuppressIsoDateTime)
{
sal_uInt32 nNFEntry = pFormatter->GetFormatIndex(nOffset, eCurLanguage);
@@ -697,18 +672,17 @@ void SvxNumberFormatShell::FillEListWithOneDateTime_Impl(std::vector<OUString>&
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 always to be added after/below.
+ const bool bSupIso = bSuppressIsoDateTime && bSuppressDuplicates &&
+ (aNewFormNInfo == "YYYY-MM-DD HH:MM:SS" || aNewFormNInfo == "YYYY-MM-DD\"T\"HH:MM:SS");
+
+ if (!bSupIso && (!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);
- }
+ rList.push_back(aNewFormNInfo);
+ aCurEntryList.push_back(nNFEntry);
}
}