summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-06-04 12:58:46 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-06-04 14:17:35 +0200
commit182974354e4536af568dfb05a7400e48a2fe1032 (patch)
treedfc89768f2f447588f4d89152c8bdde58c5b8e44 /sc
parent1fa085f223761b8dcd7e7ac592eb70450a774543 (diff)
Optimize ScAppCfg::ReadSortListCfg
Do not initialize defaults when using custom user list. Change-Id: I8428a20b65182011a25325f0b7298ea51998346b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152587 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/userlist.hxx3
-rw-r--r--sc/source/core/tool/appoptio.cxx12
-rw-r--r--sc/source/core/tool/userlist.cxx21
3 files changed, 18 insertions, 18 deletions
diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx
index 7625ad15f5ee..80968361ceac 100644
--- a/sc/inc/userlist.hxx
+++ b/sc/inc/userlist.hxx
@@ -69,9 +69,10 @@ class SC_DLLPUBLIC ScUserList
DataType maData;
public:
- ScUserList();
+ explicit ScUserList(bool initDefault = true);
ScUserList(const ScUserList& r) = default;
+ void AddDefaults();
void EraseData(size_t nIndex) { maData.erase(maData.cbegin() + nIndex); }
const ScUserListData* GetData(const OUString& rSubStr) const;
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 16a0c4cb9174..9dbc85f310ae 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -407,16 +407,18 @@ void ScAppCfg::ReadSortListCfg()
if (Sequence<OUString> aSeq; aValues[SCSORTLISTOPT_LIST] >>= aSeq)
{
- ScUserList aList;
+ ScUserList aList(false); // Do not init defaults
- // if setting is "default", keep default values from ScUserList ctor
+ // if setting is "default", keep default values
//TODO: mark "default" in a safe way
const bool bDefault = (aSeq.getLength() == 1 && aSeq[0] == "NULL");
- if (!bDefault)
+ if (bDefault)
+ {
+ aList.AddDefaults();
+ }
+ else
{
- aList.clear();
-
for (const OUString& rStr : std::as_const(aSeq))
{
aList.emplace_back(rStr);
diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx
index 4540ad3ea0f6..f38a16d98f12 100644
--- a/sc/source/core/tool/userlist.cxx
+++ b/sc/source/core/tool/userlist.cxx
@@ -200,20 +200,18 @@ sal_Int32 ScUserListData::ICompare(const OUString& rSubStr1, const OUString& rSu
return ScGlobal::GetTransliteration().compareString( rSubStr1, rSubStr2 );
}
-ScUserList::ScUserList()
+ScUserList::ScUserList(bool initDefault)
{
- using namespace ::com::sun::star;
+ if (initDefault)
+ AddDefaults();
+}
+void ScUserList::AddDefaults()
+{
sal_Unicode cDelimiter = ScGlobal::cListDelimiter;
- uno::Sequence< i18n::CalendarItem2 > xCal;
-
- const uno::Sequence< i18n::Calendar2 > xCalendars(
- ScGlobal::getLocaleData().getAllCalendars() );
-
- for ( const auto& rCalendar : xCalendars )
+ for (const auto& rCalendar : ScGlobal::getLocaleData().getAllCalendars())
{
- xCal = rCalendar.Days;
- if ( xCal.hasElements() )
+ if (const auto& xCal = rCalendar.Days; xCal.hasElements())
{
OUStringBuffer aDayShortBuf(32), aDayLongBuf(64);
sal_Int32 i;
@@ -244,8 +242,7 @@ ScUserList::ScUserList()
emplace_back(aDayLong);
}
- xCal = rCalendar.Months;
- if ( xCal.hasElements() )
+ if (const auto& xCal = rCalendar.Months; xCal.hasElements())
{
OUStringBuffer aMonthShortBuf(128), aMonthLongBuf(128);
sal_Int32 i;