summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2020-07-21 15:46:51 +0200
committerRegina Henschel <rb.henschel@t-online.de>2020-07-22 11:54:04 +0200
commit51e5afb0042bc6a10f0cd02af5733079b42fa0f7 (patch)
tree4a115d674aaebf043eb95f762cfe26cdde6e33f1
parent14bdbc36f0cf3913f6de10c746044b6aadf37095 (diff)
tdf#134969 Add solid transparence in color gradient
Converts a 'FillTransparence' percent value to a Gray color and stores it in a TransparenceGradient, so that it can be used by WriteGradientFill(). Use of third parameter rXPropSet is not possible, because it would overwrite a true transparency gradient. Causion, the property 'FillTransparenceGradient' might exist in an XPropSet of a shape with some default values. To detect, whether a gradient is actually used, you have to examine the property 'FillTransparenceGradientName'. Change-Id: Icbef599f02ebae2fcb5825fe64f546295eb78510 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99145 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
-rw-r--r--oox/source/export/drawingml.cxx23
-rw-r--r--sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odpbin0 -> 17107 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx18
3 files changed, 38 insertions, 3 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 517d9801bba6..155c33796f70 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -540,10 +540,27 @@ void DrawingML::WriteGradientFill( const Reference< XPropertySet >& rXPropSet )
else
{
mpFS->startElementNS(XML_a, XML_gradFill, XML_rotWithShape, "0");
- if( GetProperty(rXPropSet, "FillTransparenceGradient") )
- aTransparenceGradient = *o3tl::doAccess<awt::Gradient>(mAny);
+ OUString sFillTransparenceGradientName;
+ if (GetProperty(rXPropSet, "FillTransparenceGradientName")
+ && (mAny >>= sFillTransparenceGradientName)
+ && !sFillTransparenceGradientName.isEmpty())
+ {
+ if (GetProperty(rXPropSet, "FillTransparenceGradient"))
+ aTransparenceGradient = *o3tl::doAccess<awt::Gradient>(mAny);
+ }
+ else if (GetProperty(rXPropSet, "FillTransparence"))
+ {
+ // currently only StartColor and EndColor are evaluated in WriteGradientFill()
+ sal_Int32 nTransparency = 0;
+ mAny >>= nTransparency;
+ // convert percent to gray color
+ nTransparency = nTransparency * 255/100;
+ const sal_Int32 aGrayColor = static_cast<sal_Int32>( nTransparency | nTransparency << 8 | nTransparency << 16 );
+ aTransparenceGradient.StartColor = aGrayColor;
+ aTransparenceGradient.EndColor = aGrayColor;
+ }
WriteGradientFill(aGradient, aTransparenceGradient);
- mpFS->endElementNS( XML_a, XML_gradFill );
+ mpFS->endElementNS(XML_a, XML_gradFill);
}
}
diff --git a/sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odp b/sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odp
new file mode 100644
index 000000000000..bb0d7bbc5709
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odp
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 5cde7f0c8b91..f8f471f08b9a 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -97,6 +97,7 @@ public:
void testTdf128345GradientLinear();
void testTdf128345GradientRadial();
void testTdf128345GradientAxial();
+ void testTdf134969TransparencyOnColorGradient();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
@@ -143,6 +144,7 @@ public:
CPPUNIT_TEST(testTdf128345GradientLinear);
CPPUNIT_TEST(testTdf128345GradientRadial);
CPPUNIT_TEST(testTdf128345GradientAxial);
+ CPPUNIT_TEST(testTdf134969TransparencyOnColorGradient);
CPPUNIT_TEST_SUITE_END();
@@ -1212,6 +1214,22 @@ void SdOOXMLExportTest1::testTdf128345GradientAxial()
xDocShRef->DoClose();
}
+void SdOOXMLExportTest1::testTdf134969TransparencyOnColorGradient()
+{
+ ::sd::DrawDocShellRef xDocShRef
+ = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odp"), ODP);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+ xDocShRef->DoClose();
+
+ // Make sure the shape has a transparency in gradient stops.
+ 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/a:alpha", "val", "60000");
+ assertXPath(pXmlDoc, sPathStart + "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "60000");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1);
CPPUNIT_PLUGIN_IMPLEMENT();