summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2020-07-14 22:52:56 +0200
committerRegina Henschel <rb.henschel@t-online.de>2020-07-18 16:29:37 +0200
commitd187f22b7ff73954e1da39fb954c64bc315298cb (patch)
tree6165794772de6d1bd32e7b68b1f0211db499f4c8 /sd
parent9712e25425e22b59afce82f26a14a48ebb37cd38 (diff)
tdf#128345 pptx export: add transparence gradient in solid fill
In case of solid color fill a transparence gradient was not saved. OOXML has no separate element for gradient transparency but has transparency in color gradient stop elements. The patch detects a transparence gradient, combines it with the fill color and exports it as gradFill element. The import was already correct, besides a wrong start or end value in case of a symmetric gradient, which becomes AXIAL in LibreOffice. Change-Id: I4243656821629f90125d0408a38165a8a29e6e24 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98792 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/odp/tdf128345_FullTransparentGradient.odpbin0 -> 11244 bytes
-rw-r--r--sd/qa/unit/data/odp/tdf128345_GradientAxial.odpbin0 -> 12561 bytes
-rw-r--r--sd/qa/unit/data/odp/tdf128345_GradientLinear.odpbin0 -> 13384 bytes
-rw-r--r--sd/qa/unit/data/odp/tdf128345_GradientRadial.odpbin0 -> 14774 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx80
5 files changed, 80 insertions, 0 deletions
diff --git a/sd/qa/unit/data/odp/tdf128345_FullTransparentGradient.odp b/sd/qa/unit/data/odp/tdf128345_FullTransparentGradient.odp
new file mode 100644
index 000000000000..904490d4313f
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf128345_FullTransparentGradient.odp
Binary files differ
diff --git a/sd/qa/unit/data/odp/tdf128345_GradientAxial.odp b/sd/qa/unit/data/odp/tdf128345_GradientAxial.odp
new file mode 100644
index 000000000000..55b8ec1aac60
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf128345_GradientAxial.odp
Binary files differ
diff --git a/sd/qa/unit/data/odp/tdf128345_GradientLinear.odp b/sd/qa/unit/data/odp/tdf128345_GradientLinear.odp
new file mode 100644
index 000000000000..1eadfa11f08b
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf128345_GradientLinear.odp
Binary files differ
diff --git a/sd/qa/unit/data/odp/tdf128345_GradientRadial.odp b/sd/qa/unit/data/odp/tdf128345_GradientRadial.odp
new file mode 100644
index 000000000000..634d1dc1bd5f
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf128345_GradientRadial.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 57112261a4af..5cde7f0c8b91 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -93,6 +93,10 @@ public:
void testCustomshapeBitmapfillSrcrect();
void testTdf100348FontworkBitmapFill();
void testTdf100348FontworkGradientGlow();
+ void testTdf128345FullTransparentGradient();
+ void testTdf128345GradientLinear();
+ void testTdf128345GradientRadial();
+ void testTdf128345GradientAxial();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
@@ -135,6 +139,10 @@ public:
CPPUNIT_TEST(testCustomshapeBitmapfillSrcrect);
CPPUNIT_TEST(testTdf100348FontworkBitmapFill);
CPPUNIT_TEST(testTdf100348FontworkGradientGlow);
+ CPPUNIT_TEST(testTdf128345FullTransparentGradient);
+ CPPUNIT_TEST(testTdf128345GradientLinear);
+ CPPUNIT_TEST(testTdf128345GradientRadial);
+ CPPUNIT_TEST(testTdf128345GradientAxial);
CPPUNIT_TEST_SUITE_END();
@@ -1132,6 +1140,78 @@ void SdOOXMLExportTest1::testTdf100348FontworkGradientGlow()
assertXPath(pXmlDoc, sPathStart + "/a:effectLst/a:glow/a:srgbClr", "val", "ff4500");
}
+void SdOOXMLExportTest1::testTdf128345FullTransparentGradient()
+{
+ ::sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf128345_FullTransparentGradient.odp"), ODP);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+ xDocShRef->DoClose();
+
+ // Make sure the shape has no fill. Without the patch, fill was solid red.
+ xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+ const OString sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:spPr");
+ assertXPath(pXmlDoc, sPathStart + "/a:noFill");
+}
+
+void SdOOXMLExportTest1::testTdf128345GradientLinear()
+{
+ ::sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf128345_GradientLinear.odp"), ODP);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+ xDocShRef->DoClose();
+
+ // Make sure the shape has a lin fill. Without the patch, fill was solid red.
+ xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+ const OString sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill");
+ assertXPath(pXmlDoc, sPathStart + "/a:lin", "ang", "3600000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs",2);
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]", "pos", "25000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr", "val", "ff0000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "20000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]", "pos", "100000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr", "val", "ff0000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "80000");
+}
+
+void SdOOXMLExportTest1::testTdf128345GradientRadial()
+{
+ ::sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf128345_GradientRadial.odp"), ODP);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+ xDocShRef->DoClose();
+
+ // Make sure the shape has transparency. In OOXML alpha means 'opacity' with default
+ // 100000 for full opak, so only the full transparency with val 0 should be written.
+ xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+ const OString sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs",2);
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr", "val", "ff0000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", 0);
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr", "val", "ffffff");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "0");
+}
+
+void SdOOXMLExportTest1::testTdf128345GradientAxial()
+{
+ // Without the patch, symmtetric linear gradient with full transparence outside and
+ // full opak in the middle were imported as full transparent.
+ ::sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf128345_GradientAxial.odp"), ODP);
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
+ uno::Reference<beans::XPropertySet> xShapePropSet(getShapeFromPage(0, 0, xDocShRef));
+
+ awt::Gradient aTransparenceGradient;
+ xShapePropSet->getPropertyValue("FillTransparenceGradient") >>= aTransparenceGradient;
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aTransparenceGradient.StartColor);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), aTransparenceGradient.EndColor);
+ CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aTransparenceGradient.Style);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1);
CPPUNIT_PLUGIN_IMPLEMENT();