sd/qa/unit/PNGExportTests.cxx     |   53 ++++++++++++++++++++++++++++++++++++++
 sd/qa/unit/data/odg/tdf147119.odg |binary
 2 files changed, 53 insertions(+)

New commits:
commit 789e22f7eb115d56351f19ec238a5c92798b0a4c
Author:     Xisco Fauli <[email protected]>
AuthorDate: Wed Feb 2 13:35:31 2022 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Thu Feb 3 16:59:57 2022 +0100

    tdf#147119: sd_png_export_tests: Add unittest
    
    Change-Id: I69504a65926e3611e0d954d3ed317d45741b341b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129354
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx
index 86afd95bb267..a484cf735347 100644
--- a/sd/qa/unit/PNGExportTests.cxx
+++ b/sd/qa/unit/PNGExportTests.cxx
@@ -167,6 +167,59 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf113163)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf147119)
+{
+    mxComponent
+        = 
loadFromDesktop(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odg/tdf147119.odg"));
+    uno::Reference<uno::XComponentContext> xContext = getComponentContext();
+    CPPUNIT_ASSERT(xContext.is());
+    uno::Reference<drawing::XGraphicExportFilter> xGraphicExporter
+        = drawing::GraphicExportFilter::create(xContext);
+
+    uno::Sequence<beans::PropertyValue> aFilterData{
+        comphelper::makePropertyValue("PixelWidth", sal_Int32(100)),
+        comphelper::makePropertyValue("PixelHeight", sal_Int32(100)),
+        comphelper::makePropertyValue("Translucent", true),
+    };
+
+    utl::TempFile aTempFile;
+    aTempFile.EnableKillingFile();
+
+    uno::Sequence<beans::PropertyValue> aDescriptor{
+        comphelper::makePropertyValue("URL", aTempFile.GetURL()),
+        comphelper::makePropertyValue("FilterName", OUString("PNG")),
+        comphelper::makePropertyValue("FilterData", aFilterData)
+    };
+
+    uno::Reference<drawing::XDrawPagesSupplier> 
xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<lang::XComponent> 
xPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+                                           uno::UNO_QUERY);
+    xGraphicExporter->setSourceDocument(xPage);
+    xGraphicExporter->filter(aDescriptor);
+
+    SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
+    vcl::PngImageReader aPNGReader(aFileStream);
+    BitmapEx aBMPEx = aPNGReader.read();
+
+    Size aSize = aBMPEx.GetSizePixel();
+    CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize);
+    AlphaMask aAlpha = aBMPEx.GetAlpha();
+    {
+        AlphaMask::ScopedReadAccess pReadAccess(aAlpha);
+        for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX)
+        {
+            for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY)
+            {
+                // Without the fix in place, this test would have failed with
+                // - Expected: Color: R:255 G:255 B:255 A:0
+                // - Actual  : Color: R:0 G:0 B:0 A:0
+                const Color aColor = pReadAccess->GetColor(nX, nY);
+                CPPUNIT_ASSERT_EQUAL(COL_WHITE, aColor);
+            }
+        }
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf93124)
 {
     mxComponent
diff --git a/sd/qa/unit/data/odg/tdf147119.odg 
b/sd/qa/unit/data/odg/tdf147119.odg
new file mode 100644
index 000000000000..aafc9d600e4c
Binary files /dev/null and b/sd/qa/unit/data/odg/tdf147119.odg differ

Reply via email to