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-03 14:19:56 +0200 |
commit | 78b11422fa15f7d690b8a5398b03b7ce6897c49d (patch) | |
tree | 0bdcf2e1544c58fd79612cae0f7856877256e33b /sd | |
parent | d520cb91b6b577e815556a816a852d97e243141b (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)
Conflicts:
oox/inc/drawingml/textbodyproperties.hxx
Reviewed-on: https://gerrit.libreoffice.org/61244
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
(cherry picked from commit 6f1fb474694876bc4ffeb552dcc7bed8f32cd221)
Change-Id: Id7942b16882ab1f083ded2f0e577e8c9e128697c
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 f8ead710e9bf..f65322707958 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -178,6 +178,8 @@ public: bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected); void testPatternImport(); void testTdf119015(); + void testTdf120028(); + void testTdf120028b(); CPPUNIT_TEST_SUITE(SdImportTest); @@ -255,6 +257,8 @@ public: CPPUNIT_TEST(testTdf116266); CPPUNIT_TEST(testTdf114821); CPPUNIT_TEST(testTdf119015); + CPPUNIT_TEST(testTdf120028); + CPPUNIT_TEST(testTdf120028b); CPPUNIT_TEST_SUITE_END(); }; @@ -2472,6 +2476,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(); |