[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 29 18:00:47 UTC 2019


 sw/qa/extras/layout/data/tdf128399.docx |binary
 sw/qa/extras/layout/layout.cxx          |   27 +++++++++++++++++++++++++++
 sw/source/core/layout/ssfrm.cxx         |   13 +++++++------
 3 files changed, 34 insertions(+), 6 deletions(-)

New commits:
commit 435ab51ec8920033b7865f27f4afee8a852a0b31
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Oct 29 15:29:59 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Oct 29 18:59:41 2019 +0100

    tdf#128399 sw btlr: fix clicking to lower rotated cell
    
    In case a table has more than 1 btlr cells in multiple rows, the first
    captured the mouse.
    
    This was because SwFrame::GetPaintArea() assumed that left and right
    edges can be compared directly, without going via the SwRectFnSet
    abstraction. This works for hozizontal and plain vertical directions,
    but not for btlr.
    
    Change-Id: Ia3bd7623a5d8d9ad3bdfabceb10adc0dbf105059
    Reviewed-on: https://gerrit.libreoffice.org/81688
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/layout/data/tdf128399.docx b/sw/qa/extras/layout/data/tdf128399.docx
new file mode 100644
index 000000000000..04e1424ed948
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf128399.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 5b90067a174f..15a1e5f867e2 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3386,6 +3386,33 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testContinuousEndnotesDeletePageAtStart)
     assertXPath(pXmlDoc, "/root/page[1]/ftncont", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128399)
+{
+    SwDoc* pDoc = createDoc("tdf128399.docx");
+    SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+    SwFrame* pPage = pLayout->GetLower();
+    SwFrame* pBody = pPage->GetLower();
+    SwFrame* pTable = pBody->GetLower();
+    SwFrame* pRow1 = pTable->GetLower();
+    SwFrame* pRow2 = pRow1->GetNext();
+    const SwRect& rRow2Rect = pRow2->getFrameArea();
+    Point aPoint = rRow2Rect.Center();
+
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    SwPosition aPosition = *pWrtShell->GetCursor()->Start();
+    SwPosition aFirstRow(aPosition);
+    SwCursorMoveState aState(MV_NONE);
+    pLayout->GetCursorOfst(&aPosition, aPoint, &aState);
+    // Second row is +3: end node, start node and the first text node in the 2nd row.
+    sal_uLong nExpected = aFirstRow.nNode.GetIndex() + 3;
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 14
+    // - Actual  : 11
+    // i.e. clicking on the center of the 2nd row placed the cursor in the 1st row.
+    CPPUNIT_ASSERT_EQUAL(nExpected, aPosition.nNode.GetIndex());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx
index fea37d6f3310..a38c784f146f 100644
--- a/sw/source/core/layout/ssfrm.cxx
+++ b/sw/source/core/layout/ssfrm.cxx
@@ -585,6 +585,7 @@ SwRect SwFrame::GetPaintArea() const
     SwRect aRect = IsRowFrame() ? GetUpper()->getFrameArea() : getFrameArea();
     const bool bVert = IsVertical();
     SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori;
+    SwRectFnSet aRectFnSet(this);
     long nRight = (aRect.*fnRect->fnGetRight)();
     long nLeft  = (aRect.*fnRect->fnGetLeft)();
     const SwFrame* pTmp = this;
@@ -613,9 +614,9 @@ SwRect SwFrame::GetPaintArea() const
             pTmp->IsCellFrame() || pTmp->IsRowFrame() || //nobody leaves a table!
             pTmp->IsRootFrame() )
         {
-            if( bLeft || nLeft < nTmpLeft )
+            if( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 )
                 nLeft = nTmpLeft;
-            if( bRight || nTmpRight < nRight )
+            if( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 )
                 nRight = nTmpRight;
             if( pTmp->IsPageFrame() || pTmp->IsFlyFrame() || pTmp->IsRootFrame() )
                 break;
@@ -628,14 +629,14 @@ SwRect SwFrame::GetPaintArea() const
             // the first column has _no_ influence to the left range
             if( bR2L ? pTmp->GetNext() : pTmp->GetPrev() )
             {
-                if( bLeft || nLeft < nTmpLeft )
+                if( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 )
                     nLeft = nTmpLeft;
                 bLeft = false;
             }
              // the last column has _no_ influence to the right range
             if( bR2L ? pTmp->GetPrev() : pTmp->GetNext() )
             {
-                if( bRight || nTmpRight < nRight )
+                if( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 )
                     nRight = nTmpRight;
                 bRight = false;
             }
@@ -648,14 +649,14 @@ SwRect SwFrame::GetPaintArea() const
             // the next frame of a body frame may be a footnotecontainer or
             // a footer. The footnotecontainer has the same direction like
             // the body frame.
-            if( pTmp->GetPrev() && ( bLeft || nLeft < nTmpLeft ) )
+            if( pTmp->GetPrev() && ( bLeft || aRectFnSet.XDiff(nTmpLeft, nLeft) > 0 ) )
             {
                 nLeft = nTmpLeft;
                 bLeft = false;
             }
             if( pTmp->GetNext() &&
                 ( pTmp->GetNext()->IsFooterFrame() || pTmp->GetNext()->GetNext() )
-                && ( bRight || nTmpRight < nRight ) )
+                && ( bRight || aRectFnSet.XDiff(nRight, nTmpRight) > 0 ) )
             {
                 nRight = nTmpRight;
                 bRight = false;


More information about the Libreoffice-commits mailing list