sw/qa/extras/ooxmlexport/ooxmlexport7.cxx    |    3 --
 sw/source/filter/ww8/docxattributeoutput.cxx |   32 +++++++++++++++++++++------
 2 files changed, 25 insertions(+), 10 deletions(-)

New commits:
commit 8881c7935e79290fedfed812715605d17dde9d22
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Tue Feb 20 22:41:22 2024 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Feb 26 09:00:52 2024 +0100

    related tdf#126533 vml export: fix axial colors
    
    This is a follow-up from the earlier tdf#65295 clone
    which removed swapping colors on IMport for axials.
    Well, tdf#65295 had also removed EXport swap for the linear case,
    so, now that import doesn't swap, remove the axial export swap too.
    
    Additionally, some linear gradients are actually axials,
    so identify those symmetrical gradients that have
    identical start/end colors to avoid exporting as a "solid" color.
    
    [I tried changing the import to detect it was an axial,
     but got RTF export failures, chart2 false positives,
     and unit-test-the-implementation failures.]
    
    make CppunitTest_sw_ooxmlexport7 \
        CPPUNIT_TEST_NAME=testTdf126533_negativeAxialAngle
    
    The only other unit test that hit this code was
    textframe-gradient.docx - which is dominated by DML import/export.
    I can see with Word 2003 that this patch fixes the VML export
    for this unit test file also.
    
    Change-Id: I75e993c7c127a861617b14072a98778ddde03a08
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163676
    Tested-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163868
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index ef4bcb2d0000..a362cb36c221 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -642,9 +642,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf77219_backgroundShape, 
"tdf77219_backgroundShape
 
 DECLARE_OOXMLEXPORT_TEST(testTdf126533_negativeAxialAngle, 
"tdf126533_negativeAxialAngle.docx")
 {
-    if (isExported())
-        return;
-
     // axiel gradient is purple foreground/lime background in the middle 
(top-left to bottom-right)
     uno::Reference<beans::XPropertySet> 
xPageStyle(getStyles("PageStyles")->getByName("Standard"),
                                                    uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index c04a86ab4e55..334e521aba04 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -9653,16 +9653,34 @@ void DocxAttributeOutput::FormatFillGradient( const 
XFillGradientItem& rFillGrad
         switch (rGradient.GetGradientStyle())
         {
             case css::awt::GradientStyle_AXIAL:
-                AddToAttrList(m_rExport.SdrExporter().getFlyFillAttrList(), 
XML_type, "gradient");
-                AddToAttrList( m_rExport.SdrExporter().getFlyFillAttrList(), 
XML_focus, "50%" );
-                // If it is an 'axial' gradient - swap the colors
-                // (because in the import process they were imported swapped)
-                sColor1 = sEndColor;
-                sColor2 = sStartColor;
-                break;
             case css::awt::GradientStyle_LINEAR:
+            {
+                bool bIsSymmetrical = rGradient.GetGradientStyle() == 
css::awt::GradientStyle_AXIAL;
+                if (!bIsSymmetrical)
+                {
+                    const basegfx::BColorStops& rColorStops = 
rGradient.GetColorStops();
+                    if (rColorStops.size() > 2 && rColorStops.isSymmetrical())
+                    {
+                        for (auto& rStop : rColorStops)
+                        {
+                            if (basegfx::fTools::less(rStop.getStopOffset(), 
0.5))
+                                continue;
+                            if (basegfx::fTools::more(rStop.getStopOffset(), 
0.5))
+                                break;
+
+                            // the color in the middle is considered the start 
color for focus 50
+                            sColor1 = 
msfilter::util::ConvertColor(Color(rStop.getStopColor()));
+                            bIsSymmetrical = true;
+                        }
+                    }
+                }
+
+                if (bIsSymmetrical)
+                    AddToAttrList( 
m_rExport.SdrExporter().getFlyFillAttrList(), XML_focus, "50%" );
+
                 AddToAttrList(m_rExport.SdrExporter().getFlyFillAttrList(), 
XML_type, "gradient");
                 break;
+            }
             case css::awt::GradientStyle_RADIAL:
             case css::awt::GradientStyle_ELLIPTICAL:
             case css::awt::GradientStyle_SQUARE:

Reply via email to