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.cicek@collabora.com>
Change-Id: I38578297cc1aadefe8c43033cdb14b9460e22c90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175827
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
(cherry picked from commit 459a9401f342210d7f6ab8fe6fa780ae28413ef6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176825
Tested-by: Jenkins
This commit is contained in:
Bayram Çiçek
2024-11-20 12:14:09 +01:00
committed by Caolán McNamara
parent 5e3a88a283
commit 57d123745a
+22 -3
View File
@@ -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);
}
}
}