summaryrefslogtreecommitdiff
path: root/scaddins/source
diff options
context:
space:
mode:
authorgt <gt@openoffice.org>2001-05-22 10:51:24 +0000
committergt <gt@openoffice.org>2001-05-22 10:51:24 +0000
commit807ce79811ee5ec5aadbce4946004171c657796a (patch)
tree1fe805273c84db6d5f9c47e11fcdb7bd59e89162 /scaddins/source
parent3af262b542d4de160404c6ac7188bb84773f8c5d (diff)
#87269# using array of array instead only array
Diffstat (limited to 'scaddins/source')
-rw-r--r--scaddins/source/analysis/analysis.cxx6
-rw-r--r--scaddins/source/analysis/analysis.hxx14
-rw-r--r--scaddins/source/analysis/analysisadd.idl17
-rw-r--r--scaddins/source/analysis/analysishelper.cxx44
-rw-r--r--scaddins/source/analysis/analysishelper.hxx5
-rw-r--r--scaddins/source/analysis/financial.cxx57
6 files changed, 97 insertions, 46 deletions
diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx
index d4f2b49b7b4c..7bb4563baf5c 100644
--- a/scaddins/source/analysis/analysis.cxx
+++ b/scaddins/source/analysis/analysis.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysis.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: pl $ $Date: 2001-05-14 08:38:20 $
+ * last change: $Author: gt $ $Date: 2001-05-22 11:49:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -852,7 +852,7 @@ STRING SAL_CALL AnalysisAddIn::getDisplayCategoryName( const STRING& aProgrammat
*/
sal_Int32 SAL_CALL AnalysisAddIn::getWorkday( constREFXPS& xOptions,
- sal_Int32 nDate, sal_Int32 nDays, const SEQSEQ( sal_Int32 )& aHDay ) THROWDEF_RTE
+ sal_Int32 nDate, sal_Int32 nDays, const ANY& aHDay ) THROWDEF_RTE
{
if( !nDays )
return nDate;
diff --git a/scaddins/source/analysis/analysis.hxx b/scaddins/source/analysis/analysis.hxx
index 4316bf2f208c..14a0ce089921 100644
--- a/scaddins/source/analysis/analysis.hxx
+++ b/scaddins/source/analysis/analysis.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysis.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: gt $ $Date: 2001-05-09 12:33:08 $
+ * last change: $Author: gt $ $Date: 2001-05-22 11:49:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -126,7 +126,7 @@ public:
// XAnalysis
// virtual double SAL_CALL get_Test( constREFXPS&, sal_Int32 nMode, double f1, double f2, double f3 ) THROWDEF_RTE;
- virtual sal_Int32 SAL_CALL getWorkday( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nDays, const SEQSEQ( sal_Int32 )& aHDay ) THROWDEF_RTE;
+ virtual sal_Int32 SAL_CALL getWorkday( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nDays, const ANY& aHDay ) THROWDEF_RTE;
virtual double SAL_CALL getYearfrac( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode ) THROWDEF_RTE_IAE;
virtual sal_Int32 SAL_CALL getEdate( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nMonths ) THROWDEF_RTE;
virtual sal_Int32 SAL_CALL getWeeknum( constREFXPS&, sal_Int32 nStartDate, sal_Int32 nMode ) THROWDEF_RTE;
@@ -193,7 +193,7 @@ public:
virtual double SAL_CALL getImreal( const STRING& aNum ) THROWDEF_RTE_IAE;
virtual STRING SAL_CALL getImsin( const STRING& aNum ) THROWDEF_RTE_IAE;
virtual STRING SAL_CALL getImsub( const STRING& aNum1, const STRING& aNum2 ) THROWDEF_RTE_IAE;
- virtual STRING SAL_CALL getImsum( const STRING& aNum1, const SEQ( CSS::uno::Any )& aFollowingPars ) THROWDEF_RTE_IAE;
+ virtual STRING SAL_CALL getImsum( const STRING& aNum1, const SEQ( ANY )& aFollowingPars ) THROWDEF_RTE_IAE;
virtual STRING SAL_CALL getImsqrt( const STRING& aNum ) THROWDEF_RTE_IAE;
virtual STRING SAL_CALL getComplex( double fReal, double fImaginary, const STRING& rSuffix ) THROWDEF_RTE_IAE;
@@ -227,8 +227,8 @@ public:
virtual double SAL_CALL getOddfyield( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue, sal_Int32 nFirstCoup, double fRate, double fPrice, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase ) THROWDEF_RTE_IAE;
virtual double SAL_CALL getOddlprice( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastInterest, double fRate, double fYield, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase ) THROWDEF_RTE_IAE;
virtual double SAL_CALL getOddlyield( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastInterest, double fRate, double fPrice, double fRedemp, sal_Int32 nFreq, const ANY& rOptBase) THROWDEF_RTE_IAE;
- virtual double SAL_CALL getXirr( const SEQ( double )& rValues, const SEQ( sal_Int32 )& rDates, const ANY& rGuess ) THROWDEF_RTE_IAE;
- virtual double SAL_CALL getXnpv( double fRate, const SEQ( double )& rValues, const SEQ( sal_Int32 )& rDates ) THROWDEF_RTE_IAE;
+ virtual double SAL_CALL getXirr( const SEQSEQ( double )& rValues, const SEQSEQ( sal_Int32 )& rDates, const ANY& rGuess ) THROWDEF_RTE_IAE;
+ virtual double SAL_CALL getXnpv( double fRate, const SEQSEQ( double )& rValues, const SEQSEQ( sal_Int32 )& rDates ) THROWDEF_RTE_IAE;
virtual double SAL_CALL getIntrate( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, double fInvest, double fRedemp, const ANY& rOptBase ) THROWDEF_RTE_IAE;
virtual double SAL_CALL getCoupncd( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ) THROWDEF_RTE_IAE;
virtual double SAL_CALL getCoupdays( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ) THROWDEF_RTE_IAE;
@@ -236,7 +236,7 @@ public:
virtual double SAL_CALL getCoupdaybs( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ) THROWDEF_RTE_IAE;
virtual double SAL_CALL getCouppcd( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ) THROWDEF_RTE_IAE;
virtual double SAL_CALL getCoupnum( constREFXPS& xOpt, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOptBase ) THROWDEF_RTE_IAE;
- virtual double SAL_CALL getFvschedule( double fPrinc, const SEQ( double )& rSchedule ) THROWDEF_RTE_IAE;
+ virtual double SAL_CALL getFvschedule( double fPrinc, const SEQSEQ( double )& rSchedule ) THROWDEF_RTE_IAE;
};
//------------------------------------------------------------------
diff --git a/scaddins/source/analysis/analysisadd.idl b/scaddins/source/analysis/analysisadd.idl
index 57f065836cee..1fb3cf984e0e 100644
--- a/scaddins/source/analysis/analysisadd.idl
+++ b/scaddins/source/analysis/analysisadd.idl
@@ -2,9 +2,9 @@
*
* $RCSfile: analysisadd.idl,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: gt $ $Date: 2001-05-09 12:33:08 $
+ * last change: $Author: gt $ $Date: 2001-05-22 11:49:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,7 +87,7 @@ module addin
/// workday.
long getWorkday(
[in] com::sun::star::beans::XPropertySet xOptions,
- [in] long nStartDate, [in] long nDays, [in] sequence< sequence<long> > aHolidays );
+ [in] long nStartDate, [in] long nDays, [in] any aHolidays );
/// yearfrac.
double getYearfrac(
@@ -414,10 +414,15 @@ module addin
[in] long Frequency, [in] any Base );
/// xirr.
- double getXirr( [in] sequence<double> Values, [in] sequence<long> Dates, [in] any Guess );
+ double getXirr(
+ [in] sequence< sequence< double > > Values,
+ [in] sequence< sequence< long > > Dates, [in] any Guess );
/// xnpv.
- double getXnpv( [in] double Rate, [in] sequence<double> Values, [in] sequence<long> Dates );
+ double getXnpv(
+ [in] double Rate,
+ [in] sequence< sequence< double > > Values,
+ [in] sequence< sequence< long > > Dates );
/// intrate.
double getIntrate(
@@ -463,7 +468,7 @@ module addin
[in] long Frequency, [in] any Base );
/// fvschedule.
- double getFvschedule( [in] double Principal, [in] sequence<double> Schedule );
+ double getFvschedule( [in] double Principal, [in] sequence< sequence< double > > Schedule );
};
service Analysis
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index b0bee93f3bbc..e6120f3e2401 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysishelper.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: pl $ $Date: 2001-05-14 08:38:20 $
+ * last change: $Author: gt $ $Date: 2001-05-22 11:49:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -351,7 +351,8 @@ void GetDiffParam( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate
DaysToDate( nDate1, nDay1, nMonth1, nYear1 );
DaysToDate( nDate2, nDay2, nMonth2, nYear2 );
- sal_uInt16 nYears = nYear2 - nYear1;
+ sal_uInt16 nYears;
+
sal_Int32 nDayDiff, nDaysInYear;
switch( nMode )
@@ -359,11 +360,18 @@ void GetDiffParam( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate
case 0: // 0=USA (NASD) 30/360
case 4: // 4=Europe 30/360
nDaysInYear = 360;
+ nYears = nYear2 - nYear1;
nDayDiff = GetDiffDate360( nDay1, nMonth1, nYear1, IsLeapYear( nYear1 ),
nDay2, nMonth2, nYear2, nMode == 0 ) - nYears * nDaysInYear;
break;
case 1: // 1=exact/exact
+ nYears = nYear2 - nYear1;
+
nDaysInYear = IsLeapYear( nYear1 )? 366 : 365;
+
+ if( nYears && ( nMonth1 > nMonth2 || ( nMonth1 == nMonth2 && nDay1 > nDay2 ) ) )
+ nYears--;
+
if( nYears )
nDayDiff = nDate2 - DateToDays( nDay1, nMonth1, nYear2 );
else
@@ -372,11 +380,13 @@ void GetDiffParam( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate
break;
case 2: // 2=exact/360
nDaysInYear = 360;
+ nYears = sal_uInt16( ( nDate2 - nDate1 ) / nDaysInYear );
nDayDiff = nDate2 - nDate1;
nDayDiff %= nDaysInYear;
break;
case 3: //3=exact/365
nDaysInYear = 365;
+ nYears = sal_uInt16( ( nDate2 - nDate1 ) / nDaysInYear );
nDayDiff = nDate2 - nDate1;
nDayDiff %= nDaysInYear;
break;
@@ -1697,13 +1707,17 @@ void SortedIndividualInt32List::InsertHolidayList(
switch( aHDay.getValueTypeClass() )
{
case uno::TypeClass_VOID: break;
+ case uno::TypeClass_STRING:
+ if( ( ( const STRING* ) aHDay.getValue() )->getLength() )
+ THROW_IAE;
+ break;
case uno::TypeClass_DOUBLE:
{
- double f = *( double* ) aHDay.getValue();
+ double f = *( double* ) aHDay.getValue();
if( f < -2147483648.0 || f >= 2147483648.0 )
THROW_IAE;
- sal_Int32 n = sal_Int32( f );
+ sal_Int32 n = sal_Int32( f );
if( n )
{
@@ -1715,7 +1729,7 @@ void SortedIndividualInt32List::InsertHolidayList(
break;
case uno::TypeClass_SEQUENCE:
{
- SEQSEQ( ANY ) aValArr;
+ SEQSEQ( ANY ) aValArr;
if( aHDay >>= aValArr )
{
sal_Int32 nE = aValArr.getLength();
@@ -1808,6 +1822,24 @@ void DoubleList::Append( const SEQSEQ( double )& aVLst ) THROWDEF_RTE_IAE
}
+void DoubleList::Append( const SEQSEQ( sal_Int32 )& aVLst ) THROWDEF_RTE_IAE
+{
+ sal_Int32 n1, n2;
+ sal_Int32 nE1 = aVLst.getLength();
+ sal_Int32 nE2;
+
+ for( n1 = 0 ; n1 < nE1 ; n1++ )
+ {
+ const SEQ( sal_Int32 )& rList = aVLst[ n1 ];
+ nE2 = rList.getLength();
+ const sal_Int32* pList = rList.getConstArray();
+
+ for( n2 = 0 ; n2 < nE2 ; n2++ )
+ AppendDouble( pList[ n2 ] );
+ }
+}
+
+
void DoubleList::Append( const SEQ( ANY )& aVList, sal_Bool bEmptyAs0, sal_Bool bErrOnEmpty ) THROWDEF_RTE_IAE
{
sal_Int32 nE = aVList.getLength();
diff --git a/scaddins/source/analysis/analysishelper.hxx b/scaddins/source/analysis/analysishelper.hxx
index e1b45507271a..fcae971afead 100644
--- a/scaddins/source/analysis/analysishelper.hxx
+++ b/scaddins/source/analysis/analysishelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysishelper.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: gt $ $Date: 2001-05-11 10:09:35 $
+ * last change: $Author: gt $ $Date: 2001-05-22 11:49:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -330,6 +330,7 @@ public:
sal_Bool Append( double fVal );
void Append( const SEQSEQ( double )& aValList ) THROWDEF_RTE_IAE;
+ void Append( const SEQSEQ( sal_Int32 )& aValList ) THROWDEF_RTE_IAE;
void Append( const SEQ( ANY )& aValList,
sal_Bool bEmptyStringAs0 = sal_True,
sal_Bool bForceErrorOnEmpty = sal_False ) THROWDEF_RTE_IAE;
diff --git a/scaddins/source/analysis/financial.cxx b/scaddins/source/analysis/financial.cxx
index 209b59744621..ec073fd91d34 100644
--- a/scaddins/source/analysis/financial.cxx
+++ b/scaddins/source/analysis/financial.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: financial.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: gt $ $Date: 2001-05-07 06:53:51 $
+ * last change: $Author: gt $ $Date: 2001-05-22 11:51:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -330,6 +330,8 @@ double SAL_CALL AnalysisAddIn::getDollarfr( double fDollarDec, sal_Int32 nFrac )
fRet *= pow( 10.0, -ceil( log10( fFrac ) ) );
+ fRet += fInt;
+
return fRet;
}
@@ -348,6 +350,8 @@ double SAL_CALL AnalysisAddIn::getDollarde( double fDollarFrac, sal_Int32 nFrac
fRet *= pow( 10.0, ceil( log10( fFrac ) ) );
+ fRet += fInt;
+
return fRet;
}
@@ -526,17 +530,21 @@ double SAL_CALL AnalysisAddIn::getOddlyield( constREFXPS& xOpt,
double SAL_CALL AnalysisAddIn::getXirr(
- const SEQ( double )& rValues, const SEQ( sal_Int32 )& rDates, const ANY& rGuess ) THROWDEF_RTE_IAE
+ const SEQSEQ( double )& rValues, const SEQSEQ( sal_Int32 )& rDates, const ANY& rGuess ) THROWDEF_RTE_IAE
{
double fGuess = GetOpt( rGuess, 0.1 );
- sal_Int32 nNum = rValues.getLength();
- if( nNum != rDates.getLength() || nNum < 2 )
- THROW_IAE;
+ DoubleList aValList;
+ DoubleList aDateList;
- const double* pVals = rValues.getConstArray();
- const sal_Int32* pDates = rDates.getConstArray();
+ aValList.Append( rValues );
+ aDateList.Append( rDates );
+
+ sal_Int32 nNum = aValList.Count();
+
+ if( nNum != sal_Int32( aDateList.Count() ) || nNum < 2 )
+ THROW_IAE;
double f, fG, fK;
sal_Int32 nMax = 200;
@@ -546,14 +554,15 @@ double SAL_CALL AnalysisAddIn::getXirr(
double fOld = 0.0;
sal_Int32 n = 1;
sal_Int32 nNew = 0;
- sal_Int32 nNull = pDates[ 0 ];
+ double fNull = *aDateList.Get( 0 );
+
while( fabs( fDiff ) > 1E-10 && n <= nMax )
{
f = 0.0;
n++;
for( sal_Int32 i = 0 ; i < nNum ; i++ )
- f += pVals[ i ] / pow( 1.0 + fYld, double( pDates[ i ] - nNull ) / 365.0 );
+ f += *aValList.Get( i ) / pow( 1.0 + fYld, ( *aDateList.Get( i ) - fNull ) / 365.0 );
if( ( ( fOld < 0.0 && f > 0.0 ) || ( fOld > 0.0 && f < 0.0 ) ) && nNew == 0 )
{
@@ -595,21 +604,25 @@ double SAL_CALL AnalysisAddIn::getXirr(
double SAL_CALL AnalysisAddIn::getXnpv(
- double fRate, const SEQ( double )& rValues, const SEQ( sal_Int32 )& rDates ) THROWDEF_RTE_IAE
+ double fRate, const SEQSEQ( double )& rValues, const SEQSEQ( sal_Int32 )& rDates ) THROWDEF_RTE_IAE
{
- sal_Int32 nNum = rValues.getLength();
+ DoubleList aValList;
+ DoubleList aDateList;
+
+ aValList.Append( rValues );
+ aDateList.Append( rDates );
+
+ sal_Int32 nNum = aValList.Count();
- if( nNum != rDates.getLength() || nNum < 2 )
+ if( nNum != sal_Int32( aDateList.Count() ) || nNum < 2 )
THROW_IAE;
- const double* pVals = rValues.getConstArray();
- const sal_Int32* pDates = rDates.getConstArray();
double fRet = 0.0;
- sal_Int32 nNull = pDates[ 0 ];
+ double fNull = *aDateList.Get( 0 );
fRate++;
for( sal_Int32 i = 0 ; i < nNum ; i++ )
- fRet += pVals[ i ] / ( pow( fRate, double( pDates[ i ] -nNull ) / 365.0 ) );
+ fRet += *aValList.Get( i ) / ( pow( fRate, ( *aDateList.Get( i ) - fNull ) / 365.0 ) );
return fRet;
}
@@ -667,14 +680,14 @@ double SAL_CALL AnalysisAddIn::getCoupnum( constREFXPS& xOpt,
}
-double SAL_CALL AnalysisAddIn::getFvschedule( double fPrinc, const SEQ( double )& rSchedule ) THROWDEF_RTE_IAE
+double SAL_CALL AnalysisAddIn::getFvschedule( double fPrinc, const SEQSEQ( double )& rSchedule ) THROWDEF_RTE_IAE
{
- sal_Int32 nNum = rSchedule.getLength();
+ DoubleList aSchedList;
- const double* pVals = rSchedule.getConstArray();
+ aSchedList.Append( rSchedule );
- for( sal_Int32 n = 0 ; n < nNum ; n++ )
- fPrinc *= 1.0 + pVals[ n ];
+ for( const double* p = aSchedList.First() ; p ; p = aSchedList.Next() )
+ fPrinc *= 1.0 + *p;
return fPrinc;
}