ofz#3812 Divide-by-zero
Change-Id: I1a278302b995137d3e73620c003534498a59ba14 Reviewed-on: https://gerrit.libreoffice.org/43870 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
parent
3fc4211a0f
commit
85b698cbd3
@ -1687,11 +1687,14 @@ void impCorrectContinuity(basegfx::B2DPolygon& roPolygon, sal_uInt32 nIndex, Pol
|
|||||||
|
|
||||||
// calculate common direction vector, normalize
|
// calculate common direction vector, normalize
|
||||||
const basegfx::B2DVector aDirection(aNext + aPrev);
|
const basegfx::B2DVector aDirection(aNext + aPrev);
|
||||||
|
const double fDirectionLen = aDirection.getLength();
|
||||||
|
if (fDirectionLen == 0.0)
|
||||||
|
return;
|
||||||
|
|
||||||
if(PolyFlags::Smooth == nCFlag)
|
if (PolyFlags::Smooth == nCFlag)
|
||||||
{
|
{
|
||||||
// C1: apply common direction vector, preserve individual lengths
|
// C1: apply common direction vector, preserve individual lengths
|
||||||
const double fInvDirectionLen(1.0 / aDirection.getLength());
|
const double fInvDirectionLen(1.0 / fDirectionLen);
|
||||||
roPolygon.setNextControlPoint(nIndex, basegfx::B2DPoint(aPoint + (aDirection * (aNext.getLength() * fInvDirectionLen))));
|
roPolygon.setNextControlPoint(nIndex, basegfx::B2DPoint(aPoint + (aDirection * (aNext.getLength() * fInvDirectionLen))));
|
||||||
roPolygon.setPrevControlPoint(nIndex, basegfx::B2DPoint(aPoint - (aDirection * (aPrev.getLength() * fInvDirectionLen))));
|
roPolygon.setPrevControlPoint(nIndex, basegfx::B2DPoint(aPoint - (aDirection * (aPrev.getLength() * fInvDirectionLen))));
|
||||||
}
|
}
|
||||||
@ -1699,7 +1702,7 @@ void impCorrectContinuity(basegfx::B2DPolygon& roPolygon, sal_uInt32 nIndex, Pol
|
|||||||
{
|
{
|
||||||
// C2: get mediated length. Taking half of the unnormalized direction would be
|
// C2: get mediated length. Taking half of the unnormalized direction would be
|
||||||
// an approximation, but not correct.
|
// an approximation, but not correct.
|
||||||
const double fMedLength((aNext.getLength() + aPrev.getLength()) * (0.5 / aDirection.getLength()));
|
const double fMedLength((aNext.getLength() + aPrev.getLength()) * (0.5 / fDirectionLen));
|
||||||
const basegfx::B2DVector aScaledDirection(aDirection * fMedLength);
|
const basegfx::B2DVector aScaledDirection(aDirection * fMedLength);
|
||||||
|
|
||||||
// Bring Direction to correct length and apply
|
// Bring Direction to correct length and apply
|
||||||
|
Loading…
x
Reference in New Issue
Block a user