sc/qa/unit/tiledrendering/data/autofilter.ods |binary sc/qa/unit/tiledrendering/tiledrendering.cxx | 20 ++++++++++++++++++++ sc/source/ui/inc/gridwin.hxx | 1 + sc/source/ui/view/gridwin.cxx | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+)
New commits: commit f49d4bcd1ec9a89d128d7d71a811bd84fe00cc4b Author: Gökay Şatır <[email protected]> AuthorDate: Thu Jul 10 14:52:37 2025 +0300 Commit: Gökay ŞATIR <[email protected]> CommitDate: Mon Jul 14 07:01:45 2025 +0200 Calc LOK: Needs to send the autofilter position to Online side. 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 <[email protected]> Change-Id: I8afaf81595be4e666375699b1efc4efd9b138a17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187634 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Gökay ŞATIR <[email protected]> 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 Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/autofilter.ods differ diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index a99bd60e5a36..f292919d22dd 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -3596,6 +3596,26 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testCursorVisibilityAfterPaste) CPPUNIT_ASSERT_EQUAL(true, aView.m_textCursorVisible); } +CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testAutoFilterPosition) +{ + ScModelObj* pModelObj = createDoc("autofilter.ods"); + ScTestViewCallback 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 8aa035882110..8bb4ac1e4cff 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -237,6 +237,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 3ffbcfc72f2e..a170d87b53d9 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -146,6 +146,7 @@ #include <sfx2/lokhelper.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <tools/json_writer.hxx> #include <vector> #include <boost/property_tree/json_parser.hpp> @@ -937,6 +938,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(); @@ -1008,6 +1025,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));
