[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 30 19:23:45 UTC 2020


 sw/source/core/layout/trvlfrm.cxx |   61 +++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 30 deletions(-)

New commits:
commit bdb4638074e8baf9f765194d98fa8dc41de6a976
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Jul 29 14:55:49 2020 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jul 30 21:23:08 2020 +0200

    (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 at cib.de>
    (cherry picked from commit 63308aa3b109271ffb4fd47e9fea2e3281a1552d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99737
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index c7de73e4e0e7..7ec33dcea85c 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;


More information about the Libreoffice-commits mailing list