On 5/27/05, Ary Junior <[EMAIL PROTECTED]> wrote: > Hi Kohei Yoshida, if I try to declare the date argument date as a > com.sun.star.util.Date like this: > > (In my .idl file) > string test(...[in] com::sun::start::util::Date date, ...);
This should probably be string test(...[in] double date, ...); > (In my Java class implementation) > public String test(... com.sun.star.util.Date date, ...) {... This should be public String test(... double date, ...) {... > > My function don't appear in the Calc Functions Window. If I change to > "double" or "string" type, it works. Why? Sorry, I guess I mis-understood your question, so let's disregard my first advice. It was obviously the wrong advice. Let's send it into oblivion. Now, as Niklas already pointed out, a date value is internally just a double, so in your function declaration the "Date" argument should be declared a "double" type. So, inside your Java program, the date value should get translated into a double value. Now, as Niklas said, a date value is just a number of days since the "NullDate", and this "NullDate" thingy is not guaranteed to be a constant forever between different versions of OO.o. So, you need to first get this value from your com.sun.star.sheet.SpreadsheetDocument object, which holds this NullDate as one of its properties. Now, to calculate the year, month, or day of a date value which is now a double type, you need to use Calc's builtin functions such as YEAR, MONTH, and DAY. To do that you need to create a com.sun.star.sheet.FunctionAccess object, and query its interface com.sun.star.sheet.XFunctionAccess in order to call its member function "callFunction" - the gateway to Calc's builtin functions. But before you do anything with it, you first need to set the NullDate, which you just obtained from your SpreadsheetDocument object, into this FunctionAccess object as its property value. Then use the built-in functions via "callFunction" for further processing of the date value. Example code: Assume that: - Varialbe xFA holds the XFunctionAccess interface (NullDate already inserted) - Variable fDate holds the date as a double value Object[] aArg = new Object[1]; aArg[0] = new Double( fDate ); double year = Double.parseDouble( xFA.callFunction( "YEAR", aArg ).toString() ); double month = Double.parseDouble( xFA.callFunction( "MONTH", aArg ).toString() ); double day = Double.parseDouble( xFA.callFunction( "DAY", aArg ).toString() ); I hope my explanation is clear this time. Hope this helps. Kohei -- Kohei Yoshida OpenOffice.org Calc contributor http://kohei.us/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]