summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2024-02-22 09:24:12 -0500
committerJustin Luth <jluth@mail.com>2024-02-23 20:28:31 +0100
commit6dd6891a3deed8718bf2b0fcf564f229f676f8ba (patch)
treec62c9fbe5b0428cf4e3822a0ffe3fac91d729126 /oox
parent695f8fb19d839efe03a402d2a7e7ef73b6d8f436 (diff)
related tdf#126533 tdf#159824 VML: don't export: negative angles
and stop an automatic 180 reversal on import. Some documents had gradient reversals on every round trip, typically when the angle was 0-179 (mainly seen in ODT examples, since DOCX/RTF imports defaulted to be angle 180). The negative sign has special meaning, indicating that the start and end colors should be swapped. Well, swapping colors was not intentional in the export logic. Previously there was a mistaken idea that any angles > 180 needed to be swapped on import, and likely that is what prompted this overly complicated formula to try to avoid any angle > 180 during export by allowing negative angles. This tdf#126533 patchset has already eliminated import checks for angles > 180, so now a sane formula can be applied on export. In order to do that, we have to avoid emulating color swaps with 180 degree rotations at import time. So ONLY do color swapping with start/end, and leave the angle alone. That GREATLY helps unit tests (which otherwise would flip-flop the angle and the color start/stop). Very unhelpful was an undocumented, indecipherable inversion when converting to DML angle. Boy, I hope I got this right... make CppunitTest_sw_rtfexport8 \ CPPUNIT_TEST_NAME=testTdf159824_gradientAngle3 make CppunitTest_sw_rtfexport8 \ CPPUNIT_TEST_NAME=testTdf159824_gradientAngle4 make CppunitTest_sw_ooxmlexport7 \ CPPUNIT_TEST_NAME=testTdf126533_axialAngle2 Eliminating the inversion for ooxml7 test is fine since inversion does nothing to an axial. Otherwise, eliminating inversions corresponds to a color swap. Change-Id: I2aae0a7595807569ffc740689ff3840692d6159d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163798 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/vml/vmlformatting.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index f4022d0639d6..5fb422e63b9d 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -800,22 +800,29 @@ void FillModel::pushToPropMap( ShapePropertyMap& rPropMap, const GraphicHelper&
}
else // focus of -100%, 0%, and 100% is linear gradient
{
+ // LO linear gradients: top == start, but for MSO bottom == start == moColor
+ bool bSwapColors = true;
+
/* According to spec, a focus of -100% or 100% swaps the
start and stop colors, effectively reversing the gradient.
If the angle was provided as a negative,
then the colors are also (again) reversed. */
if( fFocus < -0.5 || fFocus > 0.5 )
- nVmlAngle = (nVmlAngle + 180) % 360;
+ bSwapColors = !bSwapColors;
if (moAngle.value_or(0) < 0)
- nVmlAngle = (nVmlAngle + 180) % 360;
+ bSwapColors = !bSwapColors;
+ const Color& rStartColor = bSwapColors ? aColor2 : aColor1;
+ const Color& rEndColor = bSwapColors ? aColor1 : aColor2;
// set the start and stop colors
- lcl_setGradientStop( aFillProps.maGradientProps.maGradientStops, 0.0, aColor1 );
- lcl_setGradientStop( aFillProps.maGradientProps.maGradientStops, 1.0, aColor2 );
+ lcl_setGradientStop(aFillProps.maGradientProps.maGradientStops, 0.0,
+ rStartColor);
+ lcl_setGradientStop(aFillProps.maGradientProps.maGradientStops, 1.0,
+ rEndColor);
}
// VML counts counterclockwise from bottom, DrawingML clockwise from left
- sal_Int32 nDmlAngle = (630 - nVmlAngle) % 360;
+ sal_Int32 nDmlAngle = NormAngle360(90 - nVmlAngle);
aFillProps.maGradientProps.moShadeAngle = nDmlAngle * ::oox::drawingml::PER_DEGREE;
}
else // XML_gradientRadial is rectangular gradient