Hi Daniel,

Daniel Rentz schrieb:
Regina Henschel schrieb:
Hi,

I'm expanding LOGNORMDIST to the form it has in ODF spec. There it is
LOGNORMDIST( Number x [ ; Number m = 0 [ ; Number s = 1 [ ; Logical Cumulative = TRUE() ] ] ] )

Inside OOo it is no problem. But how to export it to Excel? Excel has 3 Parameters, no one optional.

For expanding NORMDIST I had only to set the last parameter to optional.
I found in xeformula.cxx how to add the last parameter, if missing. I have used
        case ocNormDist:
            if( nParamCount == 3 )
            {
                // NORMDIST function needs 4 parameters in Excel
                PrepareParam( rFuncData );
                AppendBoolToken( true );
                FinishParam( rFuncData );
            }
        break;
and that seems to work.

But for LOGNORMDIST there are different cases, for example

LOGNORMDIST(x;m;s;TRUE()) must become LOGNORMDIST(x;m;s). A parameter has to be removed.
LOGNORMDIST(x;m;s;FALSE()) does not exist in Excel.
LOGNORMDIST(x;m;s) Nothing to do, same as in Excel.
LOGNORMDIST(x;m) must become LOGNORMDIST(x;m;1).
LOGNORMDIST(x) must become LOGNORMDIST(x;0;1).

To increase the number of parameters, you can do something similar in XclExpFmlaCompImpl::AppendTrailingParam (untested code!):


         case ocLogNormDist:
             // LOGNORMDIST function needs 3 parameters in Excel
             switch( nParamCount )
             {
                 case 1:
                     PrepareParam( rFuncData );
                     AppendIntToken( 0 );
                     FinishParam( rFuncData );
                 // do not break, add next default parameter
                 case 2:
                     PrepareParam( rFuncData );
                     AppendIntToken( 1 );
                     FinishParam( rFuncData );
                 break;
             }
         break;



That works. When exporting to xls, I get the correct function structure, if there are one, two or three parameters in OOo. If there are four parameters in OOo, I get a =#NV entry in German Excel 2007. I think, the error message is correct, because the user has to know, that there has been something, which is unknown to Excel.

It is a concession that the missing parameters are added, although the user who will export to Excel-format should know, that Excel expects three parameters. Shouldn't we do the same for saving in old OOo formats, especially, when OOo3.0 is set in general to use ODF1.0-format? If you agree, that in cases saving to old OOo-formats the missing second and third parameters should be added, where is the place to do it?

To delete the 4th parameter, you can change the function info of this function. Go to xlformula.cxx and look for ocLogNormDist, change the line from

    { ocLogNormDist,        290,    3,  3,  V, { V }, 0, 0 },

to

    { ocLogNormDist,        290,    3,  3,  V, { V, V, V, C, I }, 0, 0 },


The "C" means that the 4th parameter is Calc-only and will be stripped on export. The trailing "I" is needed for some internal resons.

I have done first the changes in formulabase.cxx. That gives no error, but I see no effect, so I cannot say if it really works. Then I changed xlformula.cxx. That works, now the entry in the xls-file has three parameters in all cases.

I have rethought the problem. It seems no good idea to strip the fourth parameter. If it is stripped, there are no errors in Excel, but the cells might have different values than OOo, because in OOo you calculate the density function and in Excel the cumulative function is calculated. The user cannot notice, that the values are wrong, because there are no warnings. That is not good and we should not do it. There is no way to determine whether the forth parameter is true or false, because it might be no constant but a reference.

The same problem is, when saving to old OOo-formats. Using four parameters should give an error, when opening in old versions.

What do you think?

kind regards
Regina

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@sc.openoffice.org
For additional commands, e-mail: dev-h...@sc.openoffice.org

Reply via email to