sw/qa/extras/rtfexport/data/tdf159824_axialGradient.odt |binary sw/qa/extras/rtfexport/rtfexport8.cxx | 34 ++++++++++++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 6 ++ 3 files changed, 40 insertions(+)
New commits: commit bb207d7816c2d32d02ee11ff784d405d2bb5de0f Author: Justin Luth <jl...@mail.com> AuthorDate: Wed Feb 21 11:52:36 2024 -0500 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Feb 23 17:41:15 2024 +0100 tdf#159824 MCGR rtf export: don't lose gradient's axial-ness This fixes alg's 7.6 regression from commit bb198176684c3d9377e26c04a29ec66deb811949 Found when trying to import these strung-out-linears as real axials. make CppunitTest_sw_rtfexport \ CPPUNIT_TEST_NAME=testTdf159824_axialGradient Change-Id: I220f1bf689b4b219bc0ae187e95aedb1a29a7233 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163705 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 9ba68c769d41d1075152a22bf37e78fb9320317b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163769 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/rtfexport/data/tdf159824_axialGradient.odt b/sw/qa/extras/rtfexport/data/tdf159824_axialGradient.odt new file mode 100644 index 000000000000..c1ce5cd31d2a Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf159824_axialGradient.odt differ diff --git a/sw/qa/extras/rtfexport/rtfexport8.cxx b/sw/qa/extras/rtfexport/rtfexport8.cxx index c78298cdddd0..ab787919dfa9 100644 --- a/sw/qa/extras/rtfexport/rtfexport8.cxx +++ b/sw/qa/extras/rtfexport/rtfexport8.cxx @@ -10,6 +10,8 @@ #include <swmodeltestbase.hxx> #include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/Gradient2.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/text/XFootnote.hpp> #include <com/sun/star/text/XFootnotesSupplier.hpp> @@ -21,7 +23,9 @@ #include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/style/TabStop.hpp> +#include <basegfx/utils/gradienttools.hxx> #include <comphelper/sequenceashashmap.hxx> +#include <docmodel/uno/UnoGradientTools.hxx> #include <tools/UnitConversion.hxx> #include <comphelper/propertyvalue.hxx> @@ -178,6 +182,36 @@ DECLARE_RTFEXPORT_TEST(testTdf158826_extraCR, "tdf158826_extraCR.rtf") uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY_THROW); } +CPPUNIT_TEST_FIXTURE(Test, testTdf159824_axialGradient) +{ + // given a frame with an axial gradient (white - green - white) + loadAndReload("tdf159824_axialGradient.odt"); + + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, + getProperty<drawing::FillStyle>(xFrame, "FillStyle")); + awt::Gradient2 aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient"); + + //const Color aColA(0x127622); // green + //const Color aColB(0xffffff); // white + + // MCGR: Use the completely imported transparency gradient to check for correctness + basegfx::BColorStops aColorStops = model::gradient::getColorStopsFromUno(aGradient.ColorStops); + + // expected: a 3-color linear gradient (or better yet a 2-color AXIAL gradient) + CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size()); + CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style); + CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0)); + //CPPUNIT_ASSERT_EQUAL(aColB, Color(aColorStops[0].getStopColor())); + // CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.5)); + // CPPUNIT_ASSERT_EQUAL(aColA, Color(aColorStops[1].getStopColor())); + // CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 1.0)); + // CPPUNIT_ASSERT_EQUAL(aColB, Color(aColorStops[2].getStopColor())); +} + DECLARE_RTFEXPORT_TEST(testTdf158830, "tdf158830.rtf") { //check centered text in table diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 8635022bad24..7dcda8f73fb2 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3754,6 +3754,12 @@ void RtfAttributeOutput::FormatFillGradient(const XFillGradientItem& rFillGradie const Color aEndColor(rColorStops.back().getStopColor()); m_aFlyProperties.push_back(std::make_pair<OString, OString>( "fillBackColor"_ostr, OString::number(wwUtility::RGBToBGR(aEndColor)))); + + if (rGradient.GetGradientStyle() == awt::GradientStyle_AXIAL) + { + m_aFlyProperties.push_back( + std::make_pair<OString, OString>("fillFocus"_ostr, OString::number(50))); + } } else {