20#include <com/sun/star/util/Date.hpp>
21#include <com/sun/star/util/XNumberFormatTypes.hpp>
22#include <com/sun/star/util/NumberFormatter.hpp>
27#include <rtl/math.hxx>
34#include <analysis.hrc>
47#define FUNCDATA( FUNCNAME, DBL, OPT, NUMOFPAR, CAT ) \
48 { "get" #FUNCNAME, ANALYSIS_FUNCNAME_##FUNCNAME, ANALYSIS_##FUNCNAME, DBL, OPT, ANALYSIS_DEFFUNCNAME_##FUNCNAME, NUMOFPAR, CAT, nullptr }
50#define FUNCDATAS( FUNCNAME, DBL, OPT, NUMOFPAR, CAT, SUFFIX ) \
51 { "get" #FUNCNAME, ANALYSIS_FUNCNAME_##FUNCNAME, ANALYSIS_##FUNCNAME, DBL, OPT, ANALYSIS_DEFFUNCNAME_##FUNCNAME, NUMOFPAR, CAT, SUFFIX }
167 static const sal_uInt16 aDaysInMonth[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
168 return aDaysInMonth[ nMonth ];
182sal_Int32
DateToDays( sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear )
184 sal_Int32 nDays = (
static_cast<sal_Int32
>(nYear)-1) * 365;
185 nDays += ((nYear-1) / 4) - ((nYear-1) / 100) + ((nYear-1) / 400);
187 for( sal_uInt16
i = 1;
i < nMonth;
i++ )
205void DaysToDate( sal_Int32 nDays, sal_uInt16& rDay, sal_uInt16& rMonth, sal_uInt16& rYear )
208 throw lang::IllegalArgumentException();
217 rYear =
static_cast<sal_uInt16
>((nTempDays / 365) -
i);
218 nTempDays -= (
static_cast<sal_Int32
>(rYear) -1) * 365;
219 nTempDays -= (( rYear -1) / 4) - (( rYear -1) / 100) + ((rYear -1) / 400);
228 if ( nTempDays > 365 )
230 if ( (nTempDays != 366) || !
IsLeapYear( rYear ) )
246 rDay =
static_cast<sal_uInt16
>(nTempDays);
259sal_Int32
GetNullDate(
const uno::Reference< beans::XPropertySet >& xOpt )
265 uno::Any aAny = xOpt->getPropertyValue(
"NullDate" );
268 return DateToDays( aDate.Day, aDate.Month, aDate.Year );
270 catch( uno::Exception& )
276 throw uno::RuntimeException();
281 sal_uInt16 nDay1, sal_uInt16 nMonth1, sal_uInt16 nYear1,
bool bLeapYear1,
282 sal_uInt16 nDay2, sal_uInt16 nMonth2, sal_uInt16 nYear2,
287 else if( bUSAMethod && ( nMonth1 == 2 && ( nDay1 == 29 || ( nDay1 == 28 && !bLeapYear1 ) ) ) )
292 if( bUSAMethod && nDay1 != 30 )
307 return nDay2 + nMonth2 * 30 + nYear2 * 360 - nDay1 - nMonth1 * 30 - nYear1 * 360;
311sal_Int32
GetDiffDate360( sal_Int32 nNullDate, sal_Int32 nDate1, sal_Int32 nDate2,
bool bUSAMethod )
316 sal_uInt16 nDay1, nMonth1, nYear1, nDay2, nMonth2, nYear2;
327 sal_uInt16 nLeaps = 0;
328 for( sal_uInt16
n = nYear1 ;
n <= nYear2 ;
n++ )
344sal_Int32
GetDiffDate( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode,
345 sal_Int32* pOptDaysIn1stYear )
347 bool bNeg = nStartDate > nEndDate;
350 std::swap( nStartDate, nEndDate );
359 sal_uInt16 nD1, nM1, nY1, nD2, nM2, nY2;
361 nStartDate += nNullDate;
362 nEndDate += nNullDate;
368 sal_Int32 nDays, nMonths;
373 nMonths += ( nY2 - nY1 ) * 12;
375 nRet = nMonths * 30 + nDays;
376 if( nMode == 0 && nM1 == 2 && nM2 != 2 && nY1 == nY2 )
377 nRet -= bLeap? 1 : 2;
379 if( pOptDaysIn1stYear )
380 *pOptDaysIn1stYear = 360;
384 if( pOptDaysIn1stYear )
386 sal_uInt16 nD, nM, nY;
388 DaysToDate( nStartDate + nNullDate, nD, nM, nY );
390 *pOptDaysIn1stYear =
IsLeapYear( nY )? 366 : 365;
392 nRet = nEndDate - nStartDate;
395 nRet = nEndDate - nStartDate;
396 if( pOptDaysIn1stYear )
397 *pOptDaysIn1stYear = 360;
400 nRet = nEndDate - nStartDate;
401 if( pOptDaysIn1stYear )
402 *pOptDaysIn1stYear = 365;
405 throw lang::IllegalArgumentException();
408 return bNeg? -nRet : nRet;
412double GetYearDiff( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode )
414 sal_Int32 nDays1stYear;
415 sal_Int32 nTotalDays =
GetDiffDate( nNullDate, nStartDate, nEndDate, nMode, &nDays1stYear );
417 return double( nTotalDays ) / double( nDays1stYear );
421sal_Int32
GetDaysInYear( sal_Int32 nNullDate, sal_Int32 nDate, sal_Int32 nMode )
431 sal_uInt16 nD, nM, nY;
439 throw lang::IllegalArgumentException();
451double GetYearFrac( sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode )
453 if( nStartDate == nEndDate )
456 if( nStartDate > nEndDate )
457 std::swap( nStartDate, nEndDate );
459 sal_Int32 nDate1 = nStartDate + nNullDate;
460 sal_Int32 nDate2 = nEndDate + nNullDate;
462 sal_uInt16 nDay1, nDay2;
463 sal_uInt16 nMonth1, nMonth2;
464 sal_uInt16 nYear1, nYear2;
478 if ( nDay1 == 30 && nDay2 == 31 )
484 if ( nMonth1 == 2 && nDay1 == (
IsLeapYear( nYear1 ) ? 29 : 28 ) )
487 if ( nMonth2 == 2 && nDay2 == (
IsLeapYear( nYear2 ) ? 29 : 28 ) )
493 nDayDiff = ( nYear2 - nYear1 ) * 360 + ( nMonth2 - nMonth1 ) * 30 + ( nDay2 - nDay1 );
498 nDayDiff = nDate2 - nDate1;
509 nDayDiff = ( nYear2 - nYear1 ) * 360 + ( nMonth2 - nMonth1 ) * 30 + ( nDay2 - nDay1 );
512 throw lang::IllegalArgumentException();
526 const bool isYearDifferent = ( nYear1 != nYear2 );
528 if ( isYearDifferent &&
529 ( ( nYear2 != nYear1 + 1 ) ||
530 ( nMonth1 < nMonth2 ) ||
531 ( nMonth1 == nMonth2 && nDay1 < nDay2 ) ) )
534 sal_Int32 nDayCount = 0;
535 for ( sal_uInt16
i = nYear1;
i <= nYear2;
i++ )
538 nDaysInYear =
static_cast<double>(nDayCount) /
static_cast<double>( nYear2 - nYear1 + 1 );
545 assert( ( !isYearDifferent ||
546 ( nYear1 + 1 == nYear2 &&
547 ( nMonth1 > nMonth2 ||
548 ( nMonth1 == nMonth2 || nDay1 >= nDay2 ) ) ) ) );
551 if ( !isYearDifferent &&
IsLeapYear( nYear1 ) )
561 if( isYearDifferent &&
563 ( ( nMonth1 < 2 ) || ( ( nMonth1 == 2 ) && ( nDay1 <= 29 ) ) ) ) ||
565 ( nMonth2 > 2 || ( ( nMonth2 == 2 ) && ( nDay2 == 29 ) ) ) ) ) )
582 throw lang::IllegalArgumentException();
585 return double( nDayDiff ) / nDaysInYear;
594 k = ::rtl::math::approxFloor(k);
616 double f = fmod( f1, f2 );
628double ConvertToDec(
const OUString& aStr, sal_uInt16 nBase, sal_uInt16 nCharLim )
630 if ( nBase < 2 || nBase > 36 )
631 throw lang::IllegalArgumentException();
633 sal_uInt32 nStrLen =
aStr.getLength();
634 if( nStrLen > nCharLim )
635 throw lang::IllegalArgumentException();
643 sal_uInt16 nFirstDig = 0;
644 bool bFirstDig =
true;
645 double fBase = nBase;
651 if(
'0' <= *
p && *
p <=
'9' )
653 else if(
'A' <= *
p && *
p <=
'Z' )
654 n = 10 + ( *
p -
'A' );
655 else if (
'a' <= *
p && *
p <=
'z' )
656 n = 10 + ( *
p -
'a' );
661 throw lang::IllegalArgumentException();
668 fVal = fVal * fBase + double(
n );
674 if( nStrLen == nCharLim && !bFirstDig && (nFirstDig >= nBase / 2) )
676 fVal = ( pow(
double( nBase ),
double( nCharLim ) ) - fVal );
686 const char*
const c =
"--123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
692 sal_Int32 nPlaces, sal_Int32 nMaxPlaces,
bool bUsePlaces )
694 fNum = ::rtl::math::approxFloor( fNum );
695 fMin = ::rtl::math::approxFloor( fMin );
696 fMax = ::rtl::math::approxFloor( fMax );
698 if( fNum < fMin || fNum > fMax || ( bUsePlaces && ( nPlaces <= 0 || nPlaces > nMaxPlaces ) ) )
699 throw lang::IllegalArgumentException();
701 sal_Int64 nNum =
static_cast< sal_Int64
>( fNum );
702 bool bNeg = nNum < 0;
704 nNum = sal_Int64( pow(
double( nBase ),
double( nMaxPlaces ) ) ) + nNum;
706 OUString aRet(OUString::number(nNum, nBase).toAsciiUpperCase());
711 sal_Int32 nLen = aRet.getLength();
712 if( !bNeg && nLen > nPlaces )
714 throw lang::IllegalArgumentException();
716 else if( ( bNeg && nLen < nMaxPlaces ) || ( !bNeg && nLen < nPlaces ) )
718 sal_Int32 nLeft = nPlaces - nLen;
719 std::unique_ptr<char[]>
p(
new char[ nLeft + 1 ] );
720 memset(
p.get(), bNeg ?
GetMaxChar( nBase ) :
'0', nLeft );
722 aRet = OUString(
p.get(), nLeft, RTL_TEXTENCODING_MS_1252 ) + aRet;
741 return c >=
'0' && c <=
'9';
747 return c ==
'.' || c ==
',';
753 return c ==
'e' || c ==
'E';
759 return c ==
'i' || c ==
'j';
765 return sal_uInt16( c -
'0' );
775 sal_Int32 nMaxExp = 307;
776 sal_uInt16 nDigCnt = 18;
778 enum State { S_End = 0, S_Sign, S_IntStart, S_Int, S_IgnoreIntDigs, S_Frac, S_IgnoreFracDigs, S_ExpSign, S_Exp };
782 bool bNegNum =
false;
783 bool bNegExp =
false;
833 fInt += double(
GetVal( c ) );
836 eS = S_IgnoreIntDigs;
845 case S_IgnoreIntDigs:
858 fFrac += double(
GetVal( c ) ) * fMult;
863 eS = S_IgnoreFracDigs;
870 case S_IgnoreFracDigs:
873 else if( !
IsNum( c ) )
916 sal_Int32 nLog10 = sal_Int32( log10( fInt ) );
921 if( nLog10 + nExp > nMaxExp )
924 fInt = ::rtl::math::pow10Exp( fInt, nExp );
936OUString
GetString(
double f,
bool bLeadingSign, sal_uInt16 nMaxDig )
938 const int nBuff = 256;
939 char aBuff[ nBuff + 1 ];
940 const char* pFormStr = bLeadingSign?
"%+.*g" :
"%.*g";
941 int nLen = snprintf( aBuff, nBuff, pFormStr,
int( nMaxDig ), f );
944 if ( nLen < 0 || nLen > nBuff )
945 nLen = strlen( aBuff );
947 OUString aRet( aBuff, nLen, RTL_TEXTENCODING_MS_1252 );
953double GetAmordegrc( sal_Int32 nNullDate,
double fCost, sal_Int32 nDate, sal_Int32 nFirstPer,
954 double fRestVal,
double fPer,
double fRate, sal_Int32 nBase )
956 sal_uInt32 nPer = sal_uInt32( fPer );
957 double fUsePer = 1.0 / fRate;
962 else if( fUsePer < 5.0 )
964 else if( fUsePer <= 6.0 )
970 double fNRate = ::rtl::math::round(
GetYearFrac( nNullDate, nDate, nFirstPer, nBase ) * fRate * fCost );
972 double fRest = fCost - fRestVal;
974 for( sal_uInt32
n = 0 ;
n < nPer ;
n++ )
976 fNRate = ::rtl::math::round( fRate * fCost );
985 return ::rtl::math::round( fCost * 0.5 );
998double GetAmorlinc( sal_Int32 nNullDate,
double fCost, sal_Int32 nDate, sal_Int32 nFirstPer,
999 double fRestVal,
double fPer,
double fRate, sal_Int32 nBase )
1001 sal_uInt32 nPer = sal_uInt32( fPer );
1002 double fOneRate = fCost * fRate;
1003 double fCostDelta = fCost - fRestVal;
1004 double f0Rate =
GetYearFrac( nNullDate, nDate, nFirstPer, nBase ) * fRate * fCost;
1005 sal_uInt32 nNumOfFullPeriods = sal_uInt32( ( fCost - fRestVal - f0Rate) / fOneRate );
1007 double fResult = 0.0;
1010 else if( nPer <= nNumOfFullPeriods )
1012 else if( nPer == nNumOfFullPeriods + 1 )
1013 fResult = fCostDelta - fOneRate * nNumOfFullPeriods - f0Rate;
1015 if ( fResult > 0.0 )
1022double GetDuration( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat,
double fCoup,
1023 double fYield, sal_Int32 nFreq, sal_Int32 nBase )
1025 double fYearfrac =
GetYearFrac( nNullDate, nSettle, nMat, nBase );
1026 double fNumOfCoups =
GetCoupnum( nNullDate, nSettle, nMat, nFreq, nBase );
1028 const double f100 = 100.0;
1029 fCoup *= f100 / double( nFreq );
1033 double nDiff = fYearfrac * nFreq - fNumOfCoups;
1037 for(
t = 1.0 ;
t < fNumOfCoups ;
t++ )
1038 fDur += (
t + nDiff ) * fCoup / pow( fYield,
t + nDiff );
1040 fDur += ( fNumOfCoups + nDiff ) * ( fCoup + f100 ) / pow( fYield, fNumOfCoups + nDiff );
1043 for(
t = 1.0 ;
t < fNumOfCoups ;
t++ )
1044 p += fCoup / pow( fYield,
t + nDiff );
1046 p += ( fCoup + f100 ) / pow( fYield, fNumOfCoups + nDiff );
1049 fDur /= double( nFreq );
1055double GetYieldmat( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue,
1056 double fRate,
double fPrice, sal_Int32 nBase )
1058 double fIssMat =
GetYearFrac( nNullDate, nIssue, nMat, nBase );
1059 double fIssSet =
GetYearFrac( nNullDate, nIssue, nSettle, nBase );
1060 double fSetMat =
GetYearFrac( nNullDate, nSettle, nMat, nBase );
1062 double y = 1.0 + fIssMat * fRate;
1063 y /= fPrice / 100.0 + fIssSet * fRate;
1072 sal_Int32 ,
double ,
double ,
double , sal_Int32 ,
1078 throw uno::RuntimeException();
1082double getYield_( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat,
double fCoup,
double fPrice,
1083 double fRedemp, sal_Int32 nFreq, sal_Int32 nBase )
1085 double fRate = fCoup;
1086 double fPriceN = 0.0;
1087 double fYield1 = 0.0;
1088 double fYield2 = 1.0;
1089 double fPrice1 =
getPrice_( nNullDate, nSettle, nMat, fRate, fYield1, fRedemp, nFreq, nBase );
1090 double fPrice2 =
getPrice_( nNullDate, nSettle, nMat, fRate, fYield2, fRedemp, nFreq, nBase );
1091 double fYieldN = ( fYield2 - fYield1 ) * 0.5;
1093 for( sal_uInt32 nIter = 0 ; nIter < 100 && !rtl::math::approxEqual(fPriceN, fPrice) ; nIter++ )
1095 fPriceN =
getPrice_( nNullDate, nSettle, nMat, fRate, fYieldN, fRedemp, nFreq, nBase );
1097 if( rtl::math::approxEqual(fPrice, fPrice1) )
1099 else if( rtl::math::approxEqual(fPrice, fPrice2) )
1101 else if( rtl::math::approxEqual(fPrice, fPriceN) )
1103 else if( fPrice < fPrice2 )
1106 fPrice2 =
getPrice_( nNullDate, nSettle, nMat, fRate, fYield2, fRedemp, nFreq, nBase );
1108 fYieldN = ( fYield2 - fYield1 ) * 0.5;
1112 if( fPrice < fPriceN )
1123 fYieldN = fYield2 - ( fYield2 - fYield1 ) * ( ( fPrice - fPrice2 ) / ( fPrice1 - fPrice2 ) );
1127 if( fabs( fPrice - fPriceN ) > fPrice / 100.0 )
1128 throw lang::IllegalArgumentException();
1134double getPrice_( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat,
double fRate,
double fYield,
1135 double fRedemp, sal_Int32 nFreq, sal_Int32 nBase )
1137 double fFreq = nFreq;
1139 double fE =
GetCoupdays( nNullDate, nSettle, nMat, nFreq, nBase );
1140 double fDSC_E =
GetCoupdaysnc( nNullDate, nSettle, nMat, nFreq, nBase ) / fE;
1141 double fN =
GetCoupnum( nNullDate, nSettle, nMat, nFreq, nBase );
1142 double fA =
GetCoupdaybs( nNullDate, nSettle, nMat, nFreq, nBase );
1144 double fRet = fRedemp / ( pow( 1.0 + fYield / fFreq, fN - 1.0 + fDSC_E ) );
1145 fRet -= 100.0 * fRate / fFreq * fA / fE;
1147 double fT1 = 100.0 * fRate / fFreq;
1148 double fT2 = 1.0 + fYield / fFreq;
1150 for(
double fK = 0.0 ; fK < fN ; fK++ )
1151 fRet += fT1 / pow( fT2, fK + fDSC_E );
1158 sal_Int32 ,
double ,
double ,
double , sal_Int32 ,
1164 throw uno::RuntimeException();
1168double GetOddlprice( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastCoup,
1169 double fRate,
double fYield,
double fRedemp, sal_Int32 nFreq, sal_Int32 nBase )
1171 double fFreq = double( nFreq );
1172 double fDCi =
GetYearFrac( nNullDate, nLastCoup, nMat, nBase ) * fFreq;
1173 double fDSCi =
GetYearFrac( nNullDate, nSettle, nMat, nBase ) * fFreq;
1174 double fAi =
GetYearFrac( nNullDate, nLastCoup, nSettle, nBase ) * fFreq;
1176 double p = fRedemp + fDCi * 100.0 * fRate / fFreq;
1177 p /= fDSCi * fYield / fFreq + 1.0;
1178 p -= fAi * 100.0 * fRate / fFreq;
1184double GetOddlyield( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastCoup,
1185 double fRate,
double fPrice,
double fRedemp, sal_Int32 nFreq, sal_Int32 nBase )
1187 double fFreq = double( nFreq );
1188 double fDCi =
GetYearFrac( nNullDate, nLastCoup, nMat, nBase ) * fFreq;
1189 double fDSCi =
GetYearFrac( nNullDate, nSettle, nMat, nBase ) * fFreq;
1190 double fAi =
GetYearFrac( nNullDate, nLastCoup, nSettle, nBase ) * fFreq;
1192 double y = fRedemp + fDCi * 100.0 * fRate / fFreq;
1193 y /= fPrice + fAi * 100.0 * fRate / fFreq;
1201double GetPmt(
double fRate,
double fNper,
double fPv,
double fFv, sal_Int32 nPayType )
1205 fPmt = ( fPv + fFv ) / fNper;
1208 double fTerm = pow( 1.0 + fRate, fNper );
1210 fPmt = ( fFv * fRate / ( fTerm - 1.0 ) + fPv * fRate / ( 1.0 - 1.0 / fTerm ) ) / ( 1.0 + fRate );
1212 fPmt = fFv * fRate / ( fTerm - 1.0 ) + fPv * fRate / ( 1.0 - 1.0 / fTerm );
1219double GetFv(
double fRate,
double fNper,
double fPmt,
double fPv, sal_Int32 nPayType )
1223 fFv = fPv + fPmt * fNper;
1226 double fTerm = pow( 1.0 + fRate, fNper );
1228 fFv = fPv * fTerm + fPmt * ( 1.0 + fRate ) * ( fTerm - 1.0 ) / fRate;
1230 fFv = fPv * fTerm + fPmt * ( fTerm - 1.0 ) / fRate;
1244 if( rDate < rSettle )
1246 while( rDate > rSettle )
1250double GetCouppcd( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase )
1253 throw lang::IllegalArgumentException();
1257 return aDate.
getDate( nNullDate );
1266 if( rDate > rSettle )
1268 while( rDate <= rSettle )
1272double GetCoupncd( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase )
1275 throw lang::IllegalArgumentException();
1279 return aDate.
getDate( nNullDate );
1283double GetCoupdaybs( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase )
1286 throw lang::IllegalArgumentException();
1288 ScaDate aSettle( nNullDate, nSettle, nBase );
1295double GetCoupdaysnc( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase )
1298 throw lang::IllegalArgumentException();
1300 if( (nBase != 0) && (nBase != 4) )
1302 ScaDate aSettle( nNullDate, nSettle, nBase );
1307 return GetCoupdays( nNullDate, nSettle, nMat, nFreq, nBase ) -
GetCoupdaybs( nNullDate, nSettle, nMat, nFreq, nBase );
1311double GetCoupdays( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase )
1314 throw lang::IllegalArgumentException();
1324 return static_cast< double >(
GetDaysInYear( 0, 0, nBase ) ) / nFreq;
1328double GetCoupnum( sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase )
1331 throw lang::IllegalArgumentException();
1333 ScaDate aMat( nNullDate, nMat, nBase );
1337 return static_cast< double >( nMonths * nFreq / 12 );
1341 aIntName( OUString::createFromAscii( r.pIntName ) ),
1342 pUINameID( r.pUINameID ),
1343 pDescrID( r.pDescrID ),
1344 bDouble( r.bDouble ),
1345 bWithOpt( r.bWithOpt ),
1346 nParam( r.nNumOfParams ),
1365 return nParamNum * 2;
1371 rList.push_back(
FuncData(rFuncData));
1393 else if( nDay >
nRef )
1415 double fDay, sal_Int32 nNullDate,
bool bInsertOnWeekend )
1417 if( (fDay < -2147483648.0) || (fDay > 2147483649.0) )
1418 throw lang::IllegalArgumentException();
1419 Insert(
static_cast< sal_Int32
>( fDay ), nNullDate, bInsertOnWeekend );
1425 sal_uInt32 nE =
Count();
1427 if( !nE || nVal <
Get( 0 ) || nVal >
Get( nE - 1 ) )
1432 for( sal_uInt32
n = 0 ;
n < nE ;
n++ )
1438 else if(
nRef > nVal )
1448 sal_Int32 nNullDate,
1449 bool bInsertOnWeekend )
1452 if( rAnyConv.
getDouble( fDay, rHolAny ) )
1453 Insert( fDay, nNullDate, bInsertOnWeekend );
1459 const uno::Reference< beans::XPropertySet >& xOptions,
1461 sal_Int32 nNullDate )
1463 rAnyConv.
init( xOptions );
1464 if( rHolAny.getValueTypeClass() == uno::TypeClass_SEQUENCE )
1466 uno::Sequence< uno::Sequence< uno::Any > > aAnySeq;
1467 if( !(rHolAny >>= aAnySeq) )
1468 throw lang::IllegalArgumentException();
1470 for(
const uno::Sequence< uno::Any >& rSubSeq : std::as_const(aAnySeq) )
1472 for(
const uno::Any& rAny : rSubSeq )
1482 const uno::Sequence< uno::Sequence< double > >& rValueSeq )
1484 for(
const uno::Sequence< double >& rSubSeq : rValueSeq )
1486 for(
const double fValue : rSubSeq )
1493 const uno::Sequence< uno::Sequence< sal_Int32 > >& rValueSeq )
1495 for(
const uno::Sequence< sal_Int32 >& rSubSeq : rValueSeq )
1497 for(
const sal_Int32 nValue : rSubSeq )
1508 css::uno::Sequence<css::uno::Sequence<css::uno::Any>>>(rAny) )
1509 Append( rAnyConv, *s, bIgnoreEmpty );
1513 if( rAnyConv.
getDouble( fValue, rAny ) )
1515 else if( !bIgnoreEmpty )
1523 const uno::Sequence< uno::Any >& rAnySeq,
1526 for(
const uno::Any& rAny : rAnySeq )
1527 Append( rAnyConv, rAny, bIgnoreEmpty );
1533 const uno::Sequence< uno::Sequence< uno::Any > >& rAnySeq,
1536 for(
const uno::Sequence< uno::Any >& rArray : rAnySeq )
1537 Append( rAnyConv, rArray, bIgnoreEmpty );
1542 const uno::Reference< beans::XPropertySet >& xOpt,
1543 const uno::Sequence< uno::Any >& rAnySeq )
1545 rAnyConv.
init( xOpt );
1546 Append( rAnyConv, rAnySeq,
true );
1559 throw lang::IllegalArgumentException();
1560 return fValue > 0.0;
1567 throw lang::IllegalArgumentException();
1575 throw lang::IllegalArgumentException();
1581 return c ==
'i' ||
c ==
'j';
1590 if(
IsImagUnit( *pStr ) && rStr.getLength() == 1)
1611 rCompl.
c = pStr[ 1 ];
1612 if( pStr[ 2 ] == 0 )
1615 rCompl.
i = ( *pStr ==
'+' )? 1.0 : -1.0;
1657 OUStringBuffer aRet;
1659 bool bHasImag =
i != 0.0;
1660 bool bHasReal = !bHasImag || (
r != 0.0);
1671 else if(
i == -1.0 )
1675 aRet.append((
c !=
'j') ?
'i' :
'j');
1678 return aRet.makeStringAndClear();
1684 if(
r == 0.0 &&
i == 0.0 )
1685 throw lang::IllegalArgumentException();
1687 double phi = acos(
r /
Abs() );
1698 if(
r == 0.0 &&
i == 0.0 )
1701 throw lang::IllegalArgumentException();
1710 phi = acos(
r /
p );
1714 p = pow(
p, fPower );
1724 static const double fMultConst = M_SQRT1_2;
1726 double i_ = sqrt(
p -
r ) * fMultConst;
1728 r = sqrt(
p +
r ) * fMultConst;
1729 i = (
i < 0.0 )? -i_ : i_;
1735 if( !::rtl::math::isValidArcArg(
r ) )
1736 throw lang::IllegalArgumentException();
1742 r_ = sin(
r ) * cosh(
i );
1743 i = cos(
r ) * sinh(
i );
1753 if( !::rtl::math::isValidArcArg(
r ) )
1754 throw lang::IllegalArgumentException();
1760 r_ = cos(
r ) * cosh(
i );
1761 i = -( sin(
r ) * sinh(
i ) );
1771 if(
z.r == 0 &&
z.i == 0 )
1772 throw lang::IllegalArgumentException();
1779 double f = 1.0 / ( a2 * a2 + b2 * b2 );
1781 r = ( a1 * a2 + b1 * b2 ) * f;
1782 i = ( a2 * b1 - a1 * b2 ) * f;
1790 double fE = exp(
r );
1798 if(
r == 0.0 &&
i == 0.0 )
1799 throw lang::IllegalArgumentException();
1801 double fAbs =
Abs();
1802 bool bNegi =
i < 0.0;
1804 i = acos(
r / fAbs );
1831 if( !::rtl::math::isValidArcArg( 2.0 *
r ) )
1832 throw lang::IllegalArgumentException();
1833 double fScale =1.0 / ( cos( 2.0 *
r ) + cosh( 2.0 *
i ));
1834 r = sin( 2.0 *
r ) * fScale;
1835 i = sinh( 2.0 *
i ) * fScale;
1839 if( !::rtl::math::isValidArcArg(
r ) )
1840 throw lang::IllegalArgumentException();
1850 if( !::rtl::math::isValidArcArg( 2 *
r ) )
1851 throw lang::IllegalArgumentException();
1852 double fScale = 1.0 / (cosh( 2.0 *
i) + cos ( 2.0 *
r));
1854 r_ = 2.0 * cos(
r ) * cosh(
i ) * fScale;
1855 i = 2.0 * sin(
r ) * sinh(
i ) * fScale;
1860 if( !::rtl::math::isValidArcArg(
r ) )
1861 throw lang::IllegalArgumentException();
1871 if( !::rtl::math::isValidArcArg( 2 *
r ) )
1872 throw lang::IllegalArgumentException();
1873 double fScale = 1.0 / (cosh( 2.0 *
i) - cos ( 2.0 *
r));
1875 r_ = 2.0 * sin(
r ) * cosh(
i ) * fScale;
1876 i = -2.0 * cos(
r ) * sinh(
i ) * fScale;
1881 if( !::rtl::math::isValidArcArg(
r ) )
1882 throw lang::IllegalArgumentException();
1892 if( !::rtl::math::isValidArcArg( 2.0 *
r ) )
1893 throw lang::IllegalArgumentException();
1894 double fScale =1.0 / ( cosh( 2.0 *
i ) - cos( 2.0 *
r ) );
1895 r = sin( 2.0 *
r ) * fScale;
1896 i = - ( sinh( 2.0 *
i ) * fScale );
1900 if( !::rtl::math::isValidArcArg(
r ) )
1901 throw lang::IllegalArgumentException();
1909 if( !::rtl::math::isValidArcArg(
r ) )
1910 throw lang::IllegalArgumentException();
1915 r_ = sinh(
r ) * cos(
i );
1916 i = cosh(
r ) * sin(
i );
1926 if( !::rtl::math::isValidArcArg(
r ) )
1927 throw lang::IllegalArgumentException();
1932 r_ = cosh(
r ) * cos(
i );
1933 i = sinh(
r ) * sin(
i );
1945 if( !::rtl::math::isValidArcArg( 2.0 *
r ) )
1946 throw lang::IllegalArgumentException();
1947 double fScale =1.0 / ( cosh( 2.0 *
r ) + cos( 2.0 *
i ));
1949 r_ = 2.0 * cosh(
r ) * cos(
i ) * fScale;
1950 i = - (2.0 * sinh(
r ) * sin(
i ) * fScale );
1955 if( !::rtl::math::isValidArcArg(
r ) )
1956 throw lang::IllegalArgumentException();
1957 r = 1.0 / cosh(
r );
1966 if( !::rtl::math::isValidArcArg( 2.0 *
r ) )
1967 throw lang::IllegalArgumentException();
1968 double fScale =1.0 / ( cosh( 2.0 *
r ) - cos( 2.0 *
i ));
1970 r_ = 2.0 * sinh(
r ) * cos(
i ) * fScale;
1971 i = - ( 2.0 * cosh(
r ) * sin(
i ) * fScale );
1976 if( !::rtl::math::isValidArcArg(
r ) )
1977 throw lang::IllegalArgumentException();
1978 r = 1.0 / sinh(
r );
1990 for(
const uno::Sequence< OUString >& rList : r )
1992 for(
const OUString& rStr : rList )
1994 if( !rStr.isEmpty() )
2003 for(
const uno::Any& r : aMultPars )
2005 switch( r.getValueTypeClass() )
2007 case uno::TypeClass_VOID:
break;
2008 case uno::TypeClass_STRING:
2010 auto pStr = o3tl::forceAccess<OUString>(r);
2012 if( !pStr->isEmpty() )
2016 case uno::TypeClass_DOUBLE:
2019 case uno::TypeClass_SEQUENCE:
2021 uno::Sequence< uno::Sequence< uno::Any > > aValArr;
2022 if( !(r >>= aValArr) )
2023 throw lang::IllegalArgumentException();
2025 for(
const uno::Sequence< uno::Any >& rArr : std::as_const(aValArr) )
2030 throw lang::IllegalArgumentException();
2037 ,
aName(
p, strlen(
p), RTL_TEXTENCODING_MS_1252)
2039 , bPrefixSupport(bPrefSupport)
2049 OUString
aStr = rRef;
2050 sal_Int32 nLen = rRef.getLength();
2051 sal_Int32
nIndex = rRef.lastIndexOf(
'^' );
2053 aStr =
aStr.subView( 0, nLen - 2 ) + OUStringChar(
aStr[ nLen - 1 ] );
2060 nLen =
aStr.getLength();
2062 bool bOneChar = (bPref && nLen > 1 && (
aName ==
p + 1));
2063 if (bOneChar || (bPref && nLen > 2 && (
aName ==
p + 2) &&
2064 *
p ==
'd' && *(
p+1) ==
'a'))
2069 case 'y':
n = -24;
break;
2070 case 'z':
n = -21;
break;
2071 case 'a':
n = -18;
break;
2072 case 'f':
n = -15;
break;
2073 case 'p':
n = -12;
break;
2074 case 'n':
n = -9;
break;
2075 case 'u':
n = -6;
break;
2076 case 'm':
n = -3;
break;
2077 case 'c':
n = -2;
break;
2086 case 'e':
n = 1;
break;
2087 case 'h':
n = 2;
break;
2088 case 'k':
n = 3;
break;
2089 case 'M':
n = 6;
break;
2090 case 'G':
n = 9;
break;
2091 case 'T':
n = 12;
break;
2092 case 'P':
n = 15;
break;
2093 case 'E':
n = 18;
break;
2094 case 'Z':
n = 21;
break;
2095 case 'Y':
n = 24;
break;
2112 else if( cLast ==
'3' )
2122 if ( *(pStr + 1) !=
'i')
2127 case 'k':
n = 10;
break;
2128 case 'M':
n = 20;
break;
2129 case 'G':
n = 30;
break;
2130 case 'T':
n = 40;
break;
2131 case 'P':
n = 50;
break;
2132 case 'E':
n = 60;
break;
2133 case 'Z':
n = 70;
break;
2134 case 'Y':
n = 80;
break;
2147 double f,
const ConvertData& r, sal_Int16 nLevFrom, sal_Int16 nLevTo )
const
2150 throw lang::IllegalArgumentException();
2152 bool bBinFromLev = ( nLevFrom > 0 && ( nLevFrom % 10 ) == 0 );
2153 bool bBinToLev = ( nLevTo > 0 && ( nLevTo % 10 ) == 0 );
2157 if ( bBinFromLev && bBinToLev )
2159 nLevFrom = sal::static_int_cast<sal_Int16>( nLevFrom - nLevTo );
2162 f *= pow( 2.0, nLevFrom );
2164 else if ( bBinFromLev )
2165 f *= ( r.
fConst /
fConst ) * ( pow( 2.0, nLevFrom ) / pow( 10.0, nLevTo ) );
2167 f *= ( r.
fConst /
fConst ) * ( pow( 10.0, nLevFrom ) / pow( 2.0, nLevTo ) );
2171 nLevFrom = sal::static_int_cast<sal_Int16>( nLevFrom - nLevTo );
2176 f = ::rtl::math::pow10Exp( f, nLevFrom );
2184 return ::rtl::math::pow10Exp( f *
fConst, -
n );
2192 double f,
const ConvertData& r, sal_Int16 nLevFrom, sal_Int16 nLevTo )
const
2195 throw lang::IllegalArgumentException();
2203 f = ::rtl::math::pow10Exp( f,
n );
2218 f = ::rtl::math::pow10Exp( f, -
n );
2226#define NEWD(str,unit,cl) maVector.emplace_back(new ConvertData(str,unit,cl))
2227#define NEWDP(str,unit,cl) maVector.emplace_back(new ConvertData(str,unit,cl,true))
2228#define NEWL(str,unit,offs,cl) maVector.emplace_back(new ConvertDataLinear(str,unit,offs,cl))
2229#define NEWLP(str,unit,offs,cl) maVector.emplace_back(new ConvertDataLinear(str,unit,offs,cl,true))
2398 NEWD(
"ludicrous speed", 2.0494886343432328E-14,
CDC_Speed );
2399 NEWD(
"ridiculous speed", 4.0156958471424288E-06,
CDC_Speed);
2416 bool bSearchFrom =
true;
2417 bool bSearchTo =
true;
2418 sal_Int16 nLevelFrom = 0;
2419 sal_Int16 nLevelTo = 0;
2421 for(
const auto& rItem :
maVector )
2426 sal_Int16
n =
p->GetMatchingLevel( rFrom );
2437 bSearchFrom =
false;
2445 sal_Int16
n =
p->GetMatchingLevel( rTo );
2462 if( !bSearchFrom && !bSearchTo )
2466 if( !pFrom || !pTo )
2467 throw lang::IllegalArgumentException();
2469 return pFrom->
Convert( fVal, *pTo, nLevelFrom, nLevelTo );
2478 bLastDayMode( true ),
2490 b30Days = (nBase == 0) || (nBase == 4);
2496 nOrigDay( rCopy.nOrigDay ),
2498 nMonth( rCopy.nMonth ),
2499 nYear( rCopy.nYear ),
2500 bLastDayMode( rCopy.bLastDayMode ),
2501 bLastDay( rCopy.bLastDay ),
2502 b30Days( rCopy.b30Days ),
2503 bUSMode( rCopy.bUSMode )
2509 if(
this != &rCopy )
2528 nDay = std::min(
nOrigDay,
static_cast< sal_uInt16
>( 30 ) );
2547 nRet = (nTo - nFrom + 1) * 30;
2550 for( sal_uInt16 nMonthIx = nFrom; nMonthIx <= nTo; ++nMonthIx )
2566 sal_Int32 nNewYear = nYearCount +
nYear;
2567 if( (nNewYear < 0) || (nNewYear > 0x7FFF) )
2568 throw lang::IllegalArgumentException();
2569 nYear =
static_cast< sal_uInt16
>( nNewYear );
2574 sal_Int32 nNewMonth = nMonthCount +
nMonth;
2575 if( nNewMonth > 12 )
2579 nMonth =
static_cast< sal_uInt16
>( nNewMonth % 12 ) + 1;
2581 else if( nNewMonth < 1 )
2584 nMonth =
static_cast< sal_uInt16
>( nNewMonth % 12 + 12 );
2587 nMonth =
static_cast< sal_uInt16
>( nNewMonth );
2595 return ::DateToDays( nRealDay,
nMonth,
nYear ) - nNullDate;
2603 sal_Int32 nDiff = 0;
2612 if( ((rFrom.
nMonth == 2) || (rFrom.
nDay < 30)) && (
aTo.nOrigDay == 31) )
2614 else if( (
aTo.nMonth == 2) &&
aTo.bLastDay )
2620 if( (
aFrom.nMonth == 2) && (
aFrom.nDay == 30) )
2622 if( (
aTo.nMonth == 2) && (
aTo.nDay == 30) )
2630 nDiff =
aFrom.getDaysInMonth() -
aFrom.nDay + 1;
2632 aFrom.bLastDay =
false;
2633 aFrom.addMonths( 1 );
2638 nDiff +=
aFrom.getDaysInMonthRange(
aFrom.nMonth, 12 );
2642 nDiff +=
aFrom.getDaysInYearRange(
aFrom.nYear,
aTo.nYear - 1 );
2647 nDiff +=
aFrom.getDaysInMonthRange(
aFrom.nMonth,
aTo.nMonth - 1 );
2652 return std::max<sal_Int32>(nDiff, 0);
2671 , bHasValidFormat(false)
2673 xFormatter = util::NumberFormatter::create(xContext);
2688 uno::Reference< util::XNumberFormatsSupplier > xFormatsSupp( xPropSet, uno::UNO_QUERY );
2689 if( !xFormatsSupp.is() )
2693 uno::Reference< util::XNumberFormats > xFormats( xFormatsSupp->getNumberFormats() );
2694 uno::Reference< util::XNumberFormatTypes > xFormatTypes( xFormats, uno::UNO_QUERY );
2695 if( xFormatTypes.is() )
2697 lang::Locale eLocale;
2699 xFormatter->attachNumberFormatsSupplier( xFormatsSupp );
2706 double fValue = 0.0;
2713 catch( uno::Exception& )
2715 throw lang::IllegalArgumentException();
2720 rtl_math_ConversionStatus eStatus;
2722 fValue = ::rtl::math::stringToDouble( rString,
'.',
',', &eStatus, &nEnd );
2723 if( (eStatus != rtl_math_ConversionStatus_Ok) || (nEnd < rString.getLength()) )
2724 throw lang::IllegalArgumentException();
2734 bool bContainsVal =
true;
2735 switch( rAny.getValueTypeClass() )
2737 case uno::TypeClass_VOID:
2738 bContainsVal =
false;
2740 case uno::TypeClass_DOUBLE:
2743 case uno::TypeClass_STRING:
2745 auto pString = o3tl::forceAccess< OUString >( rAny );
2746 if( !pString->isEmpty() )
2749 bContainsVal =
false;
2753 throw lang::IllegalArgumentException();
2755 return bContainsVal;
2760 const uno::Reference< beans::XPropertySet >& xPropSet,
2768 const uno::Reference< beans::XPropertySet >& xPropSet,
2773 if( !
getDouble( fResult, xPropSet, rAny ) )
2779 sal_Int32& rnResult,
2780 const uno::Reference< beans::XPropertySet >& xPropSet,
2784 bool bContainsVal =
getDouble( fResult, xPropSet, rAny );
2785 if( (fResult <= -2147483649.0) || (fResult >= 2147483648.0) )
2786 throw lang::IllegalArgumentException();
2788 rnResult =
static_cast< sal_Int32
>( fResult );
2789 return bContainsVal;
2793 const uno::Reference< beans::XPropertySet >& xPropSet,
2795 sal_Int32 nDefault )
2798 if( !
getInt32( nResult, xPropSet, rAny ) )
bool isFreqInvalid(sal_Int32 nFreq)
double finiteOrThrow(double d)
#define FUNCDATAS(FUNCNAME, DBL, OPT, NUMOFPAR, CAT, SUFFIX)
#define FUNCDATA(FUNCNAME, DBL, OPT, NUMOFPAR, CAT)
#define NEWD(str, unit, cl)
#define NEWL(str, unit, offs, cl)
#define NEWDP(str, unit, cl)
#define NEWLP(str, unit, offs, cl)
const FuncDataBase pFuncDatas[]
void Append(Complex &&pNew)
OUString GetString() const
void Div(const Complex &rDivisor)
void Power(double fPower)
static bool ParseString(const OUString &rComplexAsString, Complex &rReturn)
static bool IsImagUnit(sal_Unicode c)
Complex(double fReal, double fImag=0.0, sal_Unicode cC='\0')
double ConvertToBase(double fVal, sal_Int16 nMatchLevel) const
virtual double ConvertFromBase(double fVal, sal_Int16 nMatchLevel) const override
virtual double Convert(double fVal, const ConvertData &rTo, sal_Int16 nMatchLevelFrom, sal_Int16 nMatchLevelTo) const override
virtual ~ConvertDataLinear() override
double Convert(double fVal, const OUString &rFrom, const OUString &rTo)
std::vector< std::unique_ptr< ConvertData > > maVector
virtual double Convert(double fVal, const ConvertData &rTo, sal_Int16 nMatchLevelFrom, sal_Int16 nMatchLevelTo) const
ConvertData(const char pUnitName[], double fConvertConstant, ConvertDataClass eClass, bool bPrefSupport=false)
ConvertDataClass Class() const
virtual double ConvertFromBase(double fVal, sal_Int16 nMatchLevel) const
sal_Int16 GetMatchingLevel(const OUString &rRef) const
std::vector< OUString > aCompList
sal_uInt16 GetStrIndex(sal_uInt16 nParamNum) const
FuncData(const FuncDataBase &rBaseData)
Helper class for Any->double conversion, using current language settings.
double convertToDouble(const OUString &rString) const
Converts a string to double using the number formatter.
ScaAnyConverter(const css::uno::Reference< css::uno::XComponentContext > &xContext)
bool getDouble(double &rfResult, const css::uno::Any &rAny) const
Converts an Any to double (without initialization).
css::uno::Reference< css::util::XNumberFormatter2 > xFormatter
void init(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
Initializing with current language settings.
bool getInt32(sal_Int32 &rnResult, const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const css::uno::Any &rAny)
Converts an Any to sal_Int32 (with initialization).
Helper class for date calculation for various financial functions.
sal_uInt16 nDay
is the day of the original date.
sal_Int32 getDate(sal_Int32 nNullDate) const
void doAddYears(sal_Int32 nYearCount)
Adds/subtracts the given count of years, does not adjust day.
bool bLastDayMode
is the current year.
sal_uInt16 getDaysInMonth() const
sal_Int32 getDaysInYearRange(sal_uInt16 nFrom, sal_uInt16 nTo) const
@ return count of days in the given year range
void addMonths(sal_Int32 nMonthCount)
adds/subtracts the given count of months, adjusts day
void setYear(sal_uInt16 nNewYear)
sets the given year, adjusts day
void setDay()
is true, if the US method of 30-day-calculations is used.
void addYears(sal_Int32 nYearCount)
adds/subtracts the given count of years, adjusts day
bool bLastDay
if true, recalculate nDay after every calculation.
sal_uInt16 nYear
is the current month (one-based).
sal_uInt16 getYear() const
sal_uInt16 getMonth() const
ScaDate & operator=(const ScaDate &rCopy)
sal_Int32 getDaysInMonthRange(sal_uInt16 nFrom, sal_uInt16 nTo) const
@ return count of days in the given month range
static sal_Int32 getDiff(const ScaDate &rFrom, const ScaDate &rTo)
bool b30Days
is true, if original date was the last day in month.
bool bUSMode
is true, if every month has 30 days in calculations.
sal_uInt16 nMonth
is the calculated day depending on the current month/year.
bool operator<(const ScaDate &rCmp) const
virtual bool CheckInsert(double fValue) const override
virtual bool CheckInsert(double fValue) const override
virtual bool CheckInsert(double fValue) const
void Append(double fValue)
bool Find(sal_Int32 nVal) const
SortedIndividualInt32List()
sal_Int32 Get(sal_uInt32 n) const
void Insert(sal_Int32 nDay)
std::vector< sal_Int32 > maVector
~SortedIndividualInt32List()
void InsertHolidayList(const ScaAnyConverter &rAnyConv, const css::uno::Any &rHolAny, sal_Int32 nNullDate, bool bInsertOnWeekend)
std::enable_if<!(detail::IsDerivedReference< T >::value||detail::IsUnoSequenceType< T >::value||std::is_base_of< css::uno::XInterface, T >::value), typenamedetail::Optional< T >::type >::type tryAccess(css::uno::Any const &any)
static bool IsNum(sal_Unicode c)
double GetYearDiff(sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode)
static void lcl_GetCoupncd(ScaDate &rDate, const ScaDate &rSettle, const ScaDate &rMat, sal_Int32 nFreq)
double GetOddfprice(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int32, double, double, double, sal_Int32, sal_Int32)
double getYield_(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, double fCoup, double fPrice, double fRedemp, sal_Int32 nFreq, sal_Int32 nBase)
double BinomialCoefficient(double n, double k)
static void lcl_GetCouppcd(ScaDate &rDate, const ScaDate &rSettle, const ScaDate &rMat, sal_Int32 nFreq)
double GetOddfyield(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int32, double, double, double, sal_Int32, sal_Int32)
void InitFuncDataList(FuncDataList &rList)
sal_Int32 GetNullDate(const uno::Reference< beans::XPropertySet > &xOpt)
Get the null date used by the spreadsheet document.
double GetYieldmat(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nIssue, double fRate, double fPrice, sal_Int32 nBase)
static sal_uInt16 GetVal(sal_Unicode c)
double GetPmt(double fRate, double fNper, double fPv, double fFv, sal_Int32 nPayType)
double GetCoupdaysnc(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase)
double GetCouppcd(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase)
sal_Int32 GetDaysInYear(sal_Int32 nNullDate, sal_Int32 nDate, sal_Int32 nMode)
double GetAmordegrc(sal_Int32 nNullDate, double fCost, sal_Int32 nDate, sal_Int32 nFirstPer, double fRestVal, double fPer, double fRate, sal_Int32 nBase)
static char GetMaxChar(sal_uInt16 nBase)
static bool IsExpStart(sal_Unicode c)
double GetCoupnum(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase)
double GetGcd(double f1, double f2)
OUString GetString(double f, bool bLeadingSign, sal_uInt16 nMaxDig)
OUString ConvertFromDec(double fNum, double fMin, double fMax, sal_uInt16 nBase, sal_Int32 nPlaces, sal_Int32 nMaxPlaces, bool bUsePlaces)
bool ParseDouble(const sal_Unicode *&rp, double &rRet)
sal_Int32 GetDiffDate(sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode, sal_Int32 *pOptDaysIn1stYear)
double getPrice_(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, double fRate, double fYield, double fRedemp, sal_Int32 nFreq, sal_Int32 nBase)
double GetCoupdays(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase)
double GetOddlyield(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastCoup, double fRate, double fPrice, double fRedemp, sal_Int32 nFreq, sal_Int32 nBase)
double ConvertToDec(const OUString &aStr, sal_uInt16 nBase, sal_uInt16 nCharLim)
sal_Int32 GetDiffDate360(sal_uInt16 nDay1, sal_uInt16 nMonth1, sal_uInt16 nYear1, bool bLeapYear1, sal_uInt16 nDay2, sal_uInt16 nMonth2, sal_uInt16 nYear2, bool bUSAMethod)
static bool IsComma(sal_Unicode c)
sal_Int32 DateToDays(sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear)
Convert a date to a count of days starting from 01/01/0001.
static bool IsImagUnit(sal_Unicode c)
void DaysToDate(sal_Int32 nDays, sal_uInt16 &rDay, sal_uInt16 &rMonth, sal_uInt16 &rYear)
Convert a count of days starting from 01/01/0001 to a date.
double GetYearFrac(sal_Int32 nNullDate, sal_Int32 nStartDate, sal_Int32 nEndDate, sal_Int32 nMode)
Function GetYearFrac implements YEARFRAC as defined in: Open Document Format for Office Applications ...
sal_uInt16 DaysInMonth(sal_uInt16 nMonth, sal_uInt16 nYear)
sal_Int32 GetDaysInYears(sal_uInt16 nYear1, sal_uInt16 nYear2)
double GetCoupdaybs(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase)
double GetOddlprice(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nLastCoup, double fRate, double fYield, double fRedemp, sal_Int32 nFreq, sal_Int32 nBase)
double GetFv(double fRate, double fNper, double fPmt, double fPv, sal_Int32 nPayType)
bool IsLeapYear(sal_uInt16 nYear)
double GetAmorlinc(sal_Int32 nNullDate, double fCost, sal_Int32 nDate, sal_Int32 nFirstPer, double fRestVal, double fPer, double fRate, sal_Int32 nBase)
double GetCoupncd(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, sal_Int32 nBase)
double GetDuration(sal_Int32 nNullDate, sal_Int32 nSettle, sal_Int32 nMat, double fCoup, double fYield, sal_Int32 nFreq, sal_Int32 nBase)
sal_Int16 GetDayOfWeek(sal_Int32 nDate)
std::vector< FuncData > FuncDataList
const char ** pCompListID