From 96928bb74a993f3020ed71776d11b9849501f90c Mon Sep 17 00:00:00 2001 From: Marco Cecchetti Date: Thu, 10 May 2018 23:13:12 +0200 Subject: [PATCH] lok: sc: ctrl-clicking links doesn't work I think there is no reason for not execuring the code below if ((bDouble || bIsTiledRendering) && .... ) { ... } for both desktop and online. So since the code for open the clicked URL is below such if clause, I changed the code so that we return only when it's really a double click event. Moreover I reverted back the code for executing the list validation pop-up to its original place, since there is no more the need to have it executed in two places. Change-Id: Idbec2e6e45cd7ee8282005169e1132a11d4cac33 Reviewed-on: https://gerrit.libreoffice.org/54151 Tested-by: Jenkins Reviewed-by: Andras Timar --- editeng/source/editeng/impedit2.cxx | 12 ++- include/vcl/ITiledRenderable.hxx | 2 +- sc/source/core/data/global.cxx | 6 -- sc/source/ui/view/gridwin.cxx | 153 +++++++++++++++------------- 4 files changed, 96 insertions(+), 77 deletions(-) diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 4c2c0c73a3e4..f3c9930ed9e8 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -587,7 +587,17 @@ bool ImpEditEngine::MouseButtonUp( const MouseEvent& rMEvt, EditView* pView ) { if ( ( rMEvt.GetClicks() == 1 ) && rMEvt.IsLeft() && !rMEvt.IsMod2() ) { - const SvxFieldItem* pFld = pView->GetFieldUnderMousePointer(); + + const SvxFieldItem* pFld; + if ( comphelper::LibreOfficeKit::isActive() ) + { + Point aLogicClick = pView->GetWindow()->PixelToLogic( rMEvt.GetPosPixel() ); + pFld = pView->GetField( aLogicClick ); + } + else + { + pFld = pView->GetFieldUnderMousePointer(); + } if ( pFld ) { EditPaM aPaM( aCurSel.Max() ); diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index 46ad7677e910..7f8f7ce4c332 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -59,7 +59,7 @@ namespace vcl { PointerStyle::HSizeBar, "col-resize" }, { PointerStyle::VSizeBar, "row-resize" }, { PointerStyle::Hand, "grab" }, - { PointerStyle::RefHand, "grabbing" }, + { PointerStyle::RefHand, "pointer" }, // Pen, Magnify, Fill, Rotate // HShear, VShear // Mirror, Crook, Crop, MovePoint, MoveBezierWeight diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 75326696257c..a356cc362047 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -791,12 +791,6 @@ bool ScGlobal::EETextObjEqual( const EditTextObject* pObj1, void ScGlobal::OpenURL(const OUString& rURL, const OUString& rTarget) { - if (comphelper::LibreOfficeKit::isActive()) - { - if(SfxViewShell* pViewShell = SfxViewShell::Current()) - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, rURL.toUtf8().getStr()); - } - // OpenURL is always called in the GridWindow by mouse clicks in some way or another. // That's why pScActiveViewShell and nScClickMouseModifier are correct. // SvtSecurityOptions to access Libreoffice global security parameters diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 1e45e781f021..f3dacb97f4f7 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -1805,56 +1805,6 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta } } -void lcl_executeList( const ScViewData* pViewData, ScModule* pScMod, const ScMarkData& rMark ) -{ - pViewData->GetView()->SelectionChanged(); - - SfxDispatcher* pDisp = pViewData->GetViewShell()->GetDispatcher(); - bool bFormulaMode = pScMod->IsFormulaMode(); - OSL_ENSURE( pDisp || bFormulaMode, "Cursor moved on inactive View ?" ); - - // #i14927# execute SID_CURRENTCELL (for macro recording) only if there is no - // multiple selection, so the argument string completely describes the selection, - // and executing the slot won't change the existing selection (executing the slot - // here and from a recorded macro is treated equally) - if ( pDisp && !bFormulaMode && !rMark.IsMultiMarked() ) - { - OUString aAddr; // CurrentCell - if( rMark.IsMarked() ) - { - ScRange aScRange; - rMark.GetMarkArea( aScRange ); - aAddr = aScRange.Format(ScRefFlags::RANGE_ABS); - if ( aScRange.aStart == aScRange.aEnd ) - { - // make sure there is a range selection string even for a single cell - aAddr = aAddr + ":" + aAddr; - } - - //! SID_MARKAREA does not exist anymore ??? - //! What happens when selecting with the cursor ??? - } - else // only move cursor - { - ScAddress aScAddress( pViewData->GetCurX(), pViewData->GetCurY(), 0 ); - aAddr = aScAddress.Format(ScRefFlags::ADDR_ABS); - } - - SfxStringItem aPosItem( SID_CURRENTCELL, aAddr ); - // We don't want to align to the cursor position because if the - // cell cursor isn't visible after making selection, it would jump - // back to the origin of the selection where the cell cursor is. - SfxBoolItem aAlignCursorItem( FN_PARAM_2, false ); - pDisp->ExecuteList(SID_CURRENTCELL, - SfxCallMode::SLOT | SfxCallMode::RECORD, - { &aPosItem, &aAlignCursorItem }); - - pViewData->GetView()->InvalidateAttribs(); - - } - pViewData->GetViewShell()->SelectionChanged(); -} - void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) { aCurMousePos = rMEvt.GetPosPixel(); @@ -2104,7 +2054,10 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) bool bIsTiledRendering = comphelper::LibreOfficeKit::isActive(); bool bDouble = ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() ); - if ((bDouble || bIsTiledRendering) && !bRefMode && (nMouseStatus == SC_GM_DBLDOWN || bIsTiledRendering) && !pScMod->IsRefDialogOpen()) + if ((bDouble || bIsTiledRendering) + && !bRefMode + && (nMouseStatus == SC_GM_DBLDOWN || (bIsTiledRendering && nMouseStatus != SC_GM_URLDOWN)) + && !pScMod->IsRefDialogOpen()) { // data pilot table Point aPos = rMEvt.GetPosPixel(); @@ -2193,20 +2146,13 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) } } - if (bIsTiledRendering) - { - ScTabView* pTabView = pViewData->GetView(); - if (rMEvt.IsLeft() && pTabView->GetSelEngine()->SelMouseButtonUp( rMEvt )) - pTabView->SelectionChanged(); - } - if ( bIsTiledRendering && rMEvt.IsLeft() && pViewData->GetView()->GetSelEngine()->SelMouseButtonUp( rMEvt ) ) { - lcl_executeList( pViewData, pScMod, rMark); - return; + pViewData->GetView()->SelectionChanged(); } - return; + if ( bDouble ) + return; } // Links in edit cells @@ -2298,7 +2244,53 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) if ( rMEvt.IsLeft() && pViewData->GetView()->GetSelEngine()->SelMouseButtonUp( rMEvt ) ) { - lcl_executeList( pViewData, pScMod, rMark); + pViewData->GetView()->SelectionChanged(); + + SfxDispatcher* pDisp = pViewData->GetViewShell()->GetDispatcher(); + bool bFormulaMode = pScMod->IsFormulaMode(); + OSL_ENSURE( pDisp || bFormulaMode, "Cursor moved on inactive View ?" ); + + // #i14927# execute SID_CURRENTCELL (for macro recording) only if there is no + // multiple selection, so the argument string completely describes the selection, + // and executing the slot won't change the existing selection (executing the slot + // here and from a recorded macro is treated equally) + if ( pDisp && !bFormulaMode && !rMark.IsMultiMarked() ) + { + OUString aAddr; // CurrentCell + if( rMark.IsMarked() ) + { + ScRange aScRange; + rMark.GetMarkArea( aScRange ); + aAddr = aScRange.Format(ScRefFlags::RANGE_ABS); + if ( aScRange.aStart == aScRange.aEnd ) + { + // make sure there is a range selection string even for a single cell + aAddr = aAddr + ":" + aAddr; + } + + //! SID_MARKAREA does not exist anymore ??? + //! What happens when selecting with the cursor ??? + } + else // only move cursor + { + ScAddress aScAddress( pViewData->GetCurX(), pViewData->GetCurY(), 0 ); + aAddr = aScAddress.Format(ScRefFlags::ADDR_ABS); + } + + SfxStringItem aPosItem( SID_CURRENTCELL, aAddr ); + // We don't want to align to the cursor position because if the + // cell cursor isn't visible after making selection, it would jump + // back to the origin of the selection where the cell cursor is. + SfxBoolItem aAlignCursorItem( FN_PARAM_2, false ); + pDisp->ExecuteList(SID_CURRENTCELL, + SfxCallMode::SLOT | SfxCallMode::RECORD, + { &aPosItem, &aAlignCursorItem }); + + pViewData->GetView()->InvalidateAttribs(); + + } + pViewData->GetViewShell()->SelectionChanged(); + return; } } @@ -2409,11 +2401,27 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt ) if ( nPosX >= nEditCol && nPosX <= nEndCol && nPosY >= nEditRow && nPosY <= nEndRow ) { + if ( !pEditView ) + { + SetPointer( Pointer( PointerStyle::Text ) ); + return; + } + + const SvxFieldItem* pFld; + if ( comphelper::LibreOfficeKit::isActive() ) + { + Point aLogicClick = pEditView->GetWindow()->PixelToLogic( aPos ); + pFld = pEditView->GetField( aLogicClick ); + } + else + { + pFld = pEditView->GetFieldUnderMousePointer(); + } // Field can only be URL field bool bAlt = rMEvt.IsMod2(); - if ( !bAlt && !nButtonDown && pEditView && pEditView->GetFieldUnderMousePointer() ) + if ( !bAlt && !nButtonDown && pFld ) SetPointer( Pointer( PointerStyle::RefHand ) ); - else if ( pEditView && pEditView->GetEditEngine()->IsVertical() ) + else if ( pEditView->GetEditEngine()->IsVertical() ) SetPointer( Pointer( PointerStyle::TextVertical ) ); else SetPointer( Pointer( PointerStyle::Text ) ); @@ -5232,11 +5240,18 @@ bool ScGridWindow::GetEditUrl( const Point& rPos, EditView aTempView(pEngine.get(), this); aTempView.SetOutputArea( aLogicEdit ); - MapMode aOld = GetMapMode(); - SetMapMode(aEditMode); // no return anymore - bool bRet = extractURLInfo(aTempView.GetFieldUnderMousePointer(), pName, pUrl, pTarget); - SetMapMode(aOld); - + bool bRet; + if (comphelper::LibreOfficeKit::isActive()) + { + bRet = extractURLInfo(aTempView.GetField(aLogicClick), pName, pUrl, pTarget); + } + else + { + MapMode aOld = GetMapMode(); + SetMapMode(aEditMode); // no return anymore + bRet = extractURLInfo(aTempView.GetFieldUnderMousePointer(), pName, pUrl, pTarget); + SetMapMode(aOld); + } return bRet; } return false;