diff options
-rw-r--r-- | svtools/source/brwbox/brwbox1.cxx | 6 | ||||
-rw-r--r-- | svtools/source/brwbox/datwin.cxx | 13 |
2 files changed, 8 insertions, 11 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx index caf2b417cb8a..51bfecb6114b 100644 --- a/svtools/source/brwbox/brwbox1.cxx +++ b/svtools/source/brwbox/brwbox1.cxx @@ -19,6 +19,7 @@ #include <svtools/brwbox.hxx> #include <svtools/brwhead.hxx> +#include <o3tl/numeric.hxx> #include "datwin.hxx" #include <tools/debug.hxx> #include <tools/stream.hxx> @@ -2418,7 +2419,6 @@ long BrowseBox::GetTitleHeight() const return nTitleLines ? nTitleLines * nHeight + 4 : 0; } - long BrowseBox::CalcReverseZoom(long nVal) { if (IsZoom()) @@ -2426,6 +2426,8 @@ long BrowseBox::CalcReverseZoom(long nVal) const Fraction& rZoom = GetZoom(); double n = (double)nVal; n *= (double)rZoom.GetDenominator(); + if (!rZoom.GetNumerator()) + throw o3tl::divide_by_zero(); n /= (double)rZoom.GetNumerator(); nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5); } @@ -2445,8 +2447,6 @@ void BrowseBox::CursorMoved() ); } - - void BrowseBox::LoseFocus() { OSL_TRACE( "BrowseBox: %p->LoseFocus", this ); diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx index 91bff8b52be8..b2fea467c553 100644 --- a/svtools/source/brwbox/datwin.cxx +++ b/svtools/source/brwbox/datwin.cxx @@ -19,9 +19,8 @@ #include "datwin.hxx" - +#include <o3tl/numeric.hxx> #include <vcl/svapp.hxx> - #include <vcl/help.hxx> #include <vcl/image.hxx> #include <vcl/settings.hxx> @@ -101,8 +100,6 @@ void ButtonFrame::Draw( OutputDevice& rDev ) rDev.SetFillColor( aOldFillColor ); } - - BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, const OUString& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom ) : _nId( nItemId ), @@ -114,6 +111,8 @@ BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, double n = (double)_nWidth; n *= (double)rCurrentZoom.GetDenominator(); n /= (double)rCurrentZoom.GetNumerator(); + if (!rCurrentZoom.GetNumerator()) + throw o3tl::divide_by_zero(); _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); } @@ -121,19 +120,17 @@ BrowserColumn::~BrowserColumn() { } - - void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom) { _nWidth = nNewWidthPixel; double n = (double)_nWidth; n *= (double)rCurrentZoom.GetDenominator(); + if (!rCurrentZoom.GetNumerator()) + throw o3tl::divide_by_zero(); n /= (double)rCurrentZoom.GetNumerator(); _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); } - - void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, bool bCurs ) { if ( _nId == 0 ) |