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

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 2 11:17:08 UTC 2019


 sw/qa/extras/layout/data/tdf105481.odt |binary
 sw/qa/extras/layout/layout.cxx         |   63 +++++++++++++++++++++++++++++++++
 sw/source/core/text/frmform.cxx        |    3 -
 3 files changed, 64 insertions(+), 2 deletions(-)

New commits:
commit 318229900fe6d30d9b82256d908dadda8b2f4d61
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Sun Nov 24 16:09:47 2019 +0530
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Dec 2 12:16:21 2019 +0100

    tdf#105481 : Do not skip invalidation of as-char anchored objects
    
    inside a growing text-frame after doing recalc of positions of
    other frames (visually above current) in the tree. Otherwise
    the as-char anchored objects gets wrong reference (base) position
    (more accurately the base Y position) and hence get displayed at
    wrong vertical positions (in case of the bug document, it goes
    out of the page area).
    
    Some notes about the bug:
    
    Above mentioned problem is visible (at least) when you have a frame
    anchored to the bottom of the page with auto-height and it contains
    one or more <text:p> with at least one of them having a draw object
    like a shape or math formula with 'as-char' anchoring. Only the
    draw object in the last <text:p> is affected by the bug possibly
    because this text-frame is the cause of growth of the parent (upper)
    frame.
    
    Change-Id: If968c8c00aa57d26b1000e3250b352b24df47cf6
    Reviewed-on: https://gerrit.libreoffice.org/83603
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/layout/data/tdf105481.odt b/sw/qa/extras/layout/data/tdf105481.odt
new file mode 100644
index 000000000000..73cd892620a6
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf105481.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 82febf907297..f02a69ae042e 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3480,6 +3480,69 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128399)
     CPPUNIT_ASSERT_EQUAL(nExpected, aPosition.nNode.GetIndex());
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf105481)
+{
+    createDoc("tdf105481.odt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    CPPUNIT_ASSERT(pXmlDoc);
+
+    // Without the accompanying fix in place, this test would have failed
+    // because the vertical position of the as-char shape object and the
+    // as-char math object will be wrong (below/beyond the text frame's bottom).
+
+    SwTwips nTxtTop = getXPath(pXmlDoc,
+                               "/root/page/anchored/fly/txt[2]"
+                               "/infos/bounds",
+                               "top")
+                          .toInt32();
+    SwTwips nTxtBottom = nTxtTop
+                         + getXPath(pXmlDoc,
+                                    "/root/page/anchored/fly/txt[2]"
+                                    "/infos/bounds",
+                                    "height")
+                               .toInt32();
+
+    SwTwips nFormula1Top = getXPath(pXmlDoc,
+                                    "/root/page/anchored/fly/txt[2]"
+                                    "/anchored/fly[1]/infos/bounds",
+                                    "top")
+                               .toInt32();
+    SwTwips nFormula1Bottom = nFormula1Top
+                              + getXPath(pXmlDoc,
+                                         "/root/page/anchored/fly/txt[2]"
+                                         "/anchored/fly[1]/infos/bounds",
+                                         "height")
+                                    .toInt32();
+
+    SwTwips nFormula2Top = getXPath(pXmlDoc,
+                                    "/root/page/anchored/fly/txt[2]"
+                                    "/anchored/fly[2]/infos/bounds",
+                                    "top")
+                               .toInt32();
+    SwTwips nFormula2Bottom = nFormula2Top
+                              + getXPath(pXmlDoc,
+                                         "/root/page/anchored/fly/txt[2]"
+                                         "/anchored/fly[2]/infos/bounds",
+                                         "height")
+                                    .toInt32();
+
+    // Ensure that the two formula positions are at least between top and bottom of the text frame.
+    // The below two are satisfied even without the fix.
+    CPPUNIT_ASSERT_GREATEREQUAL(nTxtTop, nFormula1Top);
+    CPPUNIT_ASSERT_GREATEREQUAL(nTxtTop, nFormula2Top);
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected less than or equal to : 14423
+    // - Actual  : 14828
+    // that is, the formula is below the text-frame's y bound.
+    CPPUNIT_ASSERT_LESSEQUAL(nTxtBottom, nFormula1Bottom);
+    // Similarly for formula # 2 :
+    // - Expected less than or equal to : 14423
+    // - Actual  : 15035
+    // that is, the formula is below the text-frame's y bound.
+    CPPUNIT_ASSERT_LESSEQUAL(nTxtBottom, nFormula2Bottom);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 751d9b94c59e..d07f9f5fdf7e 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -441,8 +441,7 @@ void SwTextFrame::AdjustFrame( const SwTwips nChgHght, bool bHasToFit )
                 MakePos();
                 if ( aOldPos != getFrameArea().Pos() )
                 {
-                    // i#28701 - No format is performed for the floating screen objects.
-                    InvalidateObjs();
+                    InvalidateObjs(false);
                 }
             }
             nChgHeight = 0;


More information about the Libreoffice-commits mailing list