summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-07-08 08:22:33 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-07-08 10:28:45 +0200
commit1c6218df32838dc77da8e15dc5ce47eadad1a13f (patch)
tree3ba3504e924b987a0d4f62972a0d9c6cefeed164
parent86876ff86ef19af20e1c7202e029bbde44051a07 (diff)
Related tdf#98575 Allow editing link even when URL field is not selected
When the cursor is directly before or behind the URL field, just extend the selection so that the link is editable. Change-Id: I80afe40a1c40e2a02ec6adb18dbdb27b6e39c7d1 Reviewed-on: https://gerrit.libreoffice.org/75190 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
-rw-r--r--sd/source/ui/view/drviews7.cxx14
-rw-r--r--sd/source/ui/view/drviewsf.cxx35
2 files changed, 32 insertions, 17 deletions
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index 1e663a8e4b61..801a70d2042a 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1454,16 +1454,14 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
if (pOLV)
{
- const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+ const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
+ if (!pFieldItem)
+ pFieldItem = pOLV->GetFieldAtSelection();
if (pFieldItem)
{
- ESelection aSel = pOLV->GetSelection();
- if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
- {
- const SvxFieldData* pField = pFieldItem->GetField();
- if ( dynamic_cast< const SvxURLField *>( pField ) != nullptr )
- bDisableEditHyperlink = false;
- }
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if (dynamic_cast<const SvxURLField*>(pField))
+ bDisableEditHyperlink = false;
}
}
}
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 0d5081cbfd17..dc6d8f97c3f2 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -93,17 +93,34 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
if (pFieldItem)
{
+ // Make sure the whole field is selected
ESelection aSel = pOLV->GetSelection();
- if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
+ if (aSel.nStartPos == aSel.nEndPos)
{
- const SvxFieldData* pField = pFieldItem->GetField();
- if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
- {
- aHLinkItem.SetName(pUrlField->GetRepresentation());
- aHLinkItem.SetURL(pUrlField->GetURL());
- aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
- bField = true;
- }
+ aSel.nEndPos++;
+ pOLV->SetSelection(aSel);
+ }
+ }
+ if (!pFieldItem)
+ {
+ // Cursor probably behind the field - extend selection to select the field
+ ESelection aSel = pOLV->GetSelection();
+ if (aSel.nStartPos == aSel.nEndPos)
+ {
+ aSel.nStartPos--;
+ pOLV->SetSelection(aSel);
+ pFieldItem = pOLV->GetFieldAtSelection();
+ }
+ }
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
+ {
+ aHLinkItem.SetName(pUrlField->GetRepresentation());
+ aHLinkItem.SetURL(pUrlField->GetURL());
+ aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
+ bField = true;
}
}
if (!bField)