summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2023-11-02 14:42:07 -0400
committerJustin Luth <jluth@mail.com>2023-11-15 20:03:42 +0100
commitf2a5d091ba9f01a26139e6fc2f3c2bcfd0a6cf3b (patch)
tree8d33d9d9d8af6421da838ce40d90b12f46d2b85d /editeng
parent213c6a9999e84f084978391c16276017078bf9ed (diff)
tdf#158031 editeng SID_*_HYPERLINK: use AlsoCheckBeforeCursor
This fixes the GTK3 problem where only the first half of the link successfully ran SID_EDIT_HYPERLINK against an editeng hyperlink. Fixed for Writer and Calc editeng hyperlinks (i.e. in textboxes). TODO: fix SID_COPY_HYPERLINK (which doesn't SelectFieldAtCursor) The problem showed up when the menu option was added because the mouse was over an unselected field, but when the mouse moved to select the menu option, the slot was not considered valid anymore if the cursor had moved behind the field. (The right-click to open the context menu puts the cursor before or after the field.) Now, by checking for a field-before-the-cursor during validation, the field is found and the command is not prevented from running. Once this is all in place, some older commits from Caolan should be able to be reverted. (Strangely, SID_OPEN_HYPERLINK and SID_REMOVE_HYPERLINK seem to run before the slot is invalidated. No idea why they are different. For GEN, the popup usually either kept the pre-menu mouse position, or else it always runs the command before the slot invalidates.) Change-Id: If992b3fdc94d89162b60447458cabced2d5e3f19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158856 Reviewed-by: Justin Luth <jluth@mail.com> Tested-by: Jenkins
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editview.cxx4
-rw-r--r--editeng/source/misc/urlfieldhelper.cxx4
2 files changed, 4 insertions, 4 deletions
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index bfa98d1ae702..e1229b6918db 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1424,11 +1424,11 @@ void EditView::SelectFieldAtCursor()
assert(std::abs(aSel.nStartPos - aSel.nEndPos) == 1);
}
-const SvxFieldData* EditView::GetFieldAtCursor() const
+const SvxFieldData* EditView::GetFieldAtCursor(bool bAlsoCheckBeforeCursor) const
{
const SvxFieldItem* pFieldItem = GetFieldUnderMousePointer();
if (!pFieldItem)
- pFieldItem = GetFieldAtSelection();
+ pFieldItem = GetFieldAtSelection(bAlsoCheckBeforeCursor);
return pFieldItem ? pFieldItem->GetField() : nullptr;
}
diff --git a/editeng/source/misc/urlfieldhelper.cxx b/editeng/source/misc/urlfieldhelper.cxx
index 564bc54e781e..1ed8647a15ae 100644
--- a/editeng/source/misc/urlfieldhelper.cxx
+++ b/editeng/source/misc/urlfieldhelper.cxx
@@ -25,7 +25,7 @@ void URLFieldHelper::RemoveURLField(EditView& pEditView)
}
}
-bool URLFieldHelper::IsCursorAtURLField(const EditView& pEditView)
+bool URLFieldHelper::IsCursorAtURLField(const EditView& pEditView, bool bAlsoCheckBeforeCursor)
{
// tdf#128666 Make sure only URL field (or nothing) is selected
ESelection aSel = pEditView.GetSelection();
@@ -37,7 +37,7 @@ bool URLFieldHelper::IsCursorAtURLField(const EditView& pEditView)
if (!bIsValidSelection)
return false;
- const SvxFieldData* pField = pEditView.GetFieldAtCursor();
+ const SvxFieldData* pField = pEditView.GetFieldAtCursor(bAlsoCheckBeforeCursor);
if (dynamic_cast<const SvxURLField*>(pField))
return true;