lok calc: allow remove and edit hypelink outside of edit mode
Right now .uno:EditHyperlink and .uno:RemoveHyperlink only work on edit mode or inside a draw object, but LOK_CALLBACK_HYPERLINK_CLICKED is dispatched outside of edit mode. Change-Id: I26fb0c2e1ac438631ea71e33282e201f0a215d05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170171 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit decb72c909b3f8296fb5c6b57b267c1079a865be) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170478 Tested-by: Jenkins
This commit is contained in:
committed by
Miklos Vajna
parent
1d2c42037c
commit
d54f049ee7
@@ -184,6 +184,8 @@ interface CellSelection
|
||||
SID_CLIPBOARD_FORMAT_ITEMS [ ExecMethod = ExecuteEdit; StateMethod = GetClipState; ]
|
||||
SID_EXTERNAL_SOURCE [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
||||
SID_COPY_HYPERLINK_LOCATION [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
||||
SID_EDIT_HYPERLINK [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
||||
SID_REMOVE_HYPERLINK [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
|
||||
FID_MERGE_ON [ ExecMethod = Execute; StateMethod = GetState; ]
|
||||
FID_MERGE_OFF [ ExecMethod = Execute; StateMethod = GetState; ]
|
||||
FID_MERGE_TOGGLE [ ExecMethod = Execute; StateMethod = GetState; ]
|
||||
|
||||
@@ -396,7 +396,8 @@ public:
|
||||
/// Get the cell selection, coordinates are in logic units.
|
||||
void GetCellSelection(std::vector<tools::Rectangle>& rLogicRects);
|
||||
|
||||
bool GetEditUrl( const Point& rPos, OUString* pName=nullptr, OUString* pUrl=nullptr, OUString* pTarget=nullptr );
|
||||
bool GetEditUrl(const Point& rPos, OUString* pName = nullptr, OUString* pUrl = nullptr,
|
||||
OUString* pTarget = nullptr, SCCOL* pnCol= nullptr);
|
||||
|
||||
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <svx/hlnkitem.hxx>
|
||||
#include <basic/sbxcore.hxx>
|
||||
#include <editeng/editview.hxx>
|
||||
#include <editeng/urlfieldhelper.hxx>
|
||||
#include <svtools/cliplistener.hxx>
|
||||
|
||||
#include <cellsh.hxx>
|
||||
@@ -3223,8 +3224,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
|
||||
{
|
||||
const Point aPoint(pPosX->GetValue() * rData.GetPPTX(),
|
||||
pPosY->GetValue() * rData.GetPPTY());
|
||||
OUString aName, aUrl;
|
||||
if (pWindow->GetEditUrl(aPoint, &aName, &aUrl))
|
||||
OUString aUrl;
|
||||
if (pWindow->GetEditUrl(aPoint, nullptr, &aUrl))
|
||||
{
|
||||
uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
|
||||
= pWindow->GetClipboard();
|
||||
@@ -3236,6 +3237,55 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
|
||||
}
|
||||
break;
|
||||
|
||||
case SID_EDIT_HYPERLINK:
|
||||
case SID_REMOVE_HYPERLINK:
|
||||
{
|
||||
ScViewData& rData = GetViewData();
|
||||
ScGridWindow* pWindow = rData.GetActiveWin();
|
||||
const SfxInt32Item* pPosX = rReq.GetArg<SfxInt32Item>(FN_PARAM_1);
|
||||
const SfxInt32Item* pPosY = rReq.GetArg<SfxInt32Item>(FN_PARAM_2);
|
||||
if (pWindow && pPosX && pPosY)
|
||||
{
|
||||
const Point aPoint(pPosX->GetValue() * rData.GetPPTX(),
|
||||
pPosY->GetValue() * rData.GetPPTY());
|
||||
SCCOL nPosX;
|
||||
SCROW nPosY;
|
||||
ScSplitPos eWhich = rData.GetActivePart();
|
||||
rData.GetPosFromPixel(aPoint.X(), aPoint.Y(), eWhich, nPosX, nPosY);
|
||||
if (pWindow->GetEditUrl(aPoint, nullptr, nullptr, nullptr, &nPosX))
|
||||
{
|
||||
pTabViewShell->SetCursor(nPosX, nPosY);
|
||||
pTabViewShell->UpdateInputHandler();
|
||||
pScMod->SetInputMode(SC_INPUT_TABLE);
|
||||
ScInputHandler* pHdl = pScMod->GetInputHdl(pTabViewShell);
|
||||
if (rData.HasEditView(eWhich) && pHdl)
|
||||
{
|
||||
// Set text cursor where clicked
|
||||
EditView* pEditView = rData.GetEditView(eWhich);
|
||||
MouseEvent aEditEvt(aPoint, 1, MouseEventModifiers::SYNTHETIC,
|
||||
MOUSE_LEFT, 0);
|
||||
pEditView->MouseButtonDown(aEditEvt);
|
||||
pEditView->MouseButtonUp(aEditEvt);
|
||||
if (nSlot == SID_REMOVE_HYPERLINK)
|
||||
{
|
||||
pHdl->DataChanging();
|
||||
URLFieldHelper::RemoveURLField(*pEditView);
|
||||
pHdl->DataChanged();
|
||||
pHdl->EnterHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
pEditView->SelectFieldAtCursor();
|
||||
rData.GetViewShell()->GetViewFrame().GetDispatcher()->Execute(
|
||||
SID_HYPERLINK_DIALOG);
|
||||
}
|
||||
rReq.Done();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
OSL_FAIL("incorrect slot in ExecuteEdit");
|
||||
break;
|
||||
|
||||
@@ -2593,7 +2593,8 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
|
||||
// Only execute on ButtonUp, if ButtonDown also was done on a URL
|
||||
|
||||
OUString aName, aUrl, aTarget;
|
||||
if ( GetEditUrl( rMEvt.GetPosPixel(), &aName, &aUrl, &aTarget ) )
|
||||
SCCOL nUrlCellX;
|
||||
if (GetEditUrl(rMEvt.GetPosPixel(), &aName, &aUrl, &aTarget, &nUrlCellX))
|
||||
{
|
||||
nMouseStatus = SC_GM_NONE; // Ignore double-click
|
||||
bool isTiledRendering = comphelper::LibreOfficeKit::isActive();
|
||||
@@ -2613,7 +2614,8 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
|
||||
{
|
||||
aPos = rMEvt.GetPosPixel();
|
||||
mrViewData.GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
|
||||
OString aCursor = pViewShell->GetViewData().describeCellCursorAt(nPosX, nPosY);
|
||||
OString aCursor
|
||||
= pViewShell->GetViewData().describeCellCursorAt(nUrlCellX, nPosY);
|
||||
double fPPTX = pViewShell->GetViewData().GetPPTX();
|
||||
int mouseX = aPos.X() / fPPTX;
|
||||
int mouseY = aPos.Y() / fPPTX;
|
||||
@@ -2741,7 +2743,7 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
|
||||
OUString aName, aUrl, aTarget;
|
||||
ScTabViewShell* pViewShell = mrViewData.GetViewShell();
|
||||
if (pViewShell && nPosX == m_nDownPosX && nPosY == m_nDownPosY
|
||||
&& GetEditUrl(aPos, &aName, &aUrl, &aTarget))
|
||||
&& GetEditUrl(aPos, &aName, &aUrl, &aTarget, &nPosX))
|
||||
{
|
||||
OString aMsg(aUrl.toUtf8() + " coordinates: "
|
||||
+ pViewShell->GetViewData().describeCellCursorAt(nPosX, nPosY) + ", "
|
||||
@@ -5886,8 +5888,8 @@ std::vector<UrlData> ScGridWindow::GetEditUrls(const ScAddress& rSelectedCell)
|
||||
return vUrls;
|
||||
}
|
||||
|
||||
bool ScGridWindow::GetEditUrl( const Point& rPos,
|
||||
OUString* pName, OUString* pUrl, OUString* pTarget )
|
||||
bool ScGridWindow::GetEditUrl(const Point& rPos, OUString* pName, OUString* pUrl, OUString* pTarget,
|
||||
SCCOL* pnCol)
|
||||
{
|
||||
ScTabViewShell* pViewSh = mrViewData.GetViewShell();
|
||||
ScInputHandler* pInputHdl = nullptr;
|
||||
@@ -5910,6 +5912,8 @@ bool ScGridWindow::GetEditUrl( const Point& rPos,
|
||||
bool bFound = lcl_GetHyperlinkCell(rDoc, nPosX, nPosY, nTab, aCell, sURL);
|
||||
if( !bFound )
|
||||
return false;
|
||||
if (pnCol)
|
||||
*pnCol = nPosX;
|
||||
|
||||
const ScPatternAttr* pPattern = rDoc.GetPattern( nPosX, nPosY, nTab );
|
||||
// bForceToTop = sal_False, use the cell's real position
|
||||
|
||||
+2
-2
@@ -9705,7 +9705,7 @@ SfxVoidItem OpenHyperlinkOnCursor SID_OPEN_HYPERLINK
|
||||
]
|
||||
|
||||
SfxVoidItem EditHyperlink SID_EDIT_HYPERLINK
|
||||
()
|
||||
(SfxInt32Item PositionX FN_PARAM_1, SfxInt32Item PositionY FN_PARAM_2)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -12459,7 +12459,7 @@ SfxVoidItem SignSignatureLine SID_SIGN_SIGNATURELINE
|
||||
]
|
||||
|
||||
SfxVoidItem RemoveHyperlink SID_REMOVE_HYPERLINK
|
||||
()
|
||||
(SfxInt32Item PositionX FN_PARAM_1, SfxInt32Item PositionY FN_PARAM_2)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
|
||||
Reference in New Issue
Block a user