summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-07-07 14:04:28 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-24 11:29:03 +0200
commit8caffe13ad738d759c07b3aa0ea20ce2c170cbbe (patch)
tree03a1c1c237ff18d7168818e7e1d35fb44c711563
parented7c4c96a999bb2ef5eeced7588da5d3845d2b7d (diff)
rhbz#739252 sw: fix crash on split tables inside nested sections
Commit b5e0a143308e976b4165ff6181f4dccc3db0bd31 (tdf#108524 sw: attempt to split section frames inside table cells, take two, 2017-07-03) checked for tables in SwFrame::GetNextSctLeaf() when it considered looking up the next "follow" cell frame. But this is too general, in practice it is only necessary to look for follow cell frames in case the frame in question is in a table, but not in a table-in-section. This at the same time avoids a crash with tables inside nested sections, as it happens in the bugdoc. Reviewed-on: https://gerrit.libreoffice.org/39692 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> (cherry picked from commit 652556ec3e9218655a67b4c4de4e26fbe81855de) Conflicts: sw/source/core/layout/sectfrm.cxx Change-Id: If648cb477be5492c7158f89934435ca7021a6a63
-rw-r--r--sw/qa/extras/uiwriter/data/rhbz739252-3.odtbin0 -> 20869 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx13
-rw-r--r--sw/source/core/layout/sectfrm.cxx5
3 files changed, 16 insertions, 2 deletions
diff --git a/sw/qa/extras/uiwriter/data/rhbz739252-3.odt b/sw/qa/extras/uiwriter/data/rhbz739252-3.odt
new file mode 100644
index 000000000000..e457c035b662
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/rhbz739252-3.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index f646347a4b30..d536d1e92f65 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -202,6 +202,7 @@ public:
void testParagraphOfTextRange();
void testTdf108524();
void testTableInSection();
+ void testTableInNestedSection();
void testLinesInSectionInTable();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
@@ -308,6 +309,7 @@ public:
CPPUNIT_TEST(testTdf108524);
CPPUNIT_TEST(testTdf108524);
CPPUNIT_TEST(testTableInSection);
+ CPPUNIT_TEST(testTableInNestedSection);
CPPUNIT_TEST(testLinesInSectionInTable);
CPPUNIT_TEST_SUITE_END();
@@ -3776,6 +3778,17 @@ void SwUiWriterTest::testTableInSection()
assertXPath(pXmlDoc, "/root/page[2]/body/section/tab/row/cell", 2);
}
+void SwUiWriterTest::testTableInNestedSection()
+{
+ // The document has a nested section, containing a table that spans over 2 pages.
+ // This crashed the layout.
+ createDoc("rhbz739252-3.odt");
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+ // Make sure the table is inside a section and spans over 2 pages.
+ assertXPath(pXmlDoc, "//page[1]//section/tab", 1);
+ assertXPath(pXmlDoc, "//page[2]//section/tab", 1);
+}
+
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 5a11d6bfed66..ed15376a99ef 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -1515,9 +1515,10 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
SwLayoutFrame *pLayLeaf;
SwLayoutFrame* pCellLeaf = nullptr;
- if (IsInTab())
+ if (IsInTab() && !IsInTableInSection(this))
{
- // We are in a table, see if there is a follow cell frame created already.
+ // We are in a table (which is itself not in a section), see if there
+ // is a follow cell frame created already.
pCellLeaf = GetNextCellLeaf(MAKEPAGE_NONE);
if (!pCellLeaf)
{