[Libreoffice-commits] core.git: Branch 'distro/escriba/escriba-5.2.1' - sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Sep 4 14:05:58 UTC 2017


 sw/qa/extras/uiwriter/data/tdf112160.fodt |  125 ++++++++++++++++++++++++++++++
 sw/qa/extras/uiwriter/uiwriter.cxx        |   25 ++++++
 sw/source/core/layout/sectfrm.cxx         |    9 +-
 3 files changed, 158 insertions(+), 1 deletion(-)

New commits:
commit 5e394dce3482951adc1eefce3014565da0920055
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 4 12:44:15 2017 +0200

    tdf#112160 sw: audit GetNextLayoutLeaf() calls in SwFrame::GetNextSctLeaf()
    
    GetNextLayoutLeaf() returns the next container, not the follow one, so
    calls to that without checking first if we are in a table are always
    suspicious. This leads at the end to strange content move, as described
    in the bug.
    
    There appears to be only a single place in SwFrame::GetNextSctLeaf()
    which may be executed for split sections and called GetNextLayoutLeaf()
    unconditionally.
    
    Reviewed-on: https://gerrit.libreoffice.org/41882
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit ec262cbc56822d8fffccd6e983848df196cf5c44)
    
    Conflicts:
            sw/qa/extras/uiwriter/uiwriter.cxx
    
    Change-Id: I759d9ef63660f3d2ffe006c88b18cba7dba99f33

diff --git a/sw/qa/extras/uiwriter/data/tdf112160.fodt b/sw/qa/extras/uiwriter/data/tdf112160.fodt
new file mode 100644
index 000000000000..d02352e4d2a6
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf112160.fodt
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas
 is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:
 experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+  <office:font-face-decls>
+    <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/>
+  </office:font-face-decls>
+  <office:styles>
+    <style:default-style style:family="paragraph">
+      <style:paragraph-properties fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/>
+      <style:text-properties style:use-window-font-color="true" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="US" style:letter-kerning="true" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2"/>
+    </style:default-style>
+  </office:styles>
+  <office:automatic-styles>
+    <style:style style:name="Table1" style:family="table">
+      <style:table-properties style:width="16.623cm" fo:margin-left="0cm" fo:margin-right="0.039cm" table:align="margins"/>
+    </style:style>
+    <style:style style:name="Table1.A" style:family="table-column">
+      <style:table-column-properties style:column-width="7.664cm" style:rel-column-width="30218*"/>
+    </style:style>
+    <style:style style:name="Table1.B" style:family="table-column">
+      <style:table-column-properties style:column-width="3.669cm" style:rel-column-width="14461*"/>
+    </style:style>
+    <style:style style:name="Table1.C" style:family="table-column">
+      <style:table-column-properties style:column-width="2.096cm" style:rel-column-width="8260*"/>
+    </style:style>
+    <style:style style:name="Table1.D" style:family="table-column">
+      <style:table-column-properties style:column-width="3.194cm" style:rel-column-width="12596*"/>
+    </style:style>
+    <style:style style:name="Table1.1" style:family="table-row">
+      <style:table-row-properties fo:keep-together="auto"/>
+    </style:style>
+    <style:style style:name="Table1.A1" style:family="table-cell">
+      <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000"/>
+    </style:style>
+    <style:style style:name="Table1.D1" style:family="table-cell">
+      <style:table-cell-properties fo:padding="0.097cm" fo:border="0.05pt solid #000000"/>
+    </style:style>
+    <style:style style:name="Table1.A2" style:family="table-cell">
+      <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.05pt solid #000000"/>
+    </style:style>
+    <style:style style:name="Table1.D2" style:family="table-cell">
+      <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="0.05pt solid #000000" fo:border-top="none" fo:border-bottom="0.05pt solid #000000"/>
+    </style:style>
+    <style:style style:name="P1" style:family="paragraph" style:master-page-name="PG_5f_Default">
+      <style:paragraph-properties style:page-number="auto"/>
+    </style:style>
+    <style:page-layout style:name="pm3">
+      <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="8.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="0.4cm" fo:margin-bottom="0.499cm" fo:margin-left="2.54cm" fo:margin-right="1.799cm" fo:border="none" fo:padding="0cm" style:shadow="none" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
+        <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="none" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+      </style:page-layout-properties>
+      <style:header-style/>
+      <style:footer-style/>
+    </style:page-layout>
+  </office:automatic-styles>
+  <office:master-styles>
+    <style:master-page style:name="PG_5f_Default" style:display-name="PG_Default" style:page-layout-name="pm3"/>
+  </office:master-styles>
+  <office:body>
+    <office:text text:use-soft-page-breaks="true">
+      <text:p text:style-name="P1"/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <text:p/>
+      <table:table table:name="Table1" table:style-name="Table1">
+        <table:table-column table:style-name="Table1.A"/>
+        <table:table-column table:style-name="Table1.B"/>
+        <table:table-column table:style-name="Table1.C"/>
+        <table:table-column table:style-name="Table1.D"/>
+        <table:table-row table:style-name="Table1.1">
+          <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+            <text:section text:name="Sect1">
+              <text:p>Table1.A1</text:p>
+            </text:section>
+          </table:table-cell>
+          <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+            <text:section text:name="Sect2">
+              <text:p>Table1.B1</text:p>
+            </text:section>
+          </table:table-cell>
+          <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+            <text:section text:name="Sect3">
+              <text:p>Table1.C1</text:p>
+            </text:section>
+          </table:table-cell>
+          <table:table-cell table:style-name="Table1.D1" office:value-type="string">
+            <text:section text:name="Sect4">
+              <text:p>Table1.D1</text:p>
+            </text:section>
+          </table:table-cell>
+        </table:table-row>
+        <table:table-row table:style-name="Table1.1">
+          <table:table-cell table:style-name="Table1.A2" office:value-type="string">
+            <text:section text:name="Sect5">
+              <text:p>Table1.A2</text:p>
+            </text:section>
+          </table:table-cell>
+          <table:table-cell table:style-name="Table1.A2" office:value-type="string">
+            <text:section text:name="Sect6">
+              <text:p>Table1.B2</text:p>
+            </text:section>
+          </table:table-cell>
+          <table:table-cell table:style-name="Table1.A2" office:value-type="string">
+            <text:section text:name="Sect7">
+              <text:p>Table1.C2</text:p>
+            </text:section>
+          </table:table-cell>
+          <table:table-cell table:style-name="Table1.D2" office:value-type="string">
+            <text:section text:name="Sect8">
+              <text:p>Table1.D2</text:p>
+            </text:section>
+          </table:table-cell>
+        </table:table-row>
+      </table:table>
+      <text:p text:style-name="Standard"/>
+    </office:text>
+  </office:body>
+</office:document>
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index c9753a8f712c..3f998534ff59 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -205,6 +205,7 @@ public:
     void testTableInNestedSection();
     void testTableInSectionInTable();
     void testSectionInTableInTable();
+    void testTdf112160();
     void testLinesInSectionInTable();
     void testLinesMoveBackwardsInSectionInTable();
 
@@ -316,6 +317,7 @@ public:
     CPPUNIT_TEST(testLinesInSectionInTable);
     CPPUNIT_TEST(testTableInSectionInTable);
     CPPUNIT_TEST(testSectionInTableInTable);
+    CPPUNIT_TEST(testTdf112160);
     CPPUNIT_TEST(testLinesMoveBackwardsInSectionInTable);
     CPPUNIT_TEST_SUITE_END();
 
@@ -3840,6 +3842,29 @@ void SwUiWriterTest::testSectionInTableInTable()
     createDoc("tdf112109.fodt");
 }
 
+void SwUiWriterTest::testTdf112160()
+{
+    // Assert that the A2 cell is on page 1.
+    SwDoc* pDoc = createDoc("tdf112160.fodt");
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    sal_uInt32 nA2CellNode = getXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[1]/section/txt[last()]", "txtNodeIndex").toUInt32();
+    CPPUNIT_ASSERT_EQUAL(OUString("Table1.A2"), pDoc->GetNodes()[nA2CellNode]->GetTextNode()->GetText());
+
+    // Append a new paragraph to the end of the A2 cell.
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    while (pWrtShell->GetCursor()->GetNode().GetIndex() < nA2CellNode)
+        pWrtShell->Down(/*bSelect=*/false);
+    pWrtShell->EndPara();
+    pWrtShell->SplitNode();
+
+    // Assert that after A2 got extended, D2 stays on page 1.
+    discardDumpedLayout();
+    pXmlDoc = parseLayoutDump();
+    sal_uInt32 nD2CellNode = getXPath(pXmlDoc, "/root/page[1]/body/tab/row[2]/cell[last()]/section/txt[last()]", "txtNodeIndex").toUInt32();
+    // This was Table1.C2, Table1.D2 was moved to the next page, unexpected.
+    CPPUNIT_ASSERT_EQUAL(OUString("Table1.D2"), pDoc->GetNodes()[nD2CellNode]->GetTextNode()->GetText());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/layout/sectfrm.cxx b/sw/source/core/layout/sectfrm.cxx
index 8ae220e84272..fa47d70bc63f 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -1622,7 +1622,14 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
             InsertPage(pOldLayLeaf ? pOldLayLeaf->FindPageFrame() : FindPageFrame(),
                        false );
             // and again the whole thing
-            pLayLeaf = pOldLayLeaf ? pOldLayLeaf : GetNextLayoutLeaf();
+            if (pCellLeaf && CanContainSplitSection(this))
+                // GetNextLayoutLeaf() would refer to the next cell in the same
+                // row, avoid that. pCellLeaf points to the correct cell in the
+                // follow table, and in the next round it'll be used, as we now
+                // have a next page.
+                pLayLeaf = pCellLeaf;
+            else
+                pLayLeaf = pOldLayLeaf ? pOldLayLeaf : GetNextLayoutLeaf();
             continue;
         }
         break;


More information about the Libreoffice-commits mailing list