summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-04-21 15:18:09 +0200
committerAndras Timar <andras.timar@collabora.com>2023-05-15 21:38:55 +0200
commitfd6069d8cb4bfedba2f63f4f1839d6739a8299ac (patch)
tree514701693d91902ae960a14eb95db53429e08e90 /chart2
parent6e4c034121683d547007209827c70b8a43758f22 (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 'chart2')
-rw-r--r--chart2/qa/extras/chart2geometry.cxx33
-rw-r--r--chart2/qa/extras/chart2import.cxx34
2 files changed, 54 insertions, 13 deletions
diff --git a/chart2/qa/extras/chart2geometry.cxx b/chart2/qa/extras/chart2geometry.cxx
index bab696a15e9b..497f9a099755 100644
--- a/chart2/qa/extras/chart2geometry.cxx
+++ b/chart2/qa/extras/chart2geometry.cxx
@@ -175,6 +175,12 @@ void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_export()
// Without the patch the transparency was lost in saved pptx file.
loadFromURL(u"odp/tdf128345_ChartArea_CG_TS.odp");
+ // MCGR: Similar to testTdf128345Legend_CS_TG_axial_export:
+ // Checked that it works with the existing import file,
+ // but will change with ODF MCGR im/export again.
+ // Adapting for now, but need to re-check values after
+ // ODF im/export for MCGR is integrated
+
// Make sure the chart area has a transparency in gradient stops in saved pptx file.
xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML");
CPPUNIT_ASSERT(pXmlDoc);
@@ -192,6 +198,12 @@ void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
// Make sure chart area has transparency when pptx document is opened and resaved as odp.
// As of Aug 2020, the import generates a transparency gradient. When import is changed to
// generate solid transparency, the test needs to be adapted.
+
+ // MCGR: Similar to testTdf128345Legend_CS_TG_axial_export:
+ // Checked that it works with the existing import file,
+ // but will change with ODF MCGR im/export again. We will need to
+ // update the *.odp input file. Disable unclear values for now and
+ // adapt when ODF im/export for MCGR is integrated
loadFromURL(u"pptx/tdf128345_ChartArea_CG_TS.pptx");
// Find transparency gradient name
@@ -218,7 +230,7 @@ void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
assertXPath(pXmlDoc2, sStart + " and @draw:start='30%']");
assertXPath(pXmlDoc2, sStart + " and @draw:end='30%']");
assertXPath(pXmlDoc2, sStart + " and @draw:angle='30deg']");
- assertXPath(pXmlDoc2, sStart + " and @draw:border='20%']");
+ assertXPath(pXmlDoc2, sStart + " and @draw:border='0%']"); // MCGR: no border anymore 20% -> 0%
}
void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_export()
@@ -281,13 +293,21 @@ void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_export()
CPPUNIT_ASSERT(pXmlDoc);
OString sPathStart("//c:chartSpace/c:chart/c:legend/c:spPr/a:gradFill");
- assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 3); // axial
- // no element for 0% transparent
+
+ // MCGR: three entries due to axial being mirrored+expanded to linear
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs", 3);
+
+ // MCGR: start entry, no transparence, pos zero
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", 0);
- // 100% transparent = opacity 0. It comes from "axial", therefore it is in the middle.
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]", "pos", "0");
+
+ // MCGR: middle entry, 100% transparence, pos 0.5
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "0");
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]", "pos", "50000");
+
+ // MCGR: end entry, no transparence, pos 1.0
assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[3]/a:srgbClr/a:alpha", 0);
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[3]", "pos", "100000");
}
void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_import()
@@ -316,8 +336,9 @@ void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_import()
const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
assertXPath(pXmlDoc2, sStart + "]", 1);
- assertXPath(pXmlDoc2, sStart + " and @draw:style='axial']");
- assertXPath(pXmlDoc2, sStart + " and @draw:start='0%']");
+ // MCGR: Needs odf im/export for MCGR, then adapt.
+ assertXPath(pXmlDoc2, sStart + " and @draw:style='linear']"); // MCGR: axial -> linear
+ assertXPath(pXmlDoc2, sStart + " and @draw:start='100%']"); // MCGR: 0% -> 100%
assertXPath(pXmlDoc2, sStart + " and @draw:end='100%']");
}
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index a9c301a94b93..e309fa912c3a 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -32,8 +32,9 @@
#include <iterator>
#include <com/sun/star/util/Color.hpp>
-#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/awt/Gradient2.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <basegfx/utils/gradienttools.hxx>
class Chart2ImportTest : public ChartTest
{
@@ -798,12 +799,23 @@ void Chart2ImportTest::testBnc889755()
//tdf#139940 - the title's gradient was lost and was filled with solid blue, instead of a "blue underline".
uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
+
// Shape "Title 3"
+ // MCGR: Use the whole completely imported transparency gradient to check for correctness
uno::Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(4), uno::UNO_QUERY_THROW);
- awt::Gradient aTransparence;
+ awt::Gradient2 aTransparence;
xShapeProps->getPropertyValue("FillTransparenceGradient") >>= aTransparence;
- CPPUNIT_ASSERT(aTransparence.StartColor != aTransparence.EndColor);
- CPPUNIT_ASSERT_EQUAL(COL_WHITE, Color(ColorTransparency, aTransparence.StartColor));
+
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aTransparence);
+
+ CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.25, 0.25, 0.25));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.070000000000000007));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.25, 0.25, 0.25));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 0.080000000000000002));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[2].getStopColor(), basegfx::BColor(1.0, 1.0, 1.0));
}
void Chart2ImportTest::testBnc882383()
@@ -832,14 +844,22 @@ void Chart2ImportTest::testTransparencyGradientValue()
xPropertySet->getPropertyValue("FillTransparenceGradientName") >>= sTranspGradientName;
CPPUNIT_ASSERT(!sTranspGradientName.isEmpty());
- awt::Gradient aTransparenceGradient;
+ awt::Gradient2 aTransparenceGradient;
uno::Reference< lang::XMultiServiceFactory > xFact(xChartDoc, uno::UNO_QUERY);
CPPUNIT_ASSERT(xFact.is());
uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY);
uno::Any rTransparenceValue = xTransparenceGradient->getByName(sTranspGradientName);
CPPUNIT_ASSERT(rTransparenceValue >>= aTransparenceGradient);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(3355443), aTransparenceGradient.EndColor);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(5000268), aTransparenceGradient.StartColor);
+
+ basegfx::ColorStops aColorStops;
+ basegfx::utils::fillColorStopsFromGradient2(aColorStops, aTransparenceGradient);
+
+ // MCGR: Use the whole completely imported transparency gradient to check for correctness
+ 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.3, 0.3, 0.3));
+ CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
+ CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.2, 0.2, 0.2));
}
void Chart2ImportTest::testSimpleStrictXLSX()