diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2022-04-18 19:31:26 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-04-20 11:05:16 +0200 |
commit | d5fb8d502e77c1dfc77b2c7bdda4bb1540f3ddaf (patch) | |
tree | e6952bccc172b5954d1845dd9199651684d5761f /svx/qa/unit | |
parent | 8e9a963d20edcf5751705bb64126f51a2ace6b18 (diff) |
tdf#148501 color shades only for filled PolyPolygons
For shading parts of a shape not of Type 'ooxml-*', ColorData is used,
introduced about 2005. For 'mso_spt*' shapes they are set directly,
for others they are encoded as 'col-********' into the Type value.
During OOo time two changes were made, resulting in the bugs, that
colors are assigned to wrong segments and that shadings are too dark.
More details are in the bug report.
With this patch the colors are assigned to the correct segments again.
The too dark colors are visible in our preset shapes 'Octagon Bevel'.
The shape 'Diamond Bevel' with corrected color assignment is also
affected. Both need new ColorData. Since it is important for
Libreoffice to have good compatibility with OOXML, I have decided to
use only the four shading values available in OOXML. In the long run,
these shapes should be replaced by ones that contain the shading
information inside the <enhanced-path> element.
Change-Id: I4b8323c45bf702fc371d6e6c82dd9102d0fd9929
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133132
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx/qa/unit')
-rw-r--r-- | svx/qa/unit/customshapes.cxx | 41 | ||||
-rw-r--r-- | svx/qa/unit/data/tdf148501_OctagonBevel.odp | bin | 0 -> 15018 bytes |
2 files changed, 41 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index d4ddca038f1f..fc671384e0c8 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -1263,6 +1263,47 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf136176) } } } + +CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf148501_OctagonBevel) +{ + // The document contains a shape "Octagon Bevel". It should use shadings 40%, 20%, -20%, -40% + // from left-top to bottom-right. The test examines actual color, not the geometry. + // Load document + OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf148501_OctagonBevel.odp"; + mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + + // Generate bitmap from shape + uno::Reference<drawing::XShape> xShape = getShape(0); + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + GraphicHelper::SaveShapeAsGraphicToPath(mxComponent, xShape, "image/png", aTempFile.GetURL()); + + // Read bitmap and test color + // expected in order top-left, top, top-right, right, bottom-right: + // RGB(165|195|266), RGB(139|176|217), RGB(91|127|166), RGB(68|95|124), RGB(68|95|124) + // Without applied patch the colors were: + // RGB(193|214,236), RGB(193|214,236), RGB(80|111|145), RGB(23|32|41), RGB(193|214|236) + // So we test segments top, right and bottom-right. + SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ); + vcl::PngImageReader aPNGReader(aFileStream); + BitmapEx aBMPEx = aPNGReader.read(); + Bitmap aBMP = aBMPEx.GetBitmap(); + Bitmap::ScopedReadAccess pRead(aBMP); + Size aSize = aBMP.GetSizePixel(); + + // GetColor(Y,X). The chosen threshold for the ColorDistance can be adapted if necessary. + Color aActualColor = pRead->GetColor(aSize.Height() * 0.17, aSize.Width() * 0.5); // top + Color aExpectedColor(139, 176, 217); + sal_uInt16 nColorDistance = aExpectedColor.GetColorError(aActualColor); + CPPUNIT_ASSERT_LESS(sal_uInt16(6), nColorDistance); + aActualColor = pRead->GetColor(aSize.Height() * 0.5, aSize.Width() * 0.83); // right + aExpectedColor = Color(68, 95, 124); // same for right and bottom-right + nColorDistance = aExpectedColor.GetColorError(aActualColor); + CPPUNIT_ASSERT_LESS(sal_uInt16(6), nColorDistance); + aActualColor = pRead->GetColor(aSize.Height() * 0.75, aSize.Width() * 0.75); // bottom-right + nColorDistance = aExpectedColor.GetColorError(aActualColor); + CPPUNIT_ASSERT_LESS(sal_uInt16(6), nColorDistance); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/qa/unit/data/tdf148501_OctagonBevel.odp b/svx/qa/unit/data/tdf148501_OctagonBevel.odp Binary files differnew file mode 100644 index 000000000000..9dafaf7c2624 --- /dev/null +++ b/svx/qa/unit/data/tdf148501_OctagonBevel.odp |