diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-07-07 14:04:28 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-13 15:06:55 +0200 |
commit | 1d716b5205b72ddce5b2d9f7be5c95d1baad6660 (patch) | |
tree | cdc8ea6b70e8c6d4221ab2911e94263c612b2c1b | |
parent | ae8f5057150a13b6fba482e9abe9a6e133f80056 (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)
[ This fixes the layout loop introduced 3 commits ago, so re-enable that
test. ]
Change-Id: If648cb477be5492c7158f89934435ca7021a6a63
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/data/rhbz739252-3.odt | bin | 0 -> 20869 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/layout/sectfrm.cxx | 5 |
4 files changed, 16 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index f01ba1d82951..1097eddd5707 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -978,13 +978,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf99090_pgbrkAfterTable, "tdf99090_pgbrkAfterTable assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1); } -#if 0 DECLARE_OOXMLEXPORT_TEST(testTdf96750_landscapeFollow, "tdf96750_landscapeFollow.docx") { uno::Reference<beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle, "IsLandscape")); } -#endif DECLARE_OOXMLEXPORT_TEST(testTdf86926_A3, "tdf86926_A3.docx") { diff --git a/sw/qa/extras/uiwriter/data/rhbz739252-3.odt b/sw/qa/extras/uiwriter/data/rhbz739252-3.odt Binary files differnew file mode 100644 index 000000000000..e457c035b662 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/rhbz739252-3.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index f9a13657fea2..2c3368d578dd 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -255,6 +255,7 @@ public: void testParagraphOfTextRange(); void testTdf108524(); void testTableInSection(); + void testTableInNestedSection(); void testLinesInSectionInTable(); CPPUNIT_TEST_SUITE(SwUiWriterTest); @@ -398,6 +399,7 @@ public: CPPUNIT_TEST(testParagraphOfTextRange); CPPUNIT_TEST(testTdf108524); CPPUNIT_TEST(testTableInSection); + CPPUNIT_TEST(testTableInNestedSection); CPPUNIT_TEST(testLinesInSectionInTable); CPPUNIT_TEST_SUITE_END(); @@ -5094,6 +5096,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 d48d6da09d63..3754f55b1997 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(); if (!pCellLeaf) { |