sd/CppunitTest_sd_import_tests_skia.mk |   13 +++++++++++
 sd/Module_sd.mk                        |    1 
 sd/qa/unit/data/pptx/tdf156856.pptx    |binary
 sd/qa/unit/import-tests_skia.cxx       |   36 +++++++++++++++++++++++++++++++++
 vcl/source/filter/graphicfilter.cxx    |    4 +--
 5 files changed, 52 insertions(+), 2 deletions(-)

New commits:
commit 3cf3e0e21d2f7fa33abced5e2f7291de6e4441eb
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Aug 22 17:45:03 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Aug 22 20:02:32 2023 +0200

    tdf#156856: close write access before using AlphaMask
    
    Change-Id: I432417f03d378f81c890ce6c313a2f140b564a60
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155955
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sd/CppunitTest_sd_import_tests_skia.mk 
b/sd/CppunitTest_sd_import_tests_skia.mk
new file mode 100644
index 000000000000..bb0d0ad2a3ba
--- /dev/null
+++ b/sd/CppunitTest_sd_import_tests_skia.mk
@@ -0,0 +1,13 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 
100 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call sd_import_test,_skia))
+$(eval $(call gb_CppunitTest_use_vcl_non_headless,sd_import_tests_skia))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 9b7736a41a5f..ff09ee8c5ba3 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -33,6 +33,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sd,\
                CppunitTest_sd_uimpress) \
     CppunitTest_sd_import_tests \
     CppunitTest_sd_import_tests2 \
+    CppunitTest_sd_import_tests_skia \
     CppunitTest_sd_import_tests-smartart \
     CppunitTest_sd_export_tests-ooxml1 \
     CppunitTest_sd_export_tests-ooxml2 \
diff --git a/sd/qa/unit/data/pptx/tdf156856.pptx 
b/sd/qa/unit/data/pptx/tdf156856.pptx
new file mode 100644
index 000000000000..a4624adbce91
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf156856.pptx differ
diff --git a/sd/qa/unit/import-tests_skia.cxx b/sd/qa/unit/import-tests_skia.cxx
new file mode 100644
index 000000000000..47f6406dde32
--- /dev/null
+++ b/sd/qa/unit/import-tests_skia.cxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include "sdmodeltestbase.hxx"
+
+#include <vcl/skia/SkiaHelper.hxx>
+
+// Tests here are expected to run with Skia enabled, similar to 
CppunitTest_vcl_skia.
+// At some point, this could be true for all tests?
+
+class SdImportTestSkia : public SdModelTestBase
+{
+public:
+    SdImportTestSkia()
+        : SdModelTestBase("/sd/qa/unit/data/")
+    {
+    }
+};
+
+CPPUNIT_TEST_FIXTURE(SdImportTestSkia, testTdf156856)
+{
+    // Loading the document must not fail assertion
+    createSdImpressDoc("pptx/tdf156856.pptx");
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index ffc3b7cb92de..83c091fa9ab3 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -635,10 +635,10 @@ void GraphicFilter::ImportGraphics(std::vector< 
std::shared_ptr<Graphic> >& rGra
     // Process data after import.
     for (auto& rContext : aContexts)
     {
-        if(rContext.m_pAlphaAccess) // Need to move the AlphaMask back to the 
BitmapEx.
-            *rContext.m_pGraphic = BitmapEx( 
rContext.m_pGraphic->GetBitmapExRef().GetBitmap(), rContext.mAlphaMask );
         rContext.m_pAccess.reset();
         rContext.m_pAlphaAccess.reset();
+        if (!rContext.mAlphaMask.IsEmpty()) // Need to move the AlphaMask back 
to the BitmapEx.
+            *rContext.m_pGraphic = BitmapEx( 
rContext.m_pGraphic->GetBitmapExRef().GetBitmap(), rContext.mAlphaMask );
 
         if (rContext.m_nStatus == ERRCODE_NONE && (rContext.m_eLinkType != 
GfxLinkType::NONE) && !rContext.m_pGraphic->GetReaderContext())
         {

Reply via email to