oox/source/drawingml/fillproperties.cxx | 19 +++++++++++++++++++ sd/qa/unit/data/pptx/greysscale-graphic.pptx |binary sd/qa/unit/import-tests.cxx | 16 ++++++++++++++++ 3 files changed, 35 insertions(+)
New commits: commit 11c5329669e7a908b43a3fe51a673e8d78740f8c Author: Gülşah Köse <[email protected]> AuthorDate: Mon Feb 8 13:30:39 2021 +0300 Commit: Miklos Vajna <[email protected]> CommitDate: Wed Feb 17 09:14:25 2021 +0100 tdf#134210 Handle greyscale effect on bitmap filled custom shapes. Change-Id: Ia4a0828dad80e32cc0c7fe12227ffca717d62e03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110572 Tested-by: Jenkins Reviewed-by: Gülşah Köse <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110965 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 5ac24b948f98..bdd81e1d0434 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -172,6 +172,22 @@ Reference< XGraphic > lclMirrorGraphic(uno::Reference<graphic::XGraphic> const & return aReturnGraphic.GetXGraphic(); } +Reference< XGraphic > lclGreysScaleGraphic(uno::Reference<graphic::XGraphic> const & xGraphic) +{ + ::Graphic aGraphic(xGraphic); + ::Graphic aReturnGraphic; + + assert (aGraphic.GetType() == GraphicType::Bitmap); + + BitmapEx aBitmapEx(aGraphic.GetBitmapEx()); + aBitmapEx.Convert(BmpConversion::N8BitGreys); + + aReturnGraphic = ::Graphic(aBitmapEx); + aReturnGraphic.setOriginURL(aGraphic.getOriginURL()); + + return aReturnGraphic.GetXGraphic(); +} + Reference< XGraphic > lclCheckAndApplyChangeColorTransform(const BlipFillProperties &aBlipProps, uno::Reference<graphic::XGraphic> const & xGraphic, const GraphicHelper& rGraphicHelper, const ::Color nPhClr) { @@ -887,6 +903,9 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe if(bFlipH || bFlipV) xGraphic = lclMirrorGraphic(xGraphic, bFlipH, bFlipV ); + if(eColorMode == ColorMode_GREYS) + xGraphic = lclGreysScaleGraphic( xGraphic ); + rPropMap.setProperty(PROP_FillBitmap, xGraphic); } else diff --git a/sd/qa/unit/data/pptx/greysscale-graphic.pptx b/sd/qa/unit/data/pptx/greysscale-graphic.pptx new file mode 100644 index 000000000000..547b60c10269 Binary files /dev/null and b/sd/qa/unit/data/pptx/greysscale-graphic.pptx differ diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index e0c725031f10..6b52466c2513 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -210,6 +210,7 @@ public: void testTdf119187(); void testMirroredGraphic(); void testCropPositionGraphic(); + void testGreysScaleGraphic(); bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected); void testPatternImport(); @@ -338,6 +339,7 @@ public: CPPUNIT_TEST(testTdf119187); CPPUNIT_TEST(testMirroredGraphic); CPPUNIT_TEST(testCropPositionGraphic); + CPPUNIT_TEST(testGreysScaleGraphic); CPPUNIT_TEST_SUITE_END(); }; @@ -3254,6 +3256,20 @@ void SdImportTest::testCropPositionGraphic() xDocShRef->DoClose(); } +void SdImportTest::testGreysScaleGraphic() +{ + sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/greysscale-graphic.pptx"), PPTX); + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW); + CPPUNIT_ASSERT(xShape.is()); + uno::Reference<graphic::XGraphic> xGraphic; + xShape->getPropertyValue("FillBitmap") >>= xGraphic; + CPPUNIT_ASSERT(xGraphic.is()); + Graphic aGraphic(xGraphic); + BitmapEx aBitmap(aGraphic.GetBitmapEx()); + CPPUNIT_ASSERT_EQUAL( Color(3947580), aBitmap.GetPixelColor( 0, 0 )); + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
