summaryrefslogtreecommitdiff
path: root/svx/source/dialog/langbox.cxx
diff options
context:
space:
mode:
authorYusuf Keten <ketenyusuf@gmail.com>2020-02-04 00:14:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-02-11 18:25:37 +0100
commit5326d238d7f98b11886eb4be01f19db73f8eda39 (patch)
treeacc882aff8e915e1059aa281c391336f4a7248c9 /svx/source/dialog/langbox.cxx
parent992c2e82e29ed68e40fe61303d16762604003121 (diff)
tdf#114694: Make default value in language settings the first element
For Languages, to make the default value ​​the first element in the list, I've added 3 parameters to SvxLanguageBox::SetLanguageList(). With this parameters, function adds default value according to its existence before other values. For sorting User Interface and Currency, I removed the make_sorted function. I added std::sort with lambda expressions for both of them. Change-Id: Iae37bfe09aaac4d8ecde1caad7a14e11df551eae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87926 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svx/source/dialog/langbox.cxx')
-rw-r--r--svx/source/dialog/langbox.cxx34
1 files changed, 30 insertions, 4 deletions
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
index a2aed402ac3d..ac837e92f423 100644
--- a/svx/source/dialog/langbox.cxx
+++ b/svx/source/dialog/langbox.cxx
@@ -34,6 +34,11 @@
#include <svx/strings.hrc>
#include <bitmaps.hlst>
+#include <comphelper/string.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::linguistic2;
using namespace ::com::sun::star::uno;
@@ -185,8 +190,10 @@ void SvxLanguageBox::AddLanguages(const std::vector< LanguageType >& rLanguageTy
}
}
-void SvxLanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
- bool bHasLangNone, bool bLangNoneIsLangAll, bool bCheckSpellAvail )
+void SvxLanguageBox::SetLanguageList(SvxLanguageListFlags nLangList, bool bHasLangNone,
+ bool bLangNoneIsLangAll, bool bCheckSpellAvail,
+ bool bDefaultLangExist, LanguageType eDefaultLangType,
+ sal_Int16 nDefaultType)
{
m_bHasLangNone = bHasLangNone;
m_bLangNoneIsLangAll = bLangNoneIsLangAll;
@@ -278,10 +285,30 @@ void SvxLanguageBox::SetLanguageList( SvxLanguageListFlags nLangList,
AddLanguages(aThesAvailLang, nLangList, aEntries);
}
+ std::sort(aEntries.begin(), aEntries.end(),
+ [](const weld::ComboBoxEntry e1, const weld::ComboBoxEntry e2) {
+ static const auto aSorter = comphelper::string::NaturalStringSorter(
+ ::comphelper::getProcessComponentContext(),
+ Application::GetSettings().GetLanguageTag().getLocale());
+ return aSorter.compare(e1.sString, e2.sString) < 0;
+ });
+
+ int nSeparatorPosition = 0;
+ if (bDefaultLangExist)
+ {
+ aEntries.insert(aEntries.begin(), BuildEntry(eDefaultLangType, nDefaultType));
+ nSeparatorPosition++;
+ }
+
if (bHasLangNone)
- aEntries.push_back(BuildEntry(LANGUAGE_NONE));
+ {
+ aEntries.insert(aEntries.begin(), BuildEntry(LANGUAGE_NONE));
+ nSeparatorPosition++;
+ }
m_xControl->insert_vector(aEntries, false);
+ if (nSeparatorPosition > 0)
+ m_xControl->insert_separator(nSeparatorPosition, "");
}
int SvxLanguageBox::ImplTypeToPos(LanguageType eType) const
@@ -438,7 +465,6 @@ SvxLanguageBox::SvxLanguageBox(std::unique_ptr<weld::ComboBox> pControl)
, m_bLangNoneIsLangAll(false)
, m_bWithCheckmark(false)
{
- m_xControl->make_sorted();
m_xControl->connect_changed(LINK(this, SvxLanguageBox, ChangeHdl));
}