sw/source/core/text/widorp.cxx |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit 5daab76058e38ae16180b1bea239161b7c8be274
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Thu Apr 3 13:18:57 2025 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Thu Apr 3 18:13:22 2025 +0200

    tdf#165984 sw: don't apply hyphenation zone at disabled hyphenation
    
    Fix unit tests testTdf132599_column and
    testTdf132599_page_in_last_column.
    
    In widorp.cxx, end zone is calculated by the inheritance of
    the hyphenation zone, and as a regression, it was applied in
    the last line enabling hyphenation disabled by hyphenation-keep
    and hyphenation-keep-type.
    
    As an optimization, skip also frame update of the last line, when
    end zone is not different from the hyphenation zone, i.e. when
    the last line has already had correct line break.
    
    Regression from commit 7d384fb1c232f7aa720436bc68dc1de334bf7297
    "tdf#165984 sw cui xmloff: add Paragraph/Column/Page/Spread end zone".
    
    Change-Id: Ia54c9164d5297b5a73649259b4a25a808ece68e3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183673
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/source/core/text/widorp.cxx b/sw/source/core/text/widorp.cxx
index 1c31d2ba2245..5379954d2a7f 100644
--- a/sw/source/core/text/widorp.cxx
+++ b/sw/source/core/text/widorp.cxx
@@ -541,7 +541,11 @@ bool WidowsAndOrphans::FindWidows( SwTextFrame *pFrame, 
SwTextMargin &rLine )
             pMaster->InvalidateSize_();
         }
 
-        if ( ( bKeep || nNoHyphEndZone ) && pMasterPara && 
pMasterPara->GetNext() )
+        // applied end zone, i.e. hyphenation is not disabled completely,
+        // end zone is not zero and different from the hyphenation zone
+        bool bApplyEndZone = !bKeep && nNoHyphEndZone > 0 &&
+                nNoHyphEndZone != rAttr.GetTextHyphenZone();
+        if ( ( bKeep || bApplyEndZone ) && pMasterPara && 
pMasterPara->GetNext() )
         {
             // calculate the beginning of last hyphenated line
             TextFrameIndex nIdx(pMasterPara->GetLen());
@@ -559,14 +563,14 @@ bool WidowsAndOrphans::FindWidows( SwTextFrame *pFrame, 
SwTextMargin &rLine )
             nIdx -= pNext->GetLen();
             // hyphenated line, but not the last remaining one
             // in the case of shifting full line (bKeepLine = false)
-            if ( pNext->IsEndHyph() && ( bKeepLine || !pNext->IsLastHyph() || 
nNoHyphEndZone ) )
+            if ( pNext->IsEndHyph() && ( bKeepLine || !pNext->IsLastHyph() || 
bApplyEndZone ) )
             {
                 nExtraWidLines = rLine.GetLineNr() - m_nWidLines + 1;
                 // shift only a word: disable hyphenation in the line, if 
needed
-                if ( ( bKeepLine || nNoHyphEndZone ) && nExtraWidLines )
+                if ( ( bKeepLine || bApplyEndZone ) && nExtraWidLines )
                 {
                     pMaster->SetNoHyphOffset(nIdx);
-                    pMaster->SetNoHyphEndZone(bKeep ? -1 : nNoHyphEndZone);
+                    pMaster->SetNoHyphEndZone(bApplyEndZone ? nNoHyphEndZone : 
-1);
                     // update also columns and frames
                     pMaster->Prepare( PrepareHint::AdjustSizeWithoutFormatting 
);
                     pMaster->InvalidateSize_();

Reply via email to