20#include <com/sun/star/linguistic2/XAvailableLocales.hpp>
21#include <com/sun/star/linguistic2/XLinguServiceManager2.hpp>
22#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
24#include <rtl/ustring.hxx>
35#include <svx/strings.hrc>
36#include <bitmaps.hlst>
53 OUString aTmp( aURLObj.
GetBase() +
" " );
61 aTmp +=
SvxResId(RID_SVXSTR_LANGUAGE_ALL);
72 std::vector<LanguageType>& aLangs)
74 sal_Int32
nCount = rSeq.getLength();
76 aLangs.reserve(aLangs.size() +
nCount);
78 std::transform(rSeq.begin(), rSeq.end(), std::back_inserter(aLangs),
80 return LanguageTag::convertToLanguageType(rLocale); });
83static bool lcl_SeqHasLang(
const Sequence< sal_Int16 > & rLangSeq, sal_Int16 nLang )
85 return rLangSeq.hasElements()
86 && std::find(rLangSeq.begin(), rLangSeq.end(), nLang) != rLangSeq.end();
91bool lcl_isPrerequisite(
LanguageType nLangType,
bool requireSublang)
120 if (!sLang.isEmpty())
128 return m_xControl->find_id(OUString::number(
static_cast<sal_uInt16
>(eLangType)));
133 m_xControl->set_id(
pos, OUString::number(
static_cast<sal_uInt16
>(eLangType)));
143 m_xControl->remove_id(OUString::number(
static_cast<sal_uInt16
>(eLangType)));
148 m_xControl->append(OUString::number(
static_cast<sal_uInt16
>(eLangType)), rStr);
157 sal_Int32 nAt =
find_id( nLang );
170 SvxLanguageListFlags nLangList, std::vector<weld::ComboBoxEntry>& rEntries,
bool requireSublang)
172 for (
auto const & nLangType : rLanguageTypes )
174 if (lcl_isPrerequisite(nLangType, requireSublang))
177 if (lcl_isScriptTypeRequested( nLang, nLangList))
183 if (aNewEntry.
sString.isEmpty())
185 rEntries.push_back(aNewEntry);
195 if (e1.
sId == e2.sId)
202 if (
lt1.getLanguage() ==
lt2.getLanguage())
204 const bool isLangOnly1 =
lt1.isIsoLocale() &&
lt1.getCountry().isEmpty();
205 const bool isLangOnly2 =
lt2.isIsoLocale() &&
lt2.getCountry().isEmpty();
213 else if (isLangOnly2)
223 return aSorter.compare(e1.
sString, e2.sString) < 0;
226 std::sort(rEntries.begin(), rEntries.end(), langLess);
227 rEntries.erase(std::unique(rEntries.begin(), rEntries.end(),
229 { return e1.sId == e2.sId; }),
234 bool bLangNoneIsLangAll,
bool bCheckSpellAvail,
236 sal_Int16 nDefaultType)
249 bool bAddSeparator =
false;
254 bAddSeparator =
true;
257 if (bDefaultLangExist)
260 bAddSeparator =
true;
271 std::vector< LanguageType > aAvailLang;
272 Sequence< sal_Int16 > aSpellUsedLang;
286 aSpellUsedLang = xTmp1->getLanguages();
289 std::vector<LanguageType> aKnown;
301 std::vector<weld::ComboBoxEntry>
aEntries;
302 for ( sal_uInt32
i = 0;
i <
nCount;
i++ )
306 nLangType = aKnown[
i];
309 if ( lcl_isPrerequisite( nLangType,
true ) &&
310 (lcl_isScriptTypeRequested( nLangType, nLangList) ||
314 lcl_SeqHasLang(aSpellUsedLang,
static_cast<sal_uInt16
>(nLangType)))
318 if (
aEntries.back().sString.isEmpty())
346 std::vector<weld::ComboBoxEntry> entries;
358 if (nLang != nLangType)
394 return weld::ComboBoxEntry(aStrEntry, OUString::number(
static_cast<sal_uInt16
>(nLang)), bFound ? OUString(RID_SVXBMP_CHECKED) : OUString(RID_SVXBMP_NOTCHECKED));
402 if (rControl.has_entry())
404 EditedAndValid eOldState = m_eEditedAndValid;
405 OUString
aStr(rControl.get_active_text());
407 m_eEditedAndValid = EditedAndValid::Invalid;
410 const int nPos = rControl.find_text(
aStr);
413 int nStartSelectPos, nEndSelectPos;
414 rControl.get_entry_selection_bounds(nStartSelectPos, nEndSelectPos);
420 bool bSetEditSelection;
422 bSetEditSelection =
false;
426 bSetEditSelection =
true;
434 if (nEndSelectPos == 0)
436 OUString aText(
m_xControl->get_active_text());
437 if (nStartSelectPos == aText.getLength())
440 bSetEditSelection =
true;
444 if (bSetEditSelection)
445 rControl.select_entry_region(nStartSelectPos, nEndSelectPos);
447 m_eEditedAndValid = EditedAndValid::No;
451 OUString aCanonicalized;
453 m_eEditedAndValid = (bValid ? EditedAndValid::Valid : EditedAndValid::Invalid);
454 if (bValid && aCanonicalized !=
aStr)
457 const auto nCursorPos = aCanonicalized.getLength();
458 m_xControl->select_entry_region(nCursorPos, nCursorPos);
462 if (eOldState != m_eEditedAndValid)
464 if (m_eEditedAndValid == EditedAndValid::Invalid)
470 m_aChangeHdl.Call(rControl);
477 , m_bHasLangNone(false)
478 , m_bLangNoneIsLangAll(false)
479 , m_bWithCheckmark(false)
493 SAL_WARN(
"svx.dialog",
"SvxLanguageBox::SaveEditedAsEntry: unknown tag");
497 for (
size_t i = 0;
i < 3; ++
i)
516 SAL_WARN(
"svx.dialog",
"SvxLanguageBox::SaveEditedAsEntry: already in SvtLanguageTable: " <<
531 case css::i18n::ScriptType::LATIN:
534 case css::i18n::ScriptType::ASIAN:
537 case css::i18n::ScriptType::COMPLEX:
static const AllSettings & GetSettings()
void SetSmartProtocol(INetProtocol eTheSmartScheme)
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
LanguageType getLanguageType(bool bResolveSystem=true) const
LanguageTag & makeFallback()
bool isValidBcp47() const
static css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker()
static css::uno::Reference< css::linguistic2::XLinguServiceManager2 > GetLngSvcMgr()
static const std::vector< LanguageType > & getInstalledLanguageTypes()
static bool isLegacy(LanguageType nLang)
static LanguageType resolveSystemLanguageByScriptType(LanguageType nLang, sal_Int16 nType)
static LanguageType getSubLanguage(LanguageType nLangID)
static LanguageType getReplacementForObsoleteLanguage(LanguageType nLang)
static LanguageType getSystemLanguage()
static sal_Int16 getScriptType(LanguageType nLang)
static bool hasForbiddenCharacters(LanguageType nLang)
static void AddLanguageTag(const LanguageTag &rLanguageTag)
static sal_uInt32 GetLanguageEntryCount()
static OUString GetLanguageString(const LanguageType eType)
static LanguageType GetLanguageTypeAtIndex(sal_uInt32 nIndex)
static bool HasLanguageType(const LanguageType eType)
bool m_bLangNoneIsLangAll
SVX_DLLPRIVATE void AddLanguages(const std::vector< LanguageType > &rLanguageTypes, SvxLanguageListFlags nLangList, std::vector< weld::ComboBoxEntry > &rEntries, bool requireSublang)
void InsertLanguage(const LanguageType nLangType)
void remove_id(const LanguageType eLangType)
LanguageType get_active_id() const
void set_id(int nPos, const LanguageType eLangType)
SvxLanguageBox * SaveEditedAsEntry(SvxLanguageBox *ppBoxes[3])
EditedAndValid m_eEditedAndValid
void SetLanguageList(SvxLanguageListFlags nLangList, bool bHasLangNone, bool bLangNoneIsLangAll=false, bool bCheckSpellAvail=false, bool bDefaultLangExist=false, LanguageType eDefaultLangType=LANGUAGE_NONE, sal_Int16 nDefaultType=0)
SvxLanguageBox(std::unique_ptr< weld::ComboBox > pControl)
std::unique_ptr< weld::ComboBox > m_xControl
LanguageType get_id(int nPos) const
void set_active_id(const LanguageType eLangType)
void append(const LanguageType eLangType, const OUString &rStr)
std::unique_ptr< css::uno::Sequence< sal_Int16 > > m_xSpellUsedLang
void InsertLanguages(const std::vector< LanguageType > &rLanguageTypes)
int find_id(const LanguageType eLangType) const
SVX_DLLPRIVATE weld::ComboBoxEntry BuildEntry(const LanguageType nLangType, sal_Int16 nType=css::i18n::ScriptType::WEAK)
OUString SvxResId(TranslateId aId)
ScXMLEditAttributeMap::Entry const aEntries[]
#define LANGUAGE_USER_SYSTEM_CONFIG
#define LANGUAGE_USER_KEYID
#define LANGUAGE_DONTKNOW
static void SortLanguages(std::vector< weld::ComboBoxEntry > &rEntries)
static bool lcl_SeqHasLang(const Sequence< sal_Int16 > &rLangSeq, sal_Int16 nLang)
static void appendLocaleSeqToLangs(Sequence< css::lang::Locale > const &rSeq, std::vector< LanguageType > &aLangs)
OUString GetDicInfoStr(std::u16string_view rName, const LanguageType nLang, bool bNeg)
IMPL_LINK(SvxLanguageBox, ChangeHdl, weld::ComboBox &, rControl, void)
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
constexpr OUStringLiteral SN_SPELLCHECKER
constexpr OUStringLiteral SN_HYPHENATOR
constexpr OUStringLiteral SN_THESAURUS
SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
const LanguageTag & getLocale()
Reference< XComponentContext > getProcessComponentContext()