sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 6 ++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-)
New commits: commit 1de6ad8ef61daa2ded84fe1ba39220309f92513f Author: Justin Luth <justin.l...@collabora.com> AuthorDate: Wed Nov 27 11:26:47 2024 -0500 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Nov 29 11:22:39 2024 +0100 tdf#126533 vml gradient export: fix radial color swapping This fixes my 24.8 regression 6dd6891a3deed8718bf2b0fcf564f229f676f8ba related tdf#126533 tdf#159824 VML: don't export: negative angles So far I really haven't touched radial gradient code, but the above patch swapped the colors around for linear/axials, and (while the import for radials is probably wrong) that also changed round-tripped radials - swapping colors each time. Note that on the unit test, the initial focus is 100, so on the first import the colors are NOT swapped. But since we don't write a focus, re-imports will start swapping. See FillModel::pushToPropMap in oox/source/vml/vmlformatting.cxx make CppunitTest_sw_ooxmlexport21 \ CPPUNIT_TEST_NAME=testTdf126533_pageGradient Change-Id: I469fe7fba520e338df90e2eb0d8bdf96709d2ecc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177452 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177503 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index 41c3061fb8e7..1cffe717bed1 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -579,6 +579,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf126533_pageGradient, "fill.docx") awt::Gradient2 aGradient = getProperty<awt::Gradient2>(xPageStyle, u"FillGradient"_ustr); CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style); + + // LO and MS handle radials very differently, so it is hard to say what + // color1 (fill) and color2 should be. This test is only interested in making sure + // that the colors are not alternating back and forth on each round-trip. + CPPUNIT_ASSERT_EQUAL(Color(0xff8200), Color(ColorTransparency, aGradient.StartColor)); + CPPUNIT_ASSERT_EQUAL(Color(0x000082), Color(ColorTransparency, aGradient.EndColor)); } DECLARE_OOXMLEXPORT_TEST(testTdf126533_pageBitmap, "tdf126533_pageBitmap.docx") diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index aaef0d481f9d..b6717c92b549 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -9714,8 +9714,7 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad // LO does linear gradients top to bottom, while MSO does bottom to top. // LO does axial gradients inner to outer, while MSO does outer to inner. - // Conclusion: swap start and end colors. - const OString sColor1 = sEndColor; // LO end color is MSO start color + OString sColor1 = sEndColor; // LO end color is MSO start color OString sColor2 = sStartColor; // LO start color is MSO end color switch (rGradient.GetGradientStyle()) @@ -9755,6 +9754,10 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad case css::awt::GradientStyle_RECT: AddToAttrList(m_rExport.SdrExporter().getFlyFillAttrList(), XML_type, "gradientRadial"); + // Since "focus" is not being written here, it defaults to 0. + // A zero focus triggers a swap at LO import time, so a reverse swap is needed here. + sColor1 = sStartColor; + sColor2 = sEndColor; break; default: break;