sw/source/uibase/docvw/edtwin.cxx |   28 ++++++++++++++++++++++++++++
 sw/source/uibase/inc/edtwin.hxx   |    1 +
 2 files changed, 29 insertions(+)

New commits:
commit 1b40a48bdfd1e73dc41394bd914e9ec417458a2d
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Oct 28 11:50:48 2020 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Oct 28 18:19:59 2020 +0100

    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_l...@sil.org>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

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);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to