Kaydet (Commit) eed1ea79 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1250406 Division or modulo by float zero

and

coverity#1250407 Division or modulo by float zero
coverity#1250408 Division or modulo by float zero

Change-Id: I77e4483356f7c0b287a29637cf6b958ee665ffec
üst 445ac42c
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <svtools/brwbox.hxx> #include <svtools/brwbox.hxx>
#include <svtools/brwhead.hxx> #include <svtools/brwhead.hxx>
#include <o3tl/numeric.hxx>
#include "datwin.hxx" #include "datwin.hxx"
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
...@@ -2418,7 +2419,6 @@ long BrowseBox::GetTitleHeight() const ...@@ -2418,7 +2419,6 @@ long BrowseBox::GetTitleHeight() const
return nTitleLines ? nTitleLines * nHeight + 4 : 0; return nTitleLines ? nTitleLines * nHeight + 4 : 0;
} }
long BrowseBox::CalcReverseZoom(long nVal) long BrowseBox::CalcReverseZoom(long nVal)
{ {
if (IsZoom()) if (IsZoom())
...@@ -2426,6 +2426,8 @@ long BrowseBox::CalcReverseZoom(long nVal) ...@@ -2426,6 +2426,8 @@ long BrowseBox::CalcReverseZoom(long nVal)
const Fraction& rZoom = GetZoom(); const Fraction& rZoom = GetZoom();
double n = (double)nVal; double n = (double)nVal;
n *= (double)rZoom.GetDenominator(); n *= (double)rZoom.GetDenominator();
if (!rZoom.GetNumerator())
throw o3tl::divide_by_zero();
n /= (double)rZoom.GetNumerator(); n /= (double)rZoom.GetNumerator();
nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5); nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5);
} }
...@@ -2445,8 +2447,6 @@ void BrowseBox::CursorMoved() ...@@ -2445,8 +2447,6 @@ void BrowseBox::CursorMoved()
); );
} }
void BrowseBox::LoseFocus() void BrowseBox::LoseFocus()
{ {
OSL_TRACE( "BrowseBox: %p->LoseFocus", this ); OSL_TRACE( "BrowseBox: %p->LoseFocus", this );
......
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
#include "datwin.hxx" #include "datwin.hxx"
#include <o3tl/numeric.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/help.hxx> #include <vcl/help.hxx>
#include <vcl/image.hxx> #include <vcl/image.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
...@@ -101,8 +100,6 @@ void ButtonFrame::Draw( OutputDevice& rDev ) ...@@ -101,8 +100,6 @@ void ButtonFrame::Draw( OutputDevice& rDev )
rDev.SetFillColor( aOldFillColor ); rDev.SetFillColor( aOldFillColor );
} }
BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage,
const OUString& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom ) const OUString& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom )
: _nId( nItemId ), : _nId( nItemId ),
...@@ -114,6 +111,8 @@ BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage, ...@@ -114,6 +111,8 @@ BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage,
double n = (double)_nWidth; double n = (double)_nWidth;
n *= (double)rCurrentZoom.GetDenominator(); n *= (double)rCurrentZoom.GetDenominator();
n /= (double)rCurrentZoom.GetNumerator(); n /= (double)rCurrentZoom.GetNumerator();
if (!rCurrentZoom.GetNumerator())
throw o3tl::divide_by_zero();
_nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
} }
...@@ -121,19 +120,17 @@ BrowserColumn::~BrowserColumn() ...@@ -121,19 +120,17 @@ BrowserColumn::~BrowserColumn()
{ {
} }
void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom) void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom)
{ {
_nWidth = nNewWidthPixel; _nWidth = nNewWidthPixel;
double n = (double)_nWidth; double n = (double)_nWidth;
n *= (double)rCurrentZoom.GetDenominator(); n *= (double)rCurrentZoom.GetDenominator();
if (!rCurrentZoom.GetNumerator())
throw o3tl::divide_by_zero();
n /= (double)rCurrentZoom.GetNumerator(); n /= (double)rCurrentZoom.GetNumerator();
_nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5); _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
} }
void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, bool bCurs ) void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, bool bCurs )
{ {
if ( _nId == 0 ) if ( _nId == 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment