yCgrA‖

x9hSr‖Add-in for Programming in LibreOfficeDev Calc

warning

7vLLV‖The method of extending Calc by Add-Ins that is described in the following is outdated. The interfaces are still valid and supported, to ensure compatibility with existing Add-Ins, but for programming new Add-Ins you should use the new API functions.


aR3NC‖LibreOfficeDev Calc can be expanded by Add-Ins, which are external programming modules providing additional functions for working with spreadsheets. These are listed in the Function Wizard in the Add-In category. If you would like to program an Add-In yourself, you can learn here which functions must be exported by the so that the Add-In can be successfully attached.

qyzrA‖LibreOfficeDev searches the Add-in folder defined in the configuration for a suitable . To be recognized by LibreOfficeDev, the must have certain properties, as explained in the following. This information allows you to program your own Add-In for Function Wizard of LibreOfficeDev Calc.

CAC5V‖The Add-In Concept

qYPz8‖Each Add-In library provides several functions. Some functions are used for administrative purposes. You can choose almost any name for your own functions. However, they must also follow certain rules regarding parameter passing. The exact naming and calling conventions vary for different platforms.

CYHXE‖Functions of

Q8NDw‖At a minimum, the administrative functions GetFunctionCount and GetFunctionData must exist. Using these, the functions as well as parameter types and return values can be determined. As return values, the Double and String types are supported. As parameters, additionally the cell areas Double Array, String Array, and Cell Array are supported.

ECARD‖Parameters are passed using references. Therefore, a change of these values is basically possible. However, this is not supported in LibreOfficeDev Calc because it does not make sense within spreadsheets.

GFgFB‖Libraries can be reloaded during runtime and their contents can be analyzed by the administrative functions. For each function, information is available about count and type of parameters, internal and external function names and an administrative number.

5F3BX‖The functions are called synchronously and return their results immediately. Real time functions (asynchronous functions) are also possible; however, they are not explained in detail because of their complexity.

eDr3V‖General information about the interface

a52J5‖The maximum number of parameters in an Add-In function attached to LibreOfficeDev Calc is 16: one return value and a maximum of 15 function input parameters.

mbiCk‖The data types are defined as follows:

zw8Fb‖Data types

hrud4‖Definition

CALLTYPE

feYP7‖Under Windows: FAR PASCAL (_far _pascal)

WzRFE‖Other: default (operating system specific default)

USHORT

Dp239‖2 Byte unsigned Integer

DOUBLE

kEyLT‖8 byte platform-dependent format

Paramtype

UD5uA‖Platform-dependent like int

2vhRi‖PTR_DOUBLE =0 pointer to a double

xAFip‖PTR_STRING =1 pointer to a zero-terminated string

3sEgK‖PTR_DOUBLE_ARR =2 pointer to a double array

Gur9C‖PTR_STRING_ARR =3 pointer to a string array

sCejE‖PTR_CELL_ARR =4 pointer to a cell array

hhKaz‖NONE =5


rhfoh‖ functions

wVc9G‖Following you will find a description of those functions, which are called at the .

kDo37‖For all functions, the following applies:

void CALLTYPE fn(out, in1, in2, ...)

QZ7q4‖Output: Resulting value

kqhgX‖Input: Any number of types (double&, char*, double*, char**, Cell area), where the Cell area is an array of types double array, string array, or cell array.

GetFunctionCount()

QCZLG‖Returns the number of functions without the management functions of the reference parameter. Each function has a unique number between 0 and nCount-1. This number will be needed for the GetFunctionData and GetParameterDescription functions later.

w5DKB‖Syntax

void CALLTYPE GetFunctionCount(USHORT& nCount)

deW2z‖Parameter

USHORT &nCount:

AGnQd‖Output: Reference to a variable, which is supposed to contain the number of Add-In functions. For example: If the Add-In provides 5 functions for LibreOfficeDev Calc, then nCount=5.

GetFunctionData()

MMvZL‖Determines all the important information about an Add-In function.

fqYgr‖Syntax

void CALLTYPE GetFunctionData(USHORT& nNo, char* pFuncName, USHORT& nParamCount, Paramtype* peType, char* pInternalName)

P63DF‖Parameter

USHORT& nNo:

W4Bdb‖Input: Function number between 0 and nCount-1, inclusively.

char* pFuncName:

CSBYk‖Output: Function name as seen by the programmer, as it is named in the . This name does not determine the name used in the Function Wizard.

USHORT& nParamCount:

6yGps‖Output: Number of parameters in AddIn function. This number must be greater than 0, because there is always a result value; the maximum value is 16.

Paramtype* peType:

TjFBR‖Output: Pointer to an array of exactly 16 variables of type Paramtype. The first nParamCount entries are filled with the suitable type of parameter.

char* pInternalName:

YNrEv‖Output: Function name as seen by the user, as it appears in the Function Wizard. May contain umlauts.

rcNLZ‖The pFuncName and pInternalName parameters are char arrays, which are implemented with size 256 in LibreOfficeDev Calc.

GetParameterDescription()

sF27k‖Provides a brief description of the Add-In function and its parameters. As an option, this function can be used to show a function and parameter description in the Function Wizard.

WCRmw‖Syntax

pxoCN‖void CALLTYPE GetParameterDescription(USHORT& nNo, USHORT& nParam, char* pName, char* pDesc)

99Z6E‖Parameter

USHORT& nNo:

agM3b‖Input: Number of the function in the library; between 0 and nCount-1.

USHORT& nParam:

QHn87‖Input: Indicates, for which parameter the description is provided; parameters start at 1. If nParam is 0, the description itself is supposed to be provided in pDesc; in this case, pName does not have any meaning.

char* pName:

Eq6cW‖Output: Takes up the parameter name or type, for example, the word "Number" or "String" or "Date", and so on. Implemented in LibreOfficeDev Calc as char[256].

char* pDesc:

yf6Eg‖Output: Takes up the description of the parameter, for example, "Value, at which the universe is to be calculated." Implemented in LibreOfficeDev Calc as char[256].

52p82‖pName and pDesc are char arrays; implemented in LibreOfficeDev Calc with size 256. Please note that the space available in the Function Wizard is limited and that the 256 characters cannot be fully used.

gmvAA‖Cell areas

DodDw‖The following tables contain information about which data structures must be provided by an external program module in order to pass cell areas. LibreOfficeDev Calc distinguishes between three different arrays, depending on the data type.

UEfa5‖Double Array

ELgCT‖As a parameter, a cell area with values of the Number/Double type can be passed. A double array in LibreOfficeDev Calc is defined as follows:

8FA5p‖Offset

zS5BL‖Name

3dyGm‖Description

0

auDAv‖Col1

BLWZ3‖Column number in the upper-left corner of the cell area. Numbering starts at 0.

2

66LM7‖Row1

iPM7A‖Row number in the upper-left corner of the cell area; numbering starts at 0.

4

XMBCD‖Tab1

dwbQd‖Table number in the upper-left corner of the cell area; numbering starts at 0.

6

wuFWu‖Col2

pvAod‖Column number in the lower-right corner of the cell area. Numbering starts at 0.

8

CV3G6‖Row2

BVLeE‖Row number in the lower-right corner of the cell area; numbering starts at 0.

10

2uuuR‖Tab2

ehcuo‖Table number in the lower-right corner of the cell area; numbering starts at 0.

12

So9De‖Count

uT77x‖Number of the following elements. Empty cells are not counted or passed.

14

XVqa3‖Col

v4DFD‖Column number of the element. Numbering starts at 0.

16

sBjP5‖Row

pXswN‖Row number of the element; numbering starts at 0.

18

XDCCc‖Tab

G8ZMG‖Table number of the element; numbering starts at 0.

20

GmDaJ‖Error

5uRBa‖Error number, where the value 0 is defined as "no error." If the element comes from a formula cell the error value is determined by the formula.

22

ppLAh‖Value

K8DZU‖8 byte IEEE variable of type double/floating point

30

...

ghv37‖Next element


n6G8z‖String Array

iSVvD‖A cell area, which contains values of data type Text and is passed as a string array. A string array in LibreOfficeDev Calc is defined as follows:

yG2ic‖Offset

ehB7k‖Name

iRPCq‖Description

0

q4Dcs‖Col1

c7yR8‖Column number in the upper-left corner of the cell area. Numbering starts at 0.

2

xKiav‖Row1

vVRTp‖Row number in the upper-left corner of the cell area; numbering starts at 0.

4

5rPxH‖Tab1

3kAmA‖Table number in the upper-left corner of the cell area; numbering starts at 0.

6

kvTCA‖Col2

PNYu9‖Column number in the lower-right corner of the cell area. Numbering starts at 0.

8

QX9SD‖Row2

BXXCY‖Row number in the lower-right corner of the cell area; numbering starts at 0.

10

SGAuU‖Tab2

BGCB4‖Table number in the lower-right corner of the cell area; numbering starts at 0.

12

yAmQX‖Count

muWyx‖Number of the following elements. Empty cells are not counted or passed.

14

Wz3Kg‖Col

859tw‖Column number of the element. Numbering starts at 0.

16

eXyU8‖Row

roveF‖Row number of the element; numbering starts at 0.

18

8ZbQg‖Tab

4DfHd‖Table number of the element; numbering starts at 0.

20

M8obt‖Error

ARisE‖Error number, where the value 0 is defined as "no error." If the element comes from a formula cell the error value is determined by the formula.

22

kJBfR‖Len

XtnX2‖Length of the following string, including closing zero byte. If the length including closing zero byte equals an odd value a second zero byte is added to the string so that an even value is achieved. Therefore, Len is calculated using ((StrLen+2)&~1).

24

T3mvx‖String

RcaZn‖String with closing zero byte

24+Len

...

TFDYs‖Next element


7rrRN‖Cell Array

fCbXc‖Cell arrays are used to call cell areas containing text as well as numbers. A cell array in LibreOfficeDev Calc is defined as follows:

QiX6Y‖Offset

6oQJ6‖Name

D3xXV‖Description

0

Zty8q‖Col1

KyDw8‖Column number in the upper-left corner of the cell area. Numbering starts at 0.

2

RLggK‖Row1

r6G5T‖Row number in the upper-left corner of the cell area; numbering starts at 0.

4

TJRib‖Tab1

QmEhv‖Table number in the upper-left corner of the cell area; numbering starts at 0.

6

8BkPM‖Col2

mmA7K‖Column number in the lower-right corner of the cell area. Numbering starts at 0.

8

Zo3Z5‖Row2

Mj3nh‖Row number in the lower-right corner of the cell area; numbering starts at 0.

10

XRoJc‖Tab2

mfutR‖Table number in the lower-right corner of the cell area; numbering starts at 0.

12

7UYg2‖Count

BFhBu‖Number of the following elements. Empty cells are not counted or passed.

14

j76c8‖Col

MtDMD‖Column number of the element. Numbering starts at 0.

16

Ukqqs‖Row

4T7Bh‖Row number of the element; numbering starts at 0.

18

VGqMb‖Tab

qQdVP‖Table number of the element; numbering starts at 0.

20

GCRmy‖Error

EBD5G‖Error number, where the value 0 is defined as "no error." If the element comes from a formula cell the error value is determined by the formula.

22

EPbYb‖Type

CHk6f‖Type of cell content, 0 == Double, 1 == String

24

ufneM‖Value or Len

4EsF8‖If type == 0: 8 byte IEEE variable of type double/floating point

DALxE‖If type == 1: Length of the following string, including closing zero byte. If the length including closing zero byte equals an odd value a second zero byte is added to the string so that an even value is achieved. Therefore, Len is calculated using ((StrLen+2)&~1).

36VSE‖26 if type==1

F2WH5‖String

PBZaj‖If type == 1: String with closing zero byte

Bzn3r‖32 or 26+Len

VDmRK‖...

GBLhy‖Next element