[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Mar 25 13:45:49 UTC 2016
sw/qa/extras/uiwriter/data/tdf88453-table.odt |binary
sw/qa/extras/uiwriter/data/tdf88453.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 23 +++++++++++++++
sw/source/core/layout/tabfrm.cxx | 39 ++++++++++++++++++++++++++
4 files changed, 62 insertions(+)
New commits:
commit 51ead29f8a4ee006d60b91b9a2966a58461c5569
Author: Miklos Vajna <vmiklos at collabora.co.uk>
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
Change-Id: Iefbbb7bd6ef97a9a81929eb2599adb961e52fd38
Reviewed-on: https://gerrit.libreoffice.org/23512
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
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 3e49ee9..653b3db 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -177,6 +177,8 @@ public:
void testTdf96479();
void testTdf96536();
void testTdf96961();
+ void testTdf88453();
+ void testTdf88453Table();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -262,6 +264,8 @@ public:
CPPUNIT_TEST(testTdf96479);
CPPUNIT_TEST(testTdf96536);
CPPUNIT_TEST(testTdf96961);
+ CPPUNIT_TEST(testTdf88453);
+ CPPUNIT_TEST(testTdf88453Table);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3072,6 +3076,25 @@ void SwUiWriterTest::testTdf96961()
CPPUNIT_ASSERT(nLast > nOther);
}
+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 cea182f..4f73aaa 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -331,6 +331,7 @@ static void lcl_ShrinkCellsAndAllContent( SwRowFrame& rRow )
SwCellFrame* pCurrMasterCell = static_cast<SwCellFrame*>(rRow.Lower());
SWRECTFN( pCurrMasterCell )
+ bool bAllCellsCollapsed = true;
while ( pCurrMasterCell )
{
// NEW TABLES
@@ -347,6 +348,7 @@ static void lcl_ShrinkCellsAndAllContent( SwRowFrame& rRow )
// we have to start with the last lower frame, otherwise
// the shrink will not shrink the current cell
SwFrame* pTmp = rToAdjust.GetLastLower();
+ bool bAllLowersCollapsed = true;
if ( pTmp && pTmp->IsRowFrame() )
{
@@ -362,17 +364,36 @@ 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
{
pTmp->Shrink( (pTmp->Frame().*fnRect->fnGetHeight)() );
(pTmp->Prt().*fnRect->fnSetTop)( 0 );
(pTmp->Prt().*fnRect->fnSetHeight)( 0 );
+
+ if ((pTmp->Frame().*fnRect->fnGetHeight)() > 0)
+ bAllLowersCollapsed = false;
}
pTmp = pTmp->GetPrev();
@@ -384,8 +405,26 @@ static void lcl_ShrinkCellsAndAllContent( SwRowFrame& rRow )
false );
}
+ if (bAllLowersCollapsed)
+ {
+ // All lower frame of this cell have 0 height -> set height of the cell itself as well.
+ (pCurrMasterCell->Frame().*fnRect->fnSetHeight)(0);
+ (pCurrMasterCell->Prt().*fnRect->fnSetTop)(0);
+ (pCurrMasterCell->Prt().*fnRect->fnSetHeight)(0);
+ }
+ else
+ bAllCellsCollapsed = false;
+
pCurrMasterCell = static_cast<SwCellFrame*>(pCurrMasterCell->GetNext());
}
+
+ if (bAllCellsCollapsed)
+ {
+ // All cells have 0 height -> set height of row as well.
+ (rRow.Frame().*fnRect->fnSetHeight)(0);
+ (rRow.Prt().*fnRect->fnSetTop)(0);
+ (rRow.Prt().*fnRect->fnSetHeight)(0);
+ }
}
// Local helper function to move the content from rSourceLine to rDestLine
More information about the Libreoffice-commits
mailing list