sw/qa/uitest/writer_tests7/tdf144439.py |   22 ++++++++++++++++++++
 sw/source/core/doc/number.cxx           |   35 +++++++++++++-------------------
 2 files changed, 37 insertions(+), 20 deletions(-)

New commits:
commit d595b4436320fcd3ce0a84968d16d51f512a1e87
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Dec 19 11:40:24 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Dec 20 07:19:10 2023 +0100

    tdf#154864 Changing starting number of numbered list does nothing
    
    regression from
        commit cd3c16fbcb4f8e5e4c4448bc7cda96e8476d6aec
        Author: Noel Grandin <noel.gran...@collabora.co.uk>
        Date:   Fri Oct 14 15:14:13 2022 +0200
        tdf#129101 CTRL+A & Cut very slow
        avoid repeated invalidation of number tree, shaves 90% time off
    
    The problem is that, after the above change, InvalidateListTree is not
    called late enough to force invalidation of all necessary stuff.
    
    So simply delay that until we do re-validation in SwNumRule::Validate.
    
    Change-Id: I796cc34fe7d66d4876ee06286a8af7029a759eca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160974
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit 62afdd6f82c51cee330b278518622eaf1776e2c4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161011

diff --git a/sw/qa/uitest/writer_tests7/tdf144439.py 
b/sw/qa/uitest/writer_tests7/tdf144439.py
index 34911ee4c542..4d0ce465d5ac 100644
--- a/sw/qa/uitest/writer_tests7/tdf144439.py
+++ b/sw/qa/uitest/writer_tests7/tdf144439.py
@@ -40,6 +40,28 @@ class tdf144439(UITestCase):
             self.assertEqual(Para1.String, "List item")
             self.assertEqual(Para1.getPropertyValue("ListLabelString"), "1.1.")
 
+            # this section is checking tdf#154864 - Changing starting number 
of numbered list does nothing
+            #
+
+            with 
self.ui_test.execute_dialog_through_command(".uno:BulletsAndNumberingDialog") 
as xDialog:
+                # Select custom tab
+                xTabs = xDialog.getChild("tabcontrol")
+                select_pos(xTabs, "5")
+
+                # Select numbering
+                xNumFmt = xDialog.getChild("numfmtlb")
+                select_by_text(xNumFmt, "1, 2, 3, ...")
+
+                # Increase "start at"
+                xStartAt = xDialog.getChild("startat")
+                xStartAt.executeAction("UP", tuple())
+                xStartAt.executeAction("UP", tuple())
+
+            Paragraphs = document.Text.createEnumeration()
+            Para1 = Paragraphs.nextElement()
+            self.assertEqual(Para1.String, "List item")
+            self.assertEqual(Para1.getPropertyValue("ListLabelString"), "1.3.")
+
     def test_tdf144439_outline(self):
         with self.ui_test.create_doc_in_start_center("writer") as document:
             xWriterDoc = self.xUITest.getTopFocusWindow()
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index d2cb98924e0f..9cef97ddc2fe 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -153,10 +153,17 @@ void SwNumRule::RemoveTextNode( SwTextNode& rTextNode )
 {
     tTextNodeList::iterator aIter =
         std::find( maTextNodeList.begin(), maTextNodeList.end(), &rTextNode );
+    if ( aIter == maTextNodeList.end() )
+        return;
 
-    if ( aIter != maTextNodeList.end() )
+    maTextNodeList.erase( aIter );
+
+    // Just in case we remove a node after we have marked the rule invalid, 
but before we have validated the tree
+    if (mbInvalidRuleFlag)
     {
-        maTextNodeList.erase( aIter );
+        SwList* pList = 
rTextNode.GetDoc().getIDocumentListsAccess().getListByName( 
rTextNode.GetListId() );
+        if (pList)
+            pList->InvalidateListTree();
     }
 }
 
@@ -1051,23 +1058,6 @@ void SwNumRule::SetInvalidRule(bool bFlag)
     if (mbInvalidRuleFlag == bFlag)
         return;
 
-    if (bFlag)
-    {
-        o3tl::sorted_vector< SwList* > aLists;
-        for ( const SwTextNode* pTextNode : maTextNodeList )
-        {
-            // #i111681# - applying patch from cmc
-            SwList* pList = 
pTextNode->GetDoc().getIDocumentListsAccess().getListByName( 
pTextNode->GetListId() );
-            OSL_ENSURE( pList, "<SwNumRule::SetInvalidRule(..)> - list at 
which the text node is registered at does not exist. This is a serious issue.");
-            if ( pList )
-            {
-                aLists.insert( pList );
-            }
-        }
-        for ( auto aList : aLists )
-            aList->InvalidateListTree();
-    }
-
     mbInvalidRuleFlag = bFlag;
 }
 
@@ -1168,8 +1158,13 @@ void SwNumRule::Validate(const SwDoc& rDoc)
     o3tl::sorted_vector< SwList* > aLists;
     for ( const SwTextNode* pTextNode : maTextNodeList )
     {
-        aLists.insert( 
pTextNode->GetDoc().getIDocumentListsAccess().getListByName( 
pTextNode->GetListId() ) );
+        SwList* pList = 
pTextNode->GetDoc().getIDocumentListsAccess().getListByName( 
pTextNode->GetListId() );
+        aLists.insert( pList );
     }
+
+    for ( auto aList : aLists )
+        aList->InvalidateListTree();
+
     for ( auto aList : aLists )
         aList->ValidateListTree(rDoc);
 

Reply via email to