diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2006-08-03 12:32:46 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2006-08-03 12:32:46 +0000 |
commit | a02046b76b34bb79423ec29c048e56f082d769b7 (patch) | |
tree | 9329fd5a7b0dabee85aade2112497d1993b6d8e4 /svx/source/customshapes | |
parent | 0552cda562a5f93426030dd4baf186fa0fa92d28 (diff) |
INTEGRATION: CWS vcl64 (1.18.30); FILE MERGED
2006/08/02 11:40:56 thb 1.18.30.1: #i64758# Guarding against division by zero at various places
Diffstat (limited to 'svx/source/customshapes')
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShape2d.cxx | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index b6a94c3844d0..bb1a3e5ead96 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: EnhancedCustomShape2d.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: obo $ $Date: 2006-07-10 11:26:21 $ + * last change: $Author: ihi $ $Date: 2006-08-03 13:32:46 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -113,6 +113,9 @@ #ifndef BOOST_SHARED_PTR_HPP_INCLUDED #include <boost/shared_ptr.hpp> #endif +#ifndef _BGFX_NUMERIC_FTOOLS_HXX +#include <basegfx/numeric/ftools.hxx> +#endif //#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX //#include <basegfx/polygon/b2dpolypolygontools.hxx> @@ -1202,9 +1205,9 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : default: break; } - fXScale = (double)aLogicRect.GetWidth() / (double)nCoordWidth; - fYScale = (double)aLogicRect.GetHeight() / (double)nCoordHeight; - if ( (sal_uInt32)nXRef != 0x80000000 ) + fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth; + fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight; + if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() ) { fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight(); if ( fXRatio > 1 ) @@ -1214,7 +1217,7 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : } else fXRatio = 1.0; - if ( (sal_uInt32)nYRef != 0x80000000 ) + if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() ) { fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth(); if ( fYRatio > 1 ) @@ -1546,7 +1549,11 @@ sal_Bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Poin double dx = fRadius * fXScale; double fX = dx * cos( a ); double fY =-dx * sin( a ); - rReturnPosition = Point( Round( fX + aReferencePoint.X() ), Round( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) ); + rReturnPosition = + Point( + Round( fX + aReferencePoint.X() ), + basegfx::fTools::equalZero(fXScale) ? aReferencePoint.Y() : + Round( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) ); } else { @@ -2425,8 +2432,8 @@ void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj ) const Point& rPoint = GetPoint( seqGluePoints[ i ], sal_True, sal_True ); double fXRel = rPoint.X(); double fYRel = rPoint.Y(); - fXRel = fXRel / aLogicRect.GetWidth() * 10000; - fYRel = fYRel / aLogicRect.GetHeight() * 10000; + fXRel = aLogicRect.GetWidth() == 0 ? 0.0 : fXRel / aLogicRect.GetWidth() * 10000; + fYRel = aLogicRect.GetHeight() == 0 ? 0.0 : fYRel / aLogicRect.GetHeight() * 10000; aGluePoint.SetPos( Point( (sal_Int32)fXRel, (sal_Int32)fYRel ) ); aGluePoint.SetPercent( sal_True ); aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT ); |