diff options
author | Eike Rathke <erack@redhat.com> | 2016-10-01 12:11:19 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-10-01 22:55:57 +0000 |
commit | 2135eae2a97c17d89cb47a2074830fd2d7b2226f (patch) | |
tree | 6f91d5cdc9ffc0653275b020529848756305b71b /libreofficekit/source | |
parent | ec3aabe66bde2c8bdea2c3692ac1c4981c8910a3 (diff) |
let approxEqual() not scale too early for large representable integer values
And since this is now too much code for inline move implementation to math.cxx
Which again made it necessary to give libreofficekit lokdocview.cxx its own
implementation that doesn't even claim to build against sal ...
Change-Id: I0f80be9d9172ee20693b9babde715206f2c3d8c1
Reviewed-on: https://gerrit.libreoffice.org/29428
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'libreofficekit/source')
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 0362d256db6b..4d34428a3312 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -3179,6 +3179,26 @@ lok_doc_view_set_visible_area (LOKDocView* pDocView, GdkRectangle* pVisibleArea) priv->m_bVisibleAreaSet = true; } +namespace { +// This used to be rtl::math::approxEqual() but since that isn't inline anymore +// in rtl/math.hxx and was moved into libuno_sal as rtl_math_approxEqual() to +// cater for representable integer cases and we don't want to link against +// libuno_sal, we'll have to have an own implementation. The special large +// integer cases seems not be needed here. +inline bool lok_approxEqual(double a, double b) +{ + static const double e48 = 1.0 / (16777216.0 * 16777216.0); + // XXX loplugin:fpcomparison complains about floating-point comparison for + // a==b, though we actually want this here. + if (!(a<b) && !(a>b)) + return true; + if (a == 0.0 || b == 0.0) + return false; + const double d = fabs(a - b); + return (d < fabs(a) * e48 && d < fabs(b) * e48); +} +} + SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom) { @@ -3192,7 +3212,7 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom) fZoom = fZoom < MIN_ZOOM ? MIN_ZOOM : fZoom; fZoom = fZoom > MAX_ZOOM ? MAX_ZOOM : fZoom; - if (rtl::math::approxEqual(fZoom, priv->m_fZoom)) + if (lok_approxEqual(fZoom, priv->m_fZoom)) return; priv->m_fZoom = fZoom; |