diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-04-21 15:18:09 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-05-15 21:38:55 +0200 |
commit | fd6069d8cb4bfedba2f63f4f1839d6739a8299ac (patch) | |
tree | 514701693d91902ae960a14eb95db53429e08e90 /sw/source/filter | |
parent | 6e4c034121683d547007209827c70b8a43758f22 (diff) |
MCGR: Make MCGR default for oox im/export, cleanup
Following an error in CppunitTest_chart2_export3 I updated
the transparency definition at WriteGradientFill and
corrected usages.
Had to correct/adapt some Chart UnitTests. Some of these
changes are temporary since this will/has to change when
ODF MCGR im/export is integrated. I checked that all of
these cases actually work, comparing im LO and MSO.
Adapted some Chart2ImportTest to directly compare/check
now for the fully imported tranparence gradient with
available higher precision.
Adapted OoxDrawingmlTest testGradientMultiStepTransparency
to use new MCGR capabilities.
Adapted testTextframeGradient and tested the turn-around
with rtf gradients. These are a little bit limited and
needed some extra care.
Adapted testTextframeGradient.
Adapted SdOOXMLExportTest1, testTdf94238
Adapted SdOOXMLExportTest1, testTdf128345GradientAxial
Adapted SdOOXMLExportTest2, testTdf105739
Adapted SdOOXMLExportTest3, testTdf127372
Adapted SdOOXMLExportTest3, testTdf127379
Adapted SdMiscTest, testFillGradient
Adapted testTextframeGradient
Adapted ScFiltersTest3, testTdf129789
Adapted SdUiImpressTest, testPageFillGradient
Adapted SdOOXMLExportTest1, testTdf128345GradientLinear by
using better double-to-integer rounding (basegfx::fround) in
DrawingML::WriteGradientStop. After double calculations
this makes the tansition to integer correct and stable. Also
took back change at testTdf128345ChartArea_CG_TS_export
which showed the same flaw before.
2nd look @testTdf128345Legend_CS_TG_axial_export made me
add that stuff again and adapt the axial ColorStop adding
in the export to not export the middle enty twice. Extended
test a little bit, too.
Only do not add value if it starts at 0.0 aka StartColor,
else adding it is corect.
Adapted some tests CPPUNIT_ASSERT to CPPUNIT_ASSERT_EQUAL
after being pointed to it from gerrit_linux_clang_dbgutil
build.
Change-Id: I4a993053da8960035671b655e67908f36e59b5fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150763
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'sw/source/filter')
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index d638bfcd5f1d..868701164ed1 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3690,29 +3690,39 @@ void RtfAttributeOutput::FormatFillGradient(const XFillGradientItem& rFillGradie m_aFlyProperties.push_back(std::make_pair<OString, OString>( "fillType", OString::number(7))); // Shade using the fillAngle - const XGradient& rGradient = rFillGradient.GetGradientValue(); - const Color aStartColor(rGradient.GetColorStops().front().getStopColor()); + const XGradient& rGradient(rFillGradient.GetGradientValue()); + const basegfx::ColorStops& rColorStops(rGradient.GetColorStops()); + + // MCGR: It would be best to export the full MCGR definition here + // with all ColorStops in rColorStops, but rtf does not support this. + // Best thing to do and to stay compatible is to export front/back + // colors as start/end and - when more than two ColorStops are defined - + // guess that GradientStyle_AXIAL is used and thus create a "fillFocus" + // entry + // NOTE: I also found that loading file from testTextframeGradient + // "textframe-gradient.rtf" and save-as *inverts* the gradient, so I + // exchanged here fillColor/fillBackColor to get the correct order + const Color aStartColor(rColorStops.front().getStopColor()); m_aFlyProperties.push_back(std::make_pair<OString, OString>( - "fillBackColor", OString::number(wwUtility::RGBToBGR(aStartColor)))); + "fillColor", OString::number(wwUtility::RGBToBGR(aStartColor)))); - const Color aEndColor(rGradient.GetColorStops().back().getStopColor()); - m_aFlyProperties.push_back(std::make_pair<OString, OString>( - "fillColor", OString::number(wwUtility::RGBToBGR(aEndColor)))); - - switch (rGradient.GetGradientStyle()) + if (rColorStops.size() < 3) { - case css::awt::GradientStyle_LINEAR: - break; - case css::awt::GradientStyle_AXIAL: - m_aFlyProperties.push_back( - std::make_pair<OString, OString>("fillFocus", OString::number(50))); - break; - case css::awt::GradientStyle_RADIAL: - case css::awt::GradientStyle_ELLIPTICAL: - case css::awt::GradientStyle_SQUARE: - case css::awt::GradientStyle_RECT: - default: - break; + // two-color version, use back as 2nd color + const Color aEndColor(rColorStops.back().getStopColor()); + m_aFlyProperties.push_back(std::make_pair<OString, OString>( + "fillBackColor", OString::number(wwUtility::RGBToBGR(aEndColor)))); + } + else + { + // assume what was formally GradientStyle_AXIAL, see above and also refer to + // FillModel::pushToPropMap 'fFocus' value and usage. + // The 2nd color is the in-between color, use it + const Color aEndColor(rColorStops[1].getStopColor()); + m_aFlyProperties.push_back(std::make_pair<OString, OString>( + "fillBackColor", OString::number(wwUtility::RGBToBGR(aEndColor)))); + m_aFlyProperties.push_back( + std::make_pair<OString, OString>("fillFocus", OString::number(50))); } } |