diff options
Diffstat (limited to 'sw/source/uibase/docvw/edtwin.cxx')
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 20f5761f1361..28a672963e83 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -163,6 +163,9 @@ #include <sfx2/event.hxx> #include <memory> +#include "../../core/crsr/callnk.hxx" + + using namespace sw::mark; using namespace ::com::sun::star; @@ -1838,9 +1841,7 @@ KEYINPUT_CHECKTABLE_INSDEL: } else if (!rSh.IsCursorInParagraphMetadataField()) { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/inforeadonlydialog.ui")); - std::unique_ptr<weld::MessageDialog> xInfo(xBuilder->weld_message_dialog("InfoReadonlyDialog")); - xInfo->run(); + rSh.InfoReadOnlyDialog(); eKeyState = SwKeyState::End; } break; @@ -1993,9 +1994,7 @@ KEYINPUT_CHECKTABLE_INSDEL: } else if (!rSh.IsCursorInParagraphMetadataField()) { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/inforeadonlydialog.ui")); - std::unique_ptr<weld::MessageDialog> xInfo(xBuilder->weld_message_dialog("InfoReadonlyDialog")); - xInfo->run(); + rSh.InfoReadOnlyDialog(); eKeyState = SwKeyState::End; } break; @@ -3700,7 +3699,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) // select content of Input Field, but exclude CH_TXT_ATR_INPUTFIELDSTART // and CH_TXT_ATR_INPUTFIELDEND rSh.SttSelect(); - rSh.SelectText( aFieldAtPos.pFndTextAttr->GetStart() + 1, + rSh.SelectTextModel( aFieldAtPos.pFndTextAttr->GetStart() + 1, *(aFieldAtPos.pFndTextAttr->End()) - 1 ); } // don't reset here any longer so that, in case through MouseMove @@ -3730,8 +3729,8 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) // select content of Input Field, but exclude CH_TXT_ATR_INPUTFIELDSTART // and CH_TXT_ATR_INPUTFIELDEND rSh.SttSelect(); - rSh.SelectText( aFieldAtPos.pFndTextAttr->GetStart() + 1, - *(aFieldAtPos.pFndTextAttr->End()) - 1 ); + rSh.SelectTextModel( aFieldAtPos.pFndTextAttr->GetStart() + 1, + *(aFieldAtPos.pFndTextAttr->End()) - 1 ); } } @@ -6287,8 +6286,7 @@ OUString SwEditWin::GetSurroundingText() const rSh.GetSelectedText( sReturn, ParaBreakType::ToOnlyCR ); else if( !rSh.HasSelection() ) { - SwPosition *pPos = rSh.GetCursor()->GetPoint(); - const sal_Int32 nPos = pPos->nContent.GetIndex(); + rSh.Push(); // get the sentence around the cursor rSh.HideCursor(); @@ -6297,8 +6295,7 @@ OUString SwEditWin::GetSurroundingText() const rSh.GoEndSentence(); rSh.GetSelectedText( sReturn, ParaBreakType::ToOnlyCR ); - pPos->nContent = nPos; - rSh.ClearMark(); + rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); rSh.HideCursor(); } @@ -6318,18 +6315,20 @@ Selection SwEditWin::GetSurroundingTextSelection() const { // Return the position of the visible cursor in the sentence // around the visible cursor. - SwPosition *pPos = rSh.GetCursor()->GetPoint(); - const sal_Int32 nPos = pPos->nContent.GetIndex(); + TextFrameIndex const nPos(rSh.GetCursorPointAsViewIndex()); + + // store shell state *before* Push + ::std::unique_ptr<SwCallLink> pLink(::std::make_unique<SwCallLink>(rSh)); + rSh.Push(); rSh.HideCursor(); rSh.GoStartSentence(); - const sal_Int32 nStartPos = rSh.GetCursor()->GetPoint()->nContent.GetIndex(); + TextFrameIndex const nStartPos(rSh.GetCursorPointAsViewIndex()); - pPos->nContent = nPos; - rSh.ClearMark(); + rSh.Pop(SwCursorShell::PopMode::DeleteCurrent, ::std::move(pLink)); rSh.ShowCursor(); - return Selection( nPos - nStartPos, nPos - nStartPos ); + return Selection(sal_Int32(nPos - nStartPos), sal_Int32(nPos - nStartPos)); } } |