tdf#158031 editeng: rename GetFieldAtCursor
because it doesn't really get the field at the cursor,
and certainly is not similar to SelectFieldAtCursor.
It first gets the field under the mouse.
Then, if there is a selection, it gets the selected field,
else it looks for the field on either side.
There were LOTS of places where it
probably had not been used properly.
Most of those are gone now, so it is easier
to rename the function.
Change-Id: I1a64af24092582cf865509d2a474080258edd76c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159022
Reviewed-by: Justin Luth <jluth@mail.com>
Tested-by: Jenkins
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index e1229b6..81cc8bf 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1424,7 +1424,7 @@ void EditView::SelectFieldAtCursor()
assert(std::abs(aSel.nStartPos - aSel.nEndPos) == 1);
}
const SvxFieldData* EditView::GetFieldAtCursor(bool bAlsoCheckBeforeCursor) const
const SvxFieldData* EditView::GetFieldUnderMouseOrInSelectionOrAtCursor(bool bAlsoCheckBeforeCursor) const
{
const SvxFieldItem* pFieldItem = GetFieldUnderMousePointer();
if (!pFieldItem)
diff --git a/editeng/source/misc/urlfieldhelper.cxx b/editeng/source/misc/urlfieldhelper.cxx
index d60d7be..57f2a04 100644
--- a/editeng/source/misc/urlfieldhelper.cxx
+++ b/editeng/source/misc/urlfieldhelper.cxx
@@ -38,7 +38,8 @@ bool URLFieldHelper::IsCursorAtURLField(const EditView& pEditView, bool bAlsoChe
if (!bIsValidSelection)
return false;
const SvxFieldData* pField = pEditView.GetFieldAtCursor(bAlsoCheckBeforeCursor);
const SvxFieldData* pField
= pEditView.GetFieldUnderMouseOrInSelectionOrAtCursor(bAlsoCheckBeforeCursor);
if (dynamic_cast<const SvxURLField*>(pField))
return true;
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 2649e86..136ecd77 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1345,11 +1345,6 @@ const SvxFieldItem* OutlinerView::GetFieldAtSelection(bool bAlsoCheckBeforeCurso
return pEditView->GetFieldAtSelection(bAlsoCheckBeforeCursor);
}
const SvxFieldData* OutlinerView::GetFieldAtCursor() const
{
return pEditView->GetFieldAtCursor();
}
void OutlinerView::SelectFieldAtCursor()
{
pEditView->SelectFieldAtCursor();
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index b54f6b4..01a0e42 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -334,7 +334,7 @@ public:
const SvxFieldItem* GetFieldAtSelection(bool* pIsBeforeCursor) const;
/// return field under mouse, at selection, or immediately after (or before) the current cursor
const SvxFieldData* GetFieldAtCursor(bool bAlsoCheckBeforeCursor = false) const;
const SvxFieldData* GetFieldUnderMouseOrInSelectionOrAtCursor(bool bAlsoCheckBeforeCursor = false) const;
/// if no selection, select the field immediately after or before the current cursor
void SelectFieldAtCursor();
/// Converts position in paragraph to logical position without unfolding fields
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 4f8d41e..35860b7 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -307,9 +307,7 @@ public:
void InsertField( const SvxFieldItem& rFld );
const SvxFieldItem* GetFieldUnderMousePointer() const;
const SvxFieldItem* GetFieldAtSelection(bool bAlsoCheckBeforeCursor = false) const;
/// Return the field at the current cursor position or nullptr if no field found
const SvxFieldData* GetFieldAtCursor() const;
/// Select the field at the current cursor position
/// if no selection, select the field immediately after or before the current cursor
void SelectFieldAtCursor();
/** enables bullets for the selected paragraphs if the bullets/numbering of the first paragraph is off
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index c48b777..9ed398f 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -888,7 +888,7 @@ std::unique_ptr<const SvxFieldData> ScEditShell::GetURLField()
if (!pActiveView)
return std::unique_ptr<const SvxFieldData>();
const SvxFieldData* pField = pActiveView->GetFieldAtCursor();
const SvxFieldData* pField = pActiveView->GetFieldUnderMouseOrInSelectionOrAtCursor();
if (auto pURLField = dynamic_cast<const SvxURLField*>(pField))
return pURLField->Clone();