diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-06-05 00:19:06 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-06-10 10:17:38 +0200 |
commit | 3e72e178487c30eb7aa9343ece31937a4500da24 (patch) | |
tree | 0acae04238cb7fd94f0f0fc6f98a24c4d4a06d7d /sd | |
parent | e6ab0cd94e02b5a6be80a0052100175424311455 (diff) |
editengine-columns: PPTX support (tdf#118458)
The unit tests that used to check the workaround using tables to
emulate columns (implemented in tdf#120028) are changed to test
import of the columns.
This reverts some commits related to the mentioned workaround,
namely aef569ed83a3ccc02639e5b2a1c7cc131ba262fc,
c50ae6a282ed83762bf634fed5c91033eb305c88,
7b64bd90637a6722438bf873b1ded74ab3424c46,
33696b2820ce3c8b21b753d2c2bf92345ecb9276,
99dff69b561a8fe2d9437e6aa67a9581a6666f41.
Change-Id: I97693ad4a981780e822070938992f274920df5a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116738
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116881
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/3columns.pptx | bin | 0 -> 39915 bytes | |||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf120028b.pptx | bin | 29838 -> 0 bytes | |||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf140852.pptx | bin | 0 -> 49776 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 120 | ||||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 96 |
5 files changed, 144 insertions, 72 deletions
diff --git a/sd/qa/unit/data/pptx/3columns.pptx b/sd/qa/unit/data/pptx/3columns.pptx Binary files differnew file mode 100644 index 000000000000..596db14a0d21 --- /dev/null +++ b/sd/qa/unit/data/pptx/3columns.pptx diff --git a/sd/qa/unit/data/pptx/tdf120028b.pptx b/sd/qa/unit/data/pptx/tdf120028b.pptx Binary files differdeleted file mode 100644 index 7d50da36c120..000000000000 --- a/sd/qa/unit/data/pptx/tdf120028b.pptx +++ /dev/null diff --git a/sd/qa/unit/data/pptx/tdf140852.pptx b/sd/qa/unit/data/pptx/tdf140852.pptx Binary files differnew file mode 100644 index 000000000000..1332b5a68c8c --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf140852.pptx diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index c17820ea318b..c4a4bfd28b2b 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> #include <com/sun/star/frame/XLoadable.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -208,6 +209,8 @@ public: void testTdf119223(); void testTdf128213ShapeRot(); void testTdf96061_textHighlight(); + void testTextColumns_tdf140852(); + void testTextColumns_3columns(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -331,6 +334,8 @@ public: CPPUNIT_TEST(testTdf119223); CPPUNIT_TEST(testTdf128213ShapeRot); CPPUNIT_TEST(testTdf96061_textHighlight); + CPPUNIT_TEST(testTextColumns_tdf140852); + CPPUNIT_TEST(testTextColumns_3columns); CPPUNIT_TEST_SUITE_END(); @@ -3125,6 +3130,121 @@ void SdOOXMLExportTest2::testTdf96061_textHighlight() CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), aColor); } +void SdOOXMLExportTest2::testTextColumns_tdf140852() +{ + // The document defines two columns in slideLayout12.xml, but explicitly redefines + // in slide1.xml. Here we check that the redefinition in the slide takes precedence. + + auto xDocShRef = loadURL( + m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf140852.pptx"), PPTX); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps)); + CPPUNIT_ASSERT_EQUAL(OUString("Training will be treated as part of sharing the sweet when " + "it comes to serving ice cream"), + xParagraph->getString()); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(1000)), + xColProps->getPropertyValue("AutomaticDistance")); + } + + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps)); + CPPUNIT_ASSERT_EQUAL(OUString("Training will be treated as part of sharing the sweet when " + "it comes to serving ice cream"), + xParagraph->getString()); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(1000)), + xColProps->getPropertyValue("AutomaticDistance")); + } + + xDocShRef->DoClose(); + + xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "numCol", "1"); + assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "spcCol", "360000"); + + tempFile.EnableKillingFile(); +} + +void SdOOXMLExportTest2::testTextColumns_3columns() +{ + auto xDocShRef = loadURL( + m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/3columns.pptx"), PPTX); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(300)), + xColProps->getPropertyValue("AutomaticDistance")); + // Scale value may be unstable; just test that the text is actually scaled + sal_Int16 nScale; + CPPUNIT_ASSERT(xProps->getPropertyValue("TextFitToSizeScale") >>= nScale); + CPPUNIT_ASSERT_GREATER(sal_Int16(0), nScale); + CPPUNIT_ASSERT_LESS(sal_Int16(100), nScale); + } + + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(300)), + xColProps->getPropertyValue("AutomaticDistance")); + // Scale value may be unstable; just test that the text is actually scaled + sal_Int16 nScale; + CPPUNIT_ASSERT(xProps->getPropertyValue("TextFitToSizeScale") >>= nScale); + CPPUNIT_ASSERT_GREATER(sal_Int16(0), nScale); + CPPUNIT_ASSERT_LESS(sal_Int16(100), nScale); + } + + xDocShRef->DoClose(); + + xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "numCol", "3"); + assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "spcCol", "108000"); + + tempFile.EnableKillingFile(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index e140c41c126d..5e09f0a2996f 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -89,6 +89,7 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/text/XTextCursor.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <stlpool.hxx> @@ -225,7 +226,6 @@ public: void testPatternImport(); void testPptCrop(); void testTdf120028(); - void testTdf120028b(); void testDescriptionImport(); void testTdf83247(); void testTdf47365(); @@ -335,7 +335,6 @@ public: CPPUNIT_TEST(testTdf116266); CPPUNIT_TEST(testPptCrop); CPPUNIT_TEST(testTdf120028); - CPPUNIT_TEST(testTdf120028b); CPPUNIT_TEST(testDescriptionImport); CPPUNIT_TEST(testTdf83247); CPPUNIT_TEST(testTdf47365); @@ -990,26 +989,20 @@ void SdImportTest::testMultiColTexts() sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/multicol.pptx"), PPTX ); const SdrPage *pPage = GetPage( 1, xDocShRef ); - sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0)); - CPPUNIT_ASSERT( pTableObj ); + auto pTextObj = dynamic_cast<SdrTextObj*>(pPage->GetObj(0)); + CPPUNIT_ASSERT(pTextObj); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pTableObj->getRowCount()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pTableObj->getColumnCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), pTextObj->GetTextColumnsSpacing()); - sdr::table::SdrTableObj *pMasterTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->TRG_GetMasterPage().GetObj(0)); - CPPUNIT_ASSERT( pMasterTableObj ); + auto pMasterTextObj = dynamic_cast<SdrTextObj*>(pPage->TRG_GetMasterPage().GetObj(0)); + CPPUNIT_ASSERT(pMasterTextObj); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMasterTableObj->getRowCount()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMasterTableObj->getColumnCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pMasterTextObj->GetTextColumnsNumber()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), pMasterTextObj->GetTextColumnsSpacing()); - uno::Reference< table::XCellRange > xTable(pMasterTableObj->getTable(), uno::UNO_QUERY_THROW); - uno::Reference< beans::XPropertySet > xCell; - xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); - uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell)); - uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) ); - OUString sText = xRun->getString(); - - CPPUNIT_ASSERT_EQUAL(OUString(""), sText); //We don't import master table text for multicolumn case. + uno::Reference<text::XTextRange> xText(pMasterTextObj->getUnoShape(), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(OUString("mastershape1\nmastershape2"), xText->getString()); } void SdImportTest::testPredefinedTableStyle() @@ -3023,7 +3016,7 @@ void SdImportTest::testTdf116266() void SdImportTest::testTdf120028() { - // Check that the table shape has 4 columns. + // Check that the text 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(), @@ -3033,63 +3026,22 @@ void SdImportTest::testTdf120028() 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::XTextColumns> xCols(xShape->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xColProps->getPropertyValue("AutomaticDistance")); + + // Check font size in the shape. + uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape)); uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); - uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW); 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); + CPPUNIT_ASSERT_DOUBLES_EQUAL(13.5, fCharHeight, 1E-12); + // 13.5 * 86% is approx. 11.6 (the correct scaled font size) + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(86)), xShape->getPropertyValue("TextFitToSizeScale")); xDocShRef->DoClose(); } |