sw/qa/extras/uiwriter/uiwriter9.cxx |   26 ++++++++++++++++----------
 sw/source/core/doc/docnum.cxx       |   11 ++++++++---
 sw/source/uibase/shells/txtnum.cxx  |    1 -
 sw/source/uibase/wrtsh/wrtsh1.cxx   |   31 +------------------------------
 4 files changed, 25 insertions(+), 44 deletions(-)

New commits:
commit 91e5d1ef52964dc43875ed62acd766524fa7cc5c
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Tue Mar 19 09:22:34 2024 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Mar 20 16:20:14 2024 +0100

    tdf#159054 sw: fix .uno:DefaultNumber toggle on Heading numbering
    
    This fixes a 7.2 regression from
    commit c456f839a597f537f1c59becd7d0bb6c86248ef8
    Author: Anshu on Wed Jan 6 15:04:16 2021 +0530
        tdf#115965 tdf#92622 NoList default in menu,tool,sidebar
    
    The current implementation would set the number format
    to SVX_NUM_NUMBER_NONE, but it still looks like a number to the toolbar,
    so toggling didn't work since 7.4's bcede3c0ed94d4
    It also never cleared out the prefix/suffix when toggled off,
    and it affected ALL paragraphs using that outline numbering style.
    
    Remove numbering was doing the same kind of thing.
    
    I think the toggle was trying to follow the drop-down behaviour
    of modifying the outline numbering style itself.
    While I think the drop-down handling could be considered appropriate,
    using the toggle to pseudo-disable the entire style just seems wrong.
    
    This patch kills that, and in addition
    automatically gains all the nice undo/redo functionality.
    
    This is one tiny step in making outline numbering go away.
    
    make CppunitTest_sw_uiwriter9 \
        CPPUNIT_TEST_NAME=testTdf159054_disableOutlineNumbering
    
    Change-Id: Id6a24ac25479cb8f35bf1c2c58344390ed7512fe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164985
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx 
b/sw/qa/extras/uiwriter/uiwriter9.cxx
index a18f14c9ad9a..f46d43e537b6 100644
--- a/sw/qa/extras/uiwriter/uiwriter9.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter9.cxx
@@ -429,20 +429,26 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, 
testTdf159054_disableOutlineNumbering)
     dispatchCommand(mxComponent, ".uno:DefaultNumbering", {});
 
     // the selected paragraphs should definitely have the list label removed
-    CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara1, 
"ListLabelString"));
-    CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara2, 
"ListLabelString"));
-    // current implementation: the numbering style itself is changed too - 
affects all Heading 1's.
-    // A valid alternative implementation would be to simply 
SetCountInList(false) for 1st para,
-    // and leave the Outline style format alone.
-    CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara3, 
"ListLabelString"));
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara1, 
"ListLabelString"));
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara2, 
"ListLabelString"));
+    // the third paragraph must retain the existing numbering format
+    CPPUNIT_ASSERT_EQUAL(OUString("A."), getProperty<OUString>(xPara3, 
"ListLabelString"));
 
     // on the selection, simulate pressing the toolbar button to toggle ON 
numbering again
     dispatchCommand(mxComponent, ".uno:DefaultNumbering", {});
 
-    // current implementation: the entire format was removed, so turn 
(default) numbering on
-    CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara1, 
"ListLabelString"));
-    CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara2, 
"ListLabelString"));
-    CPPUNIT_ASSERT_EQUAL(OUString("."), getProperty<OUString>(xPara3, 
"ListLabelString"));
+    // the outline numbering format must be re-applied to the first two 
paragraphs
+    CPPUNIT_ASSERT_EQUAL(OUString("A."), getProperty<OUString>(xPara1, 
"ListLabelString"));
+    CPPUNIT_ASSERT_EQUAL(OUString("B."), getProperty<OUString>(xPara2, 
"ListLabelString"));
+    CPPUNIT_ASSERT_EQUAL(OUString("C."), getProperty<OUString>(xPara3, 
"ListLabelString"));
+
+    // on the selection, simulate a right click - list - No list
+    dispatchCommand(mxComponent, ".uno:RemoveBullets", {});
+
+    // the selected paragraphs should definitely have the list label removed
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara1, 
"ListLabelString"));
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(xPara2, 
"ListLabelString"));
+    CPPUNIT_ASSERT_EQUAL(OUString("A."), getProperty<OUString>(xPara3, 
"ListLabelString"));
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf158375_dde_disable)
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 1c7d1792abe5..73b04ad24122 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -1368,10 +1368,15 @@ void SwDoc::DelNumRules(const SwPaM& rPam, SwRootFrame 
const*const pLayout)
             {
                 pTNd->ChkCondColl();
             }
-            else if( !pOutlNd &&
-                     
static_cast<SwTextFormatColl*>(pTNd->GetFormatColl())->IsAssignedToListLevelOfOutlineStyle()
 )
+            else
             {
-                pOutlNd = pTNd;
+                auto pParaStyle = 
static_cast<SwTextFormatColl*>(pTNd->GetFormatColl());
+                if (pParaStyle && 
pParaStyle->IsAssignedToListLevelOfOutlineStyle())
+                {
+                    if (!pOutlNd)
+                        pOutlNd = pTNd;
+                    pTNd->SetCountedInList(false);
+                }
             }
         }
     }
diff --git a/sw/source/uibase/shells/txtnum.cxx 
b/sw/source/uibase/shells/txtnum.cxx
index 2c25e966c300..bdad7870afbf 100644
--- a/sw/source/uibase/shells/txtnum.cxx
+++ b/sw/source/uibase/shells/txtnum.cxx
@@ -111,7 +111,6 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
         SfxRequest aReq(GetView().GetViewFrame(), FN_NUM_BULLET_ON);
         aReq.AppendItem(SfxBoolItem(FN_PARAM_1, false));
         aReq.Done();
-        GetShell().NumOrBulletOff();
         GetShell().DelNumRules();
         GetShell().EndAllAction();
     }
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 2063029680df..bb90ab645d1c 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1704,36 +1704,7 @@ void SwWrtShell::NumOrBulletOff()
     if (!pCurNumRule)
         return;
 
-    if (pCurNumRule->IsOutlineRule())
-    {
-        SwNumRule aNumRule(*pCurNumRule);
-
-        SwTextNode * pTextNode =
-            sw::GetParaPropsNode(*GetLayout(), 
GetCursor()->GetPoint()->GetNode());
-
-        if (pTextNode)
-        {
-            int nLevel = pTextNode->GetActualListLevel();
-
-            if (nLevel < 0)
-                nLevel = 0;
-
-            if (nLevel >= MAXLEVEL)
-                nLevel = MAXLEVEL - 1;
-
-            SwNumFormat 
aFormat(aNumRule.Get(o3tl::narrowing<sal_uInt16>(nLevel)));
-
-            aFormat.SetNumberingType(SVX_NUM_NUMBER_NONE);
-            aNumRule.Set(nLevel, aFormat);
-
-            // no start or continuation of a list - the outline style is only 
changed.
-            SetCurNumRule( aNumRule, false );
-        }
-    }
-    else
-    {
-        DelNumRules();
-    }
+    DelNumRules();
 
     // #126346# - Cursor can not be anymore in front of
     // a label, because numbering/bullet is switched off.

Reply via email to