From: <prn...@us...> - 2011-04-04 21:05:13
|
Revision: 8194 http://octave.svn.sourceforge.net/octave/?rev=8194&view=rev Author: prnienhuis Date: 2011-04-04 21:05:07 +0000 (Mon, 04 Apr 2011) Log Message: ----------- New function for automated setting up, & troubleshooting, spreadsheet support. Added Paths: ----------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Added: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m (rev 0) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-04-04 21:05:07 UTC (rev 8194) @@ -0,0 +1,354 @@ +% Check Octave / Matlab environment for spreadsheet I/O support. +% +% usage: [ RETVAL ] = chk_spreadsheet_support ( [/PATH/TO/JARS], [,DEBUG_LEVEL] ) +% +% /PATH/TO/JARS = path (relative or absolute) to a subdirectory where +% java class libraries (.jar) for spreadsheet I/O reside +% DEBUG_LEVEL = integer between [0 (no output) .. 3 (full output] +% returns: +% RETVAL = 0 No spreadsheet I/O support found +% = 1 At least one spreadsheet I/O interface found +% +% CHK_SPREADSHEET_SUPPORT first check ActiveX (native MS-Excel); then +% Java JRE presence, then Java support (builtin/activated - Matlab or +% added tru octave-forge Java package (Octave); then check existing +% javaclasspath for Java class libraries (.jar) needed for spreadsheet +% I/O. +% If desired the relevant classes can be added to the dynamic +% javaclasspath. In that case the path name to the directory +% containing these classes should be specified as input argument +% with -TAKE NOTICE- /forward/ slashes. +% A second optional argument is the default debug level + +function [ retval ] = chk_spreadsheet_support (path_to_jars, dbug=0) + +% Copyright (C) 2009,2010,2011 Philip Nienhuis <prnienhuis at users.sf.net> +% +% This program is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Octave; see the file COPYING. If not, see +% <http://www.gnu.org/licenses/>. + +% Author: Philip Nienhuis +% Created 2010-11-03 +% Updates: +% 2010-12-19 Found that dom4j-1.6.1.jar is needed regardless of ML's dom4j +% presence in static classpath (ML r2007a) +% 2011-01-04 Adapted for general checks, debugging & set up, both Octave & ML +% 2011-04-04 Rebuilt into general setup/debug tool for spreadsheet I/O support +% and renamed chk_spreadsheet_support() +% + + jcp = []; retval = 0; + isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; + if (ispc), filesep = '\'; else, filesep = '/'; end %if + fprintf ('\n'); + + % Check if MS-Excel COM ActiveX server runs + if (dbug), fprintf ('Checking Excel/ActiveX/COM... '); end %if + try + app = actxserver ('Excel.application'); + % If we get here, the call succeeded & COM works. + xlsinterfaces.COM = 1; + % Close Excel to avoid zombie Excel invocation + app.Quit(); + delete(app); + if (dbug), fprintf ('OK.\n\n'); retval = 1; end %if + catch + % COM not supported + if (dbug), fprintf ('not working.\n\n'); end %if + end_try_catch + + % Check Java + if (dbug), fprintf ('Checking Java support...\n'); end %if + if (dbug > 1), fprintf (' 1. Checking Java JRE presence.... '); end %if + % Try if Java is installed at all + if (isOctave) + if (ispc) + jtst = (!system ('java -version 2> nul')); + else + jtst = (!system ('java -version 2> /dev/null')); + end %if + #else + # jtst = (version -java + end %if + if (~jtst) + error ("\nApparently no Java JRE installed."); + else + if (dbug > 1), fprintf ('OK, found one.\n'); end %if + end %if + if (dbug > 1), fprintf (' 2. Checking Octave Java support... '); end %if + try + jcp = javaclasspath ('-all'); # For Octave java pkg > 1.2.7 + if (isempty (jcp)), jcp = javaclasspath; endif # For Octave java pkg < 1.2.8 + % If we get here, at least Java works. + if (dbug > 1), fprintf ('Java package seems to work OK.\n'); end %if + % Now check for proper version + % (> 1.6.x.x) + jver = char (javaMethod ('getProperty', 'java.lang.System', 'java.version')); +# jver = char (java_invoke ('java.lang.System', 'getProperty', 'java.version')); + cjver = strsplit (jver, '.'); + if (sscanf (cjver{2}, '%d') < 6) + if (dbug) + fprintf (' Java version (%s) too old - you need at least Java 6 (v. 1.6.x.x)\n', jver); + if (isOctave) + warning (' At Octave prompt, try "!system ("java -version")"'); + else + warning (' At Matlab prompt, try "version -java"'); + end %if + end %if + return + else + if (dbug > 2), fprintf (' Java (version %s) seems OK.\n', jver); end %if + end %if + % Under *nix the classpath must first be split up. + % Matlab is braindead here. For ML we need a replacement for Octave's builtin strsplit() + % This is found on ML Central (BSD license so this is allowed) & adapted for input arg order + if (isunix) jcp = strsplit (char (jcp), ':'); end %if + if (dbug > 1) + % Check JVM virtual memory settings + jmem = javaMethod ('getRuntime', 'java.lang.Runtime'); +# jmem = java_invoke ('java.lang.Runtime', 'getRuntime'); + jmem = jmem.maxMemory().doubleValue(); + jmem = int16 (jmem/1024/1024); + fprintf (' Maximum JVM memory: %5d MiB; ', jmem); + if (jmem < 400) + fprintf ('should better be at least 400 MB!\n'); + fprintf (' Hint: adapt setting -Xmx in file "java.opts" (supposed to be here:)\n'); + if (isOctave) + fprintf (' %s\n', [matlabroot filesep 'share' filesep 'octave' filesep 'packages' filesep 'java-<version>' filesep 'java.opts']); + else + fprintf (' $matlabroot/bin/<arch>]\n'); + end %if + else + fprintf ('sufficient.\n'); + end %if + end %if + if (dbug), fprintf ('Java support OK\n'); end %if + catch + error ('No Java support found.'); + end %try_catch + + if (dbug), fprintf ('\nChecking javaclasspath for .jar libraries needed for spreadsheet I/O...:\n'); end %if + + % Try Java & Apache POI. First Check basic .xls (BIFF8) support + if (dbug > 1), fprintf ('Basic POI (.xls) <poi-3> <poi-ooxml>:\n'); end %if + jpchk1 = 0; entries1 = {'poi-3', 'poi-ooxml-3'}; missing1 = zeros (1, numel (entries1)); + % Only under *nix we might use brute force: e.g., strfind (javaclasspath, classname) + % as javaclasspath is one long string. Under Windows however classpath is a cell array + % so we need the following more subtle, platform-independent approach: + for jj=1:length (entries1) + found = 0; + for ii=1:length (jcp) + if (strfind (lower (jcp{ii}), lower (entries1{jj}))) + jpchk1 = jpchk1 + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries1{jj}); end %if + missing1(jj) = 1; + end %if + end %for + if (dbug > 1) + if (jpchk1 > 1) + fprintf (' => Apache (POI) OK\n'); + retval = 1; + else + fprintf (' => Not all classes (.jar) required for POI in classpath\n'); + end %if + end %if + % Next, check OOXML support + if (dbug > 1), fprintf ('\nPOI OOXML (.xlsx) <xbean> <poi-ooxml-schemas> <dom4j>:\n'); end %if + jpchk2 = 0; entries2 = {'xbean', 'poi-ooxml-schemas', 'dom4j-1.6.1'}; + missing2 = zeros (1, numel (entries2)); + for jj=1:length (entries2) + found = 0; + for ii=1:length (jcp) + if (strfind (lower (jcp{ii}), lower (entries2{jj}))) + jpchk2 = jpchk2 + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end % for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries2{jj}); end %if + missing2(jj) = 1; + end %if + end % for + if (dbug > 1) + if (jpchk2 > 2) + fprintf (' => POI OOXML OK\n'); + else + fprintf (' => Some classes for POI OOXML support missing\n'); + end %if + end %if + + % Try Java & JExcelAPI + if (dbug > 1), fprintf ('\nJExcelAPI (.xls (incl. BIFF5 read)) <jxl>:\n'); end %if + jpchk = 0; entries3 = {'jxl'}; missing3 = zeros (1, numel (entries3)); + for jj=1:length (entries3) + found = 0; + for ii=1:length (jcp) + if (strfind (lower (jcp{ii}), lower (entries3{jj}))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end % if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries3{jj}); end %if + missing3(jj) = 1; + end %if + end %for + if (dbug > 1) + if (jpchk > 0) + fprintf (' => Java/JExcelAPI (JXL) OK.\n'); + retval = 1; + else + fprintf (' => Not all classes (.jar) required for JXL in classpath\n'); + end %if + end %if + + % Try Java & OpenXLS + if (dbug > 1), fprintf ('\nOpenXLS (.xls (BIFF8)) <OpenXLS>:\n'); end %if + jpchk = 0; entries6 = {'OpenXLS'}; missing6 = zeros (1, numel (entries3)); + for jj=1:length (entries6) + found = 0; + for ii=1:length (jcp) + if (strfind (lower (jcp{ii}), lower (entries6{jj}))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end % if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries6{jj}); end %if + missing6(jj) = 1; + end %if + end %for + if (dbug > 1) + if (jpchk > 0) + fprintf (' => Java/OpenXLS (OXS) OK.\n'); + retval = 1; + else + fprintf (' => Not all classes (.jar) required for OXS in classpath\n'); + end %if + end %if + + % Try Java & ODF toolkit + if (dbug > 1), fprintf ('\nODF Toolkit (.ods) <odfdom> <xercesImpl>:\n'); end %if + jpchk = 0; entries4 = {'odfdom', 'xercesImpl'}; missing4 = zeros (1, numel (entries4)); + % Only under *nix we might use brute force: e.g., strfind(classpath, classname) + % as classpath is one long string. Under Windows however classpath is a cell array + % so we need the following more subtle, platform-independent approach: + for jj=1:length (entries4) + found = 0; + for ii=1:length (jcp) + if (strfind ( lower (jcp{ii}), lower (entries4{jj}))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries4{jj}); end %if + missing4(jj) = 1; + end %if + end %for + if (jpchk >= 2) % Apparently all requested classes present. + % Only now we can check for proper odfdom version (only 0.7.5 & 0.8.6 work OK). + % The odfdom team deemed it necessary to change the version call so we need this: + odfvsn = ' '; + try + % New in 0.8.6 + odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest'); +# odfvsn = java_invoke ('org.odftoolkit.odfdom.JarManifest', 'getOdfdomVersion'); + catch + % Worked in 0.7.5 + odfvsn = javaMethod ('getApplicationVersion', 'org.odftoolkit.odfdom.Version'); +# odfvsn = java_invoke ('org.odftoolkit.odfdom.Version', 'getApplicationVersion'); + end %try_catch + if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6')) + warning (' *** odfdom version (%s) is not supported - use v. 0.7.5 or 0.8.6.\n', odfvsn); + else + if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if + retval = 1; + end %if + elseif (dbug > 1) + fprintf (' => Not all required classes (.jar) in classpath for OTK\n'); + end %if + + % Try Java & jOpenDocument + if (dbug > 1), fprintf ('\njOpenDocument (.ods + experimental .sxc readonly) <jOpendocument>:\n'); end %if + jpchk = 0; entries5 = {'jOpenDocument'}; missing5 = zeros (1, numel (entries5)); + for jj=1:length (entries5) + found = 0; + for ii=1:length (jcp) + if (strfind (lower (jcp{ii}), lower (entries5{jj}))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end %for + if (~found) + if (dbug > 2), fprintf (' %s....jar missing\n', entries5{jj}); end %if + missing5(jj) = 1; + end %if + end %for + if (dbug > 1) + if (jpchk >= 1) + fprintf (' => jOpenDocument (JOD) OK.\n'); + retval = 1; + else + fprintf (' => Not all required classes (.jar) in classpath for JOD\n'); + end %if + end %if + + missing = [missing1 missing2 missing3 missing4 missing5 missing6]; + jars_complete = isempty (find (missing)); + if (dbug) + if (jars_complete) + fprintf ('All interfaces already fully supported.\n\n'); + else + fprintf ('Some class libs lacking yet...\n\n'); + end %if + end %if + + if (~jars_complete && nargin > 0) + if (dbug), fprintf ('Trying to add missing java class libs to javaclasspath...\n'); end %if + if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if + % Add missing jars to javaclasspath. First combine all entries + entries = [entries1 entries2 entries3 entries4 entries5 entries6]; + targt = sum (missing); + % Search tru list of missing entries + for ii=1:length (entries) + if (missing(ii)) + file = dir ([path_to_jars filesep entries{ii} '*']); + if (isempty (file)) + if (dbug > 2), fprintf ('\n'); end %if + else + if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath\n', file.name); end %if + try + javaaddpath ([path_to_jars filesep file.name]); + targt = targt - 1; + catch + if (dbug > 2), fprintf ('\n'); end %if + end_try_catch + end %if + end %if + end %for + if (dbug) + if (targt) + fprintf ('Some class libs still lacking...\n\n'); + else + fprintf ('All interfaces fully supported.now.\n\n'); + retval = 1; + end %f + end %if + +end %function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-04-30 21:12:12
|
Revision: 8240 http://octave.svn.sourceforge.net/octave/?rev=8240&view=rev Author: prnienhuis Date: 2011-04-30 21:12:06 +0000 (Sat, 30 Apr 2011) Log Message: ----------- Checks & bounds on input debug level Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-04-30 20:47:40 UTC (rev 8239) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-04-30 21:12:06 UTC (rev 8240) @@ -51,6 +51,7 @@ jcp = []; retval = 0; isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; if (ispc), filesep = '\'; else, filesep = '/'; end %if + dbug = min (max (dbug, 0), 3); fprintf ('\n'); % Check if MS-Excel COM ActiveX server runs @@ -62,7 +63,8 @@ % Close Excel to avoid zombie Excel invocation app.Quit(); delete(app); - if (dbug), fprintf ('OK.\n\n'); retval = 1; end %if + if (dbug), fprintf ('OK.\n\n'); end %if + retval = 1; catch % COM not supported if (dbug), fprintf ('not working.\n\n'); end %if @@ -78,8 +80,8 @@ else jtst = (!system ('java -version 2> /dev/null')); end %if - #else - # jtst = (version -java + else + jtst = (version -java) end %if if (~jtst) error ("\nApparently no Java JRE installed."); @@ -95,7 +97,6 @@ % Now check for proper version % (> 1.6.x.x) jver = char (javaMethod ('getProperty', 'java.lang.System', 'java.version')); -# jver = char (java_invoke ('java.lang.System', 'getProperty', 'java.version')); cjver = strsplit (jver, '.'); if (sscanf (cjver{2}, '%d') < 6) if (dbug) @@ -117,7 +118,6 @@ if (dbug > 1) % Check JVM virtual memory settings jmem = javaMethod ('getRuntime', 'java.lang.Runtime'); -# jmem = java_invoke ('java.lang.Runtime', 'getRuntime'); jmem = jmem.maxMemory().doubleValue(); jmem = int16 (jmem/1024/1024); fprintf (' Maximum JVM memory: %5d MiB; ', jmem); @@ -159,10 +159,10 @@ missing1(jj) = 1; end %if end %for + retval = jpchk1 > 1; if (dbug > 1) if (jpchk1 > 1) fprintf (' => Apache (POI) OK\n'); - retval = 1; else fprintf (' => Not all classes (.jar) required for POI in classpath\n'); end %if @@ -208,6 +208,7 @@ missing3(jj) = 1; end %if end %for + retval = jpchk > 0; if (dbug > 1) if (jpchk > 0) fprintf (' => Java/JExcelAPI (JXL) OK.\n'); @@ -217,8 +218,8 @@ end %if end %if - % Try Java & OpenXLS - if (dbug > 1), fprintf ('\nOpenXLS (.xls (BIFF8)) <OpenXLS>:\n'); end %if + % Try Java & OpenXLS (experimental) + if (dbug > 1), fprintf ('\nOpenXLS (.xls (BIFF8)) <OpenXLS> (experimental):\n'); end %if jpchk = 0; entries6 = {'OpenXLS'}; missing6 = zeros (1, numel (entries3)); for jj=1:length (entries6) found = 0; @@ -233,6 +234,7 @@ missing6(jj) = 1; end %if end %for + retval = jpchk > 0; if (dbug > 1) if (jpchk > 0) fprintf (' => Java/OpenXLS (OXS) OK.\n'); @@ -268,14 +270,12 @@ try % New in 0.8.6 odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest'); -# odfvsn = java_invoke ('org.odftoolkit.odfdom.JarManifest', 'getOdfdomVersion'); catch % Worked in 0.7.5 odfvsn = javaMethod ('getApplicationVersion', 'org.odftoolkit.odfdom.Version'); -# odfvsn = java_invoke ('org.odftoolkit.odfdom.Version', 'getApplicationVersion'); end %try_catch - if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6')) - warning (' *** odfdom version (%s) is not supported - use v. 0.7.5 or 0.8.6.\n', odfvsn); + if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6') || strcmp (odfvsn, '0.8.7')) + warning (' *** odfdom version (%s) is not supported - use v. 0.7.5, or 0.8.6+.\n', odfvsn); else if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if retval = 1; @@ -300,10 +300,10 @@ missing5(jj) = 1; end %if end %for + retval = jpchk >= 1; if (dbug > 1) if (jpchk >= 1) fprintf (' => jOpenDocument (JOD) OK.\n'); - retval = 1; else fprintf (' => Not all required classes (.jar) in classpath for JOD\n'); end %if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-05-15 20:36:35
|
Revision: 8262 http://octave.svn.sourceforge.net/octave/?rev=8262&view=rev Author: prnienhuis Date: 2011-05-15 20:36:29 +0000 (Sun, 15 May 2011) Log Message: ----------- Better error message when OOo directory isn't found Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-05-15 20:35:57 UTC (rev 8261) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-05-15 20:36:29 UTC (rev 8262) @@ -62,6 +62,7 @@ % 2011-05-04 Added in UNO support (OpenOffice.org & clones) % '' Improved finding jar names in javaclasspath % 2011-05-07 Improved help text +% 2011-05-15 Better error msg if OOo instal dir isn't found jcp = []; retval = 0; if (nargin < 2), dbug = 0; end %if @@ -402,7 +403,7 @@ if (dbug > 2), fprintf ('FAILED\n'); end %if end% try_catch else - if (dbug > 2), fprintf (' ? %s directory ?\n', entries0{1}); end %if + if (dbug > 2), error ('Suggested OpenOffice.org install directory: %s not found!\n', path_to_ooo); end %if end %if end %if % Rest of missing entries. Find where URE is located This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-05-16 21:55:51
|
Revision: 8268 http://octave.svn.sourceforge.net/octave/?rev=8268&view=rev Author: prnienhuis Date: 2011-05-16 21:55:44 +0000 (Mon, 16 May 2011) Log Message: ----------- Added missing "end %if"; improved reference to Java pkg install dir in Java section; adapted unojarpath to distinguish between Windows 7 *nix OOo installations (esp. URE subdir tree) Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-05-16 21:50:59 UTC (rev 8267) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-05-16 21:55:44 UTC (rev 8268) @@ -63,9 +63,12 @@ % '' Improved finding jar names in javaclasspath % 2011-05-07 Improved help text % 2011-05-15 Better error msg if OOo instal dir isn't found +% 2011-05-16 Added missing end %if +% '' Improved java pkg install dir for Octave +% '' Distinguish URE subdir tree buildup between *nix & Windows OOo install jcp = []; retval = 0; - if (nargin < 2), dbug = 0; end %if + if (nargin < 2), dbug = 0; path_to_ooo = []; end %if isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; if (ispc), filesep = '\'; else, filesep = '/'; end %if fprintf ('\n'); @@ -83,7 +86,7 @@ catch % COM not supported if (dbug), fprintf ('not working.\n\n'); end %if - end %try_catch + end %try_catch % Check Java if (dbug), fprintf ('Checking Java support...\n'); end %if @@ -135,14 +138,16 @@ % Check JVM virtual memory settings jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); jmem = jrt.maxMemory (); - if (isOctave), jmem = jmem.doubleValue(); end %if + if (isOctave), jmem = jmem.doubleValue(); end %if jmem = int16 (jmem/1024/1024); fprintf (' Maximum JVM memory: %5d MiB; ', jmem); if (jmem < 400) fprintf ('should better be at least 400 MB!\n'); fprintf (' Hint: adapt setting -Xmx in file "java.opts" (supposed to be here:)\n'); if (isOctave) - fprintf (' %s\n', [matlabroot filesep 'share' filesep 'octave' filesep 'packages' filesep 'java-<version>' filesep 'java.opts']); + tmp = eval ("which javaclasspath"); + jidx = strfind (tmp, filesep); + fprintf (' %s\n', tmp(jidx(1) : jidx(end))); else fprintf (' $matlabroot/bin/<arch>]\n'); end %if @@ -151,7 +156,7 @@ end %if end %if if (dbug), fprintf ('Java support OK\n'); end %if - catch + catch error ('No Java support found.'); end %try_catch @@ -159,7 +164,7 @@ % Try Java & UNO if (dbug > 1), fprintf ('UNO/Java (.ods, .xls, .xlsx, .sxc) <OpenOffice.org>:\n'); end %if - # entries0(1) = not a jar but a directory (<000_install_dir/program/>) + % entries0(1) = not a jar but a directory (<000_install_dir/program/>) jpchk = 0; entries0 = {'program', 'unoil', 'jurt', 'juh', 'unoloader', 'ridl'}; missing0 = zeros (1, numel (entries0)); % Only under *nix we might use brute force: e.g., strfind (javaclasspath, classname) @@ -375,7 +380,7 @@ end %if end %if - # If requested, try to add UNO stuff to javaclasspath + % If requested, try to add UNO stuff to javaclasspath ujars_complete = isempty (find (missing0)); if (dbug > 1) if (ujars_complete) @@ -385,15 +390,16 @@ end %if end %if - if (~ujars_complete && nargin > 0 && ~isempty (path_to_ooo)) + if (~ujars_complete && nargin > 2 && ~isempty (path_to_ooo)) if (dbug), fprintf ('Trying to add missing UNO java class libs to javaclasspath...\n'); end %if if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if % Add missing jars to javaclasspath. First combine all entries targt = sum (missing0); if (missing0(1)) - # Add program dir (= where soffice or soffice.exe or ooffice resides) + % Add program dir (= where soffice or soffice.exe or ooffice resides) programdir = [path_to_ooo filesep entries0{1}]; - if (fexist (programdir, 'd')) + if (exist (programdir, 'dir') == 7) +% if (fexist (programdir, 'd')) if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if try javaaddpath (programdir); @@ -409,37 +415,41 @@ % Rest of missing entries. Find where URE is located uredirlst = dir ([path_to_ooo]); jj = 1; - while (jj < size (uredirlst, 1) && jj > 0) + while (jj <= size (uredirlst, 1) && jj > 0) uredir = uredirlst(jj).name; if (uredirlst(jj).isdir && ~isempty (strfind (lower (uredirlst(jj).name), 'ure'))) uredir = uredirlst(jj).name; jj = 0; else ++jj; - endif - endwhile - # Now search for UNO jars + end %if + end %while + % Now search for UNO jars for ii=2:length (entries0) if (missing0(ii)) if (ii == 2) - # Special case as unoil.jar usuaally resides in ./Basis.../program/classes - # Find out the exact name of Basis..... + % Special case as unoil.jar usuaally resides in ./Basis.../program/classes + % Find out the exact name of Basis..... basisdirlst = dir ([path_to_ooo filesep 'basis' '*']); jj = 1; while (jj < size (basisdirlst, 1) && jj > 0) - # basisdir = basisdirlst(jj).name; + % basisdir = basisdirlst(jj).name; if (basisdirlst(jj).isdir) basisdir = basisdirlst(jj).name; jj = 0; else ++jj; - endif - endwhile - unojarpath = [ path_to_ooo filesep basisdir filesep 'program' filesep 'classes' filesep ] + end %if + end %while + unojarpath = [ path_to_ooo filesep basisdir filesep 'program' filesep 'classes' filesep ]; file = dir ([ unojarpath entries0{ii} '*' ]); else - # Rest of jars in ./ure/share/java (case not sure) - unojarpath = [ path_to_ooo filesep uredir filesep 'java' filesep ]; + % Rest of jars in ./ure/share/java (case not sure) + if (ispc) + unojarpath = [ path_to_ooo filesep uredir filesep 'java' filesep ]; + else + unojarpath = [ path_to_ooo filesep uredir filesep 'share' filesep 'java' filesep ] + end %if file = dir ([unojarpath entries0{ii} '*']); end %if if (isempty (file)) @@ -452,7 +462,7 @@ if (dbug > 2), fprintf ('OK\n'); end %if catch if (dbug > 2), fprintf ('FAILED\n'); end %if - end %try_catch + end %try_catch end %if end %if end %for @@ -462,10 +472,11 @@ else fprintf ('All interfaces fully supported.now.\n\n'); retval = 1; + end %if end %f end %if - # Rest of Java interfaces + % Rest of Java interfaces missing = [missing1 missing2 missing3 missing4 missing5 missing6]; jars_complete = isempty (find (missing)); if (dbug) @@ -496,7 +507,7 @@ if (dbug > 2), fprintf ('OK\n'); end %if catch if (dbug > 2), fprintf ('FAILED\n'); end %if - end% try_catch + end% try_catch end %if end %if end %for This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-05-22 12:49:48
|
Revision: 8277 http://octave.svn.sourceforge.net/octave/?rev=8277&view=rev Author: prnienhuis Date: 2011-05-22 12:49:42 +0000 (Sun, 22 May 2011) Log Message: ----------- More involved searching of subdirs (proper case of filenames) Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-05-20 22:48:58 UTC (rev 8276) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-05-22 12:49:42 UTC (rev 8277) @@ -63,12 +63,10 @@ % '' Improved finding jar names in javaclasspath % 2011-05-07 Improved help text % 2011-05-15 Better error msg if OOo instal dir isn't found -% 2011-05-16 Added missing end %if -% '' Improved java pkg install dir for Octave -% '' Distinguish URE subdir tree buildup between *nix & Windows OOo install +% 2011-05-20 Attempt to cope with case variations in subdir names of OOo install dir (_get_dir_) jcp = []; retval = 0; - if (nargin < 2), dbug = 0; path_to_ooo = []; end %if + if (nargin < 2), dbug = 0; end %if isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; if (ispc), filesep = '\'; else, filesep = '/'; end %if fprintf ('\n'); @@ -86,8 +84,10 @@ catch % COM not supported if (dbug), fprintf ('not working.\n\n'); end %if - end %try_catch + end %try_catch +%---------------------------------------------------------------------------------- + % Check Java if (dbug), fprintf ('Checking Java support...\n'); end %if if (dbug > 1), fprintf (' 1. Checking Java JRE presence.... '); end %if @@ -109,8 +109,8 @@ end %if if (dbug > 1 && isOctave), fprintf (' 2. Checking Octave Java support... '); end %if try - jcp = javaclasspath ('-all'); %# For Octave java pkg > 1.2.7 - if (isempty (jcp)), jcp = javaclasspath; end %if %# For Octave java pkg < 1.2.8 + jcp = javaclasspath ('-all'); % For Octave java pkg > 1.2.7 + if (isempty (jcp)), jcp = javaclasspath; end %if % For Octave java pkg < 1.2.8 % If we get here, at least Java works. if (dbug > 1 && isOctave), fprintf ('Java package seems to work OK.\n'); end %if % Now check for proper version @@ -138,16 +138,14 @@ % Check JVM virtual memory settings jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); jmem = jrt.maxMemory (); - if (isOctave), jmem = jmem.doubleValue(); end %if + if (isOctave), jmem = jmem.doubleValue(); end %if jmem = int16 (jmem/1024/1024); fprintf (' Maximum JVM memory: %5d MiB; ', jmem); if (jmem < 400) fprintf ('should better be at least 400 MB!\n'); fprintf (' Hint: adapt setting -Xmx in file "java.opts" (supposed to be here:)\n'); if (isOctave) - tmp = eval ("which javaclasspath"); - jidx = strfind (tmp, filesep); - fprintf (' %s\n', tmp(jidx(1) : jidx(end))); + fprintf (' %s\n', [matlabroot filesep 'share' filesep 'octave' filesep 'packages' filesep 'java-<version>' filesep 'java.opts']); else fprintf (' $matlabroot/bin/<arch>]\n'); end %if @@ -156,10 +154,12 @@ end %if end %if if (dbug), fprintf ('Java support OK\n'); end %if - catch + catch error ('No Java support found.'); end %try_catch +%--------------------------------------------------------------------------------- + if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if % Try Java & UNO @@ -183,7 +183,7 @@ if (~found) if (dbug > 2) if (jj == 1) - # Just a dir + % Just a dir fprintf (' %s.... (directory) not found\n', entries0{jj}); else fprintf (' %s....jar missing\n', entries0{jj}); @@ -380,26 +380,19 @@ end %if end %if +%---------------------------------------------------------------------------- + % If requested, try to add UNO stuff to javaclasspath ujars_complete = isempty (find (missing0)); - if (dbug > 1) - if (ujars_complete) - fprintf ('UNO bridge (OpenOffice.org) supported.\n\n'); - else - fprintf ('Some UNO class libs lacking yet...\n\n'); - end %if - end %if - - if (~ujars_complete && nargin > 2 && ~isempty (path_to_ooo)) - if (dbug), fprintf ('Trying to add missing UNO java class libs to javaclasspath...\n'); end %if + if (~ujars_complete && nargin > 0 && ~isempty (path_to_ooo)) + if (dbug), fprintf ('\nTrying to add missing UNO java class libs to javaclasspath...\n'); end %if if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if % Add missing jars to javaclasspath. First combine all entries targt = sum (missing0); if (missing0(1)) % Add program dir (= where soffice or soffice.exe or ooffice resides) programdir = [path_to_ooo filesep entries0{1}]; - if (exist (programdir, 'dir') == 7) -% if (fexist (programdir, 'd')) + if (fexist (programdir, 'd')) if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if try javaaddpath (programdir); @@ -407,30 +400,27 @@ if (dbug > 2), fprintf ('OK\n'); end %if catch if (dbug > 2), fprintf ('FAILED\n'); end %if - end% try_catch + end %try_catch else if (dbug > 2), error ('Suggested OpenOffice.org install directory: %s not found!\n', path_to_ooo); end %if end %if end %if - % Rest of missing entries. Find where URE is located - uredirlst = dir ([path_to_ooo]); - jj = 1; - while (jj <= size (uredirlst, 1) && jj > 0) - uredir = uredirlst(jj).name; - if (uredirlst(jj).isdir && ~isempty (strfind (lower (uredirlst(jj).name), 'ure'))) - uredir = uredirlst(jj).name; - jj = 0; - else - ++jj; - end %if - end %while + % Rest of missing entries. Find where URE is located. The below code snippets are + % ridiculously long because we don't know the exact case of the subdirs, and that + % is killing on *nix where case in file names matters... + uredir = _get_dir_ (path_to_ooo, 'ure'); + if (isempty (uredir)) + fprintf ('Could not find path to <OOo install dir>/URE/\n'); + return; + end %if % Now search for UNO jars for ii=2:length (entries0) if (missing0(ii)) if (ii == 2) - % Special case as unoil.jar usuaally resides in ./Basis.../program/classes + % Special case as unoil.jar usually resides in ./Basis<something>/program/classes % Find out the exact name of Basis..... basisdirlst = dir ([path_to_ooo filesep 'basis' '*']); + idx = strmatch ('basis', lower ({basisdirlst.name})); jj = 1; while (jj < size (basisdirlst, 1) && jj > 0) % basisdir = basisdirlst(jj).name; @@ -438,45 +428,61 @@ basisdir = basisdirlst(jj).name; jj = 0; else - ++jj; + jj = jj + 1; end %if end %while - unojarpath = [ path_to_ooo filesep basisdir filesep 'program' filesep 'classes' filesep ]; - file = dir ([ unojarpath entries0{ii} '*' ]); + basisdir = [path_to_ooo filesep basisdir ]; + % Search rest of path to unoil.jar (<basis...>/program/classes/) + basisdirentries = {'program', 'classes'}; + tmp = basisdir; jj=1; + while (~isempty (tmp) & jj <= numel (basisdirentries)) + tmp = _get_dir_ (tmp, basisdirentries{jj}); + jj = jj + 1; + end %if + if (isempty (tmp)) + fprintf ('Could not find path to <OOo install dir>/Basis.../\n'); + return; + end %if + unojarpath = tmp; + file = dir ([ unojarpath filesep entries0{2} '*' ]); else - % Rest of jars in ./ure/share/java (case not sure) - if (ispc) - unojarpath = [ path_to_ooo filesep uredir filesep 'java' filesep ]; + % Rest of jars in ./ure/share/java or ./ure/java + unojardir = _get_dir_ (uredir, 'share'); + if (isempty (unojardir)) + tmp = uredir; else - unojarpath = [ path_to_ooo filesep uredir filesep 'share' filesep 'java' filesep ] + tmp = unojardir; end %if - file = dir ([unojarpath entries0{ii} '*']); + unojarpath = _get_dir_ (tmp, 'java'); + file = dir ([unojarpath filesep entries0{ii} '*']); end %if + % Path found, now try to add jar if (isempty (file)) if (dbug > 2), fprintf (' ? %s<...>.jar ?\n', entries0{ii}); end %if else if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', file.name); end %if try - javaaddpath ([unojarpath file.name]); + javaaddpath ([unojarpath filesep file.name]); targt = targt - 1; if (dbug > 2), fprintf ('OK\n'); end %if catch if (dbug > 2), fprintf ('FAILED\n'); end %if - end %try_catch + end %try_catch end %if end %if end %for if (dbug) if (targt) - fprintf ('Some class libs still lacking...\n\n'); + fprintf ('Some UNO class libs still lacking...\n\n'); else - fprintf ('All interfaces fully supported.now.\n\n'); + fprintf ('UNO interface supported now.\n\n'); retval = 1; end %if end %f end %if - % Rest of Java interfaces +% ----------Rest of Java interfaces---------------------------------- + missing = [missing1 missing2 missing3 missing4 missing5 missing6]; jars_complete = isempty (find (missing)); if (dbug) @@ -507,13 +513,13 @@ if (dbug > 2), fprintf ('OK\n'); end %if catch if (dbug > 2), fprintf ('FAILED\n'); end %if - end% try_catch + end% try_catch end %if end %if end %for if (dbug) if (targt) - fprintf ('Some class libs still lacking...\n\n'); + fprintf ('Some other class libs still lacking...\n\n'); else fprintf ('All interfaces fully supported.now.\n\n'); retval = 1; @@ -522,3 +528,28 @@ end %if end %function + + +function [ ret_dir ] = _get_dir_ (base_dir, req_dir) + +% Construct path to subdirectory req_dir in a subdir tree, aimed +% at taking care of proper case (esp. for *nix) of existing subdir +% in the result. Case of input var req_dir is ignored on purpose. + + ret_dir = ''; + % Get list of directory entries: + ret_dir_list = dir (base_dir); + % Find matching entries: (may not work in Matlab) + idx = find (strcmpi ({ret_dir_list.name}, req_dir)); + % On *nix, several files and subdirs in one dir may have the same name as long as case differs + if (~isempty (idx)) + ii = 1; + while (~ret_dir_list(idx(ii)).isdir) + ii = ii + 1; + if (ii > numel (idx)); return; end %if + end %while + % If we get here, a dir with proper name has been found. Construct path: + ret_dir = [ base_dir filesep ret_dir_list(idx(ii)).name ]; + end %if + +end %function This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-05-30 22:07:26
|
Revision: 8292 http://octave.svn.sourceforge.net/octave/?rev=8292&view=rev Author: prnienhuis Date: 2011-05-30 22:07:19 +0000 (Mon, 30 May 2011) Log Message: ----------- Made retval value dependent on detected interfaces & adapted help text; checked ML compatibility Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-05-28 13:47:12 UTC (rev 8291) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-05-30 22:07:19 UTC (rev 8292) @@ -2,10 +2,22 @@ % % usage: [ RETVAL ] = chk_spreadsheet_support ( [/PATH/TO/JARS], [,DEBUG_LEVEL] [,PATH_TO_OOO]) % -% Input arguments (all are optional): +% CHK_SPREADSHEET_SUPPORT first checks ActiveX (native MS-Excel); then +% Java JRE presence, then Java support (builtin/activated (Matlab) or +% added tru octave-forge Java package (Octave); then check existing +% javaclasspath for Java class libraries (.jar) needed for various +% Java-based spreadsheet I/O interfaces. +% If desired the relevant classes can be added to the dynamic +% javaclasspath. In that case the path name to the directory +% containing these classes should be specified as input argument +% with -TAKE NOTICE- /forward/ slashes. In these jars reside in +% different directories, multiple calls to chk_spreadsheet_support +% can be made. +% +% Input arguments (all are optional, but the order is important): % /PATH/TO/JARS = (string) path (relative or absolute) to a % subdirectory where java class libraries (.jar) -% for spreadsheet I/O reside +% for spreadsheet I/O reside. Can be [] or '' % DEBUG_LEVEL = (integer) between [0 (no output) .. 3 (full output] % PATH_TO_OOO = (string) installation directory of Openffice.org, % usually (but not guaranteed): @@ -13,25 +25,25 @@ % - *nix: /usr/lib/ooo % - Mac OSX: ????? % IMPORTANT: PATH_TO_OOO should be such that both: -% 1. PATH_TO_OOO/program/ and -% 2. PATH_TO_OOO/ure/share/java/ridl.jar +% 1. PATH_TO_OOO/program/ +% and +% 2. PATH_TO_OOO/ure/.../ridl.jar % resolve OK % Returns: -% RETVAL = 0 No spreadsheet I/O support found -% = 1 At least one spreadsheet I/O interface found -% -% CHK_SPREADSHEET_SUPPORT first checks ActiveX (native MS-Excel); then -% Java JRE presence, then Java support (builtin/activated - Matlab or -% added tru octave-forge Java package (Octave); then check existing -% javaclasspath for Java class libraries (.jar) needed for spreadsheet -% I/O. -% If desired the relevant classes can be added to the dynamic -% javaclasspath. In that case the path name to the directory -% containing these classes should be specified as input argument -% with -TAKE NOTICE- /forward/ slashes. -% A second (optional) argument is the default debug level. -% A third (optional) argument is the installation directory of -% OpenOffice.org or clones. +% RETVAL = 0 No spreadsheet I/O support found +% <> 0 At least one spreadsheet I/O interface found. RETVAL +% RETVAL will be set to the sum of values for found interfaces: +% ---------- XLS (Excel) interfaces: ---------- +% 1 = COM (ActiveX / Excel) +% 2 = POI (Java / Apache POI) +% 4 = POI+OOXML (Java / Apache POI) +% 8 = JXL (Java / JExcelAPI) +% 16 = OXS (Java / OpenXLS) +% --- ODS (OpenOffice.org Calc) interfaces ---- +% 32 = OTK (Java/ ODF Toolkit) +% 64 = JOD (Java / jOpenDocument) +% ----------------- XLS & ODS: ---------------- +% 128 = UNO (Java / UNO bridge - OpenOffice.org) function [ retval ] = chk_spreadsheet_support (path_to_jars, dbug, path_to_ooo) @@ -52,7 +64,7 @@ % <http://www.gnu.org/licenses/>. % Author: Philip Nienhuis -% Created 2010-11-03 +% Created 2010-11-03 for Octave & Matlab % Updates: % 2010-12-19 Found that dom4j-1.6.1.jar is needed regardless of ML's dom4j % presence in static classpath (ML r2007a) @@ -64,12 +76,15 @@ % 2011-05-07 Improved help text % 2011-05-15 Better error msg if OOo instal dir isn't found % 2011-05-20 Attempt to cope with case variations in subdir names of OOo install dir (_get_dir_) +% 2011-05-27 Fix proper return value (retval); header text improved +% 2011-05-29 Made retval value dependent on detected interfaces & adapted help text jcp = []; retval = 0; - if (nargin < 2), dbug = 0; end %if + if (nargin < 3); path_to_ooo= ''; end %if + if (nargin < 2); dbug = 0; end %if isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; - if (ispc), filesep = '\'; else, filesep = '/'; end %if - fprintf ('\n'); + if (dbug); fprintf ('\n'); end %if + % interfaces = {'COM', 'POI', 'POI+OOXML', 'JXL', 'OXS', 'OTK', 'JOD', 'UNO'}; % Order = vital % Check if MS-Excel COM ActiveX server runs if (dbug), fprintf ('Checking Excel/ActiveX/COM... '); end %if @@ -80,14 +95,13 @@ % Close Excel to avoid zombie Excel invocation app.Quit(); delete(app); - if (dbug), fprintf ('OK.\n\n'); retval = 1; end %if + if (dbug), fprintf ('OK.\n\n'); end %if + retval = retval + 1; catch % COM not supported if (dbug), fprintf ('not working.\n\n'); end %if end %try_catch -%---------------------------------------------------------------------------------- - % Check Java if (dbug), fprintf ('Checking Java support...\n'); end %if if (dbug > 1), fprintf (' 1. Checking Java JRE presence.... '); end %if @@ -113,8 +127,7 @@ if (isempty (jcp)), jcp = javaclasspath; end %if % For Octave java pkg < 1.2.8 % If we get here, at least Java works. if (dbug > 1 && isOctave), fprintf ('Java package seems to work OK.\n'); end %if - % Now check for proper version - % (> 1.6.x.x) + % Now check for proper version (> 1.6.x.x) jver = char (javaMethod ('getProperty', 'java.lang.System', 'java.version')); cjver = strsplit (jver, '.'); if (sscanf (cjver{2}, '%d') < 6) @@ -133,7 +146,7 @@ % Under *nix the classpath must first be split up. % Matlab is braindead here. For ML we need a replacement for Octave's builtin strsplit() % This is found on ML Central (BSD license so this is allowed) & adapted for input arg order - if (isunix) jcp = strsplit (char (jcp), ':'); end %if + if (isunix); jcp = strsplit (char (jcp), ':'); end %if if (dbug > 1) % Check JVM virtual memory settings jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); @@ -158,49 +171,8 @@ error ('No Java support found.'); end %try_catch -%--------------------------------------------------------------------------------- - if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if - % Try Java & UNO - if (dbug > 1), fprintf ('UNO/Java (.ods, .xls, .xlsx, .sxc) <OpenOffice.org>:\n'); end %if - % entries0(1) = not a jar but a directory (<000_install_dir/program/>) - jpchk = 0; entries0 = {'program', 'unoil', 'jurt', 'juh', 'unoloader', 'ridl'}; - missing0 = zeros (1, numel (entries0)); - % Only under *nix we might use brute force: e.g., strfind (javaclasspath, classname) - % as javaclasspath is one long string. Under Windows however classpath is a cell array - % so we need the following more subtle, platform-independent approach: - for jj=1:numel (entries0) - found = 0; - for ii=1:numel (jcp) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries0{jj})))) - jpchk = jpchk + 1; found = 1; - if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if - end %if - end %for - if (~found) - if (dbug > 2) - if (jj == 1) - % Just a dir - fprintf (' %s.... (directory) not found\n', entries0{jj}); - else - fprintf (' %s....jar missing\n', entries0{jj}); - end %if - end %if - missing0(jj) = 1; - end %if - end %for - if (dbug > 1) - if (jpchk >= numel (entries0)) - fprintf (' => UNO (OOo) OK\n'); - retval = 1; - else - fprintf (' => One or more UNO classes (.jar) missing in javaclasspath\n'); - end %if - end %if - % Try Java & Apache POI. First Check basic .xls (BIFF8) support if (dbug > 1), fprintf ('\nBasic POI (.xls) <poi-3> <poi-ooxml>:\n'); end %if jpchk1 = 0; entries1 = {'poi-3', 'poi-ooxml-3'}; missing1 = zeros (1, numel (entries1)); @@ -222,10 +194,10 @@ missing1(jj) = 1; end %if end %for + if (jpchk1 >= numel (entries1)), retval = retval + 2; end %if if (dbug > 1) if (jpchk1 >= numel (entries1)) fprintf (' => Apache (POI) OK\n'); - retval = 1; else fprintf (' => Not all classes (.jar) required for POI in classpath\n'); end %if @@ -249,6 +221,8 @@ missing2(jj) = 1; end %if end % for + % Only update retval if all classes for basic POI have been found in javaclasspath + if (jpchk1 >= numel (entries1) && jpchk2 >= numel (entries2)), retval = retval + 4; end %if if (dbug > 1) if (jpchk2 >= numel (entries2)) fprintf (' => POI OOXML OK\n'); @@ -275,10 +249,10 @@ missing3(jj) = 1; end %if end %for + if (jpchk >= numel (entries3)), retval = retval + 8; end %if if (dbug > 1) if (jpchk >= numel (entries3)) fprintf (' => Java/JExcelAPI (JXL) OK.\n'); - retval = 1; else fprintf (' => Not all classes (.jar) required for JXL in classpath\n'); end %if @@ -286,26 +260,26 @@ % Try Java & OpenXLS if (dbug > 1), fprintf ('\nOpenXLS (.xls (BIFF8)) <OpenXLS>:\n'); end %if - jpchk = 0; entries6 = {'OpenXLS'}; missing6 = zeros (1, numel (entries3)); - for jj=1:length (entries6) + jpchk = 0; entries4 = {'OpenXLS'}; missing4 = zeros (1, numel (entries4)); + for jj=1:length (entries4) found = 0; for ii=1:length (jcp) jcplst = strsplit (jcp{ii}, filesep); jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries6{jj})))) + if (~isempty (strfind (lower (jcpentry), lower (entries4{jj})))) jpchk = jpchk + 1; found = 1; if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if end % if end %for if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries6{jj}); end %if - missing6(jj) = 1; + if (dbug > 2), fprintf (' %s....jar missing\n', entries4{jj}); end %if + missing4(jj) = 1; end %if end %for + if (jpchk >= numel (entries4)), retval = retval + 16; end %if if (dbug > 1) - if (jpchk >= numel (entries6)) + if (jpchk >= numel (entries4)) fprintf (' => Java/OpenXLS (OXS) OK.\n'); - retval = 1; else fprintf (' => Not all classes (.jar) required for OXS in classpath\n'); end %if @@ -313,26 +287,23 @@ % Try Java & ODF toolkit if (dbug > 1), fprintf ('\nODF Toolkit (.ods) <odfdom> <xercesImpl>:\n'); end %if - jpchk = 0; entries4 = {'odfdom', 'xercesImpl'}; missing4 = zeros (1, numel (entries4)); - % Only under *nix we might use brute force: e.g., strfind(classpath, classname) - % as classpath is one long string. Under Windows however classpath is a cell array - % so we need the following more subtle, platform-independent approach: - for jj=1:length (entries4) + jpchk = 0; entries5 = {'odfdom', 'xercesImpl'}; missing5 = zeros (1, numel (entries5)); + for jj=1:length (entries5) found = 0; for ii=1:length (jcp) jcplst = strsplit (jcp{ii}, filesep); jcpentry = jcplst {end}; - if (~isempty (strfind ( lower (jcpentry), lower (entries4{jj})))) + if (~isempty (strfind ( lower (jcpentry), lower (entries5{jj})))) jpchk = jpchk + 1; found = 1; if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if end %if end %for if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries4{jj}); end %if - missing4(jj) = 1; + if (dbug > 2), fprintf (' %s....jar missing\n', entries5{jj}); end %if + missing5(jj) = 1; end %if end %for - if (jpchk >= numel (entries4)) % Apparently all requested classes present. + if (jpchk >= numel (entries5)) % Apparently all requested classes present. % Only now we can check for proper odfdom version (only 0.7.5 & 0.8.6 work OK). % The odfdom team deemed it necessary to change the version call so we need this: odfvsn = ' '; @@ -347,7 +318,7 @@ warning (' *** odfdom version (%s) is not supported - use v. 0.7.5 or 0.8.6.\n', odfvsn); else if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if - retval = 1; + retval = retval + 32; end %if elseif (dbug > 1) fprintf (' => Not all required classes (.jar) in classpath for OTK\n'); @@ -355,35 +326,70 @@ % Try Java & jOpenDocument if (dbug > 1), fprintf ('\njOpenDocument (.ods + experimental .sxc readonly) <jOpendocument>:\n'); end %if - jpchk = 0; entries5 = {'jOpenDocument'}; missing5 = zeros (1, numel (entries5)); - for jj=1:length (entries5) + jpchk = 0; entries6 = {'jOpenDocument'}; missing6 = zeros (1, numel (entries6)); + for jj=1:length (entries6) found = 0; for ii=1:length (jcp) jcplst = strsplit (jcp{ii}, filesep); jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), lower (entries5{jj})))) + if (~isempty (strfind (lower (jcpentry), lower (entries6{jj})))) jpchk = jpchk + 1; found = 1; if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if end %if end %for if (~found) - if (dbug > 2), fprintf (' %s....jar missing\n', entries5{jj}); end %if - missing5(jj) = 1; + if (dbug > 2), fprintf (' %s....jar missing\n', entries6{jj}); end %if + missing6(jj) = 1; end %if end %for + if (jpchk >= numel (entries6)), retval = retval + 64; end %if if (dbug > 1) - if (jpchk >= numel(entries5)) + if (jpchk >= numel(entries6)) fprintf (' => jOpenDocument (JOD) OK.\n'); - retval = 1; else fprintf (' => Not all required classes (.jar) in classpath for JOD\n'); end %if end %if -%---------------------------------------------------------------------------- + % Try Java & UNO + if (dbug > 1), fprintf ('\nUNO/Java (.ods, .xls, .xlsx, .sxc) <OpenOffice.org>:\n'); end %if + % entries0(1) = not a jar but a directory (<000_install_dir/program/>) + jpchk = 0; entries0 = {'program', 'unoil', 'jurt', 'juh', 'unoloader', 'ridl'}; + missing0 = zeros (1, numel (entries0)); + for jj=1:numel (entries0) + found = 0; + for ii=1:numel (jcp) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), lower (entries0{jj})))) + jpchk = jpchk + 1; found = 1; + if (dbug > 2), fprintf (' - %s OK\n', jcp{ii}); end %if + end %if + end %for + if (~found) + if (dbug > 2) + if (jj == 1) + % Just a dir + fprintf (' %s.... (directory) not found\n', entries0{jj}); + else + fprintf (' %s....jar missing\n', entries0{jj}); + end %if + end %if + missing0(jj) = 1; + end %if + end %for + if (jpchk >= numel (entries0)), retval = retval + 128; end %if + if (dbug > 1) + if (jpchk >= numel (entries0)) + fprintf (' => UNO (OOo) OK\n'); + else + fprintf (' => One or more UNO classes (.jar) missing in javaclasspath\n'); + end %if + end %if % If requested, try to add UNO stuff to javaclasspath - ujars_complete = isempty (find (missing0)); + ujars_complete = isempty (find (missing0, 1)); + if (~ujars_complete && nargin > 0 && ~isempty (path_to_ooo)) if (dbug), fprintf ('\nTrying to add missing UNO java class libs to javaclasspath...\n'); end %if if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if @@ -392,7 +398,7 @@ if (missing0(1)) % Add program dir (= where soffice or soffice.exe or ooffice resides) programdir = [path_to_ooo filesep entries0{1}]; - if (fexist (programdir, 'd')) + if (exist (programdir, 'dir')) if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if try javaaddpath (programdir); @@ -405,14 +411,9 @@ if (dbug > 2), error ('Suggested OpenOffice.org install directory: %s not found!\n', path_to_ooo); end %if end %if end %if - % Rest of missing entries. Find where URE is located. The below code snippets are - % ridiculously long because we don't know the exact case of the subdirs, and that - % is killing on *nix where case in file names matters... - uredir = _get_dir_ (path_to_ooo, 'ure'); - if (isempty (uredir)) - fprintf ('Could not find path to <OOo install dir>/URE/\n'); - return; - end %if + % Rest of missing entries. Find where URE is located. Watch out because case of ./ure is unknown + uredir = get_dir_ (path_to_ooo, 'ure'); + if (isempty (uredir)), return; end %if % Now search for UNO jars for ii=2:length (entries0) if (missing0(ii)) @@ -420,9 +421,8 @@ % Special case as unoil.jar usually resides in ./Basis<something>/program/classes % Find out the exact name of Basis..... basisdirlst = dir ([path_to_ooo filesep 'basis' '*']); - idx = strmatch ('basis', lower ({basisdirlst.name})); jj = 1; - while (jj < size (basisdirlst, 1) && jj > 0) + while (jj <= size (basisdirlst, 1) && jj > 0) % basisdir = basisdirlst(jj).name; if (basisdirlst(jj).isdir) basisdir = basisdirlst(jj).name; @@ -432,28 +432,23 @@ end %if end %while basisdir = [path_to_ooo filesep basisdir ]; - % Search rest of path to unoil.jar (<basis...>/program/classes/) basisdirentries = {'program', 'classes'}; tmp = basisdir; jj=1; - while (~isempty (tmp) & jj <= numel (basisdirentries)) - tmp = _get_dir_ (tmp, basisdirentries{jj}); + while (~isempty (tmp) && jj <= numel (basisdirentries)) + tmp = get_dir_ (tmp, basisdirentries{jj}); jj = jj + 1; end %if - if (isempty (tmp)) - fprintf ('Could not find path to <OOo install dir>/Basis.../\n'); - return; - end %if unojarpath = tmp; file = dir ([ unojarpath filesep entries0{2} '*' ]); else % Rest of jars in ./ure/share/java or ./ure/java - unojardir = _get_dir_ (uredir, 'share'); + unojardir = get_dir_ (uredir, 'share'); if (isempty (unojardir)) tmp = uredir; else tmp = unojardir; end %if - unojarpath = _get_dir_ (tmp, 'java'); + unojarpath = get_dir_ (tmp, 'java'); file = dir ([unojarpath filesep entries0{ii} '*']); end %if % Path found, now try to add jar @@ -476,7 +471,7 @@ fprintf ('Some UNO class libs still lacking...\n\n'); else fprintf ('UNO interface supported now.\n\n'); - retval = 1; + retval = retval + 128; end %if end %f end %if @@ -484,7 +479,7 @@ % ----------Rest of Java interfaces---------------------------------- missing = [missing1 missing2 missing3 missing4 missing5 missing6]; - jars_complete = isempty (find (missing)); + jars_complete = isempty (find (missing, 1)); if (dbug) if (jars_complete) fprintf ('All interfaces already fully supported.\n\n'); @@ -494,35 +489,44 @@ end %if if (~jars_complete && nargin > 0 && ~isempty (path_to_jars)) + % Add missing jars to javaclasspath. Assume they're all in the same place if (dbug), fprintf ('Trying to add missing java class libs to javaclasspath...\n'); end %if if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if - % Add missing jars to javaclasspath. First combine all entries - entries = [entries1 entries2 entries3 entries4 entries5 entries6]; + % First combine all entries targt = sum (missing); % Search tru list of missing entries - for ii=1:length (entries) - if (missing(ii)) - file = dir ([path_to_jars filesep entries{ii} '*']); - if (isempty (file)) - if (dbug > 2), fprintf (' ? %s<...>.jar ?\n', entries{ii}); end %if - else - if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', file.name); end %if - try - javaaddpath ([path_to_jars filesep file.name]); - targt = targt - 1; - if (dbug > 2), fprintf ('OK\n'); end %if - catch - if (dbug > 2), fprintf ('FAILED\n'); end %if - end% try_catch + for ii=1:6 % Adapt in case of future new interfaces + tmpe = eval ([ 'entries' char(ii) + '0' ]); + tmpm = eval ([ 'missing' char(ii) + '0' ]); + if (sum (tmpm)) + for jj=1:numel (tmpe) + if (tmpm(jj)) + file = dir ([path_to_jars filesep tmpe{jj} '*']); + if (isempty (file)) + if (dbug > 2), fprintf (' ? %s<...>.jar ?\n', tmpe{jj}); end %if + else + if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', file.name); end %if + try + javaaddpath ([path_to_jars filesep file.name]); + targt = targt - 1; + tmpm(jj) = 0; + if (dbug > 2), fprintf ('OK\n'); end %if + catch + if (dbug > 2), fprintf ('FAILED\n'); end %if + end %try_catch + end %if + end %if + end %for + if (~sum (tmpm)) + retval = retval + 2^ii; end %if end %if end %for if (dbug) if (targt) - fprintf ('Some other class libs still lacking...\n\n'); + fprintf ('Some other class libs still lacking...\n\n'); else fprintf ('All interfaces fully supported.now.\n\n'); - retval = 1; end %if end %f end %if @@ -530,16 +534,16 @@ end %function -function [ ret_dir ] = _get_dir_ (base_dir, req_dir) +function [ ret_dir ] = get_dir_ (base_dir, req_dir) % Construct path to subdirectory req_dir in a subdir tree, aimed % at taking care of proper case (esp. for *nix) of existing subdir % in the result. Case of input var req_dir is ignored on purpose. ret_dir = ''; - % Get list of directory entries: + % Get list of directory entries ret_dir_list = dir (base_dir); - % Find matching entries: (may not work in Matlab) + % Find matching entries idx = find (strcmpi ({ret_dir_list.name}, req_dir)); % On *nix, several files and subdirs in one dir may have the same name as long as case differs if (~isempty (idx)) @@ -548,7 +552,7 @@ ii = ii + 1; if (ii > numel (idx)); return; end %if end %while - % If we get here, a dir with proper name has been found. Construct path: + % If we get here, a dir with proper name has been found. Construct path ret_dir = [ base_dir filesep ret_dir_list(idx(ii)).name ]; end %if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-06-06 18:23:55
|
Revision: 8315 http://octave.svn.sourceforge.net/octave/?rev=8315&view=rev Author: prnienhuis Date: 2011-06-06 18:23:49 +0000 (Mon, 06 Jun 2011) Log Message: ----------- Return code dependent on found interfaces. Improved ML compatibility Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-06-06 14:20:21 UTC (rev 8314) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-06-06 18:23:49 UTC (rev 8315) @@ -78,7 +78,9 @@ % 2011-05-20 Attempt to cope with case variations in subdir names of OOo install dir (_get_dir_) % 2011-05-27 Fix proper return value (retval); header text improved % 2011-05-29 Made retval value dependent on detected interfaces & adapted help text +% 2011-06-07 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg + jcp = []; retval = 0; if (nargin < 3); path_to_ooo= ''; end %if if (nargin < 2); dbug = 0; end %if @@ -146,7 +148,7 @@ % Under *nix the classpath must first be split up. % Matlab is braindead here. For ML we need a replacement for Octave's builtin strsplit() % This is found on ML Central (BSD license so this is allowed) & adapted for input arg order - if (isunix); jcp = strsplit (char (jcp), ':'); end %if + if (isunix & ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if if (dbug > 1) % Check JVM virtual memory settings jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-06-06 19:25:56
|
Revision: 8319 http://octave.svn.sourceforge.net/octave/?rev=8319&view=rev Author: prnienhuis Date: 2011-06-06 19:25:50 +0000 (Mon, 06 Jun 2011) Log Message: ----------- Fixed wrong return value update when adding UNO classes Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-06-06 18:27:03 UTC (rev 8318) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-06-06 19:25:50 UTC (rev 8319) @@ -78,9 +78,9 @@ % 2011-05-20 Attempt to cope with case variations in subdir names of OOo install dir (_get_dir_) % 2011-05-27 Fix proper return value (retval); header text improved % 2011-05-29 Made retval value dependent on detected interfaces & adapted help text -% 2011-06-07 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg +% 2011-06-06 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg +% '' Fixed wrong return value update when adding UNO classes - jcp = []; retval = 0; if (nargin < 3); path_to_ooo= ''; end %if if (nargin < 2); dbug = 0; end %if @@ -316,8 +316,8 @@ % Worked in 0.7.5 odfvsn = javaMethod ('getApplicationVersion', 'org.odftoolkit.odfdom.Version'); end %try_catch - if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6')) - warning (' *** odfdom version (%s) is not supported - use v. 0.7.5 or 0.8.6.\n', odfvsn); + if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6') || strcmp (odfvsn, '0.8.7')) + warning (' *** odfdom version (%s) is not supported - use v. 0.8.6 or 0.8.7.\n', odfvsn); else if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if retval = retval + 32; @@ -468,12 +468,12 @@ end %if end %if end %for + if (~target); retval = retval + 128; end %if if (dbug) if (targt) fprintf ('Some UNO class libs still lacking...\n\n'); else fprintf ('UNO interface supported now.\n\n'); - retval = retval + 128; end %if end %f end %if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-08-08 20:26:48
|
Revision: 8452 http://octave.svn.sourceforge.net/octave/?rev=8452&view=rev Author: prnienhuis Date: 2011-08-08 20:26:42 +0000 (Mon, 08 Aug 2011) Log Message: ----------- Extend Java JRE check for misconfigured Java installs that nevertheless work OK Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-08-08 20:21:25 UTC (rev 8451) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-08-08 20:26:42 UTC (rev 8452) @@ -80,6 +80,7 @@ % 2011-05-29 Made retval value dependent on detected interfaces & adapted help text % 2011-06-06 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg % '' Fixed wrong return value update when adding UNO classes +% 2011-08-08 Extend Java JRE check for misconfigured Java installs that nevertheless work OK jcp = []; retval = 0; if (nargin < 3); path_to_ooo= ''; end %if @@ -119,7 +120,14 @@ jtst = isempty (strfind (tst1, 'Java')); end %if if (jtst) - error ('Apparently no Java JRE installed.'); + % Java my have been misconfigure, so just try... + try + jtst = javamem; + % if empty, provoke fall-through to catch + if (isempty (jtst)); jtst = 1 / jtst; end + catch + error ('Apparently no Java JRE installed.'); + end else if (dbug > 1), fprintf ('OK, found one.\n'); end %if end %if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-09-04 20:04:15
|
Revision: 8495 http://octave.svn.sourceforge.net/octave/?rev=8495&view=rev Author: prnienhuis Date: 2011-09-04 20:04:09 +0000 (Sun, 04 Sep 2011) Log Message: ----------- Improved code to search unoil.jar (dir command in MinGW octave-3.4.2 became case-sensitive) Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-09-04 20:02:21 UTC (rev 8494) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-09-04 20:04:09 UTC (rev 8495) @@ -80,7 +80,7 @@ % 2011-05-29 Made retval value dependent on detected interfaces & adapted help text % 2011-06-06 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg % '' Fixed wrong return value update when adding UNO classes -% 2011-08-08 Extend Java JRE check for misconfigured Java installs that nevertheless work OK +% 2011-09-03 Small fix to better detect Basis* subdir when searching unoil.jar jcp = []; retval = 0; if (nargin < 3); path_to_ooo= ''; end %if @@ -120,14 +120,7 @@ jtst = isempty (strfind (tst1, 'Java')); end %if if (jtst) - % Java my have been misconfigure, so just try... - try - jtst = javamem; - % if empty, provoke fall-through to catch - if (isempty (jtst)); jtst = 1 / jtst; end - catch - error ('Apparently no Java JRE installed.'); - end + error ('Apparently no Java JRE installed.'); else if (dbug > 1), fprintf ('OK, found one.\n'); end %if end %if @@ -430,10 +423,10 @@ if (ii == 2) % Special case as unoil.jar usually resides in ./Basis<something>/program/classes % Find out the exact name of Basis..... - basisdirlst = dir ([path_to_ooo filesep 'basis' '*']); + basisdirlst = dir ([path_to_ooo filesep '?asis' '*']); jj = 1; while (jj <= size (basisdirlst, 1) && jj > 0) - % basisdir = basisdirlst(jj).name; + basisdir = basisdirlst(jj).name; if (basisdirlst(jj).isdir) basisdir = basisdirlst(jj).name; jj = 0; @@ -476,7 +469,7 @@ end %if end %if end %for - if (~target); retval = retval + 128; end %if + if (~targt); retval = retval + 128; end %if if (dbug) if (targt) fprintf ('Some UNO class libs still lacking...\n\n'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-09-18 16:23:17
|
Revision: 8553 http://octave.svn.sourceforge.net/octave/?rev=8553&view=rev Author: prnienhuis Date: 2011-09-18 16:23:11 +0000 (Sun, 18 Sep 2011) Log Message: ----------- Fixed complaint about "matlab-style short-circuit' etc. Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-09-18 16:22:25 UTC (rev 8552) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-09-18 16:23:11 UTC (rev 8553) @@ -81,6 +81,7 @@ % 2011-06-06 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg % '' Fixed wrong return value update when adding UNO classes % 2011-09-03 Small fix to better detect Basis* subdir when searching unoil.jar +% 2011-09-18 FIxed 'Matlab style short circuit' warning in L. 152 jcp = []; retval = 0; if (nargin < 3); path_to_ooo= ''; end %if @@ -149,7 +150,7 @@ % Under *nix the classpath must first be split up. % Matlab is braindead here. For ML we need a replacement for Octave's builtin strsplit() % This is found on ML Central (BSD license so this is allowed) & adapted for input arg order - if (isunix & ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if + if (isunix && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if if (dbug > 1) % Check JVM virtual memory settings jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-10-27 09:14:50
|
Revision: 8870 http://octave.svn.sourceforge.net/octave/?rev=8870&view=rev Author: prnienhuis Date: 2011-10-27 09:14:44 +0000 (Thu, 27 Oct 2011) Log Message: ----------- Tamed down error msg in case of Java problems, to better allow invocation from .octaverc Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-10-27 06:04:32 UTC (rev 8869) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-10-27 09:14:44 UTC (rev 8870) @@ -82,12 +82,14 @@ % '' Fixed wrong return value update when adding UNO classes % 2011-09-03 Small fix to better detect Basis* subdir when searching unoil.jar % 2011-09-18 FIxed 'Matlab style short circuit' warning in L. 152 +% 2011-10-27 Relaxed error msgs in Java detection, just return gracefully now. +% '' This was changed to allow invocation during Octave start up jcp = []; retval = 0; if (nargin < 3); path_to_ooo= ''; end %if - if (nargin < 2); dbug = 0; end %if + if (nargin < 2); dbug = 0; end %if isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; - if (dbug); fprintf ('\n'); end %if + if (dbug); fprintf ('\n'); end %if % interfaces = {'COM', 'POI', 'POI+OOXML', 'JXL', 'OXS', 'OTK', 'JOD', 'UNO'}; % Order = vital % Check if MS-Excel COM ActiveX server runs @@ -104,9 +106,9 @@ catch % COM not supported if (dbug), fprintf ('not working.\n\n'); end %if - end %try_catch + end %try_catch - % Check Java + % Check Java if (dbug), fprintf ('Checking Java support...\n'); end %if if (dbug > 1), fprintf (' 1. Checking Java JRE presence.... '); end %if % Try if Java is installed at all @@ -120,12 +122,15 @@ tst1 = version ('-java'); jtst = isempty (strfind (tst1, 'Java')); end %if - if (jtst) - error ('Apparently no Java JRE installed.'); - else - if (dbug > 1), fprintf ('OK, found one.\n'); end %if - end %if - if (dbug > 1 && isOctave), fprintf (' 2. Checking Octave Java support... '); end %if + if (dbug > 1) + if (jtst) + fprintf ('Apparently no Java JRE installed.'); + return; + else + fprintf ('OK, found one.\n'); + end %if + end %if + if (dbug > 1 && isOctave), fprintf (' 2. Checking Octave Java support... '); end %if try jcp = javaclasspath ('-all'); % For Octave java pkg > 1.2.7 if (isempty (jcp)), jcp = javaclasspath; end %if % For Octave java pkg < 1.2.8 @@ -155,7 +160,7 @@ % Check JVM virtual memory settings jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); jmem = jrt.maxMemory (); - if (isOctave), jmem = jmem.doubleValue(); end %if + if (isOctave), jmem = jmem.doubleValue(); end %if jmem = int16 (jmem/1024/1024); fprintf (' Maximum JVM memory: %5d MiB; ', jmem); if (jmem < 400) @@ -171,8 +176,11 @@ end %if end %if if (dbug), fprintf ('Java support OK\n'); end %if - catch - error ('No Java support found.'); + catch + if (dbug > 1) + fprintf ('No functional Java support found.'); + return + end %if end %try_catch if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2011-12-24 15:04:04
|
Revision: 9463 http://octave.svn.sourceforge.net/octave/?rev=9463&view=rev Author: prnienhuis Date: 2011-12-24 15:03:58 +0000 (Sat, 24 Dec 2011) Log Message: ----------- Amended code stanza to find unoil.jar to work in LibreOffice 3.5b2 as well Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-12-24 00:13:49 UTC (rev 9462) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2011-12-24 15:03:58 UTC (rev 9463) @@ -81,15 +81,14 @@ % 2011-06-06 Fix for javaclasspath format in *nix w. octave-java-1.2.8 pkg % '' Fixed wrong return value update when adding UNO classes % 2011-09-03 Small fix to better detect Basis* subdir when searching unoil.jar -% 2011-09-18 FIxed 'Matlab style short circuit' warning in L. 152 -% 2011-10-27 Relaxed error msgs in Java detection, just return gracefully now. -% '' This was changed to allow invocation during Octave start up +% 2011-09-18 Fixed 'Matlab style short circuit' warning in L. 152 +% 2012-12-24 Amended code stanze to find unoil.jar; now works in LibreOffice 3.5b2 as well jcp = []; retval = 0; if (nargin < 3); path_to_ooo= ''; end %if - if (nargin < 2); dbug = 0; end %if + if (nargin < 2); dbug = 0; end %if isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; - if (dbug); fprintf ('\n'); end %if + if (dbug); fprintf ('\n'); end %if % interfaces = {'COM', 'POI', 'POI+OOXML', 'JXL', 'OXS', 'OTK', 'JOD', 'UNO'}; % Order = vital % Check if MS-Excel COM ActiveX server runs @@ -106,9 +105,9 @@ catch % COM not supported if (dbug), fprintf ('not working.\n\n'); end %if - end %try_catch + end %try_catch - % Check Java + % Check Java if (dbug), fprintf ('Checking Java support...\n'); end %if if (dbug > 1), fprintf (' 1. Checking Java JRE presence.... '); end %if % Try if Java is installed at all @@ -122,15 +121,12 @@ tst1 = version ('-java'); jtst = isempty (strfind (tst1, 'Java')); end %if - if (dbug > 1) - if (jtst) - fprintf ('Apparently no Java JRE installed.'); - return; - else - fprintf ('OK, found one.\n'); - end %if - end %if - if (dbug > 1 && isOctave), fprintf (' 2. Checking Octave Java support... '); end %if + if (jtst) + error ('Apparently no Java JRE installed.'); + else + if (dbug > 1), fprintf ('OK, found one.\n'); end %if + end %if + if (dbug > 1 && isOctave), fprintf (' 2. Checking Octave Java support... '); end %if try jcp = javaclasspath ('-all'); % For Octave java pkg > 1.2.7 if (isempty (jcp)), jcp = javaclasspath; end %if % For Octave java pkg < 1.2.8 @@ -160,7 +156,7 @@ % Check JVM virtual memory settings jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); jmem = jrt.maxMemory (); - if (isOctave), jmem = jmem.doubleValue(); end %if + if (isOctave), jmem = jmem.doubleValue(); end %if jmem = int16 (jmem/1024/1024); fprintf (' Maximum JVM memory: %5d MiB; ', jmem); if (jmem < 400) @@ -176,11 +172,8 @@ end %if end %if if (dbug), fprintf ('Java support OK\n'); end %if - catch - if (dbug > 1) - fprintf ('No functional Java support found.'); - return - end %if + catch + error ('No Java support found.'); end %try_catch if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if @@ -434,16 +427,20 @@ % Find out the exact name of Basis..... basisdirlst = dir ([path_to_ooo filesep '?asis' '*']); jj = 1; - while (jj <= size (basisdirlst, 1) && jj > 0) - basisdir = basisdirlst(jj).name; - if (basisdirlst(jj).isdir) - basisdir = basisdirlst(jj).name; - jj = 0; - else - jj = jj + 1; - end %if - end %while - basisdir = [path_to_ooo filesep basisdir ]; + if (numel (basisdirlst) > 0) + while (jj <= size (basisdirlst, 1) && jj > 0) + basisdir = basisdirlst(jj).name; + if (basisdirlst(jj).isdir) + basisdir = basisdirlst(jj).name; + jj = 0; + else + jj = jj + 1; + end %if + end %while + basisdir = [path_to_ooo filesep basisdir ]; + else + basisdir = path_to_ooo; + endif basisdirentries = {'program', 'classes'}; tmp = basisdir; jj=1; while (~isempty (tmp) && jj <= numel (basisdirentries)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-19 02:20:54
|
Revision: 9963 http://octave.svn.sourceforge.net/octave/?rev=9963&view=rev Author: carandraug Date: 2012-03-19 02:20:48 +0000 (Mon, 19 Mar 2012) Log Message: ----------- chk_spreadsheet_support: make error message more helpful on why java is failing Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-03-19 00:54:13 UTC (rev 9962) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-03-19 02:20:48 UTC (rev 9963) @@ -173,7 +173,7 @@ end %if if (dbug), fprintf ('Java support OK\n'); end %if catch - error ('No Java support found.'); + error ('No Java support found: %s.' lasterr); end %try_catch if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-19 02:49:02
|
Revision: 9964 http://octave.svn.sourceforge.net/octave/?rev=9964&view=rev Author: carandraug Date: 2012-03-19 02:48:56 +0000 (Mon, 19 Mar 2012) Log Message: ----------- chk_spreadsheet_support: small syntax bugfix (missing comma) Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-03-19 02:20:48 UTC (rev 9963) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-03-19 02:48:56 UTC (rev 9964) @@ -173,7 +173,7 @@ end %if if (dbug), fprintf ('Java support OK\n'); end %if catch - error ('No Java support found: %s.' lasterr); + error ('No Java support found: %s.', lasterr); end %try_catch if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-06-24 19:33:40
|
Revision: 10683 http://octave.svn.sourceforge.net/octave/?rev=10683&view=rev Author: prnienhuis Date: 2012-06-24 19:33:33 +0000 (Sun, 24 Jun 2012) Log Message: ----------- Replaced error messages by printf & return; check for odfdom version updated to 0.8.8 Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-06-24 19:26:09 UTC (rev 10682) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-06-24 19:33:33 UTC (rev 10683) @@ -84,6 +84,9 @@ % 2011-09-18 Fixed 'Matlab style short circuit' warning in L. 152 % 2012-12-24 Amended code stanze to find unoil.jar; now works in LibreOffice 3.5b2 as well % 2012-06-07 Replaced all tabs by double space +% 2012-06-24 Replaced error msg by printf & return +% '' Added Java pkg inquiry (Octave) before attempting javaclasspath() +% '' Updated check for odfdom version (now supports 0.8.8) jcp = []; retval = 0; if (nargin < 3); path_to_ooo= ''; end %if @@ -106,7 +109,7 @@ catch % COM not supported if (dbug), fprintf ('not working.\n\n'); end %if - end %try_catch + end %try_catch % Check Java if (dbug), fprintf ('Checking Java support...\n'); end %if @@ -120,15 +123,25 @@ end %if else tst1 = version ('-java'); - jtst = isempty (strfind (tst1, 'Java')); + jtst = isempty (strfind (tst1, 'Java')); end %if if (jtst) - error ('Apparently no Java JRE installed.'); + printf ('Apparently no Java JRE installed.\n'); + return; else if (dbug > 1), fprintf ('OK, found one.\n'); end %if end %if if (dbug > 1 && isOctave), fprintf (' 2. Checking Octave Java support... '); end %if try + if (isOctave) + % Check Java package + [~, b] = pkg ('describe', 'java'); + if (strcmpi (b{:}, 'Not loaded')) + if (dbug > 1); printf ('Java package not loaded. First do: "pkg load java"\n'); end %if + elseif strcmpi (b{:}, 'Not installed') + if (dbug > 1); printf ('Java package is not installed.\n'); end %if + endif + end %if jcp = javaclasspath ('-all'); % For Octave java pkg > 1.2.7 if (isempty (jcp)), jcp = javaclasspath; end %if % For Octave java pkg < 1.2.8 % If we get here, at least Java works. @@ -152,7 +165,7 @@ % Under *nix the classpath must first be split up. % Matlab is braindead here. For ML we need a replacement for Octave's builtin strsplit() % This is found on ML Central (BSD license so this is allowed) & adapted for input arg order - if (isunix && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if + if (isunix && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if if (dbug > 1) % Check JVM virtual memory settings jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); @@ -173,8 +186,9 @@ end %if end %if if (dbug), fprintf ('Java support OK\n'); end %if - catch - error ('No Java support found: %s.', lasterr); + catch + printf ('No Java support found.\n'); + return end %try_catch if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); end %if @@ -320,8 +334,9 @@ % Worked in 0.7.5 odfvsn = javaMethod ('getApplicationVersion', 'org.odftoolkit.odfdom.Version'); end %try_catch - if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6') || strcmp (odfvsn, '0.8.7')) - warning (' *** odfdom version (%s) is not supported - use v. 0.8.6 or 0.8.7.\n', odfvsn); + if ~(strcmp (odfvsn, '0.7.5') || strcmp (odfvsn, '0.8.6') || strcmp (odfvsn, '0.8.7') + || ~isempty (strfind (odfvsn, '0.8.8'))) + warning (' *** odfdom version (%s) is not supported - use v. 0.8.6 or newer\n', odfvsn); else if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if retval = retval + 32; @@ -398,7 +413,7 @@ if (~ujars_complete && nargin > 0 && ~isempty (path_to_ooo)) if (dbug), fprintf ('\nTrying to add missing UNO java class libs to javaclasspath...\n'); end %if - if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if + if (~ischar (path_to_jars)), printf ('Path expected for arg # 1\n'); return; end %if % Add missing jars to javaclasspath. First combine all entries targt = sum (missing0); if (missing0(1)) @@ -414,7 +429,10 @@ if (dbug > 2), fprintf ('FAILED\n'); end %if end %try_catch else - if (dbug > 2), error ('Suggested OpenOffice.org install directory: %s not found!\n', path_to_ooo); end %if + if (dbug > 2) + printf ('Suggested OpenOffice.org install directory: %s not found!\n', path_to_ooo); + return + end %if end %if end %if % Rest of missing entries. Find where URE is located. Watch out because case of ./ure is unknown @@ -492,7 +510,7 @@ jars_complete = isempty (find (missing, 1)); if (dbug) if (jars_complete) - fprintf ('All interfaces already fully supported.\n\n'); + fprintf ('All Java-based interfaces (save UNO) fully supported.\n\n'); else fprintf ('Some class libs lacking yet...\n\n'); end %if @@ -501,7 +519,7 @@ if (~jars_complete && nargin > 0 && ~isempty (path_to_jars)) % Add missing jars to javaclasspath. Assume they're all in the same place if (dbug), fprintf ('Trying to add missing java class libs to javaclasspath...\n'); end %if - if (~ischar (path_to_jars)), error ('Path expected for arg # 1'); end %if + if (~ischar (path_to_jars)), printf ('Path expected for arg # 1\n'); return; end %if % First combine all entries targt = sum (missing); % Search tru list of missing entries @@ -536,7 +554,7 @@ if (targt) fprintf ('Some other class libs still lacking...\n\n'); else - fprintf ('All interfaces fully supported.now.\n\n'); + fprintf ('All Java-based interfaces fully supported.now.\n\n'); end %if end %f end %if This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |