emfio/source/reader/wmfreader.cxx | 7 +++++- sd/qa/unit/SVGExportTests.cxx | 15 -------------- vcl/qa/cppunit/pdfexport/pdfexport.cxx | 35 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 16 deletions(-)
New commits: commit b0e6f49aaf6897b1102ef92b1474ffbc64a71e09 Author: Hossein <hoss...@libreoffice.org> AuthorDate: Mon Nov 29 14:43:36 2021 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Nov 30 15:20:26 2021 +0100 tdf#145873 Fix FILEOPEN: EMF file not displayed #2 The previous patch 149bd802623d6d83ec9aa04514b938494f7f01f6 only partially fixed the problem, and the size of the graphical objects was wrongly calculated. This patch fixes this problem. The fix can be tested with: make CPPUNIT_TEST_NAME="testTdf145873" -sr \ CppunitTest_vcl_pdfexport This test exports the PPTX to PDF and checks the size of the objects. The previous test for this issue which exported to SVG is removed, as it could not test the current situation. Change-Id: I97bed99811eaf8236ded84ffe0c1a7d3d1b5bad5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125924 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl> (cherry picked from commit 20d5e320801606856c1d05c4f34d9fa82371aac8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126102 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 47513101777d..f84fdcce4cc6 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -1690,12 +1690,17 @@ namespace emfio bRet = false; break; } - else if ( nFunction == W_META_EOF ) + else if ( nRSize == 3 && nFunction == W_META_EOF ) { break; } switch( nFunction ) { + case W_META_EOF: + { + return; + } + case W_META_SETWINDOWORG: { aWinOrg = ReadYX(); diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx index 1257478e5ed2..d43815264d26 100644 --- a/sd/qa/unit/SVGExportTests.cxx +++ b/sd/qa/unit/SVGExportTests.cxx @@ -35,7 +35,6 @@ #define SVG_USE *[name()='use'] #define SVG_PATTERN *[name()='pattern'] #define SVG_RECT *[name()='rect'] -#define SVG_FONT *[name()='font'] using namespace css; @@ -335,19 +334,6 @@ public: assertXPathContent(svgDoc, SAL_STRINGIFY( /SVG_SVG/SVG_DEFS[9]/SVG_G[2]/SVG_G[2]/SVG_G[7]/SVG_G/SVG_TEXT/SVG_TSPAN/SVG_TSPAN/SVG_TSPAN ), "<number>"); } - void testTdf145873() - { - load( u"/sd/qa/unit/data/pptx/", "tdf145873.pptx" ); - save(); - - xmlDocUniquePtr svgDoc = parseXml(maTempFile); - CPPUNIT_ASSERT(svgDoc); - - // Witout the fix in place, it would have filed with: - // - Expected: 22 - Actual : 3 - number of child-nodes is incorrect - assertXPathChildren(svgDoc, SAL_STRINGIFY( /SVG_SVG/SVG_DEFS[6]/SVG_FONT ), 22); - } - CPPUNIT_TEST_SUITE(SdSVGFilterTest); CPPUNIT_TEST(testSVGExportTextDecorations); CPPUNIT_TEST(testSVGExportJavascriptURL); @@ -356,7 +342,6 @@ public: CPPUNIT_TEST(testSVGExportSlideBitmapBackground); CPPUNIT_TEST(testSVGExportSlideTileBitmapBackground); CPPUNIT_TEST(testSVGPlaceholderLocale); - CPPUNIT_TEST(testTdf145873); CPPUNIT_TEST_SUITE_END(); }; diff --git a/sd/qa/unit/data/pptx/tdf145873.pptx b/vcl/qa/cppunit/pdfexport/data/tdf145873.pptx similarity index 100% rename from sd/qa/unit/data/pptx/tdf145873.pptx rename to vcl/qa/cppunit/pdfexport/data/tdf145873.pptx diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index c21c4241b609..f4b6031ea4c3 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2823,6 +2823,41 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf144222) #endif } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf145873) +{ + // Import the bugdoc and export as PDF. + aMediaDescriptor["FilterName"] <<= OUString("impress_pdf_Export"); + saveAsPDF(u"tdf145873.pptx"); + + std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parseExport(); + CPPUNIT_ASSERT(pPdfDocument); + + // The document has one page. + CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); + + std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0); + CPPUNIT_ASSERT(pPdfPage); + int nPageObjectCount = pPdfPage->getObjectCount(); + + // tdf#145873: Without the fix #1 in place, this test would have failed with + // - Expected: 318 + // - Actual : 3 + CPPUNIT_ASSERT_EQUAL(318, nPageObjectCount); + + auto pObject = pPdfPage->getObject(4); + CPPUNIT_ASSERT_MESSAGE("no object", pObject != nullptr); + + // tdf#145873: Without the fix #2 in place, this test would have failed with + // - Expected: 3.23 + // - Actual : 3.57... + // - Delta : 0.1 + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.23, pObject->getBounds().getWidth(), 0.1); + // - Expected: 3.49 + // - Actual : 3.74... + // - Delta : 0.1 + CPPUNIT_ASSERT_DOUBLES_EQUAL(3.49, pObject->getBounds().getHeight(), 0.1); +} + } // end anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT();