summaryrefslogtreecommitdiff
path: root/oox/qa/unit
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-04-21 15:18:09 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-05-03 17:38:46 +0200
commitbb198176684c3d9377e26c04a29ec66deb811949 (patch)
tree731abe7ce1b95805900f39c6c7ac2c1c6ccfb211 /oox/qa/unit
parentf1fd3e32508ee3e8aca6f90724e7af8664652e41 (diff)
MCGR: Make MCGR default for oox im/export, cleanup
Following an error in CppunitTest_chart2_export3 I updated the transparency definition at WriteGradientFill and corrected usages. Had to correct/adapt some Chart UnitTests. Some of these changes are temporary since this will/has to change when ODF MCGR im/export is integrated. I checked that all of these cases actually work, comparing im LO and MSO. Adapted some Chart2ImportTest to directly compare/check now for the fully imported tranparence gradient with available higher precision. Adapted OoxDrawingmlTest testGradientMultiStepTransparency to use new MCGR capabilities. Adapted testTextframeGradient and tested the turn-around with rtf gradients. These are a little bit limited and needed some extra care. Adapted testTextframeGradient. Adapted SdOOXMLExportTest1, testTdf94238 Adapted SdOOXMLExportTest1, testTdf128345GradientAxial Adapted SdOOXMLExportTest2, testTdf105739 Adapted SdOOXMLExportTest3, testTdf127372 Adapted SdOOXMLExportTest3, testTdf127379 Adapted SdMiscTest, testFillGradient Adapted testTextframeGradient Adapted ScFiltersTest3, testTdf129789 Adapted SdUiImpressTest, testPageFillGradient Adapted SdOOXMLExportTest1, testTdf128345GradientLinear by using better double-to-integer rounding (basegfx::fround) in DrawingML::WriteGradientStop. After double calculations this makes the tansition to integer correct and stable. Also took back change at testTdf128345ChartArea_CG_TS_export which showed the same flaw before. 2nd look @testTdf128345Legend_CS_TG_axial_export made me add that stuff again and adapt the axial ColorStop adding in the export to not export the middle enty twice. Extended test a little bit, too. Only do not add value if it starts at 0.0 aka StartColor, else adding it is corect. Adapted some tests CPPUNIT_ASSERT to CPPUNIT_ASSERT_EQUAL after being pointed to it from gerrit_linux_clang_dbgutil build. Change-Id: I4a993053da8960035671b655e67908f36e59b5fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150763 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'oox/qa/unit')
-rw-r--r--oox/qa/unit/drawingml.cxx13
-rw-r--r--oox/qa/unit/shape.cxx137
2 files changed, 122 insertions, 28 deletions
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index 09ab7121d8c8..8d5627a16cdc 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -9,7 +9,7 @@
#include <test/unoapi_test.hxx>
-#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/awt/Gradient2.hpp>
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XNamed.hpp>
@@ -35,6 +35,7 @@
#include <docmodel/theme/Theme.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include <basegfx/utils/gradienttools.hxx>
using namespace ::com::sun::star;
@@ -181,7 +182,7 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testGradientMultiStepTransparency)
uno::Reference<container::XNamed> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Rectangle 4"), xShape->getName());
uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
- awt::Gradient aTransparence;
+ awt::Gradient2 aTransparence;
xShapeProps->getPropertyValue("FillTransparenceGradient") >>= aTransparence;
// Without the accompanying fix in place, this test would have failed with:
@@ -189,7 +190,13 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testGradientMultiStepTransparency)
// - Actual : 3487029 (0x353535)
// i.e. the end transparency was not 100%, but was 21%, leading to an unexpected visible line on
// the right of this shape.
- CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(ColorTransparency, aTransparence.EndColor));
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aTransparence);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(5), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[4].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[4].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
}
CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testShapeTextAlignment)
diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx
index 523003ee351a..e8d4f188b8d3 100644
--- a/oox/qa/unit/shape.cxx
+++ b/oox/qa/unit/shape.cxx
@@ -14,7 +14,7 @@
#include <string_view>
#include <com/sun/star/awt/FontWeight.hpp>
-#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/awt/Gradient2.hpp>
#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -37,6 +37,7 @@
#include <svx/svdoashp.hxx>
#include <tools/color.hxx>
#include <docmodel/uno/UnoThemeColor.hxx>
+#include <basegfx/utils/gradienttools.hxx>
using namespace ::com::sun::star;
@@ -467,11 +468,22 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
uno::Reference<beans::XPropertySet> xShapeProps(xDrawPage->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT),
xShapeProps->getPropertyValue(u"FillStyle"));
- awt::Gradient aGradient;
+ awt::Gradient2 aGradient;
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
+
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aGradient);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(
+ aColorStops[1].getStopColor(),
+ basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
+
CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient.Angle);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(255), aGradient.StartColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(16225862), aGradient.EndColor);
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient.XOffset);
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient.YOffset);
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
@@ -482,11 +494,22 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
uno::Reference<beans::XPropertySet> xShapeProps(xDrawPage->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT),
xShapeProps->getPropertyValue(u"FillStyle"));
- awt::Gradient aGradient;
+ awt::Gradient2 aGradient;
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
+
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aGradient);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.40000000000000002));
+ CPPUNIT_ASSERT_EQUAL(
+ aColorStops[0].getStopColor(),
+ basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
+
CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient.Angle);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(255), aGradient.EndColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(16225862), aGradient.StartColor);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.YOffset);
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style);
@@ -497,11 +520,22 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
uno::Reference<beans::XPropertySet> xShapeProps(xDrawPage->getByIndex(2), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT),
xShapeProps->getPropertyValue(u"FillStyle"));
- awt::Gradient aGradient;
+ awt::Gradient2 aGradient;
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
+
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aGradient);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
+ CPPUNIT_ASSERT_EQUAL(
+ aColorStops[0].getStopColor(),
+ basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
+
CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient.Angle);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(255), aGradient.EndColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(16225862), aGradient.StartColor);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.YOffset);
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style);
@@ -604,12 +638,23 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
uno::Reference<beans::XPropertySet> xShapeProps(xDrawPage->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT),
xShapeProps->getPropertyValue(u"FillStyle"));
- awt::Gradient aGradient;
+ awt::Gradient2 aGradient;
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
+
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aGradient);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(),
+ basegfx::BColor(1.0, 0.75294117647058822, 0.0));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(),
+ basegfx::BColor(0.75294117647058822, 0.0, 0.0));
+
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient.Angle);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(16760832), aGradient.StartColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(12582912), aGradient.EndColor);
CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::LineStyle_SOLID),
xShapeProps->getPropertyValue(u"LineStyle"));
@@ -627,19 +672,41 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
uno::Reference<beans::XPropertySet> xShapeProps(xDrawPage->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT),
xShapeProps->getPropertyValue(u"FillStyle"));
- awt::Gradient aGradient;
+ awt::Gradient2 aGradient;
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
+
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aGradient);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(),
+ basegfx::BColor(0.0, 0.51372549019607838, 0.8784313725490196));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(),
+ basegfx::BColor(0.90196078431372551, 0.90196078431372551, 0.0));
+
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(15132160), aGradient.EndColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(33760), aGradient.StartColor);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.YOffset);
xShapeProps->getPropertyValue(u"FillTransparenceGradient") >>= aGradient;
- CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style);
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aGradient);
+
// Transparency is encoded in gray color.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(5000268), aGradient.EndColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(6710886), aGradient.StartColor);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
+ CPPUNIT_ASSERT_EQUAL(
+ aColorStops[0].getStopColor(),
+ basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(
+ aColorStops[1].getStopColor(),
+ basegfx::BColor(0.29999999999999999, 0.29999999999999999, 0.29999999999999999));
+
+ CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.YOffset);
@@ -663,19 +730,39 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
uno::Reference<beans::XPropertySet> xShapeProps(xDrawPage->getByIndex(2), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(uno::Any(drawing::FillStyle_GRADIENT),
xShapeProps->getPropertyValue(u"FillStyle"));
- awt::Gradient aGradient;
+ awt::Gradient2 aGradient;
xShapeProps->getPropertyValue(u"FillGradient") >>= aGradient;
+
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aGradient);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
+ CPPUNIT_ASSERT_EQUAL(
+ aColorStops[0].getStopColor(),
+ basegfx::BColor(0.26666666666666666, 0.44705882352941179, 0.7686274509803922));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(
+ aColorStops[1].getStopColor(),
+ basegfx::BColor(0.26666666666666666, 0.44705882352941179, 0.7686274509803922));
+
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(4485828), aGradient.EndColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(4485828), aGradient.StartColor);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset);
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient.YOffset);
xShapeProps->getPropertyValue(u"FillTransparenceGradient") >>= aGradient;
- CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style);
+ // MCGR: Use the completely imported transparency gradient to check for correctness
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aGradient);
+
// Transparency is encoded in gray color.
- CPPUNIT_ASSERT_EQUAL(sal_Int32(16777215), aGradient.EndColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGradient.StartColor);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(1.0, 1.0, 1.0));
+
+ CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset);
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient.YOffset);