diff options
author | Frank Schönheit <fs@openoffice.org> | 2009-09-17 21:11:28 +0000 |
---|---|---|
committer | Frank Schönheit <fs@openoffice.org> | 2009-09-17 21:11:28 +0000 |
commit | 8e2308c3ff142e3b7232908bacdcdb85ac1f9683 (patch) | |
tree | 7fbd8b2ac26400e2e34c75ff1c05f1a4e3a2a5f2 /toolkit | |
parent | 24dff8f7929425d0ded658d8729b1257e5cf4868 (diff) |
setZoom: care for rounding errors which occur during implicit conversion from float to double
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/awt/vclxwindow.cxx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx index 93486d86e739..501ed7f009f1 100644 --- a/toolkit/source/awt/vclxwindow.cxx +++ b/toolkit/source/awt/vclxwindow.cxx @@ -2586,7 +2586,14 @@ void VCLXWindow::setZoom( float fZoomX, float /*fZoomY*/ ) throw(::com::sun::sta ::vos::OGuard aGuard( GetMutex() ); if ( GetWindow() ) - GetWindow()->SetZoom( Fraction( fZoomX ) ); + { + // Fraction::Fraction takes a double, but we have a float only. + // The implicit conversion from float to double can result in a precision loss, i.e. 1.2 is converted to + // 1.200000000047something. To prevent this, we convert explicitly to double, and round it. + double nZoom( fZoomX ); + nZoom = ::rtl::math::round( nZoom, 4 ); + GetWindow()->SetZoom( Fraction( nZoom ) ); + } } // ::com::sun::star::lang::XEventListener |