summaryrefslogtreecommitdiff
path: root/sw/source/core/layout
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-07-29 14:55:49 +0200
committerMichael Stahl <michael.stahl@cib.de>2020-07-30 11:53:02 +0200
commit63308aa3b109271ffb4fd47e9fea2e3281a1552d (patch)
tree5e66e7508d17136989a816bf31a3c47fd973798c /sw/source/core/layout
parent6c82a9fa1da15d5f83f524f6897028906dda337e (diff)
(related: tdf#134252) sw: fix assert when moving mouse pointer
SwPageFrame::GetModelPositionForViewPoint() was calling GetCharRect() on a frame that doesn't match the passed prevTextPos; it was supposed to be initialised by GetModelPositionForViewPoint() call but that didn't work because the point was outside the frame so nothing was inited. (regression from edd2db1c783bd571ff796a5298385cacc91877b9) Change-Id: Ic064c3efc1b7f29d18d713206e5ea5ac0b67fbc8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99692 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r--sw/source/core/layout/trvlfrm.cxx61
1 files changed, 31 insertions, 30 deletions
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 8ea9580f9eb4..d8714479ba75 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -292,42 +292,43 @@ bool SwPageFrame::GetModelPositionForViewPoint( SwPosition *pPos, Point &rPoint,
comphelper::FlagRestorationGuard g(
pState->m_bPosMatchesBounds, true);
SwPosition prevTextPos(*pPos);
- SwLayoutFrame::GetModelPositionForViewPoint(&prevTextPos, aPoint, pState);
-
- SwRect aTextRect;
- pTextFrame->GetCharRect(aTextRect, prevTextPos);
-
- if (prevTextPos.nContent < pContentNode->Len())
+ if (SwLayoutFrame::GetModelPositionForViewPoint(&prevTextPos, aPoint, pState))
{
- // aRextRect is just a line on the left edge of the
- // previous character; to get a better measure from
- // lcl_getDistance, extend that to a rectangle over
- // the entire character.
- SwPosition const nextTextPos(prevTextPos.nNode,
- SwIndex(prevTextPos.nContent, +1));
- SwRect nextTextRect;
- pTextFrame->GetCharRect(nextTextRect, nextTextPos);
- SwRectFnSet aRectFnSet(pTextFrame);
- if (aRectFnSet.GetTop(aTextRect) ==
- aRectFnSet.GetTop(nextTextRect)) // same line?
+ SwRect aTextRect;
+ pTextFrame->GetCharRect(aTextRect, prevTextPos);
+
+ if (prevTextPos.nContent < pContentNode->Len())
{
- // need to handle mixed RTL/LTR portions somehow
- if (aRectFnSet.GetLeft(aTextRect) <
- aRectFnSet.GetLeft(nextTextRect))
+ // aRextRect is just a line on the left edge of the
+ // previous character; to get a better measure from
+ // lcl_getDistance, extend that to a rectangle over
+ // the entire character.
+ SwPosition const nextTextPos(prevTextPos.nNode,
+ SwIndex(prevTextPos.nContent, +1));
+ SwRect nextTextRect;
+ pTextFrame->GetCharRect(nextTextRect, nextTextPos);
+ SwRectFnSet aRectFnSet(pTextFrame);
+ if (aRectFnSet.GetTop(aTextRect) ==
+ aRectFnSet.GetTop(nextTextRect)) // same line?
{
- aRectFnSet.SetRight( aTextRect,
- aRectFnSet.GetLeft(nextTextRect));
- }
- else // RTL
- {
- aRectFnSet.SetLeft( aTextRect,
- aRectFnSet.GetLeft(nextTextRect));
+ // need to handle mixed RTL/LTR portions somehow
+ if (aRectFnSet.GetLeft(aTextRect) <
+ aRectFnSet.GetLeft(nextTextRect))
+ {
+ aRectFnSet.SetRight( aTextRect,
+ aRectFnSet.GetLeft(nextTextRect));
+ }
+ else // RTL
+ {
+ aRectFnSet.SetLeft( aTextRect,
+ aRectFnSet.GetLeft(nextTextRect));
+ }
}
}
- }
- nTextDistance = lcl_getDistance(aTextRect, rPoint);
- bValidTextDistance = true;
+ nTextDistance = lcl_getDistance(aTextRect, rPoint);
+ bValidTextDistance = true;
+ }
}
double nBackDistance = 0;