summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/source/editeng/editview.cxx28
-rw-r--r--editeng/source/outliner/outlvw.cxx25
-rw-r--r--include/editeng/editview.hxx3
-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
9 files changed, 88 insertions, 28 deletions
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index c0ad8484af5d..637f36a73cba 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1225,6 +1225,34 @@ const SvxFieldItem* EditView::GetFieldAtSelection() const
return nullptr;
}
+const SvxFieldData* EditView::GetFieldAtCursor()
+{
+ const SvxFieldItem* pFieldItem = GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ // Make sure the whole field is selected
+ ESelection aSel = GetSelection();
+ if (aSel.nStartPos == aSel.nEndPos)
+ {
+ aSel.nEndPos++;
+ SetSelection(aSel);
+ }
+ }
+ if (!pFieldItem)
+ {
+ // Cursor probably behind the field - extend selection to select the field
+ ESelection aSel = GetSelection();
+ if (aSel.nStartPos == aSel.nEndPos)
+ {
+ aSel.nStartPos--;
+ SetSelection(aSel);
+ pFieldItem = GetFieldAtSelection();
+ }
+ }
+
+ return pFieldItem ? pFieldItem->GetField() : nullptr;
+}
+
void EditView::SetInvalidateMore( sal_uInt16 nPixel )
{
pImpEditView->SetInvalidateMore( nPixel );
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 43efbbb1615c..670807932277 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1319,30 +1319,7 @@ const SvxFieldItem* OutlinerView::GetFieldAtSelection() const
const SvxFieldData* OutlinerView::GetFieldAtCursor()
{
- const SvxFieldItem* pFieldItem = GetFieldAtSelection();
- if (pFieldItem)
- {
- // Make sure the whole field is selected
- ESelection aSel = GetSelection();
- if (aSel.nStartPos == aSel.nEndPos)
- {
- aSel.nEndPos++;
- SetSelection(aSel);
- }
- }
- if (!pFieldItem)
- {
- // Cursor probably behind the field - extend selection to select the field
- ESelection aSel = GetSelection();
- if (aSel.nStartPos == aSel.nEndPos)
- {
- aSel.nStartPos--;
- SetSelection(aSel);
- pFieldItem = GetFieldAtSelection();
- }
- }
-
- return pFieldItem ? pFieldItem->GetField() : nullptr;
+ return pEditView->GetFieldAtCursor();
}
void OutlinerView::SetInvalidateMore( sal_uInt16 nPixel )
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 15ac187cdfa5..9adb6bacdca8 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -29,6 +29,7 @@
#include <vcl/errcode.hxx>
#include <vcl/vclptr.hxx>
#include <editeng/editstat.hxx>
+#include <editeng/flditem.hxx>
#include <svl/languageoptions.hxx>
#include <editeng/editdata.hxx>
#include <com/sun/star/uno/Reference.h>
@@ -276,6 +277,8 @@ public:
const SvxFieldItem* GetField( const Point& rPos, sal_Int32* pnPara = nullptr, sal_Int32* pnPos = nullptr ) const;
const SvxFieldItem* GetFieldAtSelection() const;
+ /// Select and return the field at the current cursor position
+ const SvxFieldData* GetFieldAtCursor();
void SetInvalidateMore( sal_uInt16 nPixel );
sal_uInt16 GetInvalidateMore() const;
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"/>