[Libreoffice-commits] .: basic/source
Michael Meeks
michael at kemper.freedesktop.org
Fri Oct 21 07:09:51 PDT 2011
basic/source/runtime/methods1.cxx | 20 ++++++++++++++++++++
basic/source/runtime/rtlproto.hxx | 1 +
basic/source/runtime/stdobj.cxx | 2 ++
3 files changed, 23 insertions(+)
New commits:
commit 556a61a2f86fef1f828b8352fae7a4c4ed1fdd78
Author: August Sodora <augsod at gmail.com>
Date: Thu Oct 20 23:08:45 2011 -0400
Added Frac function to calc formulas and BASIC standard library
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index f54ff7b..8802245 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -2531,6 +2531,26 @@ RTLFUNC(FormatDateTime)
rPar.Get(0)->PutString( aRetStr );
}
+RTLFUNC(Frac)
+{
+ (void)pBasic;
+ (void)bWrite;
+
+ sal_uInt16 nParCount = rPar.Count();
+ if( nParCount != 2)
+ {
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return;
+ }
+
+ SbxVariable *pSbxVariable = rPar.Get(1);
+ double dVal = pSbxVariable->GetDouble();
+ if(dVal >= 0)
+ rPar.Get(0)->PutDouble(dVal - ::rtl::math::approxFloor(dVal));
+ else
+ rPar.Get(0)->PutDouble(dVal - ::rtl::math::approxCeil(dVal));
+}
+
RTLFUNC(Round)
{
(void)pBasic;
diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx
index 469cd0f..101c320 100644
--- a/basic/source/runtime/rtlproto.hxx
+++ b/basic/source/runtime/rtlproto.hxx
@@ -250,6 +250,7 @@ extern RTLFUNC(Format);
extern RTLFUNC(GetAttr);
extern RTLFUNC(Randomize); // JSM
extern RTLFUNC(Round);
+extern RTLFUNC(Frac);
extern RTLFUNC(Rnd);
extern RTLFUNC(Shell);
extern RTLFUNC(VarType);
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 72ec66a..f384784 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -295,6 +295,8 @@ static Methods aMethods[] = {
{ "FormatDateTime", SbxSTRING, 2 | _FUNCTION | _COMPATONLY, RTLNAME(FormatDateTime),0 },
{ "Date", SbxDATE, 0,NULL,0 },
{ "NamedFormat", SbxINTEGER, _OPT, NULL,0 },
+{ "Frac", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Frac),0 },
+ { "number", SbxDOUBLE, 0,NULL,0 },
{ "FRAMEANCHORCHAR", SbxINTEGER, _CPROP, RTLNAME(FRAMEANCHORCHAR),0 },
{ "FRAMEANCHORPAGE", SbxINTEGER, _CPROP, RTLNAME(FRAMEANCHORPAGE),0 },
{ "FRAMEANCHORPARA", SbxINTEGER, _CPROP, RTLNAME(FRAMEANCHORPARA),0 },
More information about the Libreoffice-commits
mailing list