sw/source/core/text/guess.cxx |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

New commits:
commit ebeaced0f7bbdbeec9762b85cc6f92a1f8610240
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Thu Aug 22 17:45:12 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Aug 23 11:42:27 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>
    (cherry picked from commit c06eee519d8a235385b4910d9ec96e5492dd0e9b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172268
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index 661c349f5d70..d16fddef5224 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))
         {

Reply via email to