[Libreoffice-commits] core.git: oox/source sd/qa

Regina Henschel (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 22 09:54:38 UTC 2020


 oox/source/export/drawingml.cxx                               |   23 ++++++++--
 sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odp |binary
 sd/qa/unit/export-tests-ooxml1.cxx                            |   18 +++++++
 3 files changed, 38 insertions(+), 3 deletions(-)

New commits:
commit 51e5afb0042bc6a10f0cd02af5733079b42fa0f7
Author:     Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Tue Jul 21 15:46:51 2020 +0200
Commit:     Regina Henschel <rb.henschel at t-online.de>
CommitDate: Wed Jul 22 11:54:04 2020 +0200

    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 at t-online.de>

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
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odp 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();


More information about the Libreoffice-commits mailing list