include/vcl/textview.hxx | 3 +++ vcl/source/edit/textview.cxx | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+)
New commits: commit c7ea7664002b54786795fab7f6233024a6362f71 Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Mon Aug 26 15:51:41 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Aug 27 11:04:14 2019 +0200 tdf#49482: Searching in the Basic IDE: showing found line After a search term has been found, the start of the selection will be vertically centered in the textview Change-Id: Ibb53d24ed6bc604a15d144af24d1b891e22a1d2e Reviewed-on: https://gerrit.libreoffice.org/78144 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/vcl/textview.hxx b/include/vcl/textview.hxx index e706d0c42e00..8f856a3346e6 100644 --- a/include/vcl/textview.hxx +++ b/include/vcl/textview.hxx @@ -215,6 +215,9 @@ public: void MatchGroup(); + // tdf#49482: Moves the start of the PaM to the center of the textview + void CenterPaM( const TextPaM& rPaM ); + bool Search( const i18nutil::SearchOptions& rSearchOptions, bool bForward ); sal_uInt16 Replace( const i18nutil::SearchOptions& rSearchOptions, bool bAll, bool bForward ); diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index c3506bd0efc8..f9c612a97a36 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -2180,6 +2180,20 @@ void TextView::MatchGroup() SetSelection( aMatchSel ); } +void TextView::CenterPaM( const TextPaM& rPaM ) +{ + // Get textview size and the corresponding y-coordinates + Size aOutSz = mpImpl->mpWindow->GetOutputSizePixel(); + long nVisStartY = mpImpl->maStartDocPos.Y(); + long nVisEndY = mpImpl->maStartDocPos.Y() + aOutSz.Height(); + + // Retrieve the coordinates of the PaM + tools::Rectangle aRect = mpImpl->mpTextEngine->PaMtoEditCursor(rPaM); + + // Recalculate the offset of the center y-coordinates and scroll + Scroll(0, (nVisStartY + nVisEndY) / 2 - aRect.TopLeft().getY()); +} + bool TextView::Search( const i18nutil::SearchOptions& rSearchOptions, bool bForward ) { bool bFound = false; @@ -2198,6 +2212,11 @@ bool TextView::Search( const i18nutil::SearchOptions& rSearchOptions, bool bForw } SetSelection( aSel ); + // tdf#49482: Move the start of the selection to the center of the textview + if (bFound) + { + CenterPaM( aSel.GetStart() ); + } ShowCursor(); return bFound; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits