Lvyue schrieb:
Hi, Daniel I have been struggling with the export part for several days,
but I can not make it work nicely.
I studied the codes, I think a document with this formula is very
similar to a document with external files, the difference is that we don't have anything to do with contents of the external file. but now, when doing export, the external file's information is not right, and I even can not exactly point out where the information is changed. :(
I wonder is there anything we lost in import?
for example, in void XclImpSupbook::CreateTables() or other place.
finally, I should say that I'm really unfamiliar with import and export,

Hello,

you are right, Excel uses its external linkage functionality to implement addins. So, what we need is when we first find a EUROCONVERT function, we have to create the related external data. In a debugger, you can try to figure out what happens, if you export a file with a single addin function, such as =HEX2DEC("ABC").

Have a look at sc/source/filter/excel/xeformula.cxx, function XclExpFmlaCompImpl::ProcessFunction(). This is the starting point for exporting every function in a formula. First, you see that we need an entry in the function info lists, due to the call to maFuncProv.GetFuncInfoFromOpCode( eOpCode );

So, add an entry into xlformula.cxx, into table saFuncTable_8 (we will implement BIFF8 only): { ocEuroConvert, 255, 4, 5, V, { E, V }, EXC_FUNCFLAG_EXPORTONLY, "EUROCONVERT" }

The 255 is the Excel function identifier for EXTERN.CALL, which tells Excel that the function is from an addin. The "4, 5" means minimum 4 parameters, maximum 5 parameters. Yes, one more than EUROCONVERT really expects, due to Excel's leading hidden tNameX token that contains the external link to the addin file EUROTOOL.XLA. V is for "value" return type. { E, V } contains the types of the parameters. E means "Excel only" - this parameter is not present in Calc (again, the hidden tNameX token). V means the next and all following parameters are values. EXC_FUNCFLAG_EXPORTONLY means the entry is only valid for the export filter. "EUROCONVERT" is the function name as used in the Excel file. This existing string will cause the export filter to handle this function similar to a VisualBasic macro call.

Next, processing of parameters is done in the while loop, which calls XclExpFmlaCompImpl::ProcessParam. There, the entry E from {E,V} in the function table triggers the line
  while( rFuncData.GetExpParamClass() == EXC_FUNC_PAR_EXCELONLY )
which calls
  XclExpFmlaCompImpl::AppendDefaultParam

There, you find a case ocExternal which is executed for "normal" addins such as the HEX2DEC from above. Here, add a new case for ocEuroConvert, and create and call a new function, e.g. "AppendEuroToolFuncToken". Implement it similar to "AppendAddInFuncToken". But instead of trying to get the Excel addin function name, we have to let the link manager create a new external link to the EUROTOOL.XLA:

void XclExpFmlaCompImpl::AppendEuroToolFuncToken( const XclExpExtFuncData& rExtFuncData, sal_uInt8 nExpClass, sal_uInt8 nSpaces )
{
    sal_uInt16 nExtSheet, nExtName;
if( mpLinkMgr && mpLinkMgr->InsertEuroTool( nExtSheet, nExtName, rExtFuncData.maFuncName ) )
        AppendNameXToken( nExtSheet, nExtName, nExpClass, nSpaces );
    else
        AppendMacroCallToken( rExtFuncData, nExpClass, nSpaces );
}


So we are assuming a new function "InsertEuroTool" in the XclExpLinkManager class, implemented in xelink.[hc]xx. Implement it similar to InsertAddIn. Some hints:

new function "InsertEuroTool" in the following classes:
XclExpLinkManager
XclExpLinkManagerImpl8
XclExpLinkManagerImpl5
XclExpLinkManagerImpl (abstract)
XclExpSupbookBuffer
XclExpExtNameBuffer


I think the creation of the link information will be another difficult part.


Please note that I am on vacation next week.
Regards
Daniel

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

Reply via email to