desktop/qa/desktop_lib/test_desktop_lib.cxx | 142 +++++++++++++++++++++++++--- include/sfx2/bindings.hxx | 2 include/vcl/window.hxx | 1 sc/inc/scmod.hxx | 2 sc/source/ui/app/scmod.cxx | 86 +++++++++++++--- sc/source/ui/app/transobj.cxx | 5 sc/source/ui/inc/gridwin.hxx | 5 sc/source/ui/inc/tabvwsh.hxx | 10 + sc/source/ui/unoobj/docuno.cxx | 30 ++++- sc/source/ui/view/gridwin.cxx | 90 ++++++++++++----- sc/source/ui/view/select.cxx | 4 sc/source/ui/view/tabvwsh4.cxx | 38 +++++++ sfx2/inc/unoctitm.hxx | 2 sfx2/source/control/bindings.cxx | 22 ++++ sfx2/source/control/unoctitm.cxx | 5 vcl/inc/window.h | 1 vcl/source/window/mouse.cxx | 11 +- vcl/source/window/window.cxx | 1 vcl/source/window/winproc.cxx | 54 ++++++---- 19 files changed, 420 insertions(+), 91 deletions(-)
New commits: commit d9abe4f1af63611f88cc50cb8b7d63dbb2d68991 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Mon Oct 11 14:50:49 2021 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:25:14 2022 +0100 lok: sc: focus gridwin before use commit ef29f8c57dbb73ee3bd2e09ea557b86bf3eacfa6 lok: sc: update ScModelObj::postMouseEvent introduced Drag&drop for online. One missing thing was getting the focus for gridwin before mouse event processing like it is done in LOKPostAsyncEvent Change-Id: I4063340985f7dcc91cf5382631615119e28ea3f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123391 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129471 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 3da3ed1194fe..f225e4609f1d 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -758,6 +758,9 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt if (LokControlHandler::postMouseEvent(pPage, pDrawView, *pGridWindow, nType, aPointHMMDraw, nCount, nButtons, nModifier)) return; + if (!pGridWindow->HasChildPathFocus(true)) + pGridWindow->GrabFocus(); + // Calc operates in pixels... const Point aPosition(nX * pViewData->GetPPTX() + pGridWindow->GetOutOffXPixel(), nY * pViewData->GetPPTY() + pGridWindow->GetOutOffYPixel()); commit e182e257250d3e11de601314af3363ef9d27ce67 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Fri Sep 10 07:16:04 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:25:06 2022 +0100 lok: sc: unit test drag & drop .. Change-Id: I774ece93e5c439c65df50e6a67d1447a062708b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121898 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129470 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 144e2fb1b16c..dc4ad0024cde 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -172,6 +172,7 @@ public: void testWriterComments(); void testSheetOperations(); void testSheetSelections(); + void testSheetDragDrop(); void testContextMenuCalc(); void testContextMenuWriter(); void testContextMenuImpress(); @@ -239,6 +240,7 @@ public: CPPUNIT_TEST(testWriterComments); CPPUNIT_TEST(testSheetOperations); CPPUNIT_TEST(testSheetSelections); + CPPUNIT_TEST(testSheetDragDrop); CPPUNIT_TEST(testContextMenuCalc); CPPUNIT_TEST(testContextMenuWriter); CPPUNIT_TEST(testContextMenuImpress); @@ -1188,6 +1190,132 @@ void DesktopLOKTest::testSheetSelections() } } +void DesktopLOKTest::testSheetDragDrop() +{ + LibLODocument_Impl* pDocument = loadDoc("sheets.ods", LOK_DOCTYPE_SPREADSHEET); + pDocument->pClass->initializeForRendering(pDocument, nullptr); + pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this); + + int row01 = 100; + int col01 = 1100; + int col02 = 2200; + int col03 = 3300; + int col05 = 5500; + int col07 = 5700; + + // Select row 01 from column 01 through column 05 + pDocument->pClass->postMouseEvent(pDocument, + LOK_MOUSEEVENT_MOUSEBUTTONDOWN, + col01, row01, + 1, 1, 0); + pDocument->pClass->postMouseEvent(pDocument, + LOK_MOUSEEVENT_MOUSEMOVE, + col02, row01, + 1, 1, 0); + pDocument->pClass->postMouseEvent(pDocument, + LOK_MOUSEEVENT_MOUSEMOVE, + col05, row01, + 1, 1, 0); + pDocument->pClass->postMouseEvent(pDocument, + LOK_MOUSEEVENT_MOUSEBUTTONUP, + col05, row01, + 1, 1, 0); + + Scheduler::ProcessEventsToIdle(); + { + SfxViewShell* pViewShell = SfxViewShell::Current(); + SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + + OUString sValue; + css::uno::Any aValue; + css::util::URL aURL; + std::unique_ptr<SfxPoolItem> pState; + + aURL.Protocol = ".uno:"; + aURL.Complete = ".uno:Address"; + aURL.Path = "Address"; + aURL.Main = ".uno:Address"; + + pViewFrame->GetBindings().QueryState(pViewFrame->GetBindings().QuerySlotId(aURL), pState); + pState->QueryValue(aValue); + aValue >>= sValue; + CPPUNIT_ASSERT_EQUAL(OUString("Sheet5.A1:E1"), sValue); + } + + // Check selection content + { + char* pMimeType = nullptr; + char* pContent = pDocument->pClass->getTextSelection(pDocument, nullptr, &pMimeType); + std::vector<long> aExpected = {1, 2, 3, 4, 5}; + std::istringstream aContent(pContent); + std::string token; + for (size_t i = 0; i < aExpected.size(); i++) + { + aContent >> token; + CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 10)); + } + + free(pMimeType); + free(pContent); + } + + // drag and drop + pDocument->pClass->postMouseEvent(pDocument, + LOK_MOUSEEVENT_MOUSEBUTTONDOWN, + col01, row01, + 1, 1, 0); + pDocument->pClass->postMouseEvent(pDocument, + LOK_MOUSEEVENT_MOUSEMOVE, + col02, row01, + 1, 1, 0); + pDocument->pClass->postMouseEvent(pDocument, + LOK_MOUSEEVENT_MOUSEMOVE, + col03, row01, + 1, 1, 0); + pDocument->pClass->postMouseEvent(pDocument, + LOK_MOUSEEVENT_MOUSEBUTTONUP, + col07, row01, + 1, 1, 0); + + Scheduler::ProcessEventsToIdle(); + { + SfxViewShell* pViewShell = SfxViewShell::Current(); + SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + + OUString sValue; + css::uno::Any aValue; + css::util::URL aURL; + std::unique_ptr<SfxPoolItem> pState; + + aURL.Protocol = ".uno:"; + aURL.Complete = ".uno:Address"; + aURL.Path = "Address"; + aURL.Main = ".uno:Address"; + + pViewFrame->GetBindings().QueryState(pViewFrame->GetBindings().QuerySlotId(aURL), pState); + pState->QueryValue(aValue); + aValue >>= sValue; + CPPUNIT_ASSERT_EQUAL(OUString("Sheet5.D1:H1"), sValue); + } + + // Check selection content + { + char* pMimeType = nullptr; + char* pContent = pDocument->pClass->getTextSelection(pDocument, nullptr, &pMimeType); + std::vector<long> aExpected = {1, 2, 3, 4, 5}; + std::istringstream aContent(pContent); + std::string token; + for (size_t i = 0; i < aExpected.size(); i++) + { + aContent >> token; + CPPUNIT_ASSERT_EQUAL(aExpected[i], strtol(token.c_str(), nullptr, 10)); + } + + free(pMimeType); + free(pContent); + } +} + namespace { void verifyContextMenuStructure(boost::property_tree::ptree& aRoot) commit c6e14321d4cd41d7034bdcb5c7e36c71d536d489 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Wed Jun 23 08:50:46 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:25:03 2022 +0100 lok: sc: update ScModelObj::postMouseEvent It is intended to process the drag & drop functionality in Calc. Change-Id: I501cd94e309dabf8472e5c5aa9661e7273cd0dae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118879 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117733 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 6a0c084388f5..3da3ed1194fe 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -759,11 +759,28 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt return; // Calc operates in pixels... - const Point aPosition(nX * pViewData->GetPPTX(), nY * pViewData->GetPPTY()); - LokMouseEventData aMouseEventData(nType, aPosition, nCount, MouseEventModifiers::SIMPLECLICK, - nButtons, nModifier); - aMouseEventData.maLogicPosition = aPointHMM; - SfxLokHelper::postMouseEventAsync(pGridWindow, aMouseEventData); + const Point aPosition(nX * pViewData->GetPPTX() + pGridWindow->GetOutOffXPixel(), + nY * pViewData->GetPPTY() + pGridWindow->GetOutOffYPixel()); + + VclEventId aEvent = VclEventId::NONE; + MouseEvent aData(aPosition, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier); + aData.setLogicPosition(aPointHMM); + switch (nType) + { + case LOK_MOUSEEVENT_MOUSEBUTTONDOWN: + aEvent = VclEventId::WindowMouseButtonDown; + break; + case LOK_MOUSEEVENT_MOUSEBUTTONUP: + aEvent = VclEventId::WindowMouseButtonUp; + break; + case LOK_MOUSEEVENT_MOUSEMOVE: + aEvent = VclEventId::WindowMouseMove; + break; + default: + break; + } + + Application::LOKHandleMouseEvent(aEvent, pGridWindow, &aData); } void ScModelObj::setTextSelection(int nType, int nX, int nY) commit 97b5e98dd1d7165dfd650c971466b913dc579d56 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Jun 23 08:18:08 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:58 2022 +0100 lok: reset and cancel properly Drag & Drop action used patch from Henry as a template: https://gerrit.libreoffice.org/c/core/+/118844/17 but without custom actions invocation Change-Id: I8bce66deffee0de16f3c24f009cfee077eb26e82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123243 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129469 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index ef8b424ce4b3..f638bad0e770 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -833,18 +833,12 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven css::uno::Reference<css::datatransfer::dnd::XDropTarget> xDropTarget( pDragWin->ImplGetWindowImpl()->mxDNDListenerContainer, css::uno::UNO_QUERY); - if ((nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) != + if (!xDropTarget.is() || + !xDropTargetDragContext.is() || + (nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) != (MouseSettings::GetStartDragCode() & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE))) { - pDragWin->ImplGetFrameData()->mbDragging = false; - return false; - } - - if (!xDropTargetDragContext.is() || - !xDropTarget.is()) - { - // cancel dragdrop - pDragWin->ImplGetFrameData()->mbDragging = false; + pFrameData->mbStartDragCalled = pFrameData->mbDragging = false; return false; } @@ -864,28 +858,40 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven nEvent == MouseNotifyEvent::MOUSEBUTTONUP && pFrameData->mbDragging) { + css::uno::Reference<css::datatransfer::XTransferable> xTransfer; css::uno::Reference<css::datatransfer::dnd::XDropTargetDropContext> xDropTargetDropContext = new GenericDropTargetDropContext(); css::uno::Reference<css::datatransfer::dnd::XDropTarget> xDropTarget( pDragWin->ImplGetWindowImpl()->mxDNDListenerContainer, css::uno::UNO_QUERY); - if (xDropTargetDropContext.is() && xDropTarget.is()) + if (!xDropTarget.is() || !xDropTargetDropContext.is()) { - static_cast<DNDListenerContainer *>(xDropTarget.get())->fireDropEvent( - xDropTargetDropContext, - css::datatransfer::dnd::DNDConstants::ACTION_MOVE, - aWinPos.X(), - aWinPos.Y(), - (css::datatransfer::dnd::DNDConstants::ACTION_COPY | - css::datatransfer::dnd::DNDConstants::ACTION_MOVE | - css::datatransfer::dnd::DNDConstants::ACTION_LINK), - css::uno::Reference<css::datatransfer::XTransferable>()); + pFrameData->mbStartDragCalled = pFrameData->mbDragging = false; + return false; } - pDragWin->ImplGetFrameData()->mbDragging = false; + Point dragOverPos = pDragWin->ImplFrameToOutput(aMousePos); + static_cast<DNDListenerContainer *>(xDropTarget.get())->fireDropEvent( + xDropTargetDropContext, + css::datatransfer::dnd::DNDConstants::ACTION_MOVE, + dragOverPos.X(), + dragOverPos.Y(), + (css::datatransfer::dnd::DNDConstants::ACTION_COPY | + css::datatransfer::dnd::DNDConstants::ACTION_MOVE | + css::datatransfer::dnd::DNDConstants::ACTION_LINK), + xTransfer); + + pFrameData->mbStartDragCalled = pFrameData->mbDragging = false; return true; } + if (pFrameData->mbDragging) + { + // wrong status, reset + pFrameData->mbStartDragCalled = pFrameData->mbDragging = false; + return false; + } + vcl::Window* pDownWin = pFrameData->mpMouseDownWin; if (pDownWin && nEvent == MouseNotifyEvent::MOUSEMOVE) { commit a286e18c4e99abb91a028d5d97022d820312f209 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Mon Oct 4 08:45:18 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:54 2022 +0100 lok: test: fix testSheetSelections The unit test is selecting again range, it will conflict with the drag & drop because it will drop to new cell address. The unit test will fail, the removed code will be used to a new unit test for drag & drop. Change-Id: I896f5cd7e6b671f3fac95c8ae76e7558fa8dd1d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123062 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129468 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 1504c2f040fe..144e2fb1b16c 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1157,20 +1157,6 @@ void DesktopLOKTest::testSheetSelections() /* * Check if clicking inside the selection deselects the whole selection */ - int const row10 = 2400; - // Select starting from row5, col1 to row10, col5 - pDocument->pClass->postMouseEvent(pDocument, - LOK_MOUSEEVENT_MOUSEBUTTONDOWN, - col1, row5, - 1, 1, 0); - pDocument->pClass->postMouseEvent(pDocument, - LOK_MOUSEEVENT_MOUSEMOVE, - col5, row5, - 1, 1, 0); - pDocument->pClass->postMouseEvent(pDocument, - LOK_MOUSEEVENT_MOUSEBUTTONUP, - col5, row10, - 1, 1, 0); // Click at row5, col4 pDocument->pClass->postMouseEvent(pDocument, commit 7c17d20423207ec705925e108757c2a38afc9579 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Oct 8 08:18:50 2021 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:49 2022 +0100 lok: send drag overlay Change-Id: I1e134fd99dffc4962bacbba97456365ab9347e37 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123242 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129467 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index a2e146862947..09cee6b08db8 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -6668,6 +6668,9 @@ void ScGridWindow::DeleteDragRectOverlay() void ScGridWindow::UpdateDragRectOverlay() { + bool bInPrintTwips = comphelper::LibreOfficeKit::isCompatFlagSet( + comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs); + MapMode aDrawMode = GetDrawMapMode(); MapMode aOldMode = GetMapMode(); if ( aOldMode != aDrawMode ) @@ -6695,7 +6698,8 @@ void ScGridWindow::UpdateDragRectOverlay() if (nY1 < nPosY) nY1 = nPosY; if (nY2 < nPosY) nY2 = nPosY; - Point aScrPos( mrViewData.GetScrPos( nX1, nY1, eWhich ) ); + Point aScrPos(bInPrintTwips ? mrViewData.GetPrintTwipsPos( nX1, nY1 ) + : mrViewData.GetScrPos( nX1, nY1, eWhich ) ); tools::Long nSizeXPix=0; tools::Long nSizeYPix=0; @@ -6706,29 +6710,42 @@ void ScGridWindow::UpdateDragRectOverlay() bool bLayoutRTL = rDoc.IsLayoutRTL( nTab ); tools::Long nLayoutSign = bLayoutRTL ? -1 : 1; + tools::Long nAdjust = comphelper::LibreOfficeKit::isActive() ? 0 : 2; if (rDoc.ValidCol(nX2) && nX2>=nX1) for (i=nX1; i<=nX2; i++) - nSizeXPix += ScViewData::ToPixel( rDoc.GetColWidth( static_cast<SCCOL>(i), nTab ), nPPTX ); + { + tools::Long nWidth = rDoc.GetColWidth( static_cast<SCCOL>(i), nTab ); + nSizeXPix += bInPrintTwips ? nWidth : ScViewData::ToPixel( nWidth, nPPTX ); + } else { aScrPos.AdjustX( -nLayoutSign ); - nSizeXPix += 2; + nSizeXPix += nAdjust; } if (rDoc.ValidRow(nY2) && nY2>=nY1) for (i=nY1; i<=nY2; i++) - nSizeYPix += ScViewData::ToPixel( rDoc.GetRowHeight( i, nTab ), nPPTY ); + { + tools::Long nHeight = rDoc.GetRowHeight( i, nTab ); + nSizeYPix += bInPrintTwips ? nHeight : ScViewData::ToPixel( nHeight, nPPTY ); + } else { aScrPos.AdjustY( -1 ); - nSizeYPix += 2; + nSizeYPix += nAdjust; + } + + if (comphelper::LibreOfficeKit::isActive()) + { + nSizeXPix -= 2; + nSizeYPix -= 2; } - aScrPos.AdjustX( -(2 * nLayoutSign) ); - aScrPos.AdjustY( -2 ); + aScrPos.AdjustX( -(nAdjust * nLayoutSign) ); + aScrPos.AdjustY( -1 * nAdjust ); tools::Rectangle aRect( aScrPos.X(), aScrPos.Y(), - aScrPos.X() + ( nSizeXPix + 2 ) * nLayoutSign, aScrPos.Y() + nSizeYPix + 2 ); + aScrPos.X() + ( nSizeXPix + nAdjust ) * nLayoutSign, aScrPos.Y() + nSizeYPix + nAdjust ); if ( bLayoutRTL ) { aRect.SetLeft( aRect.Right() ); // end position is left @@ -6782,6 +6799,33 @@ void ScGridWindow::UpdateDragRectOverlay() mpOODragRect.reset(new sdr::overlay::OverlayObjectList); mpOODragRect->append(std::move(pOverlay)); } + + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (comphelper::LibreOfficeKit::isActive() && pViewShell) + { + OString aRectsString; + tools::Rectangle aBoundingBox; + + std::vector<tools::Rectangle> aRectangles; + aRectangles.push_back(aRect); + + if (bInPrintTwips) + { + aBoundingBox = aRect; + aRectsString = rectanglesToString(aRectangles); + } + else + { + aRectsString = rectanglesToString(convertPixelToLogical(pViewShell->GetViewData(), aRectangles, aBoundingBox)); + } + + OString sBoundingBoxString = "EMPTY"; + if (!aBoundingBox.IsEmpty()) + sBoundingBoxString = aBoundingBox.toString(); + + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_SELECTION_AREA, sBoundingBoxString.getStr()); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, aRectsString.getStr()); + } } if ( aOldMode != aDrawMode ) commit 5ed6d4829c36cca41b892f1a2a0268751d40ebcd Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Wed Oct 6 18:22:36 2021 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:44 2022 +0100 lok: deglobalize SetDragObject and other Drag and Drop related functions Change-Id: Idbaec91c0ed396da9888c8ed562d2eff35686cca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123209 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129466 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index 4a89fd3424cd..3d327387b75e 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -138,7 +138,7 @@ public: void AnythingChanged(); // Drag & Drop: - const ScDragData& GetDragData() const { return *m_pDragData;} + const ScDragData& GetDragData() const; void SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ); void ResetDragObject(); void SetDragLink( diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index d7fe52ba56e7..a5dbf216f0ec 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -577,40 +577,88 @@ void ScModule::HideDisabledSlots( SfxItemSet& rSet ) void ScModule::ResetDragObject() { - m_pDragData->pCellTransfer = nullptr; - m_pDragData->pDrawTransfer = nullptr; - m_pDragData->pJumpLocalDoc = nullptr; - m_pDragData->aLinkDoc.clear(); - m_pDragData->aLinkTable.clear(); - m_pDragData->aLinkArea.clear(); - m_pDragData->aJumpTarget.clear(); - m_pDragData->aJumpText.clear(); + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->ResetDragObject(); + } + else + { + m_pDragData->pCellTransfer = nullptr; + m_pDragData->pDrawTransfer = nullptr; + m_pDragData->pJumpLocalDoc = nullptr; + m_pDragData->aLinkDoc.clear(); + m_pDragData->aLinkTable.clear(); + m_pDragData->aLinkArea.clear(); + m_pDragData->aJumpTarget.clear(); + m_pDragData->aJumpText.clear(); + } +} + +const ScDragData& ScModule::GetDragData() const +{ + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + assert(pViewShell); + return pViewShell->GetDragData(); + } + else + return *m_pDragData; } void ScModule::SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj ) { - ResetDragObject(); - m_pDragData->pCellTransfer = pCellObj; - m_pDragData->pDrawTransfer = pDrawObj; + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragObject(pCellObj, pDrawObj); + } + else + { + ResetDragObject(); + m_pDragData->pCellTransfer = pCellObj; + m_pDragData->pDrawTransfer = pDrawObj; + } } void ScModule::SetDragLink( const OUString& rDoc, const OUString& rTab, const OUString& rArea ) { - ResetDragObject(); - m_pDragData->aLinkDoc = rDoc; - m_pDragData->aLinkTable = rTab; - m_pDragData->aLinkArea = rArea; + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragLink(rDoc, rTab, rArea); + } + else + { + ResetDragObject(); + m_pDragData->aLinkDoc = rDoc; + m_pDragData->aLinkTable = rTab; + m_pDragData->aLinkArea = rArea; + } } void ScModule::SetDragJump( ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText ) { - ResetDragObject(); + if (comphelper::LibreOfficeKit::isActive()) + { + ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); + if (pViewShell) + pViewShell->SetDragJump(pLocalDoc, rTarget, rText); + } + else + { + ResetDragObject(); - m_pDragData->pJumpLocalDoc = pLocalDoc; - m_pDragData->aJumpTarget = rTarget; - m_pDragData->aJumpText = rText; + m_pDragData->pJumpLocalDoc = pLocalDoc; + m_pDragData->aJumpTarget = rTarget; + m_pDragData->aJumpText = rText; + } } ScDocument* ScModule::GetClipDoc() diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index 438e922297a4..245209e822bb 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -28,6 +28,7 @@ #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> #include <comphelper/fileformat.h> +#include <comphelper/lok.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/servicehelper.hxx> #include <sot/storage.hxx> @@ -51,6 +52,7 @@ #include <scmod.hxx> #include <dragdata.hxx> #include <sortparam.hxx> +#include <tabvwsh.hxx> #include <editeng/paperinf.hxx> #include <editeng/sizeitem.hxx> @@ -176,8 +178,9 @@ ScTransferObj::~ScTransferObj() { SolarMutexGuard aSolarGuard; + bool bIsDisposing = comphelper::LibreOfficeKit::isActive() && !ScTabViewShell::GetActiveViewShell(); ScModule* pScMod = SC_MOD(); - if (pScMod && pScMod->GetDragData().pCellTransfer == this) + if (pScMod && !bIsDisposing && pScMod->GetDragData().pCellTransfer == this) { OSL_FAIL("ScTransferObj wasn't released"); pScMod->ResetDragObject(); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index af9161b3689d..957dab0efcda 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -31,6 +31,7 @@ #include <shellids.hxx> #include <tabprotection.hxx> #include <com/sun/star/ui/dialogs/DialogClosedEvent.hpp> +#include <dragdata.hxx> #include <memory> #include <map> @@ -58,6 +59,7 @@ class ScPageBreakShell; class ScDPObject; class ScNavigatorSettings; class ScRangeName; +class ScDrawTransferObj; struct ScHeaderFieldData; @@ -161,6 +163,8 @@ private: bool mbInSwitch; OUString maName; OUString maScope; + + std::unique_ptr<ScDragData> m_pDragData; private: void Construct( TriState nForceDesignMode ); @@ -406,6 +410,12 @@ public: void EnableEditHyperlink(); virtual tools::Rectangle getLOKVisibleArea() const override; + + const ScDragData& GetDragData() const { return *m_pDragData; } + void SetDragObject(ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj); + void ResetDragObject(); + void SetDragLink(const OUString& rDoc, const OUString& rTab, const OUString& rArea); + void SetDragJump(ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 8130ac4c0e12..e50484525fdb 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -1674,7 +1674,8 @@ ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame, bInPrepareClose(false), bInDispose(false), nCurRefDlgId(0), - mbInSwitch(false) + mbInSwitch(false), + m_pDragData(new ScDragData) { const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); @@ -1865,4 +1866,39 @@ tools::Rectangle ScTabViewShell::getLOKVisibleArea() const return GetViewData().getLOKVisibleArea(); } +void ScTabViewShell::SetDragObject(ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj) +{ + ResetDragObject(); + m_pDragData->pCellTransfer = pCellObj; + m_pDragData->pDrawTransfer = pDrawObj; +} + +void ScTabViewShell::ResetDragObject() +{ + m_pDragData->pCellTransfer = nullptr; + m_pDragData->pDrawTransfer = nullptr; + m_pDragData->pJumpLocalDoc = nullptr; + m_pDragData->aLinkDoc.clear(); + m_pDragData->aLinkTable.clear(); + m_pDragData->aLinkArea.clear(); + m_pDragData->aJumpTarget.clear(); + m_pDragData->aJumpText.clear(); +} + +void ScTabViewShell::SetDragLink(const OUString& rDoc, const OUString& rTab, const OUString& rArea) +{ + ResetDragObject(); + m_pDragData->aLinkDoc = rDoc; + m_pDragData->aLinkTable = rTab; + m_pDragData->aLinkArea = rArea; +} + +void ScTabViewShell::SetDragJump(ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText) +{ + ResetDragObject(); + m_pDragData->pJumpLocalDoc = pLocalDoc; + m_pDragData->aJumpTarget = rTarget; + m_pDragData->aJumpText = rText; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 9a7c52c5c735f95dc8aeefd6ab3e2e332dd4fec1 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu Jul 15 11:31:21 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:40 2022 +0100 lok: sc: simplify drag & drop functions The ScDragData is a global use for private drag & drop in a desktop case, it will be used by tiled rendering case to pass its own local ScDragData per user. Change-Id: I0bca8e6d5c0eab82b69374a67425e2a8d746ef4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118990 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129465 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 3fe6a05a2938..00f6a80bab5d 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -43,6 +43,7 @@ namespace sdr::overlay { class OverlayManager; } class FmFormView; struct ScTableInfo; +struct ScDragData; class ScDPObject; class ScDPFieldButton; class ScOutputData; @@ -253,8 +254,8 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel void DropScroll( const Point& rMousePos ); - sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt ); - sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt ); + sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt, const ScDragData& rData ); + sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt, const ScDragData& rData ); sal_Int8 DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY, const Point& rLogicPos, sal_Int8 nDndAction ); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 229f87851110..a2e146862947 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3810,7 +3810,7 @@ static ScRange lcl_MakeDropRange( const ScDocument& rDoc, SCCOL nPosX, SCROW nPo return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); } -sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt ) +sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt, const ScDragData& rData ) { if ( rEvt.mbLeaving ) { @@ -3819,7 +3819,6 @@ sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt ) return rEvt.mnAction; } - const ScDragData& rData = SC_MOD()->GetDragData(); if ( rData.pCellTransfer ) { // Don't move source that would include filtered rows. @@ -4032,7 +4031,7 @@ sal_Int8 ScGridWindow::AcceptDrop( const AcceptDropEvent& rEvt ) { DrawMarkDropObj( nullptr ); if ( rData.pCellTransfer ) - return AcceptPrivateDrop( rEvt ); // hide drop marker for internal D&D + return AcceptPrivateDrop( rEvt, rData ); // hide drop marker for internal D&D else return rEvt.mnAction; } @@ -4050,7 +4049,7 @@ sal_Int8 ScGridWindow::AcceptDrop( const AcceptDropEvent& rEvt ) aSource.aStart.Row() != 0 || aSource.aEnd.Row() != rThisDoc.MaxRow() ) DropScroll( rEvt.maPosPixel ); - nRet = AcceptPrivateDrop( rEvt ); + nRet = AcceptPrivateDrop( rEvt, rData ); } else { @@ -4309,15 +4308,12 @@ static SotClipboardFormatId lcl_GetDropLinkId( const uno::Reference<datatransfer return nFormatId; } -sal_Int8 ScGridWindow::ExecutePrivateDrop( const ExecuteDropEvent& rEvt ) +sal_Int8 ScGridWindow::ExecutePrivateDrop( const ExecuteDropEvent& rEvt, const ScDragData& rData ) { // hide drop marker bDragRect = false; UpdateDragRectOverlay(); - ScModule* pScMod = SC_MOD(); - const ScDragData& rData = pScMod->GetDragData(); - return DropTransferObj( rData.pCellTransfer, nDragStartX, nDragStartY, PixelToLogic(rEvt.maPosPixel), rEvt.mnAction ); } @@ -4687,7 +4683,7 @@ sal_Int8 ScGridWindow::ExecuteDrop( const ExecuteDropEvent& rEvt ) ScModule* pScMod = SC_MOD(); const ScDragData& rData = pScMod->GetDragData(); if (rData.pCellTransfer) - return ExecutePrivateDrop( rEvt ); + return ExecutePrivateDrop( rEvt, rData ); Point aPos = rEvt.maPosPixel; commit 72f55df23f3ccccffba597b3a529b7b0a6c1b388 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Mon Oct 4 14:14:32 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:37 2022 +0100 sfx2: introduce SfxBindings::QuerySlotId In order to invoke QueryState with the slot id, which it is easier to invoke UNO command states in unit test. Change-Id: I36d72a4381ff8386b1f1af33284ce674cf26acd1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123063 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129464 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/include/sfx2/bindings.hxx b/include/sfx2/bindings.hxx index 47b904d6d113..38104105088d 100644 --- a/include/sfx2/bindings.hxx +++ b/include/sfx2/bindings.hxx @@ -144,6 +144,8 @@ public: void QueryControlState ( sal_uInt16 nSID, boost::property_tree::ptree& rState ); + sal_uInt16 QuerySlotId( const css::util::URL& aURL ); + const SfxPoolItem* ExecuteSynchron( sal_uInt16 nSlot, const SfxPoolItem **pArgs = nullptr); bool Execute( sal_uInt16 nSlot, diff --git a/sfx2/inc/unoctitm.hxx b/sfx2/inc/unoctitm.hxx index a88a64c261ef..5c3926391e90 100644 --- a/sfx2/inc/unoctitm.hxx +++ b/sfx2/inc/unoctitm.hxx @@ -101,6 +101,8 @@ public: void SetMasterUnoCommand( bool bSet ); SfxDispatcher* GetDispatcher_Impl(); + + sal_uInt16 GetId() const; }; class SfxDispatchController_Impl final diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index 5f929846107c..4c891e2e86b7 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -1637,6 +1637,28 @@ void SfxBindings::QueryControlState( sal_uInt16 nSlot, boost::property_tree::ptr } } +sal_uInt16 SfxBindings::QuerySlotId( const util::URL& aURL ) +{ + if (!pImpl) + return 0; + + css::uno::Reference<css::frame::XDispatch> xDispatch = + pImpl->xProv->queryDispatch(aURL, OUString(), 0); + if (!xDispatch.is()) + return 0; + + css::uno::Reference<css::lang::XUnoTunnel> xTunnel(xDispatch, css::uno::UNO_QUERY); + if (!xTunnel.is()) + return 0; + + sal_Int64 nHandle = xTunnel->getSomething(SfxOfficeDispatch::getUnoTunnelId()); + if (!nHandle) + return 0; + + SfxOfficeDispatch* pDispatch = reinterpret_cast<SfxOfficeDispatch*>(sal::static_int_cast<sal_IntPtr>(nHandle)); + return pDispatch->GetId(); +} + void SfxBindings::SetSubBindings_Impl( SfxBindings *pSub ) { if ( pImpl->pSubBindings ) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index b01500814bc9..44350d96ab9a 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -286,6 +286,11 @@ SfxDispatcher* SfxOfficeDispatch::GetDispatcher_Impl() return pImpl->GetDispatcher(); } +sal_uInt16 SfxOfficeDispatch::GetId() const +{ + return pImpl ? pImpl->GetId() : 0; +} + void SfxOfficeDispatch::SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame) { if ( pImpl ) commit f7d274026fbf6443ce3673432c384ce158ecc355 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu Jun 24 07:48:19 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:32 2022 +0100 lok: sc: handle all local mouse tracking for Calc Change-Id: I11f3477c0f966d403e076fc73b7e5507ad6597f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118877 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117779 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 4e3fcdda4a2a..229f87851110 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -2972,16 +2972,13 @@ void ScGridWindow::Tracking( const TrackingEvent& rTEvt ) } else if ( rTEvt.IsTrackingEnded() ) { - if ( !comphelper::LibreOfficeKit::isActive() ) - { - // MouseButtonUp always with matching buttons (eg for test tool, # 63148 #) - // The tracking event will indicate if it was completed and not canceled. - MouseEvent aUpEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(), - rMEvt.GetMode(), nButtonDown, rMEvt.GetModifier() ); - MouseButtonUp( aUpEvt ); - } + // MouseButtonUp always with matching buttons (eg for test tool, # 63148 #) + // The tracking event will indicate if it was completed and not canceled. + MouseEvent aUpEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(), + rMEvt.GetMode(), nButtonDown, rMEvt.GetModifier() ); + MouseButtonUp( aUpEvt ); } - else if ( !comphelper::LibreOfficeKit::isActive() ) + else MouseMove( rMEvt ); } commit 8e2224a9c9664a968123ea866d9d96b72c812fc8 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu Jun 24 07:41:14 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:24 2022 +0100 lok: sc: apply local mouse tracking only for Calc Change-Id: I6c3d4c3c59652f20596e32d3f31c5357b7ed61eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118873 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117778 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 2e4fcf0bc38d..4e3fcdda4a2a 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -409,6 +409,7 @@ ScGridWindow::ScGridWindow( vcl::Window* pParent, ScViewData& rData, ScSplitPos OSL_FAIL("GridWindow: wrong position"); } + SetUseFrameData(comphelper::LibreOfficeKit::isActive()); SetBackground(); SetMapMode(mrViewData.GetLogicMode(eWhich)); commit 9cbe076560b6d9b3502b3d6926679061e9d751bb Author: Henry Castro <hcas...@collabora.com> AuthorDate: Tue Jun 29 20:15:36 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:19 2022 +0100 lok: fix sending mouse pointer The ScGridWindow is a document window, but the Parent is not the notifier, fix it to send mouse pointer when action is drag & drop. Change-Id: I5071dce2566331ce0268a96e023ffd61a1f09e56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118870 Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118139 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx index 2b271891f787..0c77347f89f8 100644 --- a/vcl/source/window/mouse.cxx +++ b/vcl/source/window/mouse.cxx @@ -509,8 +509,10 @@ void Window::SetPointer( PointerStyle nPointer ) // issue mouse pointer events only for document windows // Doc windows' immediate parent SfxFrameViewWindow_Impl is the one with // parent notifier set during initialization - if (GetParent()->ImplGetWindowImpl()->mbLOKParentNotifier && - GetParent()->ImplGetWindowImpl()->mnLOKWindowId == 0) + if ((ImplGetFrameData()->mbDragging && + ImplGetFrameData()->mpMouseDownWin == this) || + (GetParent()->ImplGetWindowImpl()->mbLOKParentNotifier && + GetParent()->ImplGetWindowImpl()->mnLOKWindowId == 0)) { pWin->GetLOKNotifier()->libreOfficeKitViewCallback(LOK_CALLBACK_MOUSE_POINTER, aPointerString.getStr()); } commit 26dd8f2129ce77defa8154e1fe4c688cb1327308 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Wed Jun 30 18:45:38 2021 -0400 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Feb 20 12:24:07 2022 +0100 lok: sc: introduce LocalStartDrag method Update the mouse mode to start drag, otherwise it will conflict with normal cell selection. Change-Id: I6d4939b704114e7de1c9c051459fd02100a7536c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118874 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118203 Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 67a525414d92..747b328d5505 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -1012,6 +1012,7 @@ public: static VclPtr<vcl::Window> SaveFocus(); static void EndSaveFocus(const VclPtr<vcl::Window>& xFocusWin); + void LocalStartDrag(); void CaptureMouse(); void ReleaseMouse(); bool IsMouseCaptured() const; diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx index c2433e57c277..cabbcd09d074 100644 --- a/sc/source/ui/view/select.cxx +++ b/sc/source/ui/view/select.cxx @@ -31,6 +31,7 @@ #include <markdata.hxx> #include <gridwin.hxx> #include <sfx2/lokhelper.hxx> +#include <comphelper/lok.hxx> #if defined(_WIN32) #define SC_SELENG_REFMODE_UPDATE_INTERVAL_MIN 65 @@ -205,6 +206,9 @@ void ScViewFunctionSet::BeginDrag() if ( pWindow->IsTracking() ) pWindow->EndTracking( TrackingEventFlags::Cancel ); // abort selecting + if (comphelper::LibreOfficeKit::isActive()) + pWindow->LocalStartDrag(); + SC_MOD()->SetDragObject( pTransferObj.get(), nullptr ); // for internal D&D pTransferObj->StartDrag( pWindow, nDragActions ); diff --git a/vcl/inc/window.h b/vcl/inc/window.h index c932a4d09d51..b5ef63ab327c 100644 --- a/vcl/inc/window.h +++ b/vcl/inc/window.h @@ -176,6 +176,7 @@ struct ImplFrameData css::uno::Reference< css::datatransfer::clipboard::XClipboard > mxClipboard; bool mbInternalDragGestureRecognizer; + bool mbDragging; VclPtr<VirtualDevice> mpBuffer; ///< Buffer for the double-buffering bool mbInBufferedPaint; ///< PaintHelper is in the process of painting into this buffer. tools::Rectangle maBufferedRect; ///< Rectangle in the buffer that has to be painted to the screen. diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx index dc50e3c11233..2b271891f787 100644 --- a/vcl/source/window/mouse.cxx +++ b/vcl/source/window/mouse.cxx @@ -442,6 +442,11 @@ void Window::SetMouseTransparent( bool bTransparent ) mpWindowImpl->mbMouseTransparent = bTransparent; } +void Window::LocalStartDrag() +{ + ImplGetFrameData()->mbDragging = true; +} + void Window::CaptureMouse() { ImplSVData* pSVData = ImplGetSVData(); diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 2072de7e0ed0..152d163f3399 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -807,6 +807,7 @@ ImplFrameData::ImplFrameData( vcl::Window *pWindow ) maResizeIdle.SetPriority( TaskPriority::RESIZE ); maResizeIdle.SetInvokeHandler( LINK( pWindow, vcl::Window, ImplHandleResizeTimerHdl ) ); mbInternalDragGestureRecognizer = false; + mbDragging = false; mbInBufferedPaint = false; mnDPIX = 96; mnDPIY = 96; diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index 041edf1849d3..ef8b424ce4b3 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -824,21 +824,27 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven pFrameData->mbMouseIn = false; vcl::Window* pDragWin = pFrameData->mpMouseDownWin; - if (pDragWin && pFrameData->mbStartDragCalled && - nEvent == MouseNotifyEvent::MOUSEMOVE) + if (pDragWin && + nEvent == MouseNotifyEvent::MOUSEMOVE && + pFrameData->mbDragging) { css::uno::Reference<css::datatransfer::dnd::XDropTargetDragContext> xDropTargetDragContext = new GenericDropTargetDragContext(); css::uno::Reference<css::datatransfer::dnd::XDropTarget> xDropTarget( pDragWin->ImplGetWindowImpl()->mxDNDListenerContainer, css::uno::UNO_QUERY); - if (!xDropTargetDragContext.is() || - !xDropTarget.is() || - (nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) == + if ((nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) != (MouseSettings::GetStartDragCode() & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE))) + { + pDragWin->ImplGetFrameData()->mbDragging = false; + return false; + } + + if (!xDropTargetDragContext.is() || + !xDropTarget.is()) { // cancel dragdrop - pDragWin->ImplGetFrameData()->mbStartDragCalled = false; + pDragWin->ImplGetFrameData()->mbDragging = false; return false; } @@ -854,8 +860,9 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven return true; } - if (pDragWin && pFrameData->mbStartDragCalled && - nEvent == MouseNotifyEvent::MOUSEBUTTONUP) + if (pDragWin && + nEvent == MouseNotifyEvent::MOUSEBUTTONUP && + pFrameData->mbDragging) { css::uno::Reference<css::datatransfer::dnd::XDropTargetDropContext> xDropTargetDropContext = new GenericDropTargetDropContext(); @@ -875,7 +882,8 @@ bool ImplLOKHandleMouseEvent(const VclPtr<vcl::Window>& xWindow, MouseNotifyEven css::uno::Reference<css::datatransfer::XTransferable>()); } - pDragWin->ImplGetFrameData()->mbStartDragCalled = false; + pDragWin->ImplGetFrameData()->mbDragging = false; + return true; } vcl::Window* pDownWin = pFrameData->mpMouseDownWin;