Hi,

Gonzalo Diethelm wrote:
Hello,

I am a TOTAL newbie (read: never done anything) when it comes to
developing for OpenOffice.org. But I have done some development of MS
Excel add-ins in C, which end up being registered as additional
functions directly callable from an Excel spreadsheet. So, to make my
question clearer, let's say I have a pure C (not C++) module with one
public function:

  int get_easter(int year, int* month, int* day);

Given a year (i.e. 2007), it will put into month and day the date for
Easter that year (i.e. month == 4, day == 8), and return something
useful (say, the int value 20070408). The question is: how can I make
this function available in Spreadsheet, so that I can write in any given
cell:

  =GetEaster(2007)

and the function will return an Spreadsheet date value indicating
"8/Apr/2007"? Notice this entails several things:

      * Registering the GetEaster() function so that Spreadsheet knows
        about it, and knows what glue code (my C function) to call.
      * Converting parameters when appropriate (2007 in this case).
      * Calling the implementation function get_easter() with
        appropriate parameters.
      * Build a Date value with the result.
      * Tell Spreadsheet about that resulting date.
      * Hopefully, this should work under both Linux and Win32.


I know this could be done inside Spreadsheet for the case of Easter, but
this is just an example; the functions I have implemented are much more
complex than that. If anybody can point me to a manual, sample, tutorial
or any other resource, showing how this is handled correctly in
Spreadsheet, that would be grand.

Thanks and best regards,

In case of your requirement (library with one pure C function) i would simply use the uno-skeletonmaker coming with the OO.org 2.1 SDK to create a working C++ code skeleton based on your own new IDL definition representing your new Add-In function.

for example:
module mytestaddin {
interface XEasterOrSomethingelse {
long getEaster([in] long year, [in] long month, [in] long day); // throw maye an InvalidArgumentException
};

service EasterOrSomehtingelse : XEasterOrSomethingelse;

}; // end module


Note: you should use a useful module structure and should have one file per IDL definition!

idlc -I../../../idl XEasterOrSomethingelse.idl EasterOrSomethingelse.idl

regmerge addinskeleton.rdb /UCR XEasterOrSomethingelse.urd EasterOrSomethingelse.urd

uno-skeletonmaker.exe -env:UNO_INIFILENAME="file:///<office_home>/program/uno.ini" calc-add-in --cpp -l addinskeleton.rdb -tmytestaddin.EasterOrSomethingelse -o <path_to_output_diretory> -n TestEasterCalcAddInImpl

TestEasterCalcAddInImpl -> name of the C++ implementation class


The generated skeleton includes everything necessary for your add-in function. You can simply call your own C function in the method body of getEaster. The easiest way to build the component is to link your own C library into the component library.

With the introduction of the uno-skeletonmaker we have also introduced new xcu files for add-in support. So you need a xcu file as well because the implementation does use it.

Take also a look into the NetBeans Integration (http://wiki.services.openoffice.org/wiki/OpenOffice_NetBeans_Integration) where you will find some more info of the necessary files for a complete add-in extensions package. The integration use the skeletonmaker as well. C++ will be supported in the future.

I will create a C++ tutorial asap. If you need a working SDK example please let me know and i will send you a simple example which you can adapt to your needs.

Juergen












---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to