summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-12-04 15:19:00 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-12-06 08:17:10 +0100
commit64233bbaa0e91ddf14d59ae7547df6bbfa60adcc (patch)
treec17bed3b00de030ac4cf57132b21fea5144c3401 /editeng
parentc45acdcdd022a17559b9f7b85790c656a1599339 (diff)
tdf#128666 Only enable hyperlink actions when just the field is selected
Change-Id: I984df967877a47fb9f89c3626737348a87d3ffa5 Reviewed-on: https://gerrit.libreoffice.org/84418 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> (cherry picked from commit f31c3ebb60e4678eb09e377b638b368531df47dc) Reviewed-on: https://gerrit.libreoffice.org/84571
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/misc/urlfieldhelper.cxx28
1 files changed, 17 insertions, 11 deletions
diff --git a/editeng/source/misc/urlfieldhelper.cxx b/editeng/source/misc/urlfieldhelper.cxx
index 6df7171e14c0..564bc54e781e 100644
--- a/editeng/source/misc/urlfieldhelper.cxx
+++ b/editeng/source/misc/urlfieldhelper.cxx
@@ -11,27 +11,33 @@
#include <editeng/flditem.hxx>
#include <editeng/editview.hxx>
+#include <editeng/editeng.hxx>
-void URLFieldHelper::RemoveURLField(Outliner* pOutl, const OutlinerView* pOLV)
+void URLFieldHelper::RemoveURLField(EditView& pEditView)
{
- if (!pOutl || !pOLV)
- return;
-
- const SvxFieldData* pField = pOLV->GetFieldAtCursor();
+ pEditView.SelectFieldAtCursor();
+ const SvxFieldData* pField = pEditView.GetFieldAtCursor();
if (auto pUrlField = dynamic_cast<const SvxURLField*>(pField))
{
- ESelection aSel = pOLV->GetSelection();
- pOutl->QuickInsertText(pUrlField->GetRepresentation(), aSel);
- pOLV->GetEditView().Invalidate();
+ ESelection aSel = pEditView.GetSelection();
+ pEditView.GetEditEngine()->QuickInsertText(pUrlField->GetRepresentation(), aSel);
+ pEditView.Invalidate();
}
}
-bool URLFieldHelper::IsCursorAtURLField(const OutlinerView* pOLV)
+bool URLFieldHelper::IsCursorAtURLField(const EditView& pEditView)
{
- if (!pOLV)
+ // tdf#128666 Make sure only URL field (or nothing) is selected
+ ESelection aSel = pEditView.GetSelection();
+ auto nSelectedParas = aSel.nEndPara - aSel.nStartPara;
+ auto nSelectedChars = aSel.nEndPos - aSel.nStartPos;
+ bool bIsValidSelection
+ = nSelectedParas == 0
+ && (nSelectedChars == 0 || nSelectedChars == 1 || nSelectedChars == -1);
+ if (!bIsValidSelection)
return false;
- const SvxFieldData* pField = pOLV->GetFieldAtCursor();
+ const SvxFieldData* pField = pEditView.GetFieldAtCursor();
if (dynamic_cast<const SvxURLField*>(pField))
return true;