summaryrefslogtreecommitdiff
path: root/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-30 09:28:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-10-30 09:34:13 +0000
commitf69067fd66d898cca072ce91c2a04adc794378f0 (patch)
tree492b20b19e7b21d9ad70b1de65da7e6e75f2b23d /svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
parentf089b4fbc800452111e1b5be534e3fc00975cc54 (diff)
coverity#1244939 Division or modulo by float zero
and coverity#1244938 Division or modulo by float zero Change-Id: I128b1ac10f514285152cf189af24885460c9c5ca
Diffstat (limited to 'svx/source/customshapes/EnhancedCustomShapeFontWork.cxx')
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.cxx36
1 files changed, 21 insertions, 15 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index b3bc74237baa..ae31f0080514 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -41,6 +41,7 @@
#include <editeng/outlobj.hxx>
#include <editeng/editobj.hxx>
#include <editeng/editeng.hxx>
+#include <o3tl/numeric.hxx>
#include <svx/svdmodel.hxx>
#include <vector>
#include <numeric>
@@ -741,22 +742,27 @@ void FitTextOutlinesToShapeOutlines( const tools::PolyPolygon& aOutlines2d, FWDa
InsertMissingOutlinePoints( rOutlinePoly, vDistances, rTextAreaBoundRect, aLocalPoly );
InsertMissingOutlinePoints( rOutlinePoly2, vDistances2, rTextAreaBoundRect, aLocalPoly );
- sal_uInt16 j, _nPointCount = aLocalPoly.GetSize();
- for ( j = 0; j < _nPointCount; j++ )
+ sal_uInt16 _nPointCount = aLocalPoly.GetSize();
+ if (_nPointCount)
{
- Point& rPoint = aLocalPoly[ j ];
- rPoint.X() -= nLeft;
- rPoint.Y() -= nTop;
- double fX = (double)rPoint.X() / (double)nWidth;
- double fY = (double)rPoint.Y() / (double)nHeight;
-
- double fx1, fy1, fx2, fy2;
- GetPoint( rOutlinePoly, vDistances, fX, fx1, fy1 );
- GetPoint( rOutlinePoly2, vDistances2, fX, fx2, fy2 );
- double fWidth = fx2 - fx1;
- double fHeight= fy2 - fy1;
- rPoint.X() = (sal_Int32)( fx1 + fWidth * fY );
- rPoint.Y() = (sal_Int32)( fy1 + fHeight* fY );
+ if (!nWidth || !nHeight)
+ throw o3tl::divide_by_zero();
+ for (sal_uInt16 j = 0; j < _nPointCount; ++j)
+ {
+ Point& rPoint = aLocalPoly[ j ];
+ rPoint.X() -= nLeft;
+ rPoint.Y() -= nTop;
+ double fX = (double)rPoint.X() / (double)nWidth;
+ double fY = (double)rPoint.Y() / (double)nHeight;
+
+ double fx1, fy1, fx2, fy2;
+ GetPoint( rOutlinePoly, vDistances, fX, fx1, fy1 );
+ GetPoint( rOutlinePoly2, vDistances2, fX, fx2, fy2 );
+ double fWidth = fx2 - fx1;
+ double fHeight= fy2 - fy1;
+ rPoint.X() = (sal_Int32)( fx1 + fWidth * fY );
+ rPoint.Y() = (sal_Int32)( fy1 + fHeight* fY );
+ }
}
// write back polygon