GNOME Bugzilla – Bug 597849
Adapter plugin to load genuine Excel addins (XLLs)
Last modified: 2010-02-02 19:39:15 UTC
Created attachment 145066 [details] [review] gnumeric+goffice patch to add proposed functionality. I developed a patch against the currrent GIT head (at the time of writing, 2009-10-08) that enables Gnumeric to load genuine Excel plugins (XLLs). The module can load XLLs that register in Excel via the Excel4 or the Excel4v interface as described in the Excel SDK (version 5, for instance). It only works for worksheet functions which only take arguments of Excel SDK type 'P' or 'R' (XLOPER), and return an argument of the same type. The adapter module is called excelplugins and searches its own plugin directory, and recursively all directories below, for any shared module that it can load, and that provides the xlAutoOpen initialisation function, as is customary for XLLs. The new module has two potential uses: 1) Users who have their own XLL development code can recompile it under, say, Linux into a native shared object, but without any interface changes. The Linux Gnumeric plugin (excelplugins) then loads it if it is found under the excelplugins directory. Of course, the directory that is searched could be changed. The code is reasonably well tested on Linux in the above described circumstances. 2) For the Windows build, the code is meant to be able to load existing XLLs as long as they register via Excel4/Excel4v, provide xlAutoOpen, and only exchange data via XLOPER type ('P' or 'R', but note that worksheet references etc are not supported). The Windows code is as yet untested, but due to the fact that almost all of the code is completely generic, it is unlikely that many bugs will surface during the testing of the Windows code, which I am working on. The patch consists of two parts: a small (~10 lines) patch to GOFFICE, and a larger patch (~122k) patch to GNUMERIC. Since only one attachment is permitted, I concatenated them. The main part of the patch is the file gnumeric/plugins/excelplugins/excelplugins.c which contains large amounts of documentation about the methodology.
Created attachment 145164 [details] [review] gnumeric+goffice patch to add proposed functionality.
Created attachment 145194 [details] [review] Updated patch that is now also working ant tested on WIN32 I have now been able to test the proposed code with a WIN32 build (cross-built on Linux) running on native Windows XP. Only minor changes were required to make it work. This means that this code is now ready for release. It may still be desirable to add other loading locations - at the moment, the plugin only loads XLLs that are in the same directory as the excelplugins module, or in any subdirectory. This should be straightforward for anyone who wishes to do it since the search routine is cleanly separated from the load mechanism.
goffice portion reviewed and committed.
Created attachment 145212 [details] [review] gnumeric patch for XLL loading - this version uses GnmFuncEvalInfo pointer to determine which XLL function to call at run time. The code has been simplified to use the GnmEvalFunctionInfo * ei pointer provided at run time to look up the name, ei->func_call->func->name, in a map that is created at time of go_plugin_init(), to determine which XLL function to call. This obviates the need for generation of executable code at run time by the aid of mmap/VirtualProtect. The new code is free of any techniques that could pose any portability issue. The new patch is only for Gnumeric since Jody Goldberg confirmed that the Goffice part of the patch is already committed at the time of writing.
Created attachment 149719 [details] [review] Update of patch to accommodate changes to code base since last submission.
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.