Kaydet (Commit) 652556ec authored tarafından Miklos Vajna's avatar Miklos Vajna

rhbz#739252 sw: fix crash on split tables inside nested sections

Commit b5e0a143 (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.

Change-Id: If648cb477be5492c7158f89934435ca7021a6a63
Reviewed-on: https://gerrit.libreoffice.org/39692Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 02b61a54
...@@ -256,6 +256,7 @@ public: ...@@ -256,6 +256,7 @@ public:
void testTdf107976(); void testTdf107976();
void testTdf108524(); void testTdf108524();
void testTableInSection(); void testTableInSection();
void testTableInNestedSection();
void testLinesInSectionInTable(); void testLinesInSectionInTable();
CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST_SUITE(SwUiWriterTest);
...@@ -400,6 +401,7 @@ public: ...@@ -400,6 +401,7 @@ public:
CPPUNIT_TEST(testTdf107976); CPPUNIT_TEST(testTdf107976);
CPPUNIT_TEST(testTdf108524); CPPUNIT_TEST(testTdf108524);
CPPUNIT_TEST(testTableInSection); CPPUNIT_TEST(testTableInSection);
CPPUNIT_TEST(testTableInNestedSection);
CPPUNIT_TEST(testLinesInSectionInTable); CPPUNIT_TEST(testLinesInSectionInTable);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -4993,6 +4995,17 @@ void SwUiWriterTest::testTableInSection() ...@@ -4993,6 +4995,17 @@ void SwUiWriterTest::testTableInSection()
assertXPath(pXmlDoc, "/root/page[2]/body/section/tab/row/cell", 2); 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_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -1515,9 +1515,10 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage ) ...@@ -1515,9 +1515,10 @@ SwLayoutFrame *SwFrame::GetNextSctLeaf( MakePageType eMakePage )
SwLayoutFrame *pLayLeaf; SwLayoutFrame *pLayLeaf;
SwLayoutFrame* pCellLeaf = nullptr; 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(); pCellLeaf = GetNextCellLeaf();
if (!pCellLeaf) if (!pCellLeaf)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment