summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-08-06 12:31:35 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-08-07 13:43:54 +0200
commit2455caa3b07c5881010410064681e0b2e45921c9 (patch)
tree103c1566ac3b209b4998745ee86f0e95ed986b38 /oox/source
parent0ff6f5ad44a5fb9903c9a905d2ec55248ee75315 (diff)
tdf#134183 PPTX: improve import of transparency in multi-step gradients
Impress core only support a single step, improve the conversion from multi-step to single step to take transparency into account explicitly. Once we select the widest segment, look backwards and forward if there are other next segments which have the same RGB color, just different transparency and include them. This helps in general, because in case a 0% or 100% transparency is mishandled, that's very visible. (cherry picked from commit 73993fdb5d4b507694cd0edf80887d19f7e2bf9a) Conflicts: oox/source/drawingml/fillproperties.cxx Change-Id: I11d593c01a6a4b16149ce74c1408c2a39895e941 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100287 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/drawingml/fillproperties.cxx36
1 files changed, 33 insertions, 3 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index f963f103d2c8..ce6cb1f931e4 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -504,21 +504,51 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
// convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
aGradient.Angle = static_cast< sal_Int16 >( (8100 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
Color aStartColor, aEndColor;
+
+ // Try to grow the widest segment backwards: if a previous segment has the same
+ // color, just different transparency, include it.
+ while (aWidestSegmentStart != aGradientStops.begin())
+ {
+ auto it = std::prev(aWidestSegmentStart);
+ if (it->second.getColor(rGraphicHelper, nPhClr)
+ != aWidestSegmentStart->second.getColor(rGraphicHelper, nPhClr))
+ {
+ break;
+ }
+
+ aWidestSegmentStart = it;
+ }
+
+ auto aWidestSegmentEnd = std::next(aWidestSegmentStart);
+ // Try to grow the widest segment forward: if a neext segment has the same
+ // color, just different transparency, include it.
+ while (aWidestSegmentEnd != std::prev(aGradientStops.end()))
+ {
+ auto it = std::next(aWidestSegmentEnd);
+ if (it->second.getColor(rGraphicHelper, nPhClr)
+ != aWidestSegmentEnd->second.getColor(rGraphicHelper, nPhClr))
+ {
+ break;
+ }
+
+ aWidestSegmentEnd = it;
+ }
+
if( bSymmetric )
{
- aStartColor = std::next(aWidestSegmentStart)->second;
+ aStartColor = aWidestSegmentEnd->second;
aEndColor = aWidestSegmentStart->second;
nBorder *= 2;
}
else if( bSwap )
{
- aStartColor = std::next(aWidestSegmentStart)->second;
+ aStartColor = aWidestSegmentEnd->second;
aEndColor = aWidestSegmentStart->second;
}
else
{
aStartColor = aWidestSegmentStart->second;
- aEndColor = std::next(aWidestSegmentStart)->second;
+ aEndColor = aWidestSegmentEnd->second;
}
SAL_INFO("oox.drawingml.gradient", "start color: " << std::hex << sal_Int32(aStartColor.getColor( rGraphicHelper, nPhClr )) << std::dec <<