diff options
author | Sarper Akdemir <sarper.akdemir@collabora.com> | 2022-08-17 16:23:29 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-08-31 08:05:21 +0200 |
commit | a5126a21351c87138ff86a6636326eb6cd6a0f8c (patch) | |
tree | eb211306f04e98f041aab3d26ef790b56596211a /sd | |
parent | 4f738840d804a03c44fc9f468f3470688a43f926 (diff) |
tdf#144092 pptx import: correct table height during import
It appears PowerPoint can export rows of a table with row heights that
is less than the minimum height (for that row). And also export the
total table height wrong with it.
If PowerPoint imports such a table, those rows are individually
expanded to the minimum height. (Also increasing the table's total
height)
In Impress import we calculate table height by adding up individual
row heights. Table layouting code depends on the table height being
correct. This is why rows with less than minimum height lead to
layouting problems.
To compensate for this, while importing tables, layouting is skipped
until the table height is updated with the corrected height.
The correct height is calculated by layouting the table without
fitting to an area (i.e with bFit = false).
Change-Id: I79187882470a4e285b45bca1eabb469a084067f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138652
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/tdf144092-tableHeight.pptx | bin | 0 -> 34887 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 2 | ||||
-rw-r--r-- | sd/qa/unit/import-tests2.cxx | 17 |
3 files changed, 18 insertions, 1 deletions
diff --git a/sd/qa/unit/data/pptx/tdf144092-tableHeight.pptx b/sd/qa/unit/data/pptx/tdf144092-tableHeight.pptx Binary files differnew file mode 100644 index 000000000000..c597abf9a620 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf144092-tableHeight.pptx diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 6787133e3705..6c82d765f27f 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -442,7 +442,7 @@ void SdOOXMLExportTest2::testTdf119015() sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0)); CPPUNIT_ASSERT(pTableObj); // The position was previously not properly initialized: (0, 0, 100, 100) - CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(6991, 6902), Size(14099, 1999)), + CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(6991, 6902), Size(14099, 2000)), pTableObj->GetLogicRect()); uno::Reference<table::XTable> xTable(pTableObj->getTable()); diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index a1750c34042b..4357719597d9 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -138,6 +138,7 @@ public: void testTdf128596(); void testDefaultTabStop(); void testCropToZero(); + void testTdf144092TableHeight(); CPPUNIT_TEST_SUITE(SdImportTest2); @@ -210,6 +211,7 @@ public: CPPUNIT_TEST(testTdf128596); CPPUNIT_TEST(testDefaultTabStop); CPPUNIT_TEST(testCropToZero); + CPPUNIT_TEST(testTdf144092TableHeight); CPPUNIT_TEST_SUITE_END(); }; @@ -2092,6 +2094,21 @@ void SdImportTest2::testCropToZero() loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/croppedTo0.pptx"), PPTX); } +void SdImportTest2::testTdf144092TableHeight() +{ + sd::DrawDocShellRef xDocShRef = loadURL( + m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf144092-tableHeight.pptx"), PPTX); + + uno::Reference<drawing::XShape> xTableShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 7208 + // - Actual : 4595 + // i.e. the table height wasn't corrected by expanding less than minimum sized rows. + CPPUNIT_ASSERT_EQUAL(sal_Int32(7208), xTableShape->getSize().Height); + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); |