sd/qa/inc/sdtiledrenderingtest.hxx | 2 sd/qa/unit/PNGExportTests.cxx | 108 +++--- sd/qa/unit/SdrPdfImportTest.cxx | 5 sd/qa/unit/export-tests-ooxml2.cxx | 49 +- sd/qa/unit/export-tests-ooxml3.cxx | 3 sd/qa/unit/export-tests.cxx | 483 ++++++++++++++------------- sd/qa/unit/import-tests-smartart.cxx | 10 sd/qa/unit/import-tests.cxx | 6 sd/qa/unit/import-tests2.cxx | 48 +- sd/qa/unit/layout-tests.cxx | 58 +-- sd/qa/unit/tiledrendering/tiledrendering.cxx | 146 ++++---- 11 files changed, 498 insertions(+), 420 deletions(-)
New commits: commit ca6fe5a6a74177aedda411638e74ffcb12c1a4be Author: Xisco Fauli <[email protected]> AuthorDate: Fri Feb 6 10:55:35 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Feb 6 17:29:42 2026 +0100 sd: only load one document per test Change-Id: I0b235761d84e6ecad295518952dee2df7824994a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198829 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sd/qa/inc/sdtiledrenderingtest.hxx b/sd/qa/inc/sdtiledrenderingtest.hxx index 877747cf08eb..1ce66bd28cdc 100644 --- a/sd/qa/inc/sdtiledrenderingtest.hxx +++ b/sd/qa/inc/sdtiledrenderingtest.hxx @@ -51,6 +51,8 @@ protected: osl::Condition m_aDocumentSizeCondition; xmlBufferPtr m_pXmlBuffer; TestLokCallbackWrapper m_callbackWrapper; + + void testClipNumRules(const char* pFileName); }; /// A view callback tracks callbacks invoked on one specific view. diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx index bfc78b4781ec..065a506d02f3 100644 --- a/sd/qa/unit/PNGExportTests.cxx +++ b/sd/qa/unit/PNGExportTests.cxx @@ -28,6 +28,8 @@ public: : UnoApiTest(u"/sd/qa/unit/data/"_ustr) { } + + void checkVerticalAligment(std::u16string_view aFileName, bool bLegacy); }; static void assertColorsAreSimilar(const std::string& message, const BitmapColor& expected, @@ -797,59 +799,71 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf93124) CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf99729) { - const OUString filenames[] = { u"odp/tdf99729-new.odp"_ustr, u"odp/tdf99729-legacy.odp"_ustr }; - int nonwhitecounts[] = { 0, 0 }; - for (size_t i = 0; i < SAL_N_ELEMENTS(filenames); ++i) - { - // 1st check for new behaviour - having AnchoredTextOverflowLegacy compatibility flag set to false in settings.xml - loadFromFile(filenames[i]); - - uno::Reference<uno::XComponentContext> xContext = getComponentContext(); - CPPUNIT_ASSERT(xContext.is()); - uno::Reference<drawing::XGraphicExportFilter> xGraphicExporter - = drawing::GraphicExportFilter::create(xContext); - CPPUNIT_ASSERT(xGraphicExporter.is()); - - uno::Sequence<beans::PropertyValue> aFilterData{ - comphelper::makePropertyValue(u"PixelWidth"_ustr, sal_Int32(320)), - comphelper::makePropertyValue(u"PixelHeight"_ustr, sal_Int32(240)) - }; + checkVerticalAligment(u"odp/tdf99729-new.odp", false); +} - uno::Sequence<beans::PropertyValue> aDescriptor{ - comphelper::makePropertyValue(u"URL"_ustr, maTempFile.GetURL()), - comphelper::makePropertyValue(u"FilterName"_ustr, u"PNG"_ustr), - comphelper::makePropertyValue(u"FilterData"_ustr, aFilterData) - }; +CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf99729_Legacy) +{ + checkVerticalAligment(u"odp/tdf99729-legacy.odp", true); +} - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<lang::XComponent> xPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), - uno::UNO_QUERY); - CPPUNIT_ASSERT(xPage.is()); - xGraphicExporter->setSourceDocument(xPage); - xGraphicExporter->filter(aDescriptor); +void SdPNGExportTest::checkVerticalAligment(std::u16string_view aFileName, bool bLegacy) +{ + int nonwhitecounts = 0; + // 1st check for new behaviour - having AnchoredTextOverflowLegacy compatibility flag set to false in settings.xml + loadFromFile(aFileName); - SvFileStream aFileStream(maTempFile.GetURL(), StreamMode::READ); - vcl::PngImageReader aPNGReader(aFileStream); - Bitmap aBMP = aPNGReader.read(); - BitmapScopedReadAccess pRead(aBMP); - for (tools::Long nX = 154; nX < (154 + 12); ++nX) + uno::Reference<uno::XComponentContext> xContext = getComponentContext(); + CPPUNIT_ASSERT(xContext.is()); + uno::Reference<drawing::XGraphicExportFilter> xGraphicExporter + = drawing::GraphicExportFilter::create(xContext); + CPPUNIT_ASSERT(xGraphicExporter.is()); + + uno::Sequence<beans::PropertyValue> aFilterData{ + comphelper::makePropertyValue(u"PixelWidth"_ustr, sal_Int32(320)), + comphelper::makePropertyValue(u"PixelHeight"_ustr, sal_Int32(240)) + }; + + uno::Sequence<beans::PropertyValue> aDescriptor{ + comphelper::makePropertyValue(u"URL"_ustr, maTempFile.GetURL()), + comphelper::makePropertyValue(u"FilterName"_ustr, u"PNG"_ustr), + comphelper::makePropertyValue(u"FilterData"_ustr, aFilterData) + }; + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<lang::XComponent> xPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xPage.is()); + xGraphicExporter->setSourceDocument(xPage); + xGraphicExporter->filter(aDescriptor); + + SvFileStream aFileStream(maTempFile.GetURL(), StreamMode::READ); + vcl::PngImageReader aPNGReader(aFileStream); + Bitmap aBMP = aPNGReader.read(); + BitmapScopedReadAccess pRead(aBMP); + for (tools::Long nX = 154; nX < (154 + 12); ++nX) + { + for (tools::Long nY = 16; nY < (16 + 96); ++nY) { - for (tools::Long nY = 16; nY < (16 + 96); ++nY) - { - const Color aColor = pRead->GetColor(nY, nX); - if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) - || (aColor.GetBlue() != 0xff)) - ++nonwhitecounts[i]; - } + const Color aColor = pRead->GetColor(nY, nX); + if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) + || (aColor.GetBlue() != 0xff)) + ++nonwhitecounts; } } - // The numbers 1-9 should be above the Text Box in rectangle 154,16 - 170,112. - // If text alignment is wrong, the rectangle will be white. - CPPUNIT_ASSERT_MESSAGE("Tdf99729: vertical alignment of text is incorrect!", - nonwhitecounts[0] > 100); // it is 134 with cleartype disabled - // The numbers 1-9 should be below the Text Box -> rectangle 154,16 - 170,112 should be white. - CPPUNIT_ASSERT_EQUAL_MESSAGE("Tdf99729: legacy vertical alignment of text is incorrect!", 0, - nonwhitecounts[1]); + if (!bLegacy) + { + // The numbers 1-9 should be above the Text Box in rectangle 154,16 - 170,112. + // If text alignment is wrong, the rectangle will be white. + CPPUNIT_ASSERT_MESSAGE("Tdf99729: vertical alignment of text is incorrect!", + nonwhitecounts > 100); // it is 134 with cleartype disabled + } + else + { + // The numbers 1-9 should be below the Text Box -> rectangle 154,16 - 170,112 should be white. + CPPUNIT_ASSERT_EQUAL_MESSAGE("Tdf99729: legacy vertical alignment of text is incorrect!", 0, + nonwhitecounts); + } } CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf155048) diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx index 364feeca7089..f66c32b9c8fd 100644 --- a/sd/qa/unit/SdrPdfImportTest.cxx +++ b/sd/qa/unit/SdrPdfImportTest.cxx @@ -228,7 +228,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport) uno::Sequence<beans::PropertyValue> aFilterData( comphelper::InitPropertySequence({ { "ExportBookmarks", uno::Any(true) } })); aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; - save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); + saveAndReload(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); // Check PDF for annotations auto pPDFDocument = parsePDFExport(); @@ -248,8 +248,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport) CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFAnnotationSubType::Popup, pPDFAnnotation2->getSubType()); // Pop-up annotation - // Load document again - loadFromURL(maTempFile.GetURL()); + // check the loaded document again auto pNewImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); sd::ViewShell* pNewViewShell = pNewImpressDocument->GetDocShell()->GetViewShell(); CPPUNIT_ASSERT(pNewViewShell); diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index 225421f31951..3207e4d22861 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -1921,36 +1921,35 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf59323_slideFooters) assertXPath(pXmlDocSlide1, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:fld/a:rPr"); } -CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf53970) +CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf53970_embeddedMediaFile) { // Embedded media file - { - createSdImpressDoc("odp/tdf53970.odp"); - saveAndReload(TestFilter::PPTX); + createSdImpressDoc("odp/tdf53970.odp"); + saveAndReload(TestFilter::PPTX); - // Without fix in place, the media shape was lost on export. - CPPUNIT_ASSERT(getPage(0)->hasElements()); - } + // Without fix in place, the media shape was lost on export. + CPPUNIT_ASSERT(getPage(0)->hasElements()); +} +CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf53970_linkedMediaFile) +{ // Linked media file - { - createSdImpressDoc("odp/tdf53970_linked.odp"); - save(TestFilter::PPTX); - - xmlDocUniquePtr pXmlRels = parseExport(u"ppt/slides/_rels/slide1.xml.rels"_ustr); - CPPUNIT_ASSERT(pXmlRels); - assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@TargetMode='External']", 2); - - uno::Reference<beans::XPropertySet> xShape(getShape(0, getPage(0))); - CPPUNIT_ASSERT(xShape.is()); - OUString sVideoURL; - - // Without fix in place, the media shape was imported as an image after export - // and this test would have failed with exception of type com.sun.star.beans.UnknownPropertyException - CPPUNIT_ASSERT_MESSAGE("MediaURL property is not set", - xShape->getPropertyValue(u"MediaURL"_ustr) >>= sVideoURL); - CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL.isEmpty()); - } + createSdImpressDoc("odp/tdf53970_linked.odp"); + save(TestFilter::PPTX); + + xmlDocUniquePtr pXmlRels = parseExport(u"ppt/slides/_rels/slide1.xml.rels"_ustr); + CPPUNIT_ASSERT(pXmlRels); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@TargetMode='External']", 2); + + uno::Reference<beans::XPropertySet> xShape(getShape(0, getPage(0))); + CPPUNIT_ASSERT(xShape.is()); + OUString sVideoURL; + + // Without fix in place, the media shape was imported as an image after export + // and this test would have failed with exception of type com.sun.star.beans.UnknownPropertyException + CPPUNIT_ASSERT_MESSAGE("MediaURL property is not set", + xShape->getPropertyValue(u"MediaURL"_ustr) >>= sVideoURL); + CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL.isEmpty()); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx index 90c56b98a4a0..c193f7505f61 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -1132,7 +1132,10 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf168736) // Verify hyperlink to nextslide is properly exported the Relationship has Target attribute assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:hlinkClick", "action", u"ppaction://hlinkshowjump?jump=nextslide"); +} +CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf168736_2) +{ createSdImpressDoc("ppt/tdf168736-2.ppt"); save(TestFilter::PPTX); diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 822004ad2e82..2e5a68f1d38f 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -79,6 +79,11 @@ public: }; }; + void testLinkedGraphicRT(TestFilter eFilter); + void testImageWithSpecialID(TestFilter eFilter); + void testSwappedOutImageExport(TestFilter eFilter); + void testSvgImageSupport(TestFilter eFilter); + protected: uno::Reference<awt::XBitmap> getBitmapFromTable(OUString const& rName); }; @@ -558,16 +563,16 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf97630) 1); } -CPPUNIT_TEST_FIXTURE(SdExportTest, testImpressPasswordExport) +CPPUNIT_TEST_FIXTURE(SdExportTest, testImpressPasswordExport_ODP) { - std::vector<TestFilter> vFormat{ TestFilter::ODP, TestFilter::PPTX }; - - for (size_t i = 0; i < vFormat.size(); i++) - { - createSdImpressDoc(); + createSdImpressDoc(); + saveAndReload(TestFilter::ODP, /*rParams*/ {}, /*pPassword*/ "test"); +} - saveAndReload(vFormat[i], /*rParams*/ {}, /*pPassword*/ "test"); - } +CPPUNIT_TEST_FIXTURE(SdExportTest, testImpressPasswordExport_PPTX) +{ + createSdImpressDoc(); + saveAndReload(TestFilter::PPTX, /*rParams*/ {}, /*pPassword*/ "test"); } CPPUNIT_TEST_FIXTURE(SdExportTest, testDrawPasswordExport) @@ -577,67 +582,74 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testDrawPasswordExport) saveAndReload(TestFilter::ODG, /*rParams*/ {}, /*pPassword*/ "test"); } -CPPUNIT_TEST_FIXTURE(SdExportTest, testSwappedOutImageExport) +CPPUNIT_TEST_FIXTURE(SdExportTest, testSwappedOutImageExport_ODP) { - // Problem was with the swapped out images, which were not swapped in during export. + testSwappedOutImageExport(TestFilter::ODP); +} - std::vector<TestFilter> vFormat{ TestFilter::ODP, TestFilter::PPTX, TestFilter::PPT }; +CPPUNIT_TEST_FIXTURE(SdExportTest, testSwappedOutImageExport_PPT) +{ + testSwappedOutImageExport(TestFilter::PPT); +} - for (size_t i = 0; i < vFormat.size(); i++) - { - // Load the original file with one image - createSdImpressDoc("odp/document_with_two_images.odp"); - const OString sFailedMessage - = "Failed on filter: " + TestFilterNames.at(vFormat[i]).toUtf8(); +CPPUNIT_TEST_FIXTURE(SdExportTest, testSwappedOutImageExport_PPTX) +{ + testSwappedOutImageExport(TestFilter::PPTX); +} + +void SdExportTest::testSwappedOutImageExport(TestFilter eFilter) +{ + // Problem was with the swapped out images, which were not swapped in during export. + createSdImpressDoc("odp/document_with_two_images.odp"); + const OString sFailedMessage = "Failed on filter: " + TestFilterNames.at(eFilter).toUtf8(); - // Export the document and import again for a check - saveAndReload(vFormat[i]); + // Export the document and import again for a check + saveAndReload(eFilter); - // Check whether graphic exported well after it was swapped out - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, - uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), - xDrawPagesSupplier->getDrawPages()->getCount()); - uno::Reference<drawing::XDrawPage> xDrawPage( - xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW); + // Check whether graphic exported well after it was swapped out + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), + xDrawPagesSupplier->getDrawPages()->getCount()); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> XPropSet(xImage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> XPropSet(xImage, uno::UNO_QUERY_THROW); - // Check Graphic, Size - { - uno::Reference<graphic::XGraphic> xGraphic; - XPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), - xGraphic->getType() != graphic::GraphicType::EMPTY); - uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), - xBitmap->getSize().Width); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), - xBitmap->getSize().Height); - } + // Check Graphic, Size + { + uno::Reference<graphic::XGraphic> xGraphic; + XPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), + xGraphic->getType() != graphic::GraphicType::EMPTY); + uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), + xBitmap->getSize().Width); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), + xBitmap->getSize().Height); + } - // Second Image - xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW); - xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY); - XPropSet.set(xImage, uno::UNO_QUERY_THROW); + // Second Image + xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW); + xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY); + XPropSet.set(xImage, uno::UNO_QUERY_THROW); - // Check Graphic, Size - { - uno::Reference<graphic::XGraphic> xGraphic; - XPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), - xGraphic->getType() != graphic::GraphicType::EMPTY); - uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), - xBitmap->getSize().Width); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), - xBitmap->getSize().Height); - } + // Check Graphic, Size + { + uno::Reference<graphic::XGraphic> xGraphic; + XPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), + xGraphic->getType() != graphic::GraphicType::EMPTY); + uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), + xBitmap->getSize().Width); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), + xBitmap->getSize().Height); } } @@ -796,62 +808,74 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf128985) CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nWritingMode); } -CPPUNIT_TEST_FIXTURE(SdExportTest, testLinkedGraphicRT) +CPPUNIT_TEST_FIXTURE(SdExportTest, testLinkedGraphicRT_ODP) { - // FIXME: PPTX fails - std::vector<TestFilter> vFormat{ TestFilter::ODP, TestFilter::PPT }; - for (size_t i = 0; i < vFormat.size(); i++) - { - // Load the original file with one image - createSdImpressDoc("odp/document_with_linked_graphic.odp"); + testLinkedGraphicRT(TestFilter::ODP); +} - // Check if the graphic has been imported correctly (before doing the export/import run) - { - static constexpr OString sFailedImportMessage - = "Failed to correctly import the document"_ostr; - SdXImpressDocument* pXImpressDocument - = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pXImpressDocument); - SdDrawDocument* pDoc = pXImpressDocument->GetDoc(); - CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pDoc != nullptr); - const SdrPage* pPage = pDoc->GetPage(1); - CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pPage != nullptr); - SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2)); - CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject != nullptr); - CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject->IsLinkedGraphic()); - - const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), int(GraphicType::Bitmap), - int(rGraphicObj.GetGraphic().GetType())); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), sal_uLong(864900), - rGraphicObj.GetGraphic().GetSizeBytes()); - } +CPPUNIT_TEST_FIXTURE(SdExportTest, testLinkedGraphicRT_PPT) +{ + testLinkedGraphicRT(TestFilter::PPT); +} - // Save and reload - saveAndReload(vFormat[i]); +// FIXME: PPTX fails +/* +CPPUNIT_TEST_FIXTURE(SdExportTest, testLinkedGraphicRT_PPTX) +{ + testLinkedGraphicRT(TestFilter::PPTX); +} +*/ - // Check whether graphic imported well after export - { - const OString sFailedMessage - = "Failed on filter: " + TestFilterNames.at(vFormat[i]).toUtf8(); - - SdXImpressDocument* pXImpressDocument - = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); - CPPUNIT_ASSERT(pXImpressDocument); - SdDrawDocument* pDoc = pXImpressDocument->GetDoc(); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pDoc != nullptr); - const SdrPage* pPage = pDoc->GetPage(1); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pPage != nullptr); - SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2)); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObject != nullptr); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObject->IsLinkedGraphic()); - - const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), int(GraphicType::Bitmap), - int(rGraphicObj.GetGraphic().GetType())); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_uLong(864900), - rGraphicObj.GetGraphic().GetSizeBytes()); - } +void SdExportTest::testLinkedGraphicRT(TestFilter eFilter) +{ + // Load the original file with one image + createSdImpressDoc("odp/document_with_linked_graphic.odp"); + + // Check if the graphic has been imported correctly (before doing the export/import run) + { + static constexpr OString sFailedImportMessage + = "Failed to correctly import the document"_ostr; + SdXImpressDocument* pXImpressDocument + = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pXImpressDocument); + SdDrawDocument* pDoc = pXImpressDocument->GetDoc(); + CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pDoc != nullptr); + const SdrPage* pPage = pDoc->GetPage(1); + CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pPage != nullptr); + SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2)); + CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject != nullptr); + CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject->IsLinkedGraphic()); + + const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), int(GraphicType::Bitmap), + int(rGraphicObj.GetGraphic().GetType())); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), sal_uLong(864900), + rGraphicObj.GetGraphic().GetSizeBytes()); + } + + // Save and reload + saveAndReload(eFilter); + + // Check whether graphic imported well after export + { + const OString sFailedMessage = "Failed on filter: " + TestFilterNames.at(eFilter).toUtf8(); + + SdXImpressDocument* pXImpressDocument + = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pXImpressDocument); + SdDrawDocument* pDoc = pXImpressDocument->GetDoc(); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pDoc != nullptr); + const SdrPage* pPage = pDoc->GetPage(1); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pPage != nullptr); + SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2)); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObject != nullptr); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObject->IsLinkedGraphic()); + + const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), int(GraphicType::Bitmap), + int(rGraphicObj.GetGraphic().GetType())); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_uLong(864900), + rGraphicObj.GetGraphic().GetSizeBytes()); } } @@ -890,65 +914,73 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf79082) "position", u"25.4cm"); } -CPPUNIT_TEST_FIXTURE(SdExportTest, testImageWithSpecialID) +CPPUNIT_TEST_FIXTURE(SdExportTest, testImageWithSpecialID_ODP) { - // Check how LO handles when the imported graphic's ID is different from that one - // which is generated by LO. + testImageWithSpecialID(TestFilter::ODP); +} - std::vector<TestFilter> vFormat{ TestFilter::ODP, TestFilter::PPTX, TestFilter::PPT }; - for (size_t i = 0; i < vFormat.size(); i++) - { - // Load the original file - createSdImpressDoc("odp/images_with_special_IDs.odp"); - const OString sFailedMessage - = "Failed on filter: " + TestFilterNames.at(vFormat[i]).toUtf8(); - saveAndReload(vFormat[i]); +CPPUNIT_TEST_FIXTURE(SdExportTest, testImageWithSpecialID_PPT) +{ + testImageWithSpecialID(TestFilter::PPT); +} - // Check whether graphic was exported well - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, - uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), - xDrawPagesSupplier->getDrawPages()->getCount()); - uno::Reference<drawing::XDrawPage> xDrawPage( - xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW); +CPPUNIT_TEST_FIXTURE(SdExportTest, testImageWithSpecialID_PPTX) +{ + testImageWithSpecialID(TestFilter::PPTX); +} - uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> XPropSet(xImage, uno::UNO_QUERY_THROW); +void SdExportTest::testImageWithSpecialID(TestFilter eFilter) +{ + // Check how LO handles when the imported graphic's ID is different from that one + // which is generated by LO. + createSdImpressDoc("odp/images_with_special_IDs.odp"); + const OString sFailedMessage = "Failed on filter: " + TestFilterNames.at(eFilter).toUtf8(); + saveAndReload(eFilter); + + // Check whether graphic was exported well + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), + xDrawPagesSupplier->getDrawPages()->getCount()); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY_THROW); - // Check Graphic, Size - { - uno::Reference<graphic::XGraphic> xGraphic; - XPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), - xGraphic->getType() != graphic::GraphicType::EMPTY); - uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), - xBitmap->getSize().Width); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), - xBitmap->getSize().Height); - } + uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> XPropSet(xImage, uno::UNO_QUERY_THROW); - // Second Image - xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW); - xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY); - XPropSet.set(xImage, uno::UNO_QUERY_THROW); + // Check Graphic, Size + { + uno::Reference<graphic::XGraphic> xGraphic; + XPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), + xGraphic->getType() != graphic::GraphicType::EMPTY); + uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), + xBitmap->getSize().Width); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), + xBitmap->getSize().Height); + } - // Check Graphic, Size - { - uno::Reference<graphic::XGraphic> xGraphic; - XPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), - xGraphic->getType() != graphic::GraphicType::EMPTY); - uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), - xBitmap->getSize().Width); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), - xBitmap->getSize().Height); - } + // Second Image + xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW); + xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY); + XPropSet.set(xImage, uno::UNO_QUERY_THROW); + + // Check Graphic, Size + { + uno::Reference<graphic::XGraphic> xGraphic; + XPropSet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), + xGraphic->getType() != graphic::GraphicType::EMPTY); + uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is()); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), + xBitmap->getSize().Width); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), + xBitmap->getSize().Height); } } @@ -1535,46 +1567,44 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testPageWithTransparentBackground) CPPUNIT_TEST_FIXTURE(SdExportTest, testTextRotation) { - // Save behavior depends on whether ODF strict or extended is used. - comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); - // The contained shape has a text rotation vert="vert" which corresponds to // loext:writing-mode="tb-rl90" in the graphic-properties of the style of the shape in ODF 1.3 // extended. // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when // attribute value "tb-rl90" is included in ODF strict. - { - createSdImpressDoc("pptx/shape-text-rotate.pptx"); - saveAndReload(TestFilter::ODP); + createSdImpressDoc("pptx/shape-text-rotate.pptx"); + saveAndReload(TestFilter::ODP); - uno::Reference<drawing::XDrawPage> xPage(getPage(0)); - uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage)); - CPPUNIT_ASSERT(xPropSet.is()); + uno::Reference<drawing::XDrawPage> xPage(getPage(0)); + uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage)); + CPPUNIT_ASSERT(xPropSet.is()); + + auto aWritingMode = xPropSet->getPropertyValue(u"WritingMode"_ustr).get<sal_Int16>(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(text::WritingMode2::TB_RL90), aWritingMode); +} + +CPPUNIT_TEST_FIXTURE(SdExportTest, testTextRotation_ODFVER_013) +{ + comphelper::ScopeGuard g([]() { SetODFDefaultVersion(SvtSaveOptions::ODFVER_LATEST); }); - auto aWritingMode = xPropSet->getPropertyValue(u"WritingMode"_ustr).get<sal_Int16>(); - CPPUNIT_ASSERT_EQUAL(sal_Int16(text::WritingMode2::TB_RL90), aWritingMode); - } // In ODF 1.3 strict the workaround to use the TextRotateAngle is used instead. - { - SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); + SetODFDefaultVersion(SvtSaveOptions::ODFDefaultVersion::ODFVER_013); - createSdImpressDoc("pptx/shape-text-rotate.pptx"); - saveAndReload(TestFilter::ODP); + createSdImpressDoc("pptx/shape-text-rotate.pptx"); + saveAndReload(TestFilter::ODP); - uno::Reference<drawing::XDrawPage> xPage(getPage(0)); - uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage)); + uno::Reference<drawing::XDrawPage> xPage(getPage(0)); + uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage)); - CPPUNIT_ASSERT(xPropSet.is()); - auto aGeomPropSeq = xPropSet->getPropertyValue(u"CustomShapeGeometry"_ustr) - .get<uno::Sequence<beans::PropertyValue>>(); - comphelper::SequenceAsHashMap aCustomShapeGeometry(aGeomPropSeq); + CPPUNIT_ASSERT(xPropSet.is()); + auto aGeomPropSeq = xPropSet->getPropertyValue(u"CustomShapeGeometry"_ustr) + .get<uno::Sequence<beans::PropertyValue>>(); + comphelper::SequenceAsHashMap aCustomShapeGeometry(aGeomPropSeq); - auto it = aCustomShapeGeometry.find(u"TextRotateAngle"_ustr); - CPPUNIT_ASSERT(it != aCustomShapeGeometry.end()); + auto it = aCustomShapeGeometry.find(u"TextRotateAngle"_ustr); + CPPUNIT_ASSERT(it != aCustomShapeGeometry.end()); - CPPUNIT_ASSERT_EQUAL(double(-90), - aCustomShapeGeometry[u"TextRotateAngle"_ustr].get<double>()); - } + CPPUNIT_ASSERT_EQUAL(double(-90), aCustomShapeGeometry[u"TextRotateAngle"_ustr].get<double>()); } CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf115394PPT) @@ -2460,46 +2490,53 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf153179) CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getPage(0)->getCount()); } -CPPUNIT_TEST_FIXTURE(SdExportTest, testSvgImageSupport) +CPPUNIT_TEST_FIXTURE(SdExportTest, testSvgImageSupport_ODP) { - for (TestFilter eFormat : { TestFilter::ODP, TestFilter::PPTX }) - { - // Load the original file - createSdImpressDoc("odp/SvgImageTest.odp"); - // Save into the target format - saveAndReload(eFormat); + testSvgImageSupport(TestFilter::ODP); +} - const OString sFailedMessage = "Failed on filter: " + TestFilterNames.at(eFormat).toUtf8(); +CPPUNIT_TEST_FIXTURE(SdExportTest, testSvgImageSupport_PPTX) +{ + testSvgImageSupport(TestFilter::PPTX); +} - // Check whether SVG graphic was exported as expected - uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, - uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(1), - xDrawPagesSupplier->getDrawPages()->getCount()); - uno::Reference<drawing::XDrawPage> xDrawPage( - xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDrawPage.is()); +void SdExportTest::testSvgImageSupport(TestFilter eFilter) +{ + // Load the original file + createSdImpressDoc("odp/SvgImageTest.odp"); + // Save into the target format + saveAndReload(eFilter); - // Get the image - uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(0), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPropertySet(xImage, uno::UNO_QUERY_THROW); + const OString sFailedMessage = "Failed on filter: " + TestFilterNames.at(eFilter).toUtf8(); - // Convert to a XGraphic - uno::Reference<graphic::XGraphic> xGraphic; - xPropertySet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); + // Check whether SVG graphic was exported as expected + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(1), + xDrawPagesSupplier->getDrawPages()->getCount()); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDrawPage.is()); - // Access the Graphic - Graphic aGraphic(xGraphic); + // Get the image + uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xImage, uno::UNO_QUERY_THROW); - // Check if it contains a VectorGraphicData struct - auto pVectorGraphic = aGraphic.getVectorGraphicData(); - CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pVectorGraphic); + // Convert to a XGraphic + uno::Reference<graphic::XGraphic> xGraphic; + xPropertySet->getPropertyValue(u"Graphic"_ustr) >>= xGraphic; + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); - // Which should be of type SVG, which means we have a SVG file - CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), VectorGraphicDataType::Svg, - pVectorGraphic->getType()); - } + // Access the Graphic + Graphic aGraphic(xGraphic); + + // Check if it contains a VectorGraphicData struct + auto pVectorGraphic = aGraphic.getVectorGraphicData(); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pVectorGraphic); + + // Which should be of type SVG, which means we have a SVG file + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), VectorGraphicDataType::Svg, + pVectorGraphic->getType()); } CPPUNIT_TEST_FIXTURE(SdExportTest, testTableBordersTransparancy) diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx index acf70c5a4d27..22cbc6958669 100644 --- a/sd/qa/unit/import-tests-smartart.cxx +++ b/sd/qa/unit/import-tests-smartart.cxx @@ -375,16 +375,6 @@ CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt, testTextAutoRotation) testText(2, 15, u"p"_ustr, 2250, 0); } -CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt, testBasicProcess) -{ - //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet. -} - -CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt, testPyramid) -{ - //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet. -} - CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt, testPyramidOneChild) { // Load a document with a pyra algorithm in it. diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 56d487113d97..000f441f4499 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -1968,7 +1968,7 @@ CPPUNIT_TEST_FIXTURE(SdImportTest, testBnc910045) CPPUNIT_ASSERT_EQUAL(Color(0x4f81bd), nColor); } -CPPUNIT_TEST_FIXTURE(SdImportTest, testRowHeight) +CPPUNIT_TEST_FIXTURE(SdImportTest, testRowHeight_n80340) { createSdImpressDoc("pptx/n80340.pptx"); const SdrPage* pPage = GetPage(1); @@ -1982,7 +1982,10 @@ CPPUNIT_TEST_FIXTURE(SdImportTest, testRowHeight) uno::Reference<beans::XPropertySet> xRefRow(xRows->getByIndex(0), uno::UNO_QUERY_THROW); xRefRow->getPropertyValue(u"Height"_ustr) >>= nHeight; CPPUNIT_ASSERT_EQUAL(sal_Int32(508), nHeight); +} +CPPUNIT_TEST_FIXTURE(SdImportTest, testRowHeight_tableScale) +{ createSdImpressDoc("pptx/tablescale.pptx"); const SdrPage* pPage2 = GetPage(1); @@ -1992,6 +1995,7 @@ CPPUNIT_TEST_FIXTURE(SdImportTest, testRowHeight) uno::Reference<css::table::XTable> xTable2(pTableObj2->getTable(), uno::UNO_SET_THROW); uno::Reference<css::table::XTableRows> xRows2(xTable2->getRows(), uno::UNO_SET_THROW); + sal_Int32 nHeight; for (sal_Int32 nRow = 0; nRow < 7; ++nRow) { uno::Reference<beans::XPropertySet> xRefRow2(xRows2->getByIndex(nRow), diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index cc41b075d22a..570e2b9690cb 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -1552,27 +1552,43 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, testDescriptionImport) CPPUNIT_ASSERT_EQUAL(u"We Can Do It!"_ustr, sDesc); } -CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf83247) +CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf83247_odp_loopPause10) { - auto GetPause = [this](const OUString& sSrc) { - loadFromFile(sSrc); - uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(mxComponent, - uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPresentationProps( - xPresentationSupplier->getPresentation(), uno::UNO_QUERY_THROW); + // Check that presentation:pause attribute is imported correctly + loadFromFile(u"odp/loopPause10.odp"); + uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(mxComponent, + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(), + uno::UNO_QUERY_THROW); - auto retVal = xPresentationProps->getPropertyValue(u"Pause"_ustr); - return retVal.get<sal_Int32>(); - }; + auto retVal = xPresentationProps->getPropertyValue(u"Pause"_ustr); + CPPUNIT_ASSERT_EQUAL(sal_Int32(10), retVal.get<sal_Int32>()); +} - // 1. Check that presentation:pause attribute is imported correctly - CPPUNIT_ASSERT_EQUAL(sal_Int32(10), GetPause(u"odp/loopPause10.odp"_ustr)); +CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf83247_odp_loopNoPause) +{ + // ODF compliance: if presentation:pause attribute is absent, it must be treated as 0 + loadFromFile(u"odp/loopNoPause.odp"); + uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(mxComponent, + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(), + uno::UNO_QUERY_THROW); + + auto retVal = xPresentationProps->getPropertyValue(u"Pause"_ustr); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), retVal.get<sal_Int32>()); +} - // 2. ODF compliance: if presentation:pause attribute is absent, it must be treated as 0 - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause(u"odp/loopNoPause.odp"_ustr)); +CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf83247_ppt_loopNoPause) +{ + // Import PPT: pause should be 0 + loadFromFile(u"ppt/loopNoPause.ppt"); + uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(mxComponent, + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(), + uno::UNO_QUERY_THROW); - // 3. Import PPT: pause should be 0 - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause(u"ppt/loopNoPause.ppt"_ustr)); + auto retVal = xPresentationProps->getPropertyValue(u"Pause"_ustr); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), retVal.get<sal_Int32>()); } CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf47365) diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx index fe3a27418553..4663e8b1605c 100644 --- a/sd/qa/unit/layout-tests.cxx +++ b/sd/qa/unit/layout-tests.cxx @@ -369,30 +369,32 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf156955) CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf148966) { // Test related to IgnoreBreakAfterMultilineField compatibility flag. - { - createSdImpressDoc("pptx/tdf148966.pptx"); - xmlDocUniquePtr pXmlDoc = parseLayout(); - // Without the accompanying fix, would fail with: - // - Expected: 5952 - // - Actual : 7814 - // i.e. Line break after multiline field should have been ignored. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"5952"); - } - { - createSdImpressDoc("odp/tdf148966-withflag.odp"); - xmlDocUniquePtr pXmlDoc = parseLayout(); - // Without the accompanying fix, would fail with: - // - Expected: 5952 - // - Actual : 7814 - // i.e. When IgnoreBreakAfterMultilineField flag is set, line break - // after multiline field should have been ignored. - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"5952"); - } - { - createSdImpressDoc("odp/tdf148966-withoutflag.odp"); - xmlDocUniquePtr pXmlDoc = parseLayout(); - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"7814"); - } + createSdImpressDoc("pptx/tdf148966.pptx"); + xmlDocUniquePtr pXmlDoc = parseLayout(); + // Without the accompanying fix, would fail with: + // - Expected: 5952 + // - Actual : 7814 + // i.e. Line break after multiline field should have been ignored. + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"5952"); +} + +CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf148966_WithFlag) +{ + createSdImpressDoc("odp/tdf148966-withflag.odp"); + xmlDocUniquePtr pXmlDoc = parseLayout(); + // Without the accompanying fix, would fail with: + // - Expected: 5952 + // - Actual : 7814 + // i.e. When IgnoreBreakAfterMultilineField flag is set, line break + // after multiline field should have been ignored. + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"5952"); +} + +CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf148966_WithoutFlag) +{ + createSdImpressDoc("odp/tdf148966-withoutflag.odp"); + xmlDocUniquePtr pXmlDoc = parseLayout(); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"7814"); } CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTableVerticalText) @@ -509,7 +511,7 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf164622) "y", u"892"); } -CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf168010) +CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf168010_ODP_enabled) { // Test UseTrailingEmptyLinesInLayout compatibility option. // The test documents have an auto-shrink text "textbox "; the box itself is positioned @@ -544,7 +546,10 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf168010) CPPUNIT_ASSERT_DOUBLES_EQUAL(6700, y, 100); assertXPathContent(pXml, "/metafile['2']/push/push/textarray[3]/text", u"textbox"); } +} +CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf168010_ODP_disabled) +{ // 3. It must be disabled in an existing ODP without that option in settings.xml loadFromFile(u"odp/trailing-paragraphs.odp"); { @@ -568,7 +573,10 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf168010) CPPUNIT_ASSERT_DOUBLES_EQUAL(8100, y, 100); assertXPathContent(pXml, "/metafile['4']/push/push/textarray[3]/text", u"textbox"); } +} +CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf168010_PPTX) +{ // Now test PPTX and its round-trip. The text there imports as draw:custom-shape; it generates // a single textarray element. diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index f8002fd8ab2e..a0fc63542e0a 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1147,78 +1147,84 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testPostKeyEventInvalidation) * tests a cut/paste bug around bullet items in a list and * graphic (bitmap) bullet items in a list (Tdf103083, Tdf166882) */ -CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testClipNumRules) +CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testClipNumRules_tdf103083) { - std::vector<const char*> aFileNames = { "tdf103083.fodp", "tdf166882.odp" }; - for (const char* pFileName : aFileNames) - { - // Load the document. - SdXImpressDocument* pXImpressDocument = createDoc(pFileName); - CPPUNIT_ASSERT(pXImpressDocument); - - sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); - CPPUNIT_ASSERT(pViewShell); - SdPage* pActualPage = pViewShell->GetActualPage(); - - SdrObject* pObject1 = pActualPage->GetObj(1); - CPPUNIT_ASSERT_EQUAL(SdrObjKind::OutlineText, pObject1->GetObjIdentifier()); - SdrTextObj* pTextObject = static_cast<SdrTextObj*>(pObject1); - - SdrView* pView = pViewShell->GetView(); - - // select contents of bullet item - ::tools::Rectangle aRect = pTextObject->GetCurrentBoundRect(); - pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, - o3tl::toTwips(aRect.Left() + 2, o3tl::Length::mm100), o3tl::toTwips(aRect.Top() + 2, o3tl::Length::mm100), - 1, MOUSE_LEFT, 0); - pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, - o3tl::toTwips(aRect.Left() + 2, o3tl::Length::mm100), o3tl::toTwips(aRect.Top() + 2, o3tl::Length::mm100), - 1, MOUSE_LEFT, 0); - Scheduler::ProcessEventsToIdle(); - pView->SdrBeginTextEdit(pTextObject); - CPPUNIT_ASSERT(pView->GetTextEditObject()); - EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView(); - rEditView.SetSelection(ESelection(2, 0, 2, 33)); // start para, start char, end para, end char. - CPPUNIT_ASSERT_EQUAL(u"They have all the same formatting"_ustr, rEditView.GetSelected()); - SdrOutliner* pOutliner = pView->GetTextEditOutliner(); - CPPUNIT_ASSERT_EQUAL(u"No-Logo Content~LT~Gliederung 2"_ustr, - pOutliner->GetStyleSheet(2)->GetName()); - const EditTextObject& aEdit = pTextObject->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem* pNumFmt = aEdit.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET); - SvxNumberFormat aNumFmt(pNumFmt->GetNumRule().GetLevel(2)); - - // cut contents of bullet item - dispatchCommand(mxComponent, u".uno:Cut"_ustr, uno::Sequence<beans::PropertyValue>()); - - CPPUNIT_ASSERT(pView->GetTextEditObject()); - EditView& rEditView2 = pView->GetTextEditOutlinerView()->GetEditView(); - rEditView2.SetSelection(ESelection(2, 0, 2, 10)); // start para, start char, end para, end char. - CPPUNIT_ASSERT_EQUAL(OUString(), rEditView2.GetSelected()); - - // paste contents of bullet item - dispatchCommand(mxComponent, u".uno:Paste"_ustr, uno::Sequence<beans::PropertyValue>()); - - // send an ESC key to trigger the commit of the edit to the main model - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE); - pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE); - Scheduler::ProcessEventsToIdle(); + testClipNumRules("tdf103083.fodp"); +} - pView->SdrBeginTextEdit(pTextObject); - CPPUNIT_ASSERT(pView->GetTextEditObject()); - pOutliner = pView->GetTextEditOutliner(); - EditView& rEditView3 = pView->GetTextEditOutlinerView()->GetEditView(); - rEditView3.SetSelection(ESelection(2, 0, 2, 33)); // start para, start char, end para, end char. - CPPUNIT_ASSERT_EQUAL(u"They have all the same formatting"_ustr, rEditView3.GetSelected()); - CPPUNIT_ASSERT_EQUAL(u"No-Logo Content~LT~Gliederung 2"_ustr, - pOutliner->GetStyleSheet(2)->GetName()); - - const EditTextObject& aEdit2 = pTextObject->GetOutlinerParaObject()->GetTextObject(); - const SvxNumBulletItem* pNumFmt2 = aEdit2.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET); - SvxNumberFormat aNumFmt2(pNumFmt2->GetNumRule().GetLevel(2)); - - bool bEqual(aNumFmt2 == aNumFmt); - CPPUNIT_ASSERT_MESSAGE("Bullet properties changed after paste", bEqual); - } +CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testClipNumRules_tdf166882) +{ + testClipNumRules("tdf166882.odp"); +} + +void SdTiledRenderingTest::testClipNumRules(const char* pFileName) +{ + // Load the document. + SdXImpressDocument* pXImpressDocument = createDoc(pFileName); + CPPUNIT_ASSERT(pXImpressDocument); + + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + SdPage* pActualPage = pViewShell->GetActualPage(); + + SdrObject* pObject1 = pActualPage->GetObj(1); + CPPUNIT_ASSERT_EQUAL(SdrObjKind::OutlineText, pObject1->GetObjIdentifier()); + SdrTextObj* pTextObject = static_cast<SdrTextObj*>(pObject1); + + SdrView* pView = pViewShell->GetView(); + + // select contents of bullet item + ::tools::Rectangle aRect = pTextObject->GetCurrentBoundRect(); + pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, + o3tl::toTwips(aRect.Left() + 2, o3tl::Length::mm100), o3tl::toTwips(aRect.Top() + 2, o3tl::Length::mm100), + 1, MOUSE_LEFT, 0); + pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, + o3tl::toTwips(aRect.Left() + 2, o3tl::Length::mm100), o3tl::toTwips(aRect.Top() + 2, o3tl::Length::mm100), + 1, MOUSE_LEFT, 0); + Scheduler::ProcessEventsToIdle(); + pView->SdrBeginTextEdit(pTextObject); + CPPUNIT_ASSERT(pView->GetTextEditObject()); + EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView(); + rEditView.SetSelection(ESelection(2, 0, 2, 33)); // start para, start char, end para, end char. + CPPUNIT_ASSERT_EQUAL(u"They have all the same formatting"_ustr, rEditView.GetSelected()); + SdrOutliner* pOutliner = pView->GetTextEditOutliner(); + CPPUNIT_ASSERT_EQUAL(u"No-Logo Content~LT~Gliederung 2"_ustr, + pOutliner->GetStyleSheet(2)->GetName()); + const EditTextObject& aEdit = pTextObject->GetOutlinerParaObject()->GetTextObject(); + const SvxNumBulletItem* pNumFmt = aEdit.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET); + SvxNumberFormat aNumFmt(pNumFmt->GetNumRule().GetLevel(2)); + + // cut contents of bullet item + dispatchCommand(mxComponent, u".uno:Cut"_ustr, uno::Sequence<beans::PropertyValue>()); + + CPPUNIT_ASSERT(pView->GetTextEditObject()); + EditView& rEditView2 = pView->GetTextEditOutlinerView()->GetEditView(); + rEditView2.SetSelection(ESelection(2, 0, 2, 10)); // start para, start char, end para, end char. + CPPUNIT_ASSERT_EQUAL(OUString(), rEditView2.GetSelected()); + + // paste contents of bullet item + dispatchCommand(mxComponent, u".uno:Paste"_ustr, uno::Sequence<beans::PropertyValue>()); + + // send an ESC key to trigger the commit of the edit to the main model + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE); + Scheduler::ProcessEventsToIdle(); + + pView->SdrBeginTextEdit(pTextObject); + CPPUNIT_ASSERT(pView->GetTextEditObject()); + pOutliner = pView->GetTextEditOutliner(); + EditView& rEditView3 = pView->GetTextEditOutlinerView()->GetEditView(); + rEditView3.SetSelection(ESelection(2, 0, 2, 33)); // start para, start char, end para, end char. + CPPUNIT_ASSERT_EQUAL(u"They have all the same formatting"_ustr, rEditView3.GetSelected()); + CPPUNIT_ASSERT_EQUAL(u"No-Logo Content~LT~Gliederung 2"_ustr, + pOutliner->GetStyleSheet(2)->GetName()); + + const EditTextObject& aEdit2 = pTextObject->GetOutlinerParaObject()->GetTextObject(); + const SvxNumBulletItem* pNumFmt2 = aEdit2.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET); + SvxNumberFormat aNumFmt2(pNumFmt2->GetNumRule().GetLevel(2)); + + bool bEqual(aNumFmt2 == aNumFmt); + CPPUNIT_ASSERT_MESSAGE("Bullet properties changed after paste", bEqual); } /**
