lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx |   14 +++++++++-----
 lingucomponent/source/hyphenator/hyphen/hyphenimp.hxx |    2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 29091962399dfae3707b1bbd981ce037c97684ec
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sat Nov 23 09:38:02 2024 +0500
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sat Nov 23 10:03:17 2024 +0100

    tdf#164005: make sure to initialize locales before use of Hyphenator
    
    Change-Id: I23ab742801ab00b68e4f8c5e7bc415c401e28c37
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177076
    Reviewed-by: Mike Kaganski <[email protected]>
    Tested-by: Jenkins

diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx 
b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
index cc35bf3aa84d..c528318dc33d 100644
--- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
+++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
@@ -108,7 +108,7 @@ PropertyHelper_Hyphenation& Hyphenator::GetPropHelper_Impl()
     return *pPropHelper;
 }
 
-Sequence< Locale > SAL_CALL Hyphenator::getLocales()
+void Hyphenator::ensureLocales()
 {
     MutexGuard  aGuard( GetLinguMutex() );
 
@@ -212,17 +212,19 @@ Sequence< Locale > SAL_CALL Hyphenator::getLocales()
             aSuppLocales.realloc(0);
         }
     }
+}
 
+Sequence< Locale > SAL_CALL Hyphenator::getLocales()
+{
+    MutexGuard aGuard(GetLinguMutex());
+    ensureLocales();
     return aSuppLocales;
 }
 
 sal_Bool SAL_CALL Hyphenator::hasLocale(const Locale& rLocale)
 {
     MutexGuard  aGuard( GetLinguMutex() );
-
-    if (!aSuppLocales.hasElements())
-        getLocales();
-
+    ensureLocales();
     return comphelper::findValue(aSuppLocales, rLocale) != -1;
 }
 
@@ -658,6 +660,7 @@ Reference < XHyphenatedWord > SAL_CALL 
Hyphenator::queryAlternativeSpelling(
         sal_Int16 nIndex,
         const css::uno::Sequence< css::beans::PropertyValue >& aProperties )
 {
+    ensureLocales();
     // Firstly we allow only one plus character before the hyphen to avoid to 
miss the right break point:
     for (int extrachar = 1; extrachar <= 2; extrachar++)
     {
@@ -686,6 +689,7 @@ Reference< XPossibleHyphens > SAL_CALL 
Hyphenator::createPossibleHyphens( const
                       aWord, Sequence< sal_Int16 >() );
     }
 
+    ensureLocales();
     int k = -1;
     for (size_t j = 0; j < mvDicts.size(); ++j)
     {
diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.hxx 
b/lingucomponent/source/hyphenator/hyphen/hyphenimp.hxx
index 45ebca112544..f60639ff2aa6 100644
--- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.hxx
+++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.hxx
@@ -119,6 +119,8 @@ private:
         static OUString makeLowerCase(const OUString&, CharClass const *);
         static OUString makeUpperCase(const OUString&, CharClass const *);
         static OUString makeInitCap(const OUString&, CharClass const *);
+
+    void ensureLocales();
 };
 
 #endif

Reply via email to