Kaydet (Commit) a02046b7 authored tarafından Ivo Hinkelmann's avatar Ivo Hinkelmann

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
üst 0552cda5
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: EnhancedCustomShape2d.cxx,v $ * $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 Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -113,6 +113,9 @@ ...@@ -113,6 +113,9 @@
#ifndef BOOST_SHARED_PTR_HPP_INCLUDED #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#endif #endif
#ifndef _BGFX_NUMERIC_FTOOLS_HXX
#include <basegfx/numeric/ftools.hxx>
#endif
//#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX //#ifndef _BGFX_POLYPOLYGON_B2DPOLYGONTOOLS_HXX
//#include <basegfx/polygon/b2dpolypolygontools.hxx> //#include <basegfx/polygon/b2dpolypolygontools.hxx>
...@@ -1202,9 +1205,9 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : ...@@ -1202,9 +1205,9 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
default: default:
break; break;
} }
fXScale = (double)aLogicRect.GetWidth() / (double)nCoordWidth; fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth;
fYScale = (double)aLogicRect.GetHeight() / (double)nCoordHeight; fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight;
if ( (sal_uInt32)nXRef != 0x80000000 ) if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() )
{ {
fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight(); fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight();
if ( fXRatio > 1 ) if ( fXRatio > 1 )
...@@ -1214,7 +1217,7 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) : ...@@ -1214,7 +1217,7 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
} }
else else
fXRatio = 1.0; fXRatio = 1.0;
if ( (sal_uInt32)nYRef != 0x80000000 ) if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() )
{ {
fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth(); fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth();
if ( fYRatio > 1 ) if ( fYRatio > 1 )
...@@ -1546,7 +1549,11 @@ sal_Bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Poin ...@@ -1546,7 +1549,11 @@ sal_Bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Poin
double dx = fRadius * fXScale; double dx = fRadius * fXScale;
double fX = dx * cos( a ); double fX = dx * cos( a );
double fY =-dx * sin( 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 else
{ {
...@@ -2425,8 +2432,8 @@ void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj ) ...@@ -2425,8 +2432,8 @@ void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj )
const Point& rPoint = GetPoint( seqGluePoints[ i ], sal_True, sal_True ); const Point& rPoint = GetPoint( seqGluePoints[ i ], sal_True, sal_True );
double fXRel = rPoint.X(); double fXRel = rPoint.X();
double fYRel = rPoint.Y(); double fYRel = rPoint.Y();
fXRel = fXRel / aLogicRect.GetWidth() * 10000; fXRel = aLogicRect.GetWidth() == 0 ? 0.0 : fXRel / aLogicRect.GetWidth() * 10000;
fYRel = fYRel / aLogicRect.GetHeight() * 10000; fYRel = aLogicRect.GetHeight() == 0 ? 0.0 : fYRel / aLogicRect.GetHeight() * 10000;
aGluePoint.SetPos( Point( (sal_Int32)fXRel, (sal_Int32)fYRel ) ); aGluePoint.SetPos( Point( (sal_Int32)fXRel, (sal_Int32)fYRel ) );
aGluePoint.SetPercent( sal_True ); aGluePoint.SetPercent( sal_True );
aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT ); aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT );
......
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