[ooo-build-commit] patches/dev300 patches/vba scratch/sc-vba
Noel Power
noelp at kemper.freedesktop.org
Tue Aug 4 04:51:38 PDT 2009
patches/dev300/apply | 5
patches/vba/vba-financial-functions.diff | 813 ++++++++++
patches/vba/vba-typename-fix.diff | 94 +
scratch/sc-vba/testvba/TestDocuments/FinancialFuncTests.xls |binary
scratch/sc-vba/testvba/TestDocuments/logs/unix/FinancialFuncTests.log | 31
5 files changed, 942 insertions(+), 1 deletion(-)
New commits:
commit 1d132eb71238e00de150ec791f2147a9424f68c0
Author: Noel Power <noel.power at novell.com>
Date: Tue Aug 4 12:44:40 2009 +0100
add missing Financial functions to basic runtime, fix typename issue
* patches/dev300/apply:
* patches/vba/vba-financial-functions.diff: added missing functions, additionally n#525633 additionally fix argument translation errors ( n#525635, n#525642, n#525647 )
* patches/vba/vba-typename-fix.diff: fix for n#525649
* scratch/sc-vba/testvba/TestDocuments/FinancialFuncTests.xls: test doc
* scratch/sc-vba/testvba/TestDocuments/logs/unix/FinancialFuncTests.log: and log
diff --git a/patches/dev300/apply b/patches/dev300/apply
index d4cd132..f2a8d33 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1904,10 +1904,13 @@ vba-commandbar-toolbar-fix.diff, Fong
vba-automation-set-fix.diff, n#507501, iz#103859
# various improvements, handle tooltip, handle seperators, fix bug where
# toolbar control isn't displayed if the macro isn't resolved,
-# added classed for excel toolbar import ( disabled )
+# added classes for excel toolbar import ( disabled )
tool-menu-bar-improvements.diff
# fix for the issue in Styles.Add in Calc
vba-styles-add-fix.diff, Fong
+vba-financial-functions.diff, n#525633, n#525635, n#525642, n#525647,
+vba-typename-fix.diff, n#525649
+
[VBAUntested]
SectionOwner => noelpwer
# doesn't work
diff --git a/patches/vba/vba-financial-functions.diff b/patches/vba/vba-financial-functions.diff
new file mode 100644
index 0000000..842c8e2
--- /dev/null
+++ b/patches/vba/vba-financial-functions.diff
@@ -0,0 +1,813 @@
+diff --git basic/source/runtime/methods1.cxx basic/source/runtime/methods1.cxx
+index 6917e1b..1f87c04 100644
+--- basic/source/runtime/methods1.cxx
++++ basic/source/runtime/methods1.cxx
+@@ -82,11 +82,15 @@
+ #include <com/sun/star/uno/Sequence.hxx>
+ #include <com/sun/star/lang/XMultiServiceFactory.hpp>
+ #include <com/sun/star/i18n/XCalendar.hpp>
++#include <com/sun/star/sheet/XFunctionAccess.hpp>
+
+ using namespace comphelper;
++using namespace com::sun::star::sheet;
+ using namespace com::sun::star::uno;
+ using namespace com::sun::star::i18n;
+
++void unoToSbxValue( SbxVariable* pVar, const Any& aValue );
++Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, com::sun::star::beans::Property* pUnoProperty = NULL );
+
+ static Reference< XCalendar > getLocaleCalendar( void )
+ {
+@@ -2508,6 +2512,546 @@ RTLFUNC(Round)
+ rPar.Get(0)->PutDouble( dRes );
+ }
+
++void CallFunctionAccessFunction( const Sequence< Any >& aArgs, const rtl::OUString& sFuncName, SbxVariable* pRet )
++{
++ static Reference< XFunctionAccess > xFunc;
++ Any aRes;
++ try
++ {
++ if ( !xFunc.is() )
++ {
++ Reference< XMultiServiceFactory > xFactory( getProcessServiceFactory() );
++ if( xFactory.is() )
++ {
++ xFunc.set( xFactory->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.sheet.FunctionAccess")), UNO_QUERY_THROW);
++ }
++ }
++ Any aRet = xFunc->callFunction( sFuncName, aArgs );
++
++ unoToSbxValue( pRet, aRet );
++
++ }
++ catch( Exception& )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ }
++}
++
++RTLFUNC(SYD)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 4 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++
++ // retrieve non-optional params
++
++ Sequence< Any > aParams( 4 );
++ aParams[ 0 ] <<= makeAny( rPar.Get(1)->GetDouble() );
++ aParams[ 1 ] <<= makeAny( rPar.Get(2)->GetDouble() );
++ aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() );
++ aParams[ 3 ] <<= makeAny( rPar.Get(4)->GetDouble() );
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYD") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(SLN)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 3 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++
++ // retrieve non-optional params
++
++ Sequence< Any > aParams( 3 );
++ aParams[ 0 ] <<= makeAny( rPar.Get(1)->GetDouble() );
++ aParams[ 1 ] <<= makeAny( rPar.Get(2)->GetDouble() );
++ aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() );
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SLN") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(Pmt)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 3 || nArgCount > 5 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++
++ double rate = rPar.Get(1)->GetDouble();
++ double nper = rPar.Get(2)->GetDouble();
++ double pmt = rPar.Get(3)->GetDouble();
++
++ // set default values for Optional args
++ double fv = 0;
++ double type = 0;
++
++ // fv
++ if ( nArgCount >= 4 )
++ {
++ if( rPar.Get(4)->GetType() != SbxEMPTY )
++ fv = rPar.Get(4)->GetDouble();
++ }
++ // type
++ if ( nArgCount >= 5 )
++ {
++ if( rPar.Get(5)->GetType() != SbxEMPTY )
++ type = rPar.Get(5)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 5 );
++ aParams[ 0 ] <<= rate;
++ aParams[ 1 ] <<= nper;
++ aParams[ 2 ] <<= pmt;
++ aParams[ 3 ] <<= fv;
++ aParams[ 4 ] <<= type;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Pmt") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(PPmt)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 4 || nArgCount > 6 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++
++ double rate = rPar.Get(1)->GetDouble();
++ double per = rPar.Get(2)->GetDouble();
++ double nper = rPar.Get(3)->GetDouble();
++ double pv = rPar.Get(4)->GetDouble();
++
++ // set default values for Optional args
++ double fv = 0;
++ double type = 0;
++
++ // fv
++ if ( nArgCount >= 5 )
++ {
++ if( rPar.Get(5)->GetType() != SbxEMPTY )
++ fv = rPar.Get(5)->GetDouble();
++ }
++ // type
++ if ( nArgCount >= 6 )
++ {
++ if( rPar.Get(6)->GetType() != SbxEMPTY )
++ type = rPar.Get(6)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 6 );
++ aParams[ 0 ] <<= rate;
++ aParams[ 1 ] <<= per;
++ aParams[ 2 ] <<= nper;
++ aParams[ 3 ] <<= pv;
++ aParams[ 4 ] <<= fv;
++ aParams[ 5 ] <<= type;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PPmt") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(PV)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 3 || nArgCount > 5 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++
++ double rate = rPar.Get(1)->GetDouble();
++ double nper = rPar.Get(2)->GetDouble();
++ double pmt = rPar.Get(3)->GetDouble();
++
++ // set default values for Optional args
++ double fv = 0;
++ double type = 0;
++
++ // fv
++ if ( nArgCount >= 4 )
++ {
++ if( rPar.Get(4)->GetType() != SbxEMPTY )
++ fv = rPar.Get(4)->GetDouble();
++ }
++ // type
++ if ( nArgCount >= 5 )
++ {
++ if( rPar.Get(5)->GetType() != SbxEMPTY )
++ type = rPar.Get(5)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 5 );
++ aParams[ 0 ] <<= rate;
++ aParams[ 1 ] <<= nper;
++ aParams[ 2 ] <<= pmt;
++ aParams[ 3 ] <<= fv;
++ aParams[ 4 ] <<= type;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PV") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(NPV)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 1 || nArgCount > 2 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++
++ Sequence< Any > aParams( 2 );
++ aParams[ 0 ] <<= makeAny( rPar.Get(1)->GetDouble() );
++ Any aValues = sbxToUnoValue( rPar.Get(2),
++ getCppuType( (Sequence<double>*)0 ) );
++
++ // convert for calc functions
++ Sequence< Sequence< double > > sValues(1);
++ aValues >>= sValues[ 0 ];
++ aValues <<= sValues;
++
++ aParams[ 1 ] <<= aValues;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NPV") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(NPer)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 3 || nArgCount > 5 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++
++ double rate = rPar.Get(1)->GetDouble();
++ double pmt = rPar.Get(2)->GetDouble();
++ double pv = rPar.Get(3)->GetDouble();
++
++ // set default values for Optional args
++ double fv = 0;
++ double type = 0;
++
++ // fv
++ if ( nArgCount >= 4 )
++ {
++ if( rPar.Get(4)->GetType() != SbxEMPTY )
++ fv = rPar.Get(4)->GetDouble();
++ }
++ // type
++ if ( nArgCount >= 5 )
++ {
++ if( rPar.Get(5)->GetType() != SbxEMPTY )
++ type = rPar.Get(5)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 5 );
++ aParams[ 0 ] <<= rate;
++ aParams[ 1 ] <<= pmt;
++ aParams[ 2 ] <<= pv;
++ aParams[ 3 ] <<= fv;
++ aParams[ 4 ] <<= type;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NPer") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(MIRR)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 3 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++
++ // retrieve non-optional params
++
++ Sequence< Any > aParams( 3 );
++ Any aValues = sbxToUnoValue( rPar.Get(1),
++ getCppuType( (Sequence<double>*)0 ) );
++
++ // convert for calc functions
++ Sequence< Sequence< double > > sValues(1);
++ aValues >>= sValues[ 0 ];
++ aValues <<= sValues;
++
++ aParams[ 0 ] <<= aValues;
++ aParams[ 1 ] <<= makeAny( rPar.Get(2)->GetDouble() );
++ aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() );
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("MIRR") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(IRR)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 1 || nArgCount > 2 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++ Any aValues = sbxToUnoValue( rPar.Get(1),
++ getCppuType( (Sequence<double>*)0 ) );
++
++ // convert for calc functions
++ Sequence< Sequence< double > > sValues(1);
++ aValues >>= sValues[ 0 ];
++ aValues <<= sValues;
++
++ // set default values for Optional args
++ double guess = 0.1;
++ // guess
++ if ( nArgCount >= 2 )
++ {
++ if( rPar.Get(2)->GetType() != SbxEMPTY )
++ guess = rPar.Get(2)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 2 );
++ aParams[ 0 ] <<= aValues;
++ aParams[ 1 ] <<= guess;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IRR") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(IPmt)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 4 || nArgCount > 6 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++
++ double rate = rPar.Get(1)->GetDouble();
++ double per = rPar.Get(2)->GetInteger();
++ double nper = rPar.Get(3)->GetDouble();
++ double pv = rPar.Get(4)->GetDouble();
++
++ // set default values for Optional args
++ double fv = 0;
++ double type = 0;
++
++ // fv
++ if ( nArgCount >= 5 )
++ {
++ if( rPar.Get(5)->GetType() != SbxEMPTY )
++ fv = rPar.Get(5)->GetDouble();
++ }
++ // type
++ if ( nArgCount >= 6 )
++ {
++ if( rPar.Get(6)->GetType() != SbxEMPTY )
++ type = rPar.Get(6)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 6 );
++ aParams[ 0 ] <<= rate;
++ aParams[ 1 ] <<= per;
++ aParams[ 2 ] <<= nper;
++ aParams[ 3 ] <<= pv;
++ aParams[ 4 ] <<= fv;
++ aParams[ 5 ] <<= type;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IPmt") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(FV)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 3 || nArgCount > 5 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++
++ double rate = rPar.Get(1)->GetDouble();
++ double nper = rPar.Get(2)->GetDouble();
++ double pmt = rPar.Get(3)->GetDouble();
++
++ // set default values for Optional args
++ double pv = 0;
++ double type = 0;
++
++ // pv
++ if ( nArgCount >= 4 )
++ {
++ if( rPar.Get(4)->GetType() != SbxEMPTY )
++ pv = rPar.Get(4)->GetDouble();
++ }
++ // type
++ if ( nArgCount >= 5 )
++ {
++ if( rPar.Get(5)->GetType() != SbxEMPTY )
++ type = rPar.Get(5)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 5 );
++ aParams[ 0 ] <<= rate;
++ aParams[ 1 ] <<= nper;
++ aParams[ 2 ] <<= pmt;
++ aParams[ 3 ] <<= pv;
++ aParams[ 4 ] <<= type;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FV") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(DDB)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 4 || nArgCount > 5 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++
++ double cost = rPar.Get(1)->GetDouble();
++ double salvage = rPar.Get(2)->GetDouble();
++ double life = rPar.Get(3)->GetDouble();
++ double period = rPar.Get(4)->GetDouble();
++
++ // set default values for Optional args
++ double factor = 2;
++
++ // factor
++ if ( nArgCount >= 5 )
++ {
++ if( rPar.Get(5)->GetType() != SbxEMPTY )
++ factor = rPar.Get(5)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 5 );
++ aParams[ 0 ] <<= cost;
++ aParams[ 1 ] <<= salvage;
++ aParams[ 2 ] <<= life;
++ aParams[ 3 ] <<= period;
++ aParams[ 4 ] <<= factor;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DDB") ), rPar.Get( 0 ) );
++}
++
++RTLFUNC(Rate)
++{
++ (void)pBasic;
++ (void)bWrite;
++
++ ULONG nArgCount = rPar.Count()-1;
++
++ if ( nArgCount < 3 || nArgCount > 6 )
++ {
++ StarBASIC::Error( SbERR_BAD_ARGUMENT );
++ return;
++ }
++ // retrieve non-optional params
++
++ double nper = 0;
++ double pmt = 0;
++ double pv = 0;
++
++ nper = rPar.Get(1)->GetDouble();
++ pmt = rPar.Get(2)->GetDouble();
++ pv = rPar.Get(3)->GetDouble();
++
++ // set default values for Optional args
++ double fv = 0;
++ double type = 0;
++ double guess = 0.1;
++
++ // fv
++ if ( nArgCount >= 4 )
++ {
++ if( rPar.Get(4)->GetType() != SbxEMPTY )
++ fv = rPar.Get(4)->GetDouble();
++ }
++
++ // type
++ if ( nArgCount >= 5 )
++ {
++ if( rPar.Get(5)->GetType() != SbxEMPTY )
++ type = rPar.Get(5)->GetDouble();
++ }
++
++ // guess
++ if ( nArgCount >= 6 )
++ {
++ if( rPar.Get(6)->GetType() != SbxEMPTY )
++ type = rPar.Get(6)->GetDouble();
++ }
++
++ Sequence< Any > aParams( 6 );
++ aParams[ 0 ] <<= nper;
++ aParams[ 1 ] <<= pmt;
++ aParams[ 2 ] <<= pv;
++ aParams[ 3 ] <<= fv;
++ aParams[ 4 ] <<= type;
++ aParams[ 5 ] <<= guess;
++
++ CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Rate") ), rPar.Get( 0 ) );
++}
++
+ RTLFUNC(StrReverse)
+ {
+ (void)pBasic;
+diff --git basic/source/runtime/rtlproto.hxx basic/source/runtime/rtlproto.hxx
+index 3564a46..7f4df3c 100644
+--- basic/source/runtime/rtlproto.hxx
++++ basic/source/runtime/rtlproto.hxx
+@@ -167,29 +167,41 @@ extern RTLFUNC(Kill); // JSM
+ extern RTLFUNC(MkDir); // JSM
+ extern RTLFUNC(RmDir); // JSM
+ extern RTLFUNC(SendKeys); // JSM
++extern RTLFUNC(DDB);
+ extern RTLFUNC(DoEvents);
+ extern RTLFUNC(DimArray);
+ extern RTLFUNC(Dir);
+ extern RTLFUNC(Exp);
+ extern RTLFUNC(FileLen);
+ extern RTLFUNC(Fix);
++extern RTLFUNC(FV);
+ extern RTLFUNC(Hex);
+ extern RTLFUNC(Input);
+ extern RTLFUNC(InStr);
+ extern RTLFUNC(InStrRev);
+ extern RTLFUNC(Int);
++extern RTLFUNC(IPmt);
++extern RTLFUNC(IRR);
+ extern RTLFUNC(Join);
+ extern RTLFUNC(LCase);
+ extern RTLFUNC(Left);
+ extern RTLFUNC(Log);
+ extern RTLFUNC(LTrim);
+ extern RTLFUNC(Mid);
++extern RTLFUNC(MIRR);
++extern RTLFUNC(NPer);
++extern RTLFUNC(NPV);
+ extern RTLFUNC(Oct);
++extern RTLFUNC(Pmt);
++extern RTLFUNC(PPmt);
++extern RTLFUNC(PV);
++extern RTLFUNC(Rate);
+ extern RTLFUNC(Replace);
+ extern RTLFUNC(Right);
+ extern RTLFUNC(RTrim);
+ extern RTLFUNC(RTL);
+ extern RTLFUNC(Sgn);
++extern RTLFUNC(SLN);
+ extern RTLFUNC(Space);
+ extern RTLFUNC(Split);
+ extern RTLFUNC(Sqr);
+@@ -197,6 +209,7 @@ extern RTLFUNC(Str);
+ extern RTLFUNC(StrComp);
+ extern RTLFUNC(String);
+ extern RTLFUNC(StrReverse);
++extern RTLFUNC(SYD);
+ extern RTLFUNC(Tan);
+ extern RTLFUNC(UCase);
+ extern RTLFUNC(Val);
+diff --git basic/source/runtime/stdobj.cxx basic/source/runtime/stdobj.cxx
+index f997065..38ba7cd 100644
+--- basic/source/runtime/stdobj.cxx
++++ basic/source/runtime/stdobj.cxx
+@@ -175,7 +175,12 @@ static Methods aMethods[] = {
+ { "expression", SbxVARIANT, 0,NULL,0 },
+ { "CVErr", SbxVARIANT, 1 | _FUNCTION, RTLNAME(CVErr),0 },
+ { "expression", SbxVARIANT, 0,NULL,0 },
+-
++{ "DDB", SbxDOUBLE, 5 | _FUNCTION | _COMPTMASK, RTLNAME(DDB),0 },
++ { "Cost", SbxDOUBLE, 0, NULL,0 },
++ { "Salvage", SbxDOUBLE, 0, NULL,0 },
++ { "Life", SbxDOUBLE, 0, NULL,0 },
++ { "Period", SbxDOUBLE, 0, NULL,0 },
++ { "Factor", SbxVARIANT, _OPT, NULL,0 },
+ { "Date", SbxDATE, _LFUNCTION,RTLNAME(Date),0 },
+ { "DateAdd", SbxDATE, 3 | _FUNCTION, RTLNAME(DateAdd),0 },
+ { "Interval", SbxSTRING, 0,NULL,0 },
+@@ -273,6 +278,12 @@ static Methods aMethods[] = {
+ { "FreeLibrary", SbxNULL, 1 | _FUNCTION, RTLNAME(FreeLibrary),0 },
+ { "Modulename", SbxSTRING, 0,NULL,0 },
+
++{ "FV", SbxDOUBLE, 5 | _FUNCTION | _COMPTMASK, RTLNAME(FV),0 },
++ { "Rate", SbxDOUBLE, 0, NULL,0 },
++ { "NPer", SbxDOUBLE, 0, NULL,0 },
++ { "Pmt", SbxDOUBLE, 0, NULL,0 },
++ { "PV", SbxVARIANT, _OPT, NULL,0 },
++ { "Due", SbxVARIANT, _OPT, NULL,0 },
+ { "Get", SbxNULL, 3 | _FUNCTION, RTLNAME(Get),0 },
+ { "filenumber", SbxINTEGER, 0,NULL,0 },
+ { "recordnumber", SbxLONG, 0,NULL,0 },
+@@ -333,6 +344,16 @@ static Methods aMethods[] = {
+ { "Compare", SbxINTEGER, _OPT, NULL,0 },
+ { "Int", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Int),0 },
+ { "number", SbxDOUBLE, 0,NULL,0 },
++{ "IPmt", SbxDOUBLE, 6 | _FUNCTION | _COMPTMASK, RTLNAME(IPmt),0 },
++ { "Rate", SbxDOUBLE, 0, NULL,0 },
++ { "Per", SbxDOUBLE, 0, NULL,0 },
++ { "NPer", SbxDOUBLE, 0, NULL,0 },
++ { "PV", SbxDOUBLE, 0, NULL,0 },
++ { "FV", SbxVARIANT, _OPT, NULL,0 },
++ { "Due", SbxVARIANT, _OPT, NULL,0 },
++{ "IRR", SbxDOUBLE, 2 | _FUNCTION | _COMPTMASK, RTLNAME(IRR),0 },
++ { "ValueArray", SbxARRAY, 0, NULL,0 },
++ { "Guess", SbxVARIANT, _OPT, NULL,0 },
+ { "IsArray", SbxBOOL, 1 | _FUNCTION, RTLNAME(IsArray),0 },
+ { "Variant", SbxVARIANT, 0,NULL,0 },
+ { "IsDate", SbxBOOL, 1 | _FUNCTION, RTLNAME(IsDate),0 },
+@@ -401,6 +422,10 @@ static Methods aMethods[] = {
+ { "Length", SbxLONG, _OPT, NULL,0 },
+ { "Minute", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Minute),0 },
+ { "Date", SbxDATE, 0,NULL,0 },
++{ "MIRR", SbxDOUBLE, 2 | _FUNCTION | _COMPTMASK, RTLNAME(MIRR),0 },
++ { "ValueArray", SbxARRAY, 0, NULL,0 },
++ { "FinanceRate", SbxDOUBLE, 0, NULL,0 },
++ { "ReinvestRate", SbxDOUBLE, 0, NULL,0 },
+ { "MkDir", SbxNULL, 1 | _FUNCTION, RTLNAME(MkDir),0 },
+ { "pathname", SbxSTRING, 0,NULL,0 },
+ { "Month", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Month),0 },
+@@ -417,6 +442,15 @@ static Methods aMethods[] = {
+
+ { "Nothing", SbxOBJECT, _CPROP, RTLNAME(Nothing),0 },
+ { "Now", SbxDATE, _FUNCTION, RTLNAME(Now),0 },
++{ "NPer", SbxDOUBLE, 5 | _FUNCTION | _COMPTMASK, RTLNAME(NPer),0 },
++ { "Rate", SbxDOUBLE, 0, NULL,0 },
++ { "Pmt", SbxDOUBLE, 0, NULL,0 },
++ { "PV", SbxDOUBLE, 0, NULL,0 },
++ { "FV", SbxVARIANT, _OPT, NULL,0 },
++ { "Due", SbxVARIANT, _OPT, NULL,0 },
++{ "NPV", SbxDOUBLE, 2 | _FUNCTION | _COMPTMASK, RTLNAME(NPV),0 },
++ { "Rate", SbxDOUBLE, 0, NULL,0 },
++ { "ValueArray", SbxARRAY, 0, NULL,0 },
+ { "Null", SbxNULL, _CPROP, RTLNAME(Null),0 },
+
+ { "Oct", SbxSTRING, 1 | _FUNCTION, RTLNAME(Oct),0 },
+@@ -428,16 +462,46 @@ static Methods aMethods[] = {
+ { "stop", SbxLONG, 0,NULL,0 },
+ { "interval", SbxLONG, 0,NULL,0 },
+ { "Pi", SbxDOUBLE, _CPROP, RTLNAME(PI),0 },
++
++{ "Pmt", SbxDOUBLE, 5 | _FUNCTION | _COMPTMASK, RTLNAME(Pmt),0 },
++ { "Rate", SbxDOUBLE, 0, NULL,0 },
++ { "NPer", SbxDOUBLE, 0, NULL,0 },
++ { "PV", SbxDOUBLE, 0, NULL,0 },
++ { "FV", SbxVARIANT, _OPT, NULL,0 },
++ { "Due", SbxVARIANT, _OPT, NULL,0 },
++
++{ "PPmt", SbxDOUBLE, 6 | _FUNCTION | _COMPTMASK, RTLNAME(PPmt),0 },
++ { "Rate", SbxDOUBLE, 0, NULL,0 },
++ { "Per", SbxDOUBLE, 0, NULL,0 },
++ { "NPer", SbxDOUBLE, 0, NULL,0 },
++ { "PV", SbxDOUBLE, 0, NULL,0 },
++ { "FV", SbxVARIANT, _OPT, NULL,0 },
++ { "Due", SbxVARIANT, _OPT, NULL,0 },
++
+ { "Put", SbxNULL, 3 | _FUNCTION, RTLNAME(Put),0 },
+ { "filenumber", SbxINTEGER, 0,NULL,0 },
+ { "recordnumber", SbxLONG, 0,NULL,0 },
+ { "variablename", SbxVARIANT, 0,NULL,0 },
+
++{ "PV", SbxDOUBLE, 5 | _FUNCTION | _COMPTMASK, RTLNAME(PV),0 },
++ { "Rate", SbxDOUBLE, 0, NULL,0 },
++ { "NPer", SbxDOUBLE, 0, NULL,0 },
++ { "Pmt", SbxDOUBLE, 0, NULL,0 },
++ { "FV", SbxVARIANT, _OPT, NULL,0 },
++ { "Due", SbxVARIANT, _OPT, NULL,0 },
++
+ { "QBColor", SbxLONG, 1 | _FUNCTION, RTLNAME(QBColor),0 },
+ { "number", SbxINTEGER, 0,NULL,0 },
+
+ { "Randomize", SbxNULL, 1 | _FUNCTION, RTLNAME(Randomize),0 },
+ { "Number", SbxDOUBLE, _OPT, NULL,0 },
++{ "Rate", SbxDOUBLE, 6 | _FUNCTION | _COMPTMASK, RTLNAME(Rate),0 },
++ { "NPer", SbxDOUBLE, 0, NULL,0 },
++ { "Pmt", SbxDOUBLE, 0, NULL,0 },
++ { "PV", SbxDOUBLE, 0, NULL,0 },
++ { "FV", SbxVARIANT, _OPT, NULL,0 },
++ { "Due", SbxVARIANT, _OPT, NULL,0 },
++ { "Guess", SbxVARIANT, _OPT, NULL,0 },
+ { "Red", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Red),0 },
+ { "RGB-Value", SbxLONG, 0,NULL,0 },
+ { "Reset", SbxNULL, 0 | _FUNCTION, RTLNAME(Reset),0 },
+@@ -492,6 +556,15 @@ static Methods aMethods[] = {
+ { "WindowStyle", SbxINTEGER, _OPT, NULL,0 },
+ { "Sin", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Sin),0 },
+ { "number", SbxDOUBLE, 0,NULL,0 },
++{ "SLN", SbxDOUBLE, 2 | _FUNCTION | _COMPTMASK, RTLNAME(SLN),0 },
++ { "Cost", SbxDOUBLE, 0,NULL,0 },
++ { "Double", SbxDOUBLE, 0,NULL,0 },
++ { "Life", SbxDOUBLE, 0,NULL,0 },
++{ "SYD", SbxDOUBLE, 2 | _FUNCTION | _COMPTMASK, RTLNAME(SYD),0 },
++ { "Cost", SbxDOUBLE, 0,NULL,0 },
++ { "Salvage", SbxDOUBLE, 0,NULL,0 },
++ { "Life", SbxDOUBLE, 0,NULL,0 },
++ { "Period", SbxDOUBLE, 0,NULL,0 },
+ { "Space", SbxSTRING, 1 | _FUNCTION, RTLNAME(Space),0 },
+ { "string", SbxLONG, 0,NULL,0 },
+ { "Spc", SbxSTRING, 1 | _FUNCTION, RTLNAME(Spc),0 },
+diff --git sc/source/ui/vba/vbawsfunction.cxx sc/source/ui/vba/vbawsfunction.cxx
+index 6d6629b..101e1c9 100644
+--- sc/source/ui/vba/vbawsfunction.cxx
++++ sc/source/ui/vba/vbawsfunction.cxx
+@@ -74,13 +74,48 @@ ScVbaWSFunction::invoke(const rtl::OUString& FunctionName, const uno::Sequence<
+
+ for (int i=0; i < Params.getLength();i++)
+ {
++ aArrayTemp[i]= aArray[i];
+ uno::Reference<excel::XRange> myRange( aArray[ i ], uno::UNO_QUERY );
+ if ( myRange.is() )
+ {
+ aArrayTemp[i] = myRange->getCellRange();
+ continue;
+ }
+- aArrayTemp[i]= aArray[i];
++ else if ( aArray[ i ].getValueType().getTypeClass() == uno::TypeClass_SEQUENCE )
++ {
++ // the sheet.FunctionAccess service doesn't deal with Sequences, only Sequences of Sequence
++ uno::Type aType = aArray[ i ].getValueType();
++ if ( aType.equals( getCppuType( (uno::Sequence<sal_Int16>*)0 ) ) )
++ {
++ uno::Sequence< uno::Sequence< sal_Int16 > > aTmp(1);
++ aArray[ i ] >>= aTmp[ 0 ];
++ aArrayTemp[i] <<= aTmp;
++ }
++ else if ( aType.equals( getCppuType( (uno::Sequence<sal_Int32>*)0 ) ) )
++ {
++ uno::Sequence< uno::Sequence< sal_Int32 > > aTmp(1);
++ aArray[ i ] >>= aTmp[ 0 ];
++ aArrayTemp[i] <<= aTmp;
++ }
++ else if ( aType.equals( getCppuType( (uno::Sequence<double>*)0 ) ) )
++ {
++ uno::Sequence< uno::Sequence< double > > aTmp(1);
++ aArray[ i ] >>= aTmp[ 0 ];
++ aArrayTemp[i] <<= aTmp;
++ }
++ else if ( aType.equals( getCppuType( (uno::Sequence<rtl::OUString>*)0 ) ) )
++ {
++ uno::Sequence< uno::Sequence< rtl::OUString > > aTmp(1);
++ aArray[ i ] >>= aTmp[ 0 ];
++ aArrayTemp[i] <<= aTmp;
++ }
++ else if ( aType.equals( getCppuType( (uno::Sequence<uno::Any>*)0 ) ) )
++ {
++ uno::Sequence< uno::Sequence<uno::Any > > aTmp(1);
++ aArray[ i ] >>= aTmp[ 0 ];
++ aArrayTemp[i] <<= aTmp;
++ }
++ }
+ }
+
+ for ( int count=0; count < aParamTemp.getLength(); ++count )
diff --git a/patches/vba/vba-typename-fix.diff b/patches/vba/vba-typename-fix.diff
new file mode 100644
index 0000000..ca117e8
--- /dev/null
+++ b/patches/vba/vba-typename-fix.diff
@@ -0,0 +1,94 @@
+diff --git basic/source/runtime/methods.cxx basic/source/runtime/methods.cxx
+index 2c5dab3..5b239a6 100644
+--- basic/source/runtime/methods.cxx
++++ basic/source/runtime/methods.cxx
+@@ -79,7 +79,8 @@
+ #include <com/sun/star/io/XStream.hpp>
+ #include <com/sun/star/io/XSeekable.hpp>
+ #include <com/sun/star/script/XErrorQuery.hpp>
+-
++#include <ooo/vba/XHelperInterface.hpp>
++#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
+ using namespace comphelper;
+ using namespace osl;
+ using namespace com::sun::star::uno;
+@@ -3670,6 +3671,65 @@ String getBasicTypeName( SbxDataType eType )
+ return aRetStr;
+ }
+
++String getObjectTypeName( SbxVariable* pVar )
++{
++ rtl::OUString sRet( RTL_CONSTASCII_USTRINGPARAM("Object") );
++ if ( pVar )
++ {
++ SbxBase* pObj = pVar->GetObject();
++ if( !pObj )
++ sRet = String( RTL_CONSTASCII_USTRINGPARAM("Nothing") );
++ else
++ {
++ SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pVar );
++ if ( !pUnoObj )
++ {
++ if ( SbxBase* pBaseObj = pVar->GetObject() )
++ pUnoObj = PTR_CAST(SbUnoObject, pBaseObj );
++ }
++ if ( pUnoObj )
++ {
++ Any aObj = pUnoObj->getUnoAny();
++ // For upstreaming unless we start to build oovbaapi by default
++ // we need to get detect the vba-ness of the object in some
++ // other way
++ // note: Automation objects do not support XServiceInfo
++ Reference< XServiceInfo > xServInfo( aObj, UNO_QUERY );
++ if ( xServInfo.is() )
++ {
++ // is this a VBA object ?
++ Reference< ooo::vba::XHelperInterface > xVBA( aObj, UNO_QUERY );
++ Sequence< rtl::OUString > sServices = xServInfo->getSupportedServiceNames();
++ if ( sServices.getLength() )
++ sRet = sServices[ 0 ];
++ }
++ else
++ {
++ Reference< com::sun::star::bridge::oleautomation::XAutomationObject > xAutoMation( aObj, UNO_QUERY );
++ if ( xAutoMation.is() )
++ {
++ Reference< XInvocation > xInv( aObj, UNO_QUERY );
++ if ( xInv.is() )
++ {
++ try
++ {
++ xInv->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("$GetTypeName") ) ) >>= sRet;
++ }
++ catch( Exception& )
++ {
++ }
++ }
++ }
++ }
++ sal_Int32 nDot = sRet.lastIndexOf( '.' );
++ if ( nDot != -1 && nDot < sRet.getLength() )
++ sRet = sRet.copy( nDot + 1 );
++ }
++ }
++ }
++ return sRet;
++}
++
+ RTLFUNC(TypeName)
+ {
+ (void)pBasic;
+@@ -3681,7 +3741,12 @@ RTLFUNC(TypeName)
+ {
+ SbxDataType eType = rPar.Get(1)->GetType();
+ BOOL bIsArray = ( ( eType & SbxARRAY ) != 0 );
+- String aRetStr = getBasicTypeName( eType );
++
++ String aRetStr;
++ if ( SbiRuntime::isVBAEnabled() && eType == SbxOBJECT )
++ aRetStr = getObjectTypeName( rPar.Get(1) );
++ else
++ aRetStr = getBasicTypeName( eType );
+ if( bIsArray )
+ aRetStr.AppendAscii( "()" );
+ rPar.Get(0)->PutString( aRetStr );
diff --git a/scratch/sc-vba/testvba/TestDocuments/FinancialFuncTests.xls b/scratch/sc-vba/testvba/TestDocuments/FinancialFuncTests.xls
new file mode 100644
index 0000000..d4776b9
Binary files /dev/null and b/scratch/sc-vba/testvba/TestDocuments/FinancialFuncTests.xls differ
diff --git a/scratch/sc-vba/testvba/TestDocuments/logs/unix/FinancialFuncTests.log b/scratch/sc-vba/testvba/TestDocuments/logs/unix/FinancialFuncTests.log
new file mode 100644
index 0000000..5633a81
--- /dev/null
+++ b/scratch/sc-vba/testvba/TestDocuments/logs/unix/FinancialFuncTests.log
@@ -0,0 +1,31 @@
+Test run started : 04/08/2009 12:42:26
+----------------------------------------------------------------
+FinancialFuncs
+ TEST START : FinancialFuncs
+ ITEM Assertion OK : DDB test
+ ITEM Assertion OK : FV test
+ ITEM Assertion OK : IPmt test
+ ITEM Assertion FAIL : IRR test
+ ITEM Assertion OK : MIRR test
+ ITEM Assertion FAIL : NPer test
+ ITEM Assertion FAIL : NPV test
+ ITEM Assertion FAIL : Pmt test
+ ITEM Assertion OK : PPmt test
+ ITEM Assertion OK : PV test
+ ITEM Assertion FAIL : Rate test
+ ITEM Assertion OK : SLN test
+ ITEM Assertion OK : SYD test
+Test Results
+============
+
+IRR test Failed: expected 35.8625323270733 got 35.8625323273411
+NPer test Failed: expected 21.5365977313406 got 21.5365977313408
+NPV test Failed: expected 3874.42183648785 got 3874.42183648784
+Pmt test Failed: expected 20276.3942884139 got 20276.3942884138
+Rate test Failed: expected 4.67819164224935E-02 got 4.67819164225E-02
+Tests passed: 8
+Tests failed: 5
+
+END 'FinancialFuncs
+ TEST OK : FinancialFuncs
+Test run finished : 04/08/2009 12:42:36
More information about the ooo-build-commit
mailing list