bnc#816593 DOCX import: fix auto table width wrt nested tables

The bugdoc has a table with a single cell, and also a nested table in
that cell. Both tables have auto width. The problem was that the width
of the outer table was too large.

There is a trick in DomainMapperTableManager::startLevel() to get the
cell widths at the correct level: do the same in
DomainMapperTableManager::endLevel(), and that'll fix the table width
problem. (Because with that, the outer table will correctly have access
to its cell width.)

Change-Id: Ib750f0475364fd7e47c445cb54f2df34f3af085d
This commit is contained in:
Miklos Vajna
2013-08-28 16:15:12 +02:00
parent b70d4ad13b
commit 76d1ca523d
3 changed files with 22 additions and 0 deletions
Binary file not shown.
+13
View File
@@ -127,6 +127,7 @@ public:
void testFdo66474();
void testGroupshapeRotation();
void testBnc780044Spacing();
void testTableAutoNested();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -220,6 +221,7 @@ void Test::run()
{"fdo66474.docx", &Test::testFdo66474},
{"groupshape-rotation.docx", &Test::testGroupshapeRotation},
{"bnc780044_spacing.docx", &Test::testBnc780044Spacing},
{"table-auto-nested.docx", &Test::testTableAutoNested},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1495,6 +1497,17 @@ void Test::testBnc780044Spacing()
CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
}
void Test::testTableAutoNested()
{
// This was 176, when compat option is not enabled, the auto paragraph bottom margin value was incorrect.
CPPUNIT_ASSERT_EQUAL(sal_Int32(494), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
// This was 115596, i.e. the width of the outer table was too large.
CPPUNIT_ASSERT_EQUAL(sal_Int32(23051), getProperty<sal_Int32>(xTables->getByIndex(1), "Width"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
@@ -483,7 +483,16 @@ void DomainMapperTableManager::endLevel( )
{
m_aTableGrid.pop_back( );
m_aGridSpans.pop_back( );
// Do the same trick as in startLevel(): pop the value that was pushed too early.
boost::optional<sal_Int32> oCurrentWidth;
if (m_bPushCurrentWidth && !m_aCellWidths.empty() && !m_aCellWidths.back()->empty())
oCurrentWidth.reset(m_aCellWidths.back()->back());
m_aCellWidths.pop_back( );
// And push it back to the right level.
if (oCurrentWidth)
m_aCellWidths.back()->push_back(*oCurrentWidth);
m_nCell.pop_back( );
m_nTableWidth = 0;
m_nLayoutType = 0;