sw/source/core/text/guess.cxx |   30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

New commits:
commit c06eee519d8a235385b4910d9ec96e5492dd0e9b
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Aug 22 17:45:12 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Aug 22 20:37:34 2024 +0200

    crashtesting: crash on hyphenation of ooo56629-9.odt
    
    a problem I think since:
    
    commit b5e275f47a54bd7fee39dad516a433fde5be872d
    CommitDate: Fri Jan 19 17:37:41 2024 +0100
    
        tdf#106733 sw: implement CharNoHyphenation
    
    Change-Id: Ic49c136019e93f79818bec7811317bb4f37d6ac1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172287
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index f28d4838a554..f0867a2557a6 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -627,12 +627,28 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, 
SwTextFormatInfo &rInf,
 
         m_nBreakStart = m_nBreakPos;
 
-        bHyph = BreakType::HYPHENATION == aResult.breakType &&
+        bHyph = BreakType::HYPHENATION == aResult.breakType;
+        if (bHyph)
+        {
+            LanguageType aNoHyphLang;
+            if (rPor.InFieldGrp())
+            {
+                // If we are inside a field portion, we use a temporary string 
which
+                // differs from the string at the textnode. Therefore we are 
not allowed
+                // to call the GetLangOfChar function.
+                aNoHyphLang = LANGUAGE_DONTKNOW;
+            }
+            else
+            {
                 // allow hyphenation of the word only if it's not disabled by 
character formatting
-                LANGUAGE_NONE != rInf.GetTextFrame()->GetLangOfChar(
-                        TextFrameIndex( sal_Int32(m_nBreakPos) +
-                                aResult.rHyphenatedWord->getHyphenationPos() ),
-                        1, true, /*bNoneIfNoHyphenation=*/true );
+                aNoHyphLang = rInf.GetTextFrame()->GetLangOfChar(
+                                  TextFrameIndex( sal_Int32(m_nBreakPos) +
+                                            
aResult.rHyphenatedWord->getHyphenationPos() ),
+                                    1, true, /*bNoneIfNoHyphenation=*/true );
+            }
+            // allow hyphenation of the word only if it's not disabled by 
character formatting
+            bHyph = aNoHyphLang != LANGUAGE_NONE;
+        }
 
         if (bHyph && m_nBreakPos != TextFrameIndex(COMPLETE_STRING))
         {
commit 1b8292342f53bf0f5d9ce3bc729078fb5ed49b9d
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Aug 22 17:26:58 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Aug 22 20:37:26 2024 +0200

    update comment to refer to 'GetLangOfChar' intead of 'GetLang'
    
    since:
    
    commit e621b1cda4de9c0765e489a7c80642dd1e819f25
    CommitDate: Fri Jun 8 21:51:32 2018 +0200
    
        sw_redlinehide: add SwTextFrame::GetLangOfChar()
    
    Change-Id: I23264cee245e4698cf5ce111bb4ddafc916ca5d6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172286
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index 661c349f5d70..f28d4838a554 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -544,12 +544,12 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, 
SwTextFormatInfo &rInf,
         // We have to switch the current language if we have a script
         // change at nCutPos. Otherwise LATIN punctuation would never
         // be allowed to be hanging punctuation.
-        // NEVER call GetLang if the string has been modified!!!
+        // NEVER call GetLangOfChar if the string has been modified!!!
         LanguageType aLang = rInf.GetFont()->GetLanguage();
 
         // If we are inside a field portion, we use a temporary string which
         // differs from the string at the textnode. Therefore we are not 
allowed
-        // to call the GetLang function.
+        // to call the GetLangOfChar function.
         if ( m_nCutPos && ! rPor.InFieldGrp() )
         {
             const CharClass& rCC = GetAppCharClass();

Reply via email to