diff options
author | Sarper Akdemir <sarper.akdemir@collabora.com> | 2022-09-19 09:56:57 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-09-20 08:29:29 +0200 |
commit | 9ecc76988ec46ba0d6c5cb72ac88f65da48867b1 (patch) | |
tree | 86a1409d99ad0a0b724ebd92ba6658d411dbc045 /sd | |
parent | 4616f006df9497a8beaeb9181368b8708f1eeedc (diff) |
tdf#89928 pptx import: implement import of BiLevel threshold
Implement import BiLevel effect's threshold value.
If threshold isn't exactly 50%, we can't map it to the doc model.
Therefore as a workaround apply the BiLevel (Black/White) effect with
specified threshold directly to the graphic.
Change-Id: Ib24d149d74b103d926560708c68bb937b02c4cfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140136
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/tdf89928-blackWhiteEffectThreshold.pptx | bin | 0 -> 36640 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests2.cxx | 45 |
2 files changed, 45 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/tdf89928-blackWhiteEffectThreshold.pptx b/sd/qa/unit/data/pptx/tdf89928-blackWhiteEffectThreshold.pptx Binary files differnew file mode 100644 index 000000000000..90edf8ea0afb --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf89928-blackWhiteEffectThreshold.pptx diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index 17c793d08ab8..bf4939c39365 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -141,6 +141,7 @@ public: void testDefaultTabStop(); void testCropToZero(); void testTdf144092TableHeight(); + void testTdf89928BlackWhiteThreshold(); CPPUNIT_TEST_SUITE(SdImportTest2); @@ -215,6 +216,7 @@ public: CPPUNIT_TEST(testDefaultTabStop); CPPUNIT_TEST(testCropToZero); CPPUNIT_TEST(testTdf144092TableHeight); + CPPUNIT_TEST(testTdf89928BlackWhiteThreshold); CPPUNIT_TEST_SUITE_END(); }; @@ -2121,6 +2123,49 @@ void SdImportTest2::testTdf144092TableHeight() xDocShRef->DoClose(); } +void SdImportTest2::testTdf89928BlackWhiteThreshold() +{ + // A slide with two graphics, one with color HSV{0,0,74%} and one with HSV{0,0,76%} + // where both have an applied 75% Black/White Color Effect. + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc( + u"sd/qa/unit/data/pptx/tdf89928-blackWhiteEffectThreshold.pptx"), + PPTX); + + // First graphic should appear black + { + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), + uno::UNO_SET_THROW); + uno::Reference<graphic::XGraphic> xGraphic; + xShape->getPropertyValue("Graphic") >>= xGraphic; + CPPUNIT_ASSERT(xGraphic.is()); + + Graphic aGraphic(xGraphic); + BitmapEx aBitmap(aGraphic.GetBitmapEx()); + + // Without the accompanying fix in place, this test would have failed with: + // - Expected: Color: R:0 G:0 B:0 A:0 + // - Actual : Color: R:189 G:189 B:189 A:0 + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0x000000), aBitmap.GetPixelColor(0, 0)); + } + + // Second graphic should appear white + { + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(1, 0, xDocShRef), + uno::UNO_SET_THROW); + uno::Reference<graphic::XGraphic> xGraphic; + xShape->getPropertyValue("Graphic") >>= xGraphic; + CPPUNIT_ASSERT(xGraphic.is()); + + Graphic aGraphic(xGraphic); + BitmapEx aBitmap(aGraphic.GetBitmapEx()); + + CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency, 0xFFFFFF), aBitmap.GetPixelColor(0, 0)); + } + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); |