diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-15 14:42:20 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-08-15 16:45:47 +0200 |
commit | 6c06c8a2be3d8cbbcb8ab1aaaeb04db95114dfcb (patch) | |
tree | da573528dfb4f0526c1aa920ff36af4dd19fafb4 /sd | |
parent | 54c158ff35ab5a0b5fa538562755638e052d51f2 (diff) |
tdf#153008: srcRect may have some members negative
The overly strict check (implying that all members must be non-negative,
to perform the crop) excluded valid cases where some of the members were
negative, and some positive.
Change-Id: I629689bdccedf9e37632a9fe14654778c0f14a6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155717
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/tdf153008-srcRect-smallNegBound.pptx | bin | 0 -> 23988 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests2.cxx | 19 |
2 files changed, 19 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/tdf153008-srcRect-smallNegBound.pptx b/sd/qa/unit/data/pptx/tdf153008-srcRect-smallNegBound.pptx Binary files differnew file mode 100644 index 000000000000..9870e3f2e2e9 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf153008-srcRect-smallNegBound.pptx diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx index 4d197b364449..4e535c7749c7 100644 --- a/sd/qa/unit/import-tests2.cxx +++ b/sd/qa/unit/import-tests2.cxx @@ -1918,6 +1918,25 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, testIndentDuplication) CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nIndent2); } +CPPUNIT_TEST_FIXTURE(SdImportTest2, test_srcRect_smallNegBound) +{ + // Given a cropped custom shape, with a srcRect having a small negative value in one of bounds + createSdImpressDoc("pptx/tdf153008-srcRect-smallNegBound.pptx"); + + uno::Reference<graphic::XGraphic> xGraphic( + getShapeFromPage(0, 0)->getPropertyValue("FillBitmap"), uno::UNO_QUERY_THROW); + + BitmapEx aBitmap(Graphic(xGraphic).GetBitmapEx()); + + // Properly cropped bitmap should have black pixels close to left edge, near vertical center. + // Before the fix, the gear was distorted, and this area was white. + auto yMiddle = aBitmap.GetSizePixel().Height() / 2; + auto x5Percent = aBitmap.GetSizePixel().Width() / 20; + CPPUNIT_ASSERT(aBitmap.GetPixelColor(x5Percent, yMiddle).IsDark()); + // Just in case, check that the corner is bright (it is in fact yellow) + CPPUNIT_ASSERT(aBitmap.GetPixelColor(0, 0).IsBright()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |