svx/source/sidebar/paragraph/ParaPropertyPanel.cxx |    7 +++++++
 svx/source/sidebar/paragraph/ParaPropertyPanel.hxx |    1 +
 2 files changed, 8 insertions(+)

New commits:
commit e499c8d2fba41c5958e8611f6cb007cca3e62ed9
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Mar 17 13:57:07 2025 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Mar 17 17:20:53 2025 +0100

    tdf#165354 sw HyphenationKeepLine: apply it on the sidebar
    
    Use the default HyphenationKeepLine=true, when hyphenation
    is enabled by using the sidebar (i.e. Move Line = false).
    Otherwise use the actual HyphenationKeepLine setting,
    when KeepLineType is modified by the sidebar buttons (instead
    of using always the (mostly bad) Move Line = true).
    
    Follow-up to commit f8b9cd8fd13897094a014ad06df406f0c78adc62
    "tdf#165354 sw xmloff: implement HyphenationKeepLine – part 2"
    and commit 3e02ffb76c484a05cdc140d8a10bc3d993fe8320
    "tdf#i165354 sw offapi DOCX: implement HyphenationKeepLine – part 1".
    
    Change-Id: I25bb8b7a1be518f152b056870a313008aa180edb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183031
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: Jenkins

diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx 
b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
index c729f76bc710..b6ecad25c21a 100644
--- a/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
+++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.cxx
@@ -262,6 +262,7 @@ void ParaPropertyPanel::fill_hyphenzone(SvxHyphenZoneItem & 
rHyphen)
                     : 
mxTBxHyphenation->get_item_active("HyphenateLastFullLine")
                         ? 3
                         : 4;
+    rHyphen.SetKeepLine(mbKeepLine);
 }
 
 // for hyphenation
@@ -524,6 +525,11 @@ void ParaPropertyPanel::StateChangedHyphenationImpl( 
SfxItemState eState, const
         mxTBxHyphenation->set_item_active("HyphenateColumn", 
!pOldItem->IsKeep() || pOldItem->GetKeepType() < 3);
         mxTBxHyphenation->set_item_active("HyphenatePage", !pOldItem->IsKeep() 
|| pOldItem->GetKeepType() < 2);
         mxTBxHyphenation->set_item_active("HyphenateSpread", 
!pOldItem->IsKeep() || pOldItem->GetKeepType() < 1);
+        // When hyphenation is disabled, set HyphenationKeepLine to the 
default true (i.e. Move Line = false),
+        // so enabling hyphenation on the sidebar will result the preferred 
"Move Line = false" state.
+        // When hyphenation is enabled, store and use the actual value of 
HyphenationKeepLine at
+        // changing HyphenationKeepType using the sidebar buttons.
+        mbKeepLine = !bHyph || pOldItem->IsKeepLine();
         set_hyphenation_other_visible( bHyph );
     }
 }
@@ -601,6 +607,7 @@ ParaPropertyPanel::ParaPropertyPanel(weld::Widget* pParent,
       mxCompound(m_xBuilder->weld_metric_spin_button(u"compound"_ustr, 
FieldUnit::CHAR)),
       mxWordLength(m_xBuilder->weld_metric_spin_button(u"wordlength"_ustr, 
FieldUnit::CHAR)),
       mxZone(m_xBuilder->weld_metric_spin_button(u"zone"_ustr, FieldUnit::CM)),
+      mbKeepLine(false),
       mbUpdatingHyphenateButtons(false),
       maTxtLeft (0),
       maUpper (0),
diff --git a/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx 
b/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
index aadce3f71b3d..aa43825c3f22 100644
--- a/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
+++ b/svx/source/sidebar/paragraph/ParaPropertyPanel.hxx
@@ -115,6 +115,7 @@ private:
     std::optional<SvxRelativeField> mxCompound;
     std::optional<SvxRelativeField> mxWordLength;
     std::optional<SvxRelativeField> mxZone;
+    bool mbKeepLine;
     bool mbUpdatingHyphenateButtons;
 
     // Data Member

Reply via email to