summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-07-08 08:22:33 +0200
committerPranam Lashkari <lpranam@collabora.com>2021-02-05 09:11:23 +0100
commit2608bbd931b4fcbeeb517b8e6afb5a126e41ba72 (patch)
tree37204358a5daa3f6c04ac5064c18bfd3a8dd163e
parent7c4435b8c69ca3a9d5ff1d280152cec1bfc51a1e (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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110054 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-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 bff0ceea6f29..bf7e6a426231 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -1446,16 +1446,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 f9f941e78cf5..24edd1887ad9 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -99,17 +99,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)