summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-03-24 17:09:21 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-03-24 17:38:20 +0000
commitf4eb82cf9fea5c1df49fad6ee2d91fc51854cd29 (patch)
treee2574f17cc424992224844f56d9b277440f74b6f
parent64afe3040bf3d07bb0b13f03b33fce074383ee39 (diff)
tdf#88453 sw layout, nested table split: shrink inner tables as well
Commit b4b5dbee1ec7770ed64d7270de46d5cfc06b87b6 (tdf#88453 sw layout: fix split of nested tables with large amount of rows, 2016-03-23) took care of two similar problems when splitting tables which has nested ones (setting cell height to 0 when its content height is 0, and setting row height to 0 when its cells' height are zero). Turns out there is a third aspect of the same problem: when row heights are set to 0 during shrinking for table split purposes, the table height has to be set to 0 as well, in case the table contains only 0-height rows. With this, the original bugdoc's layout is the expected one. Change-Id: I3f5392eb914a60e9caa5182dc6d44bd3a93f41d6 Reviewed-on: https://gerrit.libreoffice.org/23497 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sw/qa/extras/uiwriter/data/tdf88453-table.odtbin0 -> 27182 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx11
-rw-r--r--sw/source/core/layout/tabfrm.cxx16
3 files changed, 27 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf88453-table.odt b/sw/qa/extras/uiwriter/data/tdf88453-table.odt
new file mode 100644
index 000000000000..2c205616a9cb
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf88453-table.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 5a3cbb710fe8..f6b9d74618c2 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -189,6 +189,7 @@ public:
void testTdf96479();
void testTdf96961();
void testTdf88453();
+ void testTdf88453Table();
void testClassificationPaste();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
@@ -282,6 +283,7 @@ public:
CPPUNIT_TEST(testTdf96479);
CPPUNIT_TEST(testTdf96961);
CPPUNIT_TEST(testTdf88453);
+ CPPUNIT_TEST(testTdf88453Table);
CPPUNIT_TEST(testClassificationPaste);
CPPUNIT_TEST_SUITE_END();
@@ -3523,6 +3525,15 @@ void SwUiWriterTest::testTdf88453()
assertXPath(pXmlDoc, "/root/page[2]/body/tab", 1);
}
+void SwUiWriterTest::testTdf88453Table()
+{
+ createDoc("tdf88453-table.odt");
+ calcLayout();
+ // This was 2: layout could not split the large outer table in the document
+ // into 3 pages.
+ CPPUNIT_ASSERT_EQUAL(3, getPages());
+}
+
namespace
{
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 2f16c985ccd1..e185feac12f3 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -364,11 +364,27 @@ static void lcl_ShrinkCellsAndAllContent( SwRowFrame& rRow )
if ( pTmp->IsTabFrame() )
{
SwRowFrame* pTmpRow = static_cast<SwRowFrame*>(static_cast<SwTabFrame*>(pTmp)->Lower());
+ bool bAllRowsCollapsed = true;
+
while ( pTmpRow )
{
lcl_ShrinkCellsAndAllContent( *pTmpRow );
+
+ if ((pTmpRow->Frame().*fnRect->fnGetHeight)() > 0)
+ bAllRowsCollapsed = false;
+
pTmpRow = static_cast<SwRowFrame*>(pTmpRow->GetNext());
}
+
+ if (bAllRowsCollapsed)
+ {
+ // All rows of this table have 0 height -> set height of the table itself as well.
+ (pTmp->Frame().*fnRect->fnSetHeight)(0);
+ (pTmp->Prt().*fnRect->fnSetTop)(0);
+ (pTmp->Prt().*fnRect->fnSetHeight)(0);
+ }
+ else
+ bAllLowersCollapsed = false;
}
else
{