include/svx/numfmtsh.hxx | 5 +-- svx/source/items/numfmtsh.cxx | 64 ++++++++++++------------------------------ 2 files changed, 22 insertions(+), 47 deletions(-)
New commits: commit 8a1d66a27428359e853a20acf0f308e4fcdda692 Author: Eike Rathke <er...@redhat.com> AuthorDate: Sat Feb 22 20:59:17 2020 +0100 Commit: Eike Rathke <er...@redhat.com> CommitDate: Sat Feb 22 22:12:31 2020 +0100 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 <er...@redhat.com> Tested-by: Jenkins diff --git a/include/svx/numfmtsh.hxx b/include/svx/numfmtsh.hxx index fe1193aee5a3..563920af41ca 100644 --- a/include/svx/numfmtsh.hxx +++ b/include/svx/numfmtsh.hxx @@ -203,8 +203,9 @@ private: bool bSuppressDuplicates ); SVX_DLLPRIVATE short FillEListWithDateTime_Impl( std::vector<OUString>& rList,short nSelPos, bool bSuppressDuplicates ); - SVX_DLLPRIVATE void FillEListWithOneDateTime_Impl( std::vector<OUString>& rList, short & nSelPos, - bool bSuppressDuplicates, NfIndexTableOffset nOffset ); + SVX_DLLPRIVATE void FillEListWithOneFormat_Impl( std::vector<OUString>& rList, short & nSelPos, + bool bSuppressDuplicates, NfIndexTableOffset nOffset, + bool bSuppressIsoDateTime ); SVX_DLLPRIVATE short FillEListWithCurrency_Impl( std::vector<OUString>& rList,short nSelPos); SVX_DLLPRIVATE short FillEListWithSysCurrencys( std::vector<OUString>& rList,short nSelPos); SVX_DLLPRIVATE short FillEListWithUserCurrencys( std::vector<OUString>& rList,short nSelPos); 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); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits