sw/qa/extras/uiwriter/data/tdf88453-table.odt |binary sw/qa/extras/uiwriter/data/tdf88453.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx | 24 +++++++++++++++- sw/source/core/layout/tabfrm.cxx | 39 ++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-)
New commits: commit 37b98c7d9a2598143e3c6454aced6a8ee9d2f704 Author: Miklos Vajna <[email protected]> Date: Wed Mar 23 16:44:43 2016 +0100 tdf#88453 sw layout: fix split of nested tables with large amount of rows This does not fix the original bugdoc, just the case described in comment 2. The bugdoc has an outer table of a single cell, and that cell has a nested table with a single column and many rows. When we split the table, we set the height of the last row frame to zero, then the height of the last but one, and so on, till the reduced table fits the page, then move the 0-height frames to the next page, and so on. All this recursively, to support nested tables. The problem is that 0-height is set only for the contents of the cell frames, but not for the cell or row frames themselves, so in case e.g. the default ~0.10cm inner margin of the cell frames, even a 0-height text frame results in a cell frame height of 111 twips. And this error can accumlate if there are enough rows, e.g. with the default fonts 123 rows are enough to trigger the situation when even a completely reduced table doesn't fit the first page frame, and the layout throws up its hands. Fix the problem by setting the height of the cell and row frames to 0 as well in case their content is 0-sized anyway (so a re-format will later restore their correct height). (cherry picked from commits b4b5dbee1ec7770ed64d7270de46d5cfc06b87b6 and f4eb82cf9fea5c1df49fad6ee2d91fc51854cd29) Conflicts: sw/qa/extras/uiwriter/uiwriter.cxx sw/source/core/layout/tabfrm.cxx Change-Id: Iefbbb7bd6ef97a9a81929eb2599adb961e52fd38 Reviewed-on: https://gerrit.libreoffice.org/23513 Tested-by: Jenkins <[email protected]> Reviewed-by: Andras Timar <[email protected]> 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 0000000..2c20561 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf88453-table.odt differ diff --git a/sw/qa/extras/uiwriter/data/tdf88453.odt b/sw/qa/extras/uiwriter/data/tdf88453.odt new file mode 100644 index 0000000..de8491b Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf88453.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index e835ee2..e386bcb 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -105,6 +105,8 @@ public: void testTdf89954(); void testTdf89720(); void testTdf96479(); + void testTdf88453(); + void testTdf88453Table(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -148,7 +150,8 @@ public: CPPUNIT_TEST(testTdf89954); CPPUNIT_TEST(testTdf89720); CPPUNIT_TEST(testTdf96479); - + CPPUNIT_TEST(testTdf88453); + CPPUNIT_TEST(testTdf88453Table); CPPUNIT_TEST_SUITE_END(); private: @@ -1247,6 +1250,25 @@ void SwUiWriterTest::testTdf96479() } } +void SwUiWriterTest::testTdf88453() +{ + createDoc("tdf88453.odt"); + calcLayout(); + xmlDocPtr pXmlDoc = parseLayoutDump(); + // This was 0: the table does not fit the first page, but it wasn't split + // to continue on the second page. + 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()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 4f80e08..e6c25fd 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -330,6 +330,7 @@ static void lcl_ShrinkCellsAndAllContent( SwRowFrm& rRow ) SwCellFrm* pCurrMasterCell = static_cast<SwCellFrm*>(rRow.Lower()); SWRECTFN( pCurrMasterCell ) + bool bAllCellsCollapsed = true; while ( pCurrMasterCell ) { // NEW TABLES @@ -346,6 +347,7 @@ static void lcl_ShrinkCellsAndAllContent( SwRowFrm& rRow ) // we have to start with the last lower frame, otherwise // the shrink will not shrink the current cell SwFrm* pTmp = rToAdjust.GetLastLower(); + bool bAllLowersCollapsed = true; if ( pTmp && pTmp->IsRowFrm() ) { @@ -361,17 +363,36 @@ static void lcl_ShrinkCellsAndAllContent( SwRowFrm& rRow ) if ( pTmp->IsTabFrm() ) { SwRowFrm* pTmpRow = static_cast<SwRowFrm*>(static_cast<SwTabFrm*>(pTmp)->Lower()); + bool bAllRowsCollapsed = true; + while ( pTmpRow ) { lcl_ShrinkCellsAndAllContent( *pTmpRow ); + + if ((pTmpRow->Frm().*fnRect->fnGetHeight)() > 0) + bAllRowsCollapsed = false; + pTmpRow = static_cast<SwRowFrm*>(pTmpRow->GetNext()); } + + if (bAllRowsCollapsed) + { + // All rows of this table have 0 height -> set height of the table itself as well. + (pTmp->Frm().*fnRect->fnSetHeight)(0); + (pTmp->Prt().*fnRect->fnSetTop)(0); + (pTmp->Prt().*fnRect->fnSetHeight)(0); + } + else + bAllLowersCollapsed = false; } else { pTmp->Shrink( (pTmp->Frm().*fnRect->fnGetHeight)() ); (pTmp->Prt().*fnRect->fnSetTop)( 0 ); (pTmp->Prt().*fnRect->fnSetHeight)( 0 ); + + if ((pTmp->Frm().*fnRect->fnGetHeight)() > 0) + bAllLowersCollapsed = false; } pTmp = pTmp->GetPrev(); @@ -383,8 +404,26 @@ static void lcl_ShrinkCellsAndAllContent( SwRowFrm& rRow ) false ); } + if (bAllLowersCollapsed) + { + // All lower frame of this cell have 0 height -> set height of the cell itself as well. + (pCurrMasterCell->Frm().*fnRect->fnSetHeight)(0); + (pCurrMasterCell->Prt().*fnRect->fnSetTop)(0); + (pCurrMasterCell->Prt().*fnRect->fnSetHeight)(0); + } + else + bAllCellsCollapsed = false; + pCurrMasterCell = static_cast<SwCellFrm*>(pCurrMasterCell->GetNext()); } + + if (bAllCellsCollapsed) + { + // All cells have 0 height -> set height of row as well. + (rRow.Frm().*fnRect->fnSetHeight)(0); + (rRow.Prt().*fnRect->fnSetTop)(0); + (rRow.Prt().*fnRect->fnSetHeight)(0); + } } // Local helper function to move the content from rSourceLine to rDestLine _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
