From c81d766dd4ff7d8b580b7fdc79db6e68c5f14204 Mon Sep 17 00:00:00 2001 From: László Németh Date: Thu, 30 Jan 2020 11:26:58 +0100 Subject: tdf#130287 disable orphan/widow control in Table Contents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit paragraph style to avoid missing text lines later in vertically merged table cells at page break. From commit 49f453755b72654ba454acc321210e8b040df714 ("tdf#89714 - enable Widow/Orphan in default style"), Table Contents got unnecessary orphan/window control. Unfortunately, recent table layout code cannot ignore these settings completely, causing known problems, see for example tdf#128959 (FILEOPEN DOCX Table row content disappears when broken between pages). Change-Id: Idd570f17b0a11af85072a65f3422535b993db306 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87730 Tested-by: Jenkins Reviewed-by: László Németh Tested-by: László Németh --- sw/qa/extras/uiwriter/uiwriter.cxx | 22 ++++++++++++++++++++++ sw/source/core/doc/DocumentStylePoolManager.cxx | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index c5201ff2b017..8ef96faa47dc 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -243,6 +243,7 @@ public: void testTdf75137(); void testTdf83798(); void testTdf89714(); + void testTdf130287(); void testPropertyDefaults(); void testTableBackgroundColor(); void testTdf88899(); @@ -450,6 +451,7 @@ public: CPPUNIT_TEST(testTdf75137); CPPUNIT_TEST(testTdf83798); CPPUNIT_TEST(testTdf89714); + CPPUNIT_TEST(testTdf130287); CPPUNIT_TEST(testPropertyDefaults); CPPUNIT_TEST(testTableBackgroundColor); CPPUNIT_TEST(testTdf88899); @@ -3643,6 +3645,26 @@ void SwUiWriterTest::testTdf89714() CPPUNIT_ASSERT_EQUAL( uno::makeAny(sal_Int8(2)), xPropState->getPropertyDefault("ParaWidows") ); } +void SwUiWriterTest::testTdf130287() +{ + //create a new writer document + SwDoc* pDoc = createDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + //insert a 1-cell table in the newly created document + SwInsertTableOptions TableOpt(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(TableOpt, 1, 1); + //checking for the row and column + uno::Reference xTable(getParagraphOrTable(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getColumns()->getCount()); + uno::Reference xCell = xTable->getCellByName("A1"); + uno::Reference xCellText(xCell, uno::UNO_QUERY); + uno::Reference xParagraph = getParagraphOfText(1, xCellText); + // they were 2 (orphan/widow control enabled unnecessarily in Table Contents paragraph style) + CPPUNIT_ASSERT_EQUAL( sal_Int8(0), getProperty(xParagraph, "ParaOrphans")); + CPPUNIT_ASSERT_EQUAL( sal_Int8(0), getProperty(xParagraph, "ParaWidows")); +} + void SwUiWriterTest::testPropertyDefaults() { createDoc(); diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index fb3d2a15c752..60d38a272a55 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -799,6 +799,11 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, SwFormatLineNumber aLN; aLN.SetCountLines( false ); aSet.Put( aLN ); + if (nId == RES_POOLCOLL_TABLE) + { + aSet.Put( SvxWidowsItem( 0, RES_PARATR_WIDOWS ) ); + aSet.Put( SvxOrphansItem( 0, RES_PARATR_ORPHANS ) ); + } } break; -- cgit