summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 10:53:31 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 13:06:24 +0200
commitb9de047454c2603e2f5a5108254cd3f967e8a88b (patch)
tree589c20e48bfed9c3cfe6696c24c67d49f568c6bd /scaddins
parent448e9da1b440561441602e3a0956218b2702767e (diff)
loplugin:flatten in scaddins..sd
Change-Id: I190323ce910224f883c4370b2c752644a5a35edd Reviewed-on: https://gerrit.libreoffice.org/42626 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/source/analysis/analysisdefs.hxx2
-rw-r--r--scaddins/source/analysis/analysishelper.cxx66
-rw-r--r--scaddins/source/analysis/bessel.cxx21
-rw-r--r--scaddins/source/pricing/pricing.hxx2
4 files changed, 39 insertions, 52 deletions
diff --git a/scaddins/source/analysis/analysisdefs.hxx b/scaddins/source/analysis/analysisdefs.hxx
index 47bd092fd512..9acef5d76108 100644
--- a/scaddins/source/analysis/analysisdefs.hxx
+++ b/scaddins/source/analysis/analysisdefs.hxx
@@ -22,7 +22,7 @@
#define CHK_Freq ( nFreq != 1 && nFreq != 2 && nFreq != 4 )
#define CHK_FINITE(d) if( !::rtl::math::isFinite( d ) ) throw css::lang::IllegalArgumentException()
-#define RETURN_FINITE(d) if( ::rtl::math::isFinite( d ) ) return d; else throw css::lang::IllegalArgumentException()
+#define RETURN_FINITE(d) if( !::rtl::math::isFinite( d ) ) throw css::lang::IllegalArgumentException(); return d;
#endif
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index d8836e82ae79..19ea47cc5ef0 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -686,18 +686,15 @@ double ConvertToDec( const OUString& aStr, sal_uInt16 nBase, sal_uInt16 nCharLim
else
n = nBase;
- if( n < nBase )
+ if( n >= nBase )
+ throw lang::IllegalArgumentException(); // illegal char!
+
+ if( bFirstDig )
{
- if( bFirstDig )
- {
- bFirstDig = false;
- nFirstDig = n;
- }
- fVal = fVal * fBase + double( n );
+ bFirstDig = false;
+ nFirstDig = n;
}
- else
- // illegal char!
- throw lang::IllegalArgumentException();
+ fVal = fVal * fBase + double( n );
p++;
@@ -1504,20 +1501,18 @@ void SortedIndividualInt32List::InsertHolidayList(
if( rHolAny.getValueTypeClass() == uno::TypeClass_SEQUENCE )
{
uno::Sequence< uno::Sequence< uno::Any > > aAnySeq;
- if( rHolAny >>= aAnySeq )
+ if( !(rHolAny >>= aAnySeq) )
+ throw lang::IllegalArgumentException();
+
+ const uno::Sequence< uno::Any >* pSeqArray = aAnySeq.getConstArray();
+ for( sal_Int32 nIndex1 = 0; nIndex1 < aAnySeq.getLength(); nIndex1++ )
{
- const uno::Sequence< uno::Any >* pSeqArray = aAnySeq.getConstArray();
- for( sal_Int32 nIndex1 = 0; nIndex1 < aAnySeq.getLength(); nIndex1++ )
- {
- const uno::Sequence< uno::Any >& rSubSeq = pSeqArray[ nIndex1 ];
- const uno::Any* pAnyArray = rSubSeq.getConstArray();
+ const uno::Sequence< uno::Any >& rSubSeq = pSeqArray[ nIndex1 ];
+ const uno::Any* pAnyArray = rSubSeq.getConstArray();
- for( sal_Int32 nIndex2 = 0; nIndex2 < rSubSeq.getLength(); nIndex2++ )
- InsertHolidayList( rAnyConv, pAnyArray[ nIndex2 ], nNullDate, false/*bInsertOnWeekend*/ );
- }
+ for( sal_Int32 nIndex2 = 0; nIndex2 < rSubSeq.getLength(); nIndex2++ )
+ InsertHolidayList( rAnyConv, pAnyArray[ nIndex2 ], nNullDate, false/*bInsertOnWeekend*/ );
}
- else
- throw lang::IllegalArgumentException();
}
else
InsertHolidayList( rAnyConv, rHolAny, nNullDate, false/*bInsertOnWeekend*/ );
@@ -1751,13 +1746,10 @@ void Complex::Power( double fPower )
{
if( r == 0.0 && i == 0.0 )
{
- if( fPower > 0 )
- {
- r = i = 0.0;
- return;
- }
- else
+ if( fPower <= 0 )
throw lang::IllegalArgumentException();
+ r = i = 0.0;
+ return;
}
double p, phi;
@@ -2102,15 +2094,13 @@ void ComplexList::Append( const uno::Sequence< uno::Any >& aMultPars, ComplListA
case uno::TypeClass_SEQUENCE:
{
uno::Sequence< uno::Sequence< uno::Any > > aValArr;
- if( r >>= aValArr )
- {
- sal_Int32 nE = aValArr.getLength();
- const uno::Sequence< uno::Any >* pArr = aValArr.getConstArray();
- for( sal_Int32 n = 0 ; n < nE ; n++ )
- Append( pArr[ n ], eAH );
- }
- else
+ if( !(r >>= aValArr) )
throw lang::IllegalArgumentException();
+
+ sal_Int32 nE = aValArr.getLength();
+ const uno::Sequence< uno::Any >* pArr = aValArr.getConstArray();
+ for( sal_Int32 n = 0 ; n < nE ; n++ )
+ Append( pArr[ n ], eAH );
}
break;
default:
@@ -2558,10 +2548,10 @@ double ConvertDataList::Convert( double fVal, const OUString& rFrom, const OUStr
++it;
}
- if( pFrom && pTo )
- return pFrom->Convert( fVal, *pTo, nLevelFrom, nLevelTo );
- else
+ if( !pFrom || !pTo )
throw lang::IllegalArgumentException();
+
+ return pFrom->Convert( fVal, *pTo, nLevelFrom, nLevelTo );
}
diff --git a/scaddins/source/analysis/bessel.cxx b/scaddins/source/analysis/bessel.cxx
index b7fb5ab419d9..bc0c1d8a6b0b 100644
--- a/scaddins/source/analysis/bessel.cxx
+++ b/scaddins/source/analysis/bessel.cxx
@@ -74,10 +74,9 @@ double BesselJ( double x, sal_Int32 N )
bool bAsymptoticPossible = pow(fX,0.4) > N;
if (fEstimateIteration > fMaxIteration)
{
- if (bAsymptoticPossible)
- return fSign * sqrt(f_2_DIV_PI/fX)* cos(fX-N*f_PI_DIV_2-f_PI_DIV_4);
- else
+ if (!bAsymptoticPossible)
throw NoConvergenceException();
+ return fSign * sqrt(f_2_DIV_PI/fX)* cos(fX-N*f_PI_DIV_2-f_PI_DIV_4);
}
double const epsilon = 1.0e-15; // relative error
@@ -148,10 +147,10 @@ double BesselJ( double x, sal_Int32 N )
k = k + 1.0;
}
while (!bHasfound && k <= fMaxIteration);
- if (bHasfound)
- return u * fSign;
- else
+ if (!bHasfound)
throw NoConvergenceException(); // unlikely to happen
+
+ return u * fSign;
}
@@ -367,10 +366,9 @@ double Bessely0( double fX )
k=k+1;
}
while (!bHasFound && k<fMaxIteration);
- if (bHasFound)
- return u*f_2_DIV_PI;
- else
+ if (!bHasFound)
throw NoConvergenceException(); // not likely to happen
+ return u*f_2_DIV_PI;
}
// See #i31656# for a commented version of this implementation, attachment #desc6
@@ -423,10 +421,9 @@ double Bessely1( double fX )
k=k+1;
}
while (!bHasFound && k<fMaxIteration);
- if (bHasFound)
- return -u*2.0/f_PI;
- else
+ if (!bHasFound)
throw NoConvergenceException();
+ return -u*2.0/f_PI;
}
double BesselY( double fNum, sal_Int32 nOrder )
diff --git a/scaddins/source/pricing/pricing.hxx b/scaddins/source/pricing/pricing.hxx
index 82fbbb6cacc5..eb353e0a2235 100644
--- a/scaddins/source/pricing/pricing.hxx
+++ b/scaddins/source/pricing/pricing.hxx
@@ -38,7 +38,7 @@
#include <com/sun/star/sheet/addin/XPricingFunctions.hpp>
#include <cppuhelper/implbase.hxx>
-#define RETURN_FINITE(d) if( ::rtl::math::isFinite( d ) ) return d; else throw css::lang::IllegalArgumentException()
+#define RETURN_FINITE(d) if( !::rtl::math::isFinite( d ) ) throw css::lang::IllegalArgumentException(); return d;
namespace sca {