sc/source/core/tool/dbdata.cxx |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

New commits:
commit f6b9c471cace1963e8b625ecfe2c20f5248984eb
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Wed Feb 16 21:43:43 2022 +0100
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Thu Feb 17 11:35:38 2022 +0100

    Handle the possible case of broadcasted row block, tdf#119083 follow-up
    
    Though unlikely and apparently not happening, the changed ScHint
    may theoretically notify for a block of rows, not just one
    address. Do not join out-of-band rows to the dirty header columns.
    
    Change-Id: I524bcbedf063fe6b5ff5b99bc984fcb9dc02b6ab
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130054
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 8d2d146b31d8..3042404e0eaa 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -932,15 +932,30 @@ void ScDBData::Notify( const SfxHint& rHint )
         // multiple cells are affected. Expand the range to what this is
         // listening to. Broadcasted address outside should not happen,
         // but... let it trigger a refresh if.
-        ScRange aHeaderRange( GetHeaderArea());
+        const ScRange aHeaderRange( GetHeaderArea());
+        ScAddress aHintAddress( pScHint->GetStartAddress());
         if (aHeaderRange.IsValid())
         {
             mpContainer->GetDirtyTableColumnNames().Join( aHeaderRange);
-            if (!aHeaderRange.Contains( pScHint->GetRange()))
-                mpContainer->GetDirtyTableColumnNames().Join( 
pScHint->GetRange());
+            // Header range is one row.
+            // The ScHint's "range" is an address with row count.
+            // Though broadcasted is usually only one cell, check for the
+            // possible case of row block and for one cell in the same row.
+            if (aHintAddress.Row() <= aHeaderRange.aStart.Row()
+                    && aHeaderRange.aStart.Row() < aHintAddress.Row() + 
pScHint->GetRowCount())
+            {
+                aHintAddress.SetRow( aHeaderRange.aStart.Row());
+                if (!aHeaderRange.Contains( aHintAddress))
+                    mpContainer->GetDirtyTableColumnNames().Join( 
aHintAddress);
+            }
         }
         else
-            mpContainer->GetDirtyTableColumnNames().Join( pScHint->GetRange());
+        {
+            // We need *some* range in the dirty list even without header area,
+            // otherwise the container would not attempt to call a refresh.
+            aHintAddress.SetRow( nStartRow);
+            mpContainer->GetDirtyTableColumnNames().Join( aHintAddress);
+        }
     }
 
     // Do not refresh column names here, which might trigger unwanted

Reply via email to