Description: Enable spreadsheet support
 This patch does 4 things:
 - make sure the java package is loaded if available (the field "loaded" does
   not seem to be very reliable, so force package loading if autoload is
   enabled)
 - add UNO and JXL interfaces the java classpath if available (auto-detection
   by chk_spreadsheet_support does not work well)
 - let chk_spreadsheet_support auto-detect other JARs from /usr/share/java and
   /usr/local/share/java in case the user installed them manually
 - do not delete PKG_ADD in post_install.m, we need it!
Author: Sébastien Villemot <sebastien.villemot@ens.fr>
Forwarded: not-needed
Last-Update: 2012-06-09
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/PKG_ADD
+++ b/PKG_ADD
@@ -4,10 +4,35 @@
 javapkgind = find (cellfun(@(x) strcmp(x.name, "java"), pkglist), 1, "first");
 if ~isempty (javapkgind)
   javapkg = pkglist{javapkgind};
-  if javapkg.loaded
-    # Assume jar files are in /lib/java and let chk_spreadsheet_support sort it out
-    libdir = octave_config_info("libdir");
-    spr_status = chk_spreadsheet_support ([libdir "/java"]);
+  if exist (javapkg.dir, "dir") && (javapkg.autoload || javapkg.loaded)
+      ## Force loading of java package if autoload=yes but loaded=no
+      if ~javapkg.loaded
+          pkg load java
+      endif
+
+      ## Add UNO support if present
+      if exist ("/usr/share/libreoffice/program", "dir") ...
+              && exist ("/usr/share/libreoffice/program/classes/unoil.jar", "file") ...
+              && exist ("/usr/share/java/jurt.jar", "file") ...
+              && exist ("/usr/share/java/juh.jar", "file") ...
+              && exist ("/usr/share/java/unoloader.jar", "file") ...
+              && exist ("/usr/share/java/ridl.jar", "file")
+          javaaddpath /usr/share/libreoffice/program
+          javaaddpath /usr/share/libreoffice/program/classes/unoil.jar
+          javaaddpath /usr/share/java/jurt.jar
+          javaaddpath /usr/share/java/juh.jar
+          javaaddpath /usr/share/java/unoloader.jar
+          javaaddpath /usr/share/java/ridl.jar
+      endif
+
+      ## Add JXL support if present
+      if exist ("/usr/share/java/jxl.jar", "file")
+          javaaddpath /usr/share/java/jxl.jar
+      endif
+
+      ## Auto-detect other interfaces possibly installed
+      chk_spreadsheet_support ("/usr/share/java");
+      chk_spreadsheet_support ("/usr/local/share/java");
   endif
 endif
-clear javapkgind javapkg libdir spr_status pkglist ;
\ No newline at end of file
+clear javapkgind javapkg pkglist ;
--- a/post_install.m
+++ /dev/null
@@ -1,14 +0,0 @@
-## this function removes the PKG_ADD script from the .oct directory of the io
-## package after installation. The reason is that PKG_ADD calls chk_spreadsheet_support
-## which belongs to the io package itself. While it is ok when called from the
-## .m directory (since chk_spreadsheet_support is there), when called from the
-## .oct directory it fails since the package hasn't been loaded yet
-
-function post_install (desc)
-  file = cstrcat (desc.archprefix, filesep, octave_config_info ("canonical_host_type"),
-                  "-", octave_config_info ("api_version"), filesep, "PKG_ADD");
-  [err, msg] = unlink (file);
-  if (err)
-    warning ("Unable to remove PKG_ADD: %S", msg);
-  endif
-endfunction
