From 040f348ee00a0d01653b3071be3d9886a08f87fe Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 12 Jul 2019 15:30:12 +0200 Subject: tdf#62561 Add remove/edit hyperlink to calc context menu Change-Id: Idb1b96dc4e95be40a796f9178975207099101b87 Reviewed-on: https://gerrit.libreoffice.org/75497 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- sc/sdi/drtxtob.sdi | 4 +++- sc/sdi/editsh.sdi | 4 +++- sc/source/ui/drawfunc/drtxtob.cxx | 23 ++++++++++++++++++++++- sc/source/ui/view/editsh.cxx | 24 ++++++++++++++++++++++++ sc/uiconfig/scalc/popupmenu/celledit.xml | 3 ++- sc/uiconfig/scalc/popupmenu/drawtext.xml | 2 ++ 6 files changed, 56 insertions(+), 4 deletions(-) (limited to 'sc') diff --git a/sc/sdi/drtxtob.sdi b/sc/sdi/drtxtob.sdi index e1a7f4aa09d1..89be1b24c3ee 100644 --- a/sc/sdi/drtxtob.sdi +++ b/sc/sdi/drtxtob.sdi @@ -129,7 +129,9 @@ interface TableDrawText SID_HYPERLINK_SETLINK [ ExecMethod = Execute; Export = FALSE; ] SID_HYPERLINK_GETLINK [ StateMethod = GetState; Export = FALSE; ] - SID_OPEN_HYPERLINK [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + SID_OPEN_HYPERLINK [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + SID_EDIT_HYPERLINK [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + SID_REMOVE_HYPERLINK [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] SID_ENABLE_HYPHENATION [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] SID_TEXTDIRECTION_LEFT_TO_RIGHT [ ExecMethod = Execute; StateMethod = GetAttrState; Export = FALSE; ] diff --git a/sc/sdi/editsh.sdi b/sc/sdi/editsh.sdi index 9e1e5d4a0509..5718fc63407e 100644 --- a/sc/sdi/editsh.sdi +++ b/sc/sdi/editsh.sdi @@ -78,7 +78,9 @@ interface TableText SID_HYPERLINK_SETLINK [ ExecMethod = Execute; Export = FALSE; ] SID_HYPERLINK_GETLINK [ StateMethod = GetState; Export = FALSE; ] - SID_OPEN_HYPERLINK [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + SID_OPEN_HYPERLINK [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + SID_EDIT_HYPERLINK [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] + SID_REMOVE_HYPERLINK [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ] SID_TRANSLITERATE_SENTENCE_CASE [ ExecMethod = ExecuteTrans; StateMethod = GetState; Export = FALSE; ] SID_TRANSLITERATE_TITLE_CASE [ ExecMethod = ExecuteTrans; StateMethod = GetState; Export = FALSE; ] diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index c37b8f11e7ed..877434afee80 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -328,6 +329,20 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq ) } break; + case SID_EDIT_HYPERLINK: + { + // Ensure the field is selected first + pOutView->GetFieldAtCursor(); + pViewData->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_HYPERLINK_DIALOG); + } + break; + + case SID_REMOVE_HYPERLINK: + { + URLFieldHelper::RemoveURLField(pOutliner, pOutView); + } + break; + case SID_ENABLE_HYPHENATION: case SID_TEXTDIRECTION_LEFT_TO_RIGHT: case SID_TEXTDIRECTION_TOP_TO_BOTTOM: @@ -406,7 +421,9 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) rSet.Put(aHLinkItem); } - if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SfxItemState::UNKNOWN ) + if (rSet.GetItemState(SID_OPEN_HYPERLINK) != SfxItemState::UNKNOWN + || rSet.GetItemState(SID_EDIT_HYPERLINK) != SfxItemState::UNKNOWN + || rSet.GetItemState(SID_REMOVE_HYPERLINK) != SfxItemState::UNKNOWN) { SdrView* pView = pViewData->GetScDrawView(); OutlinerView* pOutView = pView->GetTextEditOutlinerView(); @@ -421,7 +438,11 @@ void ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) } } if( !bEnable ) + { rSet.DisableItem( SID_OPEN_HYPERLINK ); + rSet.DisableItem( SID_EDIT_HYPERLINK ); + rSet.DisableItem( SID_REMOVE_HYPERLINK ); + } } if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SfxItemState::UNKNOWN ) diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx index f458a0a75b8e..c2e3e3a4c118 100644 --- a/sc/source/ui/view/editsh.cxx +++ b/sc/source/ui/view/editsh.cxx @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -627,6 +628,27 @@ void ScEditShell::Execute( SfxRequest& rReq ) ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() ); return; } + case SID_EDIT_HYPERLINK: + { + // Ensure the field is selected first + pEditView->GetFieldAtCursor(); + pViewData->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( + SID_HYPERLINK_DIALOG); + } + break; + case SID_REMOVE_HYPERLINK: + { + // Ensure the field is selected first + pEditView->GetFieldAtCursor(); + const SvxURLField* pURLField = GetURLField(); + if (pURLField) + { + ESelection aSel = pEditView->GetSelection(); + pEditView->GetEditEngine()->QuickInsertText(pURLField->GetRepresentation(), aSel); + } + + } + break; case FN_INSERT_SOFT_HYPHEN: lclInsertCharacter( pTableView, pTopView, CHAR_SHY ); @@ -752,6 +774,8 @@ void ScEditShell::GetState( SfxItemSet& rSet ) break; case SID_OPEN_HYPERLINK: + case SID_EDIT_HYPERLINK: + case SID_REMOVE_HYPERLINK: { if ( !GetURLField() ) rSet.DisableItem( nWhich ); diff --git a/sc/uiconfig/scalc/popupmenu/celledit.xml b/sc/uiconfig/scalc/popupmenu/celledit.xml index ea0aed174520..526b47df2453 100644 --- a/sc/uiconfig/scalc/popupmenu/celledit.xml +++ b/sc/uiconfig/scalc/popupmenu/celledit.xml @@ -25,7 +25,8 @@ - + + diff --git a/sc/uiconfig/scalc/popupmenu/drawtext.xml b/sc/uiconfig/scalc/popupmenu/drawtext.xml index b070b3231df3..d05b1bf8a57d 100644 --- a/sc/uiconfig/scalc/popupmenu/drawtext.xml +++ b/sc/uiconfig/scalc/popupmenu/drawtext.xml @@ -24,6 +24,8 @@ + + -- cgit