summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-10-28 11:50:48 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-10-28 18:19:59 +0100
commit1b40a48bdfd1e73dc41394bd914e9ec417458a2d (patch)
treec712da29956e7d16e4d85ef7d0c25be1e65879cb /sw
parent15f2bf415bb25324eaf26ea87ef8b724a090b942 (diff)
tdf#95096 add a DeleteSurroundingText to SwEditWin
Change-Id: I6995a4e0e3a08a9cca26580585cdfe151389321f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104931 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx28
-rw-r--r--sw/source/uibase/inc/edtwin.hxx1
2 files changed, 29 insertions, 0 deletions
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index f28599ccf030..f28f7088d798 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6481,6 +6481,34 @@ Selection SwEditWin::GetSurroundingTextSelection() const
}
}
+bool SwEditWin::DeleteSurroundingText(const Selection& rSelection)
+{
+ SwWrtShell& rSh = m_rView.GetWrtShell();
+
+ if (rSh.HasSelection())
+ return false;
+
+ // rSelection is relative to the start of the sentence, so find that and
+ // adjust the range by it
+ SwPosition *pPos = rSh.GetCursor()->GetPoint();
+ const sal_Int32 nPos = pPos->nContent.GetIndex();
+
+ rSh.HideCursor();
+ rSh.GoStartSentence();
+ const sal_Int32 nStartPos = rSh.GetCursor()->GetPoint()->nContent.GetIndex();
+ pPos->nContent = nPos;
+ rSh.ClearMark();
+ rSh.ShowCursor();
+
+ if (rSh.SelectText(nStartPos + rSelection.Min(), nStartPos + rSelection.Max()))
+ {
+ rSh.Delete();
+ return true;
+ }
+
+ return false;
+}
+
void SwEditWin::LogicInvalidate(const tools::Rectangle* pRectangle)
{
OString sRectangle;
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index ec8994cf791e..a74afc85d085 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -190,6 +190,7 @@ class SW_DLLPUBLIC SwEditWin final : public vcl::Window,
virtual OUString GetSurroundingText() const override;
virtual Selection GetSurroundingTextSelection() const override;
+ virtual bool DeleteSurroundingText(const Selection& rSelection) override;
void ShowAutoCorrectQuickHelp(const OUString& rWord, SvxAutoCorrect& rACorr);
bool ShowAutoText(const std::vector<OUString>& rChunkCandidates);