diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-09-21 11:50:57 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-10-02 21:04:01 +0200 |
commit | ff28de400ecf0e367d98a58285f3f82a8e85df6f (patch) | |
tree | 0bbb7d9fdf03643c14aa0fd4bf7c871d234ddbbd /sd | |
parent | 2c2ecb7eaa448f33162ce60154af207228ac05a8 (diff) |
tdf#120028 PPTX import: map shapes with multiple columns to table shapes
This is a combination of 3 commits.
1st commit:
Longer term the core Impress shape has to be improved so that it can have
text in multiple columns.
Shorter term, map text with multiple columns to table shapes, that gives
correct layout in many cases and requires changes to the import filter
only.
(cherry picked from commit aef569ed83a3ccc02639e5b2a1c7cc131ba262fc)
Commit #2:
Related: tdf#120028 PPTX import: fix font size of multi-col shape text
Normal shapes have a TextFitToSize property for this, but table cell
content has to be scaled manually, as the rendering has no automatic
support for them. Luckily the file format has the info we need to scale
at import time.
(cherry picked from commit c8b2849d140677f7b35523096eb2bc715b3dc507)
Commit #3:
Related: tdf#120028 PPTX import: fix font color of multi-col shape text
Not just font color, anything defined via list styles were not imported.
(cherry picked from commit 800bf1071a30955ff70373b2fb5886eadce59dee)
Change-Id: Id7942b16882ab1f083ded2f0e577e8c9e128697c
Reviewed-on: https://gerrit.libreoffice.org/61243
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/tdf120028.pptx | bin | 0 -> 30465 bytes | |||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf120028b.pptx | bin | 0 -> 29838 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 77 |
3 files changed, 77 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/tdf120028.pptx b/sd/qa/unit/data/pptx/tdf120028.pptx Binary files differnew file mode 100644 index 000000000000..035c36730663 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf120028.pptx diff --git a/sd/qa/unit/data/pptx/tdf120028b.pptx b/sd/qa/unit/data/pptx/tdf120028b.pptx Binary files differnew file mode 100644 index 000000000000..7d50da36c120 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf120028b.pptx diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 0c7f4debfd99..2ef5faebe78b 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -188,6 +188,8 @@ public: void testPatternImport(); void testPptCrop(); void testTdf119015(); + void testTdf120028(); + void testTdf120028b(); CPPUNIT_TEST_SUITE(SdImportTest); @@ -270,6 +272,8 @@ public: CPPUNIT_TEST(testTdf116266); CPPUNIT_TEST(testPptCrop); CPPUNIT_TEST(testTdf119015); + CPPUNIT_TEST(testTdf120028); + CPPUNIT_TEST(testTdf120028b); CPPUNIT_TEST_SUITE_END(); }; @@ -2557,6 +2561,79 @@ void SdImportTest::testTdf119015() xDocShRef->DoClose(); } +void SdImportTest::testTdf120028() +{ + // Check that the table shape has 4 columns. + ::sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf120028.pptx"), PPTX); + uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xDoc.is()); + + uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xPage.is()); + + // This failed, shape was not a table, all text was rendered in a single + // column. + uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage)); + uno::Reference<table::XColumnRowRange> xModel(xShape->getPropertyValue("Model"), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + + uno::Reference<table::XTableColumns> xColumns = xModel->getColumns(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xColumns->getCount()); + + // Check font size in the A1 cell. + uno::Reference<table::XCellRange> xCells(xModel, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xCell(xCells->getCellByPosition(0, 0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell)); + uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); + uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY); + double fCharHeight = 0; + xPropSet->getPropertyValue("CharHeight") >>= fCharHeight; + // This failed, non-scaled height was 13.5. + CPPUNIT_ASSERT_DOUBLES_EQUAL(11.5, fCharHeight, 1E-12); + + xDocShRef->DoClose(); +} + +void SdImportTest::testTdf120028b() +{ + // Check that the table shape has 4 columns. + ::sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf120028b.pptx"), PPTX); + uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xDoc.is()); + + uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xPage.is()); + + uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage)); + CPPUNIT_ASSERT(xShape.is()); + + uno::Reference<table::XColumnRowRange> xModel(xShape->getPropertyValue("Model"), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + + uno::Reference<table::XTableColumns> xColumns = xModel->getColumns(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xColumns->getCount()); + + // Check font color in the A1 cell. + uno::Reference<table::XCellRange> xCells(xModel, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xCell(xCells->getCellByPosition(0, 0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell)); + uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); + uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY); + sal_Int32 nCharColor = 0; + xPropSet->getPropertyValue("CharColor") >>= nCharColor; + // This was 0x1f497d, not white: text list style from placeholder shape + // from slide layout was ignored. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffff), nCharColor); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); |