summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGökay Şatır <gokaysatir@gmail.com>2025-07-10 14:52:37 +0300
committerAndras Timar <andras.timar@collabora.com>2025-09-09 12:47:46 +0200
commit74780936283c3969f1f141b3a179c743ec84a56e (patch)
tree3fa8028cd4a4b636fbc82933d14586ed63b7e978
parentd0417d85ce7725bdc964732b28af07fedc44e451 (diff)
Calc LOK: Needs to send the autofilter position to Online side.cp-24.04.16-3
Issue: JSDialogs are not sending the position of the popup windows. To precisely position the popup window on the Online side, we need to have the column and row number of the autofilter button. This improvement sends the column and row indexes. Also a test added. Signed-off-by: Gökay Şatır <gokaysatir@gmail.com> Change-Id: I8afaf81595be4e666375699b1efc4efd9b138a17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187634 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Gökay ŞATIR <gokaysatir@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190674 Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sc/qa/unit/tiledrendering/data/autofilter.odsbin0 -> 11730 bytes
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx20
-rw-r--r--sc/source/ui/inc/gridwin.hxx1
-rw-r--r--sc/source/ui/view/gridwin.cxx18
4 files changed, 39 insertions, 0 deletions
diff --git a/sc/qa/unit/tiledrendering/data/autofilter.ods b/sc/qa/unit/tiledrendering/data/autofilter.ods
new file mode 100644
index 000000000000..a4ad405fdcc2
--- /dev/null
+++ b/sc/qa/unit/tiledrendering/data/autofilter.ods
Binary files differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index d8faaca18469..c56231406c8a 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -4091,6 +4091,26 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testFreezeRowOrColumn)
CPPUNIT_ASSERT_EQUAL(std::string("8"), index);
}
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testAutoFilterPosition)
+{
+ ScModelObj* pModelObj = createDoc("autofilter.ods");
+ ViewCallback aView;
+ pModelObj->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
+ ScTabViewShell* pView = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+
+ pView->SetCursor(0, 0); // Go to A1.
+ Scheduler::ProcessEventsToIdle();
+
+ // Use autofilter button shortcut (ALT + DOWNARROW) to avoid coordinate based click.
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::DOWN | KEY_MOD2);
+ pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::DOWN | KEY_MOD2);
+ Scheduler::ProcessEventsToIdle();
+
+ // We should have the autofilter position callback.
+ auto it = aView.m_aStateChanges.find("AutoFilterInfo");
+ CPPUNIT_ASSERT(it != aView.m_aStateChanges.end());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index bbaba1d1a201..6109f0eef341 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -229,6 +229,7 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::DocWindow, public DropTarget
bool DoPageFieldSelection( SCCOL nCol, SCROW nRow );
bool DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
+ void SendAutofilterPopupPosition(SCCOL nCol, SCROW nRow);
void DoPushPivotButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt, bool bButton, bool bPopup, bool bMultiField );
void DoPushPivotToggle( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 8419806e2aab..bda7836aacfc 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -145,6 +145,7 @@
#include <sfx2/lokhelper.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <tools/json_writer.hxx>
#include <vector>
#include <boost/property_tree/json_parser.hpp>
@@ -936,6 +937,22 @@ void collectUIInformation(const OUString& aRow, const OUString& aCol , const OUS
}
+void ScGridWindow::SendAutofilterPopupPosition(SCCOL nCol, SCROW nRow) {
+ ScTabViewShell* pViewShell = mrViewData.GetViewShell();
+ if (pViewShell)
+ {
+ tools::JsonWriter writer;
+ writer.put("commandName", "AutoFilterInfo");
+ {
+ const auto aState = writer.startNode("state");
+ writer.put("column", nCol);
+ writer.put("row", nRow);
+ }
+ OString info = writer.finishAndGetAsOString();
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, info);
+ }
+}
+
void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
{
SCTAB nTab = mrViewData.GetTabNo();
@@ -1007,6 +1024,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
aPos.setY(aPos.getY() / fZoomY);
nSizeX = nSizeX / fZoomX;
nSizeY = nSizeY / fZoomY;
+ SendAutofilterPopupPosition(nCol, nRow); // Send the position of the autofilter popup.
}
tools::Rectangle aCellRect(bLOKActive ? aPos : OutputToScreenPixel(aPos), Size(nSizeX, nSizeY));