summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-07-12 15:30:12 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-07-15 11:32:02 +0200
commit040f348ee00a0d01653b3071be3d9886a08f87fe (patch)
tree0959fbc683b13b76445cdb67d43781fa07620610 /sc
parentf74fbba22e435852c1ee37abf4384be7db6d8607 (diff)
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 <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/sdi/drtxtob.sdi4
-rw-r--r--sc/sdi/editsh.sdi4
-rw-r--r--sc/source/ui/drawfunc/drtxtob.cxx23
-rw-r--r--sc/source/ui/view/editsh.cxx24
-rw-r--r--sc/uiconfig/scalc/popupmenu/celledit.xml3
-rw-r--r--sc/uiconfig/scalc/popupmenu/drawtext.xml2
6 files changed, 56 insertions, 4 deletions
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 <editeng/lrspitem.hxx>
#include <editeng/lspcitem.hxx>
#include <editeng/ulspitem.hxx>
+#include <editeng/urlfieldhelper.hxx>
#include <svx/hlnkitem.hxx>
#include <svx/svdoutl.hxx>
#include <svx/sdooitm.hxx>
@@ -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 <editeng/wghtitem.hxx>
#include <sfx2/basedlgs.hxx>
#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
#include <sfx2/msg.hxx>
#include <sfx2/objface.hxx>
#include <sfx2/objsh.hxx>
@@ -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 @@
</menu:menu>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:OpenHyperlinkOnCursor"/>
- <menu:menuitem menu:id=".uno:HyperlinkDialog"/>
+ <menu:menuitem menu:id=".uno:EditHyperlink"/>
+ <menu:menuitem menu:id=".uno:RemoveHyperlink"/>
<menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:ResetAttributes"/>
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 @@
<menu:menuitem menu:id=".uno:ParagraphDialog"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:OpenHyperlinkOnCursor"/>
+ <menu:menuitem menu:id=".uno:EditHyperlink"/>
+ <menu:menuitem menu:id=".uno:RemoveHyperlink"/>
<menu:menuitem menu:id=".uno:ThesaurusFromContext"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:StandardTextAttributes"/>