[Libreoffice-commits] libvisio.git: 2 commits - src/lib
David Tardon
dtardon at redhat.com
Mon Jul 3 13:56:59 UTC 2017
src/lib/VSDContentCollector.cpp | 15 +++++++--------
src/lib/libvisio_utils.h | 3 ++-
2 files changed, 9 insertions(+), 9 deletions(-)
New commits:
commit 246155061002dc7e373f9cad435ff4382f4ff000
Author: David Tardon <dtardon at redhat.com>
Date: Mon Jul 3 15:56:15 2017 +0200
ofz#2335 avoid divide by zero
Change-Id: Icdc998f3415be6b70612305320faf2e08160f279
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 720ff41..f43ac24 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -1464,14 +1464,14 @@ void libvisio::VSDContentCollector::collectInfiniteLine(unsigned /* id */, unsig
double xline = 0.0;
double yline = 0.0;
- if (x1 == x2)
+ if (VSD_APPROX_EQUAL(x1, x2))
{
xmove = x1;
ymove = 0;
xline = x1;
yline = m_pageHeight;
}
- else if (y1 == y2)
+ else if (VSD_APPROX_EQUAL(y1, y2))
{
xmove = 0;
ymove = y1;
diff --git a/src/lib/libvisio_utils.h b/src/lib/libvisio_utils.h
index 3216ba2..d69b14c 100644
--- a/src/lib/libvisio_utils.h
+++ b/src/lib/libvisio_utils.h
@@ -22,6 +22,7 @@
#define VSD_EPSILON 1E-10
#define VSD_ALMOST_ZERO(m) (fabs(m) <= VSD_EPSILON)
+#define VSD_APPROX_EQUAL(x, y) VSD_ALMOST_ZERO((x) - (y))
#include <librevenge/librevenge.h>
#include <librevenge-stream/librevenge-stream.h>
commit 2501d71f919cc3234718634eda82fd81ba9c9e78
Author: David Tardon <dtardon at redhat.com>
Date: Mon Jul 3 15:52:07 2017 +0200
use VSD_ALMOST_ZERO macro consistently
Change-Id: I8a40d35ac9a90d1e1683172dbff27bfd3250428c
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 98fae36..720ff41 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -1327,7 +1327,6 @@ void libvisio::VSDContentCollector::collectDocumentTheme(const VSDXTheme *theme)
m_documentTheme = theme;
}
-#define LIBVISIO_EPSILON 1E-10
void libvisio::VSDContentCollector::collectEllipticalArcTo(unsigned /* id */, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc)
{
_handleLevelChange(level);
@@ -1348,7 +1347,7 @@ void libvisio::VSDContentCollector::collectEllipticalArcTo(unsigned /* id */, un
m_x = x3;
m_y = y3;
- if (fabs(((x1-x2n)*(y2n-y3n) - (x2n-x3n)*(y1-y2n))) <= LIBVISIO_EPSILON || fabs(((x2n-x3n)*(y1-y2n) - (x1-x2n)*(y2n-y3n))) <= LIBVISIO_EPSILON)
+ if (VSD_ALMOST_ZERO(((x1-x2n)*(y2n-y3n) - (x2n-x3n)*(y1-y2n))) || VSD_ALMOST_ZERO(((x2n-x3n)*(y1-y2n) - (x1-x2n)*(y2n-y3n))))
// most probably all of the points lie on the same line, so use lineTo instead
{
librevenge::RVNGPropertyList end;
@@ -2065,10 +2064,10 @@ double libvisio::VSDContentCollector::_NURBSBasis(unsigned knot, unsigned degree
else
return 0;
}
- if (knotVector.size() > knot+degree && fabs(knotVector[knot+degree]-knotVector[knot]) > LIBVISIO_EPSILON)
+ if (knotVector.size() > knot+degree && !VSD_ALMOST_ZERO(knotVector[knot+degree]-knotVector[knot]))
basis = (point-knotVector[knot])/(knotVector[knot+degree]-knotVector[knot]) * _NURBSBasis(knot, degree-1, point, knotVector);
- if (knotVector.size() > knot+degree+1 && fabs(knotVector[knot+degree+1] - knotVector[knot+1]) > LIBVISIO_EPSILON)
+ if (knotVector.size() > knot+degree+1 && !VSD_ALMOST_ZERO(knotVector[knot+degree+1] - knotVector[knot+1]))
basis += (knotVector[knot+degree+1]-point)/(knotVector[knot+degree+1]-knotVector[knot+1]) * _NURBSBasis(knot+1, degree-1, point, knotVector);
return basis;
@@ -2090,7 +2089,7 @@ void libvisio::VSDContentCollector::_generatePolylineFromNURBS(unsigned degree,
node.insert("librevenge:path-action", "L");
double x = 0;
double y = 0;
- double denominator = LIBVISIO_EPSILON;
+ double denominator = VSD_EPSILON;
for (unsigned p = 0; p < controlPoints.size() && p < weights.size(); p++)
{
@@ -2119,7 +2118,7 @@ bool libvisio::VSDContentCollector::_isUniform(const std::vector<double> &weight
double previousValue = weights[0];
for (std::vector<double>::size_type i = 0; i < weights.size(); ++i)
{
- if (fabs(weights[i] - previousValue) < LIBVISIO_EPSILON)
+ if (VSD_ALMOST_ZERO(weights[i] - previousValue))
previousValue = weights[i];
else
return false;
diff --git a/src/lib/libvisio_utils.h b/src/lib/libvisio_utils.h
index 773f5b0..3216ba2 100644
--- a/src/lib/libvisio_utils.h
+++ b/src/lib/libvisio_utils.h
@@ -20,7 +20,7 @@
#include "VSDTypes.h"
-#define VSD_EPSILON 1E-6
+#define VSD_EPSILON 1E-10
#define VSD_ALMOST_ZERO(m) (fabs(m) <= VSD_EPSILON)
#include <librevenge/librevenge.h>
More information about the Libreoffice-commits
mailing list