sc/source/ui/view/tabview4.cxx |   25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

New commits:
commit 459a9401f342210d7f6ab8fe6fa780ae28413ef6
Author:     Bayram Çiçek <bayram.ci...@collabora.com>
AuthorDate: Wed Oct 30 16:29:16 2024 +0300
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Oct 31 12:59:06 2024 +0100

    sc: autofill: send to-be-deleted cell addresses
    
    with LOK_CALLBACK_TOOLTIP
    
    also avoid nullptr ViewShells:
    
    -        if (comphelper::LibreOfficeKit::isActive())
    +        if (ScTabViewShell* pLOKViewShell
    +            = comphelper::LibreOfficeKit::isActive() ? 
aViewData.GetViewShell() : nullptr)
    
    Signed-off-by: Bayram Çiçek <bayram.ci...@collabora.com>
    Change-Id: I38578297cc1aadefe8c43033cdb14b9460e22c90
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175827
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 6fdfa0cefb81..99353eac81be 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -288,7 +288,26 @@ void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB 
nCurZ )
         aHelpStr = aHelpStr.replaceFirst("%2", OUString::number(nCols) );
     }
     else if ( aViewData.GetDelMark( aDelRange ) )
+    {
         aHelpStr = ScResId( STR_QUICKHELP_DELETE );
+
+        if (ScTabViewShell* pLOKViewShell
+            = comphelper::LibreOfficeKit::isActive() ? 
aViewData.GetViewShell() : nullptr)
+        {
+            // autofill: collect the cell addresses that will be deleted
+            OUString sDeleteCellAddress
+                = OUString::Concat(OUString::number(aDelRange.aStart.Row()) + 
" "
+                                   + OUString::number(aDelRange.aStart.Col()) 
+ " "
+                                   + OUString::number(aDelRange.aEnd.Row()) + 
" "
+                                   + OUString::number(aDelRange.aEnd.Col()));
+
+            tools::JsonWriter writer;
+            writer.put("type", "autofilldeletecells");
+            writer.put("delrange", sDeleteCellAddress);
+            OString sPayloadString = writer.finishAndGetAsOString();
+            pLOKViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TOOLTIP, 
sPayloadString);
+        }
+    }
     else if ( nEndX != aMarkRange.aEnd.Col() || nEndY != aMarkRange.aEnd.Row() 
)
         aHelpStr = rDoc.GetAutoFillPreview( aMarkRange, nEndX, nEndY );
 
@@ -313,7 +332,8 @@ void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB 
nCurZ )
         sTipString = aHelpStr;
         sTopParent = pWin;
 
-        if (comphelper::LibreOfficeKit::isActive())
+        if (ScTabViewShell* pLOKViewShell
+            = comphelper::LibreOfficeKit::isActive() ? 
aViewData.GetViewShell() : nullptr)
         {
             // we need to use nAddX and nAddX here because we need the next 
row&column address
             OUString sCol = OUString::number(nEndX + nAddX);
@@ -327,8 +347,7 @@ void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB 
nCurZ )
             writer.put("text", sTipString);
             writer.put("celladdress", sCellAddress);
             OString sPayloadString = writer.finishAndGetAsOString();
-            ScTabViewShell* pViewShell = aViewData.GetViewShell();
-            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TOOLTIP, 
sPayloadString);
+            pLOKViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TOOLTIP, 
sPayloadString);
         }
     }
 }

Reply via email to