summaryrefslogtreecommitdiff
path: root/oox/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-08-06 12:31:35 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-08-06 13:25:19 +0200
commit73993fdb5d4b507694cd0edf80887d19f7e2bf9a (patch)
treebb71b6fde8fb04550882b9ef679e60b92742fb64 /oox/qa
parent74be8bb787a44464957e5d3105c8de6d36e81b4a (diff)
tdf#134183 PPTX: improve import of transparency in multi-step gradients
Impress core only support a single step, improve the conversion from multi-step to single step to take transparency into account explicitly. Once we select the widest segment, look backwards and forward if there are other next segments which have the same RGB color, just different transparency and include them. This helps in general, because in case a 0% or 100% transparency is mishandled, that's very visible. Change-Id: I11d593c01a6a4b16149ce74c1408c2a39895e941 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100231 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'oox/qa')
-rw-r--r--oox/qa/unit/data/gradient-multistep-transparency.pptxbin0 -> 34042 bytes
-rw-r--r--oox/qa/unit/drawingml.cxx27
2 files changed, 27 insertions, 0 deletions
diff --git a/oox/qa/unit/data/gradient-multistep-transparency.pptx b/oox/qa/unit/data/gradient-multistep-transparency.pptx
new file mode 100644
index 000000000000..83946c71b403
--- /dev/null
+++ b/oox/qa/unit/data/gradient-multistep-transparency.pptx
Binary files differ
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index ee5ae764af70..d88f91797304 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -10,7 +10,9 @@
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
+#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/XShape.hpp>
@@ -199,6 +201,31 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testChartDataLabelCharColor)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffff), nCharColor);
}
+CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testGradientMultiStepTransparency)
+{
+ // Load a document with a multi-step gradient.
+ OUString aURL
+ = m_directories.getURLFromSrc(DATA_DIRECTORY) + "gradient-multistep-transparency.pptx";
+ load(aURL);
+
+ // Check the end transparency of the gradient.
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+ 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;
+ xShapeProps->getPropertyValue("FillTransparenceGradient") >>= aTransparence;
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 16777215 (0xffffff)
+ // - 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(static_cast<sal_Int32>(0xffffff), aTransparence.EndColor);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */