summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2021-01-28 22:20:36 +0530
committerPranam Lashkari <lpranam@collabora.com>2021-02-05 09:11:40 +0100
commit7c5b671c5e57782c8872347b9adc91ef0ba8adec (patch)
tree6cfe49dd50daf14d1aed61da850014e0bb586c44
parent2608bbd931b4fcbeeb517b8e6afb5a126e41ba72 (diff)
avoid automatical text selection in impress text box
to avoid character besides the cursor getting selected after adding hyperlink in text box Change-Id: I35609829fe0f43568001eaf95ca2ebe7c50aa17d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110314 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--sd/source/ui/view/drviews7.cxx16
-rw-r--r--sd/source/ui/view/drviewsf.cxx39
2 files changed, 9 insertions, 46 deletions
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index bf7e6a426231..a74e9858df4e 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -37,6 +37,7 @@
#include <editeng/sizeitem.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/lrspitem.hxx>
+#include <editeng/urlfieldhelper.hxx>
#include <officecfg/Office/Common.hxx>
#include <officecfg/Office/Impress.hxx>
#include <svx/svxids.hrc>
@@ -1443,19 +1444,8 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
{
if( mpDrawView->IsTextEdit() )
{
- OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
- if (pOLV)
- {
- const SvxFieldItem* pFieldItem = pOLV->GetFieldUnderMousePointer();
- if (!pFieldItem)
- pFieldItem = pOLV->GetFieldAtSelection();
- if (pFieldItem)
- {
- const SvxFieldData* pField = pFieldItem->GetField();
- if (dynamic_cast<const SvxURLField*>(pField))
- bDisableEditHyperlink = false;
- }
- }
+ if (URLFieldHelper::IsCursorAtURLField(mpDrawView->GetTextEditOutlinerView()))
+ bDisableEditHyperlink = false;
}
else
{
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 24edd1887ad9..28c0c2db8f51 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -95,41 +95,14 @@ void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
if (pOLV)
{
- bool bField = false;
- const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
- if (pFieldItem)
+ const SvxFieldData* pField = pOLV->GetFieldAtCursor();
+ if( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
{
- // Make sure the whole field is selected
- ESelection aSel = pOLV->GetSelection();
- if (aSel.nStartPos == aSel.nEndPos)
- {
- 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();
- }
+ aHLinkItem.SetName(pUrlField->GetRepresentation());
+ aHLinkItem.SetURL(pUrlField->GetURL());
+ aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
}
- 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)
+ else
{
// use selected text as name for urls
OUString sReturn = pOLV->GetSelected();