From cc69c3dde48f5038567ae0b964b9ef9b5f302748 Mon Sep 17 00:00:00 2001 From: Olivier Hallot Date: Tue, 16 Jun 2020 23:57:06 -0300 Subject: tdf#134032 Calling Calc function from basic Change-Id: I7c3c64e0df4d89b46e49afb869f3e2de0825a6e2 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/96485 Tested-by: Jenkins Reviewed-by: Olivier Hallot (cherry picked from commit 7af288d0fa90e5e31c29014501f06f776a00366a) Reviewed-on: https://gerrit.libreoffice.org/c/help/+/96504 Reviewed-by: Adolfo Jayme Barrientos --- AllLangHelp_sbasic.mk | 1 + source/auxiliary/sbasic.tree | 1 + source/text/sbasic/shared/03131600.xhp | 11 +- source/text/sbasic/shared/calc_functions.xhp | 865 +++++++++++++++++++++++++++ source/text/scalc/01/04060115.xhp | 43 +- source/text/scalc/01/04060116.xhp | 1 + 6 files changed, 896 insertions(+), 26 deletions(-) create mode 100644 source/text/sbasic/shared/calc_functions.xhp diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk index 6a53d6bea4..6dcb58d11e 100644 --- a/AllLangHelp_sbasic.mk +++ b/AllLangHelp_sbasic.mk @@ -358,6 +358,7 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\ helpcontent2/source/text/sbasic/shared/03170010 \ helpcontent2/source/text/sbasic/shared/05060700 \ helpcontent2/source/text/sbasic/shared/code-stubs \ + helpcontent2/source/text/sbasic/shared/calc_functions \ helpcontent2/source/text/sbasic/shared/classmodule \ helpcontent2/source/text/sbasic/shared/compatible \ helpcontent2/source/text/sbasic/shared/compatibilitymode \ diff --git a/source/auxiliary/sbasic.tree b/source/auxiliary/sbasic.tree index 804b8613b9..fc7df973da 100644 --- a/source/auxiliary/sbasic.tree +++ b/source/auxiliary/sbasic.tree @@ -50,6 +50,7 @@ Comparison Operators Strings UNO Objects, Functions and Services + Calling Calc functions Exclusive VBA functions Other Commands diff --git a/source/text/sbasic/shared/03131600.xhp b/source/text/sbasic/shared/03131600.xhp index ddf4fe234c..b0c499b8c7 100644 --- a/source/text/sbasic/shared/03131600.xhp +++ b/source/text/sbasic/shared/03131600.xhp @@ -33,7 +33,7 @@ API;FunctionAccess -CreateUnoService Function +

CreateUnoService Function

Instantiates a Uno service with the ProcessServiceManager. @@ -45,11 +45,11 @@ Calc functions;API Service -Calling Calc functions in Basic -CreateUnoService function; Calling Calc functions Calling Calc functions in Basic: +
+ REM The code below does not work for add-in functions, which have a different calling procedure. Function MyVlook(item, InRange As Object, FromCol As Integer) Dim oService As Object oService = createUnoService("com.sun.star.sheet.FunctionAccess") @@ -57,7 +57,7 @@ MyVlook = oService.callFunction("VLOOKUP",Array(item, InRange, FromCol, True)) End Function - +
oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" ) @@ -78,5 +78,8 @@ FileOpenDialog=files(0) End Function +
+ +
diff --git a/source/text/sbasic/shared/calc_functions.xhp b/source/text/sbasic/shared/calc_functions.xhp new file mode 100644 index 0000000000..7f0169fd7a --- /dev/null +++ b/source/text/sbasic/shared/calc_functions.xhp @@ -0,0 +1,865 @@ + + + + + + + Calling Calc Functions in Macros + /text/sbasic/shared/calc_functions.xhp + + + + + calling Calc function;macros + macros;calling Calc function + createUNOservice function;calling Calc function + API;addin.Analysis + +

Calling Calc Functions

+In addition to the native BASIC functions, you can call Calc functions in your macros and scripts. +

Calling Internal Calc functions in Basic

+ Use the CreateUNOService function to access the com.sun.star.sheet.FunctionAccess service. + + +

Calling Add-In Calc Functions in BASIC

+The Calc Add-In functions are in service com.sun.star.sheet.addin.Analysis. + + +REM Example calling Addin function SQRTPI +Function MySQRTPI(arg as double) as double + Dim oService as Object + oService = createUNOService("com.sun.star.sheet.addin.Analysis") + MySQRTPI = oService.getSqrtPi(arg) +End Function + + + + + + Calc Function name + + + UNO service name + + + + + ACCRINT + + + com.sun.star.sheet.addin.Analysis.getAccrint + + + + + ACCRINTM + + + com.sun.star.sheet.addin.Analysis.getAccrintm + + + + + AMORDEGRC + + + com.sun.star.sheet.addin.Analysis.getAmordegrc + + + + + AMORLINC + + + com.sun.star.sheet.addin.Analysis.getAmorlinc + + + + + BESSELI + + + com.sun.star.sheet.addin.Analysis.getBesseli + + + + + BESSELJ + + + com.sun.star.sheet.addin.Analysis.getBesselj + + + + + BESSELK + + + com.sun.star.sheet.addin.Analysis.getBesselk + + + + + BESSELY + + + com.sun.star.sheet.addin.Analysis.getBessely + + + + + BIN2DEC + + + com.sun.star.sheet.addin.Analysis.getBin2Dec + + + + + BIN2HEX + + + com.sun.star.sheet.addin.Analysis.getBin2Hex + + + + + BIN2OCT + + + com.sun.star.sheet.addin.Analysis.getBin2Oct + + + + + COMPLEX + + + com.sun.star.sheet.addin.Analysis.getComplex + + + + + CONVERT + + + com.sun.star.sheet.addin.Analysis.getConvert + + + + + COUPDAYBS + + + com.sun.star.sheet.addin.Analysis.getCoupdaybs + + + + + COUPDAYS + + + com.sun.star.sheet.addin.Analysis.getCoupdays + + + + + COUPDAYSNC + + + com.sun.star.sheet.addin.Analysis.getCoupdaysnc + + + + + COUPNCD + + + com.sun.star.sheet.addin.Analysis.getCoupncd + + + + + COUPNUM + + + com.sun.star.sheet.addin.Analysis.getCoupnum + + + + + COUPPCD + + + com.sun.star.sheet.addin.Analysis.getCouppcd + + + + + CUMIPMT + + + com.sun.star.sheet.addin.Analysis.getCumipmt + + + + + CUMPRINC + + + com.sun.star.sheet.addin.Analysis.getCumprinc + + + + + DEC2BIN + + + com.sun.star.sheet.addin.Analysis.getDec2Bin + + + + + DEC2HEX + + + com.sun.star.sheet.addin.Analysis.getDec2Hex + + + + + DEC2OCT + + + com.sun.star.sheet.addin.Analysis.getDec2Oct + + + + + DELTA + + + com.sun.star.sheet.addin.Analysis.getDelta + + + + + DISC + + + com.sun.star.sheet.addin.Analysis.getDisc + + + + + DOLLARDE + + + com.sun.star.sheet.addin.Analysis.getDollarde + + + + + DOLLARFR + + + com.sun.star.sheet.addin.Analysis.getDollarfr + + + + + DURATION + + + com.sun.star.sheet.addin.Analysis.getDuration + + + + + EDATE + + + com.sun.star.sheet.addin.Analysis.getEdate + + + + + EFFECT + + + com.sun.star.sheet.addin.Analysis.getEffect + + + + + EOMONTH + + + com.sun.star.sheet.addin.Analysis.getEomonth + + + + + ERF + + + com.sun.star.sheet.addin.Analysis.getErf + + + + + ERFC + + + com.sun.star.sheet.addin.Analysis.getErfc + + + + + FACTDOUBLE + + + com.sun.star.sheet.addin.Analysis.getFactdouble + + + + + FVSCHEDULE + + + com.sun.star.sheet.addin.Analysis.getFvschedule + + + + + GCD + + + com.sun.star.sheet.addin.Analysis.getGcd + + + + + GESTEP + + + com.sun.star.sheet.addin.Analysis.getGestep + + + + + HEX2BIN + + + com.sun.star.sheet.addin.Analysis.getHex2Bin + + + + + HEX2DEC + + + com.sun.star.sheet.addin.Analysis.getHex2Dec + + + + + HEX2OCT + + + com.sun.star.sheet.addin.Analysis.getHex2Oct + + + + + IMABS + + + com.sun.star.sheet.addin.Analysis.getImabs + + + + + IMAGINARY + + + com.sun.star.sheet.addin.Analysis.getImaginary + + + + + IMARGUMENT + + + com.sun.star.sheet.addin.Analysis.getImargument + + + + + IMCONJUGATE + + + com.sun.star.sheet.addin.Analysis.getImconjugate + + + + + IMCOS + + + com.sun.star.sheet.addin.Analysis.getImcos + + + + + IMCOSH + + + com.sun.star.sheet.addin.Analysis.getImcosh + + + + + IMCOT + + + com.sun.star.sheet.addin.Analysis.getImcot + + + + + IMCSC + + + com.sun.star.sheet.addin.Analysis.getImcsc + + + + + IMCSCH + + + com.sun.star.sheet.addin.Analysis.getImcsch + + + + + IMDIV + + + com.sun.star.sheet.addin.Analysis.getImdiv + + + + + IMEXP + + + com.sun.star.sheet.addin.Analysis.getImexp + + + + + IMLN + + + com.sun.star.sheet.addin.Analysis.getImln + + + + + IMLOG10 + + + com.sun.star.sheet.addin.Analysis.getImlog10 + + + + + IMLOG2 + + + com.sun.star.sheet.addin.Analysis.getImlog2 + + + + + IMPOWER + + + com.sun.star.sheet.addin.Analysis.getImpower + + + + + IMPRODUCT + + + com.sun.star.sheet.addin.Analysis.getImproduct + + + + + IMREAL + + + com.sun.star.sheet.addin.Analysis.getImreal + + + + + IMSEC + + + com.sun.star.sheet.addin.Analysis.getImsec + + + + + IMSECH + + + com.sun.star.sheet.addin.Analysis.getImsech + + + + + Imsin + + + com.sun.star.sheet.addin.Analysis.getImsin + + + + + IMSINH + + + com.sun.star.sheet.addin.Analysis.getImsinh + + + + + IMSQRT + + + com.sun.star.sheet.addin.Analysis.getImsqrt + + + + + IMSUB + + + com.sun.star.sheet.addin.Analysis.getImsub + + + + + IMSUM + + + com.sun.star.sheet.addin.Analysis.getImsum + + + + + IMTAN + + + com.sun.star.sheet.addin.Analysis.getImtan + + + + + INTRATE + + + com.sun.star.sheet.addin.Analysis.getIntrate + + + + + ISEVEN + + + com.sun.star.sheet.addin.Analysis.getIseven + + + + + ISODD + + + com.sun.star.sheet.addin.Analysis.getIsodd + + + + + LCM + + + com.sun.star.sheet.addin.Analysis.getLcm + + + + + MDURATION + + + com.sun.star.sheet.addin.Analysis.getMduration + + + + + MROUND + + + com.sun.star.sheet.addin.Analysis.getMround + + + + + MULTINOMIAL + + + com.sun.star.sheet.addin.Analysis.getMultinomial + + + + + NETWORKDAYS + + + com.sun.star.sheet.addin.Analysis.getNetworkdays + + + + + NOMINAL + + + com.sun.star.sheet.addin.Analysis.getNominal + + + + + OCT2BIN + + + com.sun.star.sheet.addin.Analysis.getOct2Bin + + + + + OCT2DEC + + + com.sun.star.sheet.addin.Analysis.getOct2Dec + + + + + OCT2HEX + + + com.sun.star.sheet.addin.Analysis.getOct2Hex + + + + + ODDFPRICE + + + com.sun.star.sheet.addin.Analysis.getOddfprice + + + + + ODDFYIELD + + + com.sun.star.sheet.addin.Analysis.getOddfyield + + + + + ODDLPRICE + + + com.sun.star.sheet.addin.Analysis.getOddlprice + + + + + ODDLYIELD + + + com.sun.star.sheet.addin.Analysis.getOddlyield + + + + + PRICE + + + com.sun.star.sheet.addin.Analysis.getPrice + + + + + PRICEDISC + + + com.sun.star.sheet.addin.Analysis.getPricedisc + + + + + PRICEMAT + + + com.sun.star.sheet.addin.Analysis.getPricemat + + + + + QUOTIENT + + + com.sun.star.sheet.addin.Analysis.getQuotient + + + + + RANDBETWEEN + + + com.sun.star.sheet.addin.Analysis.getRandbetween + + + + + RECEIVED + + + com.sun.star.sheet.addin.Analysis.getReceived + + + + + SERIESSUM + + + com.sun.star.sheet.addin.Analysis.getSeriessum + + + + + SQRTPI + + + com.sun.star.sheet.addin.Analysis.getSqrtpi + + + + + TBILLEQ + + + com.sun.star.sheet.addin.Analysis.getTbilleq + + + + + TBILLPRICE + + + com.sun.star.sheet.addin.Analysis.getTbillprice + + + + + TBILLYIELD + + + com.sun.star.sheet.addin.Analysis.getTbillyield + + + + + WEEKNUM + + + com.sun.star.sheet.addin.Analysis.getWeeknum + + + + + WORKDAY + + + com.sun.star.sheet.addin.Analysis.getWorkday + + + + + XIRR + + + com.sun.star.sheet.addin.Analysis.getXirr + + + + + XNPV + + + com.sun.star.sheet.addin.Analysis.getXnpv + + + + + YEARFRAC + + + com.sun.star.sheet.addin.Analysis.getYearfrac + + + + + YIELD + + + com.sun.star.sheet.addin.Analysis.getYield + + + + + YIELDDISC + + + com.sun.star.sheet.addin.Analysis.getYielddisc + + + + + YIELDMAT + + + com.sun.star.sheet.addin.Analysis.getYieldmat + + +
+
+ +
+ +
diff --git a/source/text/scalc/01/04060115.xhp b/source/text/scalc/01/04060115.xhp index f45c7a8032..1e16911f34 100644 --- a/source/text/scalc/01/04060115.xhp +++ b/source/text/scalc/01/04060115.xhp @@ -32,9 +32,8 @@ analysis functions
- -Add-in Functions, List of Analysis Functions Part One - +

Add-in Functions, List of Analysis Functions Part One

+The Add-in functions are supplied by the UNO com.sun.star.sheet.addin.Analysis service.
@@ -47,7 +46,7 @@ -BESSELI +

BESSELI

Calculates the modified Bessel function of the first kind In(x). @@ -64,7 +63,7 @@
-BESSELJ +

BESSELJ

Calculates the Bessel function of the first kind Jn(x) (cylinder function). @@ -81,7 +80,7 @@
-BESSELK +

BESSELK

Calculates the modified Bessel function of the second kind Kn(x). @@ -98,7 +97,7 @@
-BESSELY +

BESSELY

Calculates the Bessel function of the second kind Yn(x). @@ -120,7 +119,7 @@ mw added one entry -BIN2DEC +

BIN2DEC

The result is the decimal number for the binary number entered. @@ -139,7 +138,7 @@ mw added one entry -BIN2HEX +

BIN2HEX

The result is the hexadecimal number for the binary number entered. @@ -159,7 +158,7 @@ mw added one entry -BIN2OCT +

BIN2OCT

The result is the octal number for the binary number entered. @@ -179,7 +178,7 @@ mw added one entry -DELTA +

DELTA

The result is TRUE (1) if both numbers, which are delivered as an argument, are equal, otherwise it is FALSE (0). @@ -197,7 +196,7 @@ mw added one entry -DEC2BIN +

DEC2BIN

The result is the binary number for the decimal number entered between -512 and 511. @@ -217,7 +216,7 @@ mw added one entr -DEC2HEX +

DEC2HEX

The result is the hexadecimal number for the decimal number entered. @@ -237,7 +236,7 @@ mw added one entr -DEC2OCT +

DEC2OCT

The result is the octal number for the decimal number entered. @@ -257,7 +256,7 @@ mw added one entr -ERF +

ERF

Returns values of the Gaussian error integral. @@ -277,7 +276,7 @@ -ERF.PRECISE +

ERF.PRECISE

Returns values of the Gaussian error integral between 0 and the given limit. @@ -295,7 +294,7 @@ -ERFC +

ERFC

Returns complementary values of the Gaussian error integral between x and infinity. @@ -313,7 +312,7 @@ -ERFC.PRECISE +

ERFC.PRECISE

Returns complementary values of the Gaussian error integral between x and infinity. @@ -332,7 +331,7 @@ mw added one entry -GESTEP +

GESTEP

The result is 1 if Number is greater than or equal to Step. @@ -350,7 +349,7 @@ mw added one entry -HEX2BIN +

HEX2BIN

The result is the binary number for the hexadecimal number entered. @@ -370,7 +369,7 @@ mw added one entry -HEX2DEC +

HEX2DEC

The result is the decimal number for the hexadecimal number entered. @@ -389,7 +388,7 @@ mw added one entry -HEX2OCT +

HEX2OCT

The result is the octal number for the hexadecimal number entered. diff --git a/source/text/scalc/01/04060116.xhp b/source/text/scalc/01/04060116.xhp index 9316d93204..4f9abb4227 100644 --- a/source/text/scalc/01/04060116.xhp +++ b/source/text/scalc/01/04060116.xhp @@ -31,6 +31,7 @@ complex numbers in analysis functions

Add-in Functions, List of Analysis Functions Part Two

+The Add-in functions are supplied by the UNO com.sun.star.sheet.addin.Analysis service.
-- cgit