diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2014-03-24 20:47:43 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2014-03-24 20:51:57 +0100 |
commit | 59475ae16329edd32d286eb912c3f52d3395c818 (patch) | |
tree | f5812659f4e8e591936a6a38619228daaa21ad00 /sfx2 | |
parent | afd7ad155d4fd3219f51b38e8193d9284a65715e (diff) |
cppcheck: fix Division by zero + move some lines
See http://nabble.documentfoundation.org/Cppcheck-reports-quot-Division-by-zero-quot-in-new-cxx-sfx2-module-td4102613.html
Change-Id: I71433bcb20575016ee2e993a67c6e09646672f9b
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/new.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx index d8bbd51a09e9..04b1200abab6 100644 --- a/sfx2/source/doc/new.cxx +++ b/sfx2/source/doc/new.cxx @@ -68,14 +68,19 @@ Size SfxPreviewBase_Impl::GetOptimalSize() const void SfxPreviewWin_Impl::ImpPaint( const Rectangle&, GDIMetaFile* pFile, Window* pWindow ) { + pWindow->SetLineColor(); + Color aLightGrayCol( COL_LIGHTGRAY ); + pWindow->SetFillColor( aLightGrayCol ); + pWindow->DrawRect( Rectangle( Point( 0,0 ), pWindow->GetOutputSize() ) ); + Size aTmpSize = pFile ? pFile->GetPrefSize() : Size(1,1 ); DBG_ASSERT( aTmpSize.Height()*aTmpSize.Width(), "size of first page is 0, overload GetFirstPageSize or set vis-area!" ); #define FRAME 4 long nWidth = pWindow->GetOutputSize().Width() - 2*FRAME; long nHeight = pWindow->GetOutputSize().Height() - 2*FRAME; - if( nWidth < 0 ) nWidth = 0; - if( nHeight < 0 ) nHeight = 0; + if (nWidth <= 0 || nHeight <= 0) + return; double dRatio=((double)aTmpSize.Width())/aTmpSize.Height(); double dRatioPreV=((double) nWidth ) / nHeight; @@ -93,11 +98,6 @@ void SfxPreviewWin_Impl::ImpPaint( } Point bPoint=Point(nWidth,nHeight)-aPoint; - - pWindow->SetLineColor(); - Color aLightGrayCol( COL_LIGHTGRAY ); - pWindow->SetFillColor( aLightGrayCol ); - pWindow->DrawRect( Rectangle( Point( 0,0 ), pWindow->GetOutputSize() ) ); if ( pFile ) { Color aBlackCol( COL_BLACK ); |