summaryrefslogtreecommitdiffstats
path: root/svx/qa/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 05:03:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 05:03:24 +0000
commite3cf16e6fbf8d39cad8762f002b6db1d4f61ed36 (patch)
tree3c1753125149dcf36ba42a57f1574369e8524225 /svx/qa/unit
parentAdding debian version 4:24.2.2-3. (diff)
downloadlibreoffice-e3cf16e6fbf8d39cad8762f002b6db1d4f61ed36.tar.xz
libreoffice-e3cf16e6fbf8d39cad8762f002b6db1d4f61ed36.zip
Merging upstream version 4:24.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'svx/qa/unit')
-rw-r--r--svx/qa/unit/customshapes.cxx42
-rw-r--r--svx/qa/unit/data/tdf160421_3D_FlipLight.odpbin0 -> 23011 bytes
2 files changed, 42 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 6ae5cc819c..fcc68aacf4 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -63,6 +63,9 @@ protected:
// get shape nShapeIndex from page 0
uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex);
sal_uInt8 countShapes();
+ // fX and fY are positions relative to the size of the bitmap of the shape
+ // Thus the position is indepedent from DPI
+ Color getColor(uno::Reference<drawing::XShape> xShape, const double& fX, const double& fY);
};
uno::Reference<drawing::XShape> CustomshapesTest::getShape(sal_uInt8 nShapeIndex)
@@ -89,6 +92,18 @@ sal_uInt8 CustomshapesTest::countShapes()
return xDrawPage->getCount();
}
+Color CustomshapesTest::getColor(uno::Reference<drawing::XShape> xShape, const double& fX,
+ const double& fY)
+{
+ GraphicHelper::SaveShapeAsGraphicToPath(mxComponent, xShape, "image/png", maTempFile.GetURL());
+ SvFileStream aFileStream(maTempFile.GetURL(), StreamMode::READ);
+ vcl::PngImageReader aPNGReader(aFileStream);
+ Bitmap aBMP = aPNGReader.read().GetBitmap();
+ Size aSize = aBMP.GetSizePixel();
+ BitmapScopedReadAccess pRead(aBMP);
+ return pRead->GetColor(aSize.Height() * fY, aSize.Width() * fX);
+}
+
CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf150302)
{
loadFromFile(u"FontworkSameLetterHeights.fodg");
@@ -1381,6 +1396,33 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf153000_MS0_SPT_25_31)
CPPUNIT_ASSERT_EQUAL(aExpected[i], aCoordinates.getLength());
}
}
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf160421_3D_FlipLight)
+{
+ // The document contains (0)an extruded 'rectangle' custom shape which is illuminated with front
+ // light, (1) this shape vertically flipped and (2) this shape horizontally flipped.
+ // When the shape is flipped vertically or horizontally, the light direction should not
+ // change. MS Office behaves in this way for ppt and pptx and it is meaningful as flipping is
+ // applied to the shape, not to the scene.
+
+ // Load document.
+ loadFromFile(u"tdf160421_3D_FlipLight.odp");
+
+ // Get color from untransformed shape (0).
+ uno::Reference<drawing::XShape> xShape = getShape(0);
+ Color aNormalColor = getColor(xShape, 0.6, 0.6);
+
+ // Test that color from vertically flipped shape (1) is same as normal color. Without the fix
+ // it was only build from ambient light and thus much darker.
+ xShape = getShape(1);
+ sal_uInt16 nColorDistance = aNormalColor.GetColorError(getColor(xShape, 0.6, 0.6));
+ CPPUNIT_ASSERT_LESS(sal_uInt16(6), nColorDistance);
+
+ // Same for horizontally flipped shape (2)
+ xShape = getShape(2);
+ nColorDistance = aNormalColor.GetColorError(getColor(xShape, 0.6, 0.6));
+ CPPUNIT_ASSERT_LESS(sal_uInt16(6), nColorDistance);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf160421_3D_FlipLight.odp b/svx/qa/unit/data/tdf160421_3D_FlipLight.odp
new file mode 100644
index 0000000000..2decc51e3e
--- /dev/null
+++ b/svx/qa/unit/data/tdf160421_3D_FlipLight.odp
Binary files differ