20#include <com/sun/star/lang/XMultiServiceFactory.hpp>
21#include <com/sun/star/document/XDocumentLanguages.hpp>
22#include <com/sun/star/linguistic2/LanguageGuessing.hpp>
49 catch (
const uno::Exception &)
51 SAL_WARN(
"fwk",
"failed to get language guessing component" );
58 const uno::Reference< frame::XFrame > & rxFrame,
61 const OUString & rCurLang,
62 const OUString & rKeyboardLang,
63 const OUString & rGuessedTextLang )
68 if( !rCurLang.isEmpty() &&
70 rLangItems.insert( rCurLang );
90 const uno::Reference< linguistic2::XLanguageGuessing >& xLangGuesser( rLangGuessHelper.
GetGuesser() );
91 if ( xLangGuesser.is() && !rGuessedTextLang.isEmpty())
93 css::lang::Locale aLocale(xLangGuesser->guessPrimaryLanguage( rGuessedTextLang, 0, rGuessedTextLang.getLength()) );
101 if( !rKeyboardLang.isEmpty() )
104 rLangItems.insert( rKeyboardLang );
108 Reference< css::frame::XModel >
xModel;
111 Reference< css::frame::XController >
xController = rxFrame->getController();
115 Reference< document::XDocumentLanguages > xDocumentLanguages(
xModel, UNO_QUERY );
121 const sal_Int16 nMaxCount = 7;
122 if ( !xDocumentLanguages.is() )
125 const Sequence< Locale > rLocales( xDocumentLanguages->getDocumentLanguages(
static_cast<sal_Int16
>(nScriptType), nMaxCount ));
126 for (
const Locale& rLocale : rLocales )
128 if ( rLangItems.size() ==
static_cast< size_t >(nMaxCount) )
131 rLangItems.insert( rLocale.Language );
135auto (*g_pGetMultiplexerListener)(
136 css::uno::Reference<css::uno::XComponentContext>
const & xComponentContext,
137 uno::Reference<uno::XInterface>
const&,
138 std::function<bool (uno::Reference<ui::XContextChangeEventListener>
const&)>
const&)
139 -> uno::Reference<ui::XContextChangeEventListener> =
nullptr;
141uno::Reference<ui::XContextChangeEventListener>
143 css::uno::Reference<css::uno::XComponentContext>
const & xComponentContext,
144 uno::Reference<uno::XInterface>
const& xEventFocus,
145 std::function<
bool (uno::Reference<ui::XContextChangeEventListener>
const&)>
const& rPredicate)
const LanguageTag & GetLanguageTag() const
const LanguageTag & GetUILanguageTag() const
static const AllSettings & GetSettings()
LanguageType getLanguageType(bool bResolveSystem=true) const
LanguageTag & makeFallback()
static OUString GetLanguageString(const LanguageType eType)
static LanguageType GetLanguageType(std::u16string_view rStr)
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetGuesser() const
css::uno::Reference< css::linguistic2::XLanguageGuessing > m_xLanguageGuesser
#define LANGUAGE_DONTKNOW
#define SAL_WARN(area, stream)
auto(* g_pGetMultiplexerListener)(css::uno::Reference< css::uno::XComponentContext > const &xComponentContext, uno::Reference< uno::XInterface > const &, std::function< bool(uno::Reference< ui::XContextChangeEventListener > const &)> const &) -> uno::Reference< ui::XContextChangeEventListener >=nullptr
bool IsScriptTypeMatchingToLanguage(SvtScriptType nScriptType, LanguageType nLang)
void FillLangItems(std::set< OUString > &rLangItems, const uno::Reference< frame::XFrame > &rxFrame, const LanguageGuessingHelper &rLangGuessHelper, SvtScriptType nScriptType, const OUString &rCurLang, const OUString &rKeyboardLang, const OUString &rGuessedTextLang)
uno::Reference< ui::XContextChangeEventListener > GetFirstListenerWith_Impl(css::uno::Reference< css::uno::XComponentContext > const &xComponentContext, uno::Reference< uno::XInterface > const &xEventFocus, std::function< bool(uno::Reference< ui::XContextChangeEventListener > const &)> const &rPredicate)
Reference< XController > xController
Reference< XModel > xModel