summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2024-02-21 11:52:36 -0500
committerMiklos Vajna <vmiklos@collabora.com>2024-02-26 09:03:14 +0100
commitffaf75303273c3803cce58f887b5fb8bd570ff18 (patch)
tree99e36bc9212345a80b4e77fb905a84685dd07f74 /sw
parent8881c7935e79290fedfed812715605d17dde9d22 (diff)
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_rtfexport8 \ CPPUNIT_TEST_NAME=testTdf159824_axialGradient Change-Id: I220f1bf689b4b219bc0ae187e95aedb1a29a7233 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163705 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163869 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/tdf159824_axialGradient.odtbin0 -> 11830 bytes
-rw-r--r--sw/qa/extras/rtfexport/rtfexport8.cxx34
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx6
3 files changed, 40 insertions, 0 deletions
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
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf159824_axialGradient.odt
Binary files 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 2d68556e8a23..05e1cbc2cd22 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3747,6 +3747,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
{