summaryrefslogtreecommitdiff
path: root/vcl/source/edit/textview.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/edit/textview.cxx')
-rw-r--r--vcl/source/edit/textview.cxx19
1 files changed, 19 insertions, 0 deletions
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;