From: <prn...@us...> - 2010-01-03 22:33:53
|
Revision: 6698 http://octave.svn.sourceforge.net/octave/?rev=6698&view=rev Author: prnienhuis Date: 2010-01-03 22:33:41 +0000 (Sun, 03 Jan 2010) Log Message: ----------- Fixed some small bugs; added JOpenDocument support for odsfinfo.m; fixed reading from date/time cells when using jOpenDocument; improved help texts; cleaned up code. Modified Paths: -------------- trunk/octave-forge/main/io/inst/ods2oct.m trunk/octave-forge/main/io/inst/odsfinfo.m trunk/octave-forge/main/io/inst/odsopen.m trunk/octave-forge/main/io/inst/odsread.m Modified: trunk/octave-forge/main/io/inst/ods2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/ods2oct.m 2010-01-03 22:30:17 UTC (rev 6697) +++ trunk/octave-forge/main/io/inst/ods2oct.m 2010-01-03 22:33:41 UTC (rev 6698) @@ -56,7 +56,7 @@ ## ## Erroneous data and empty cells turn up empty in @var{rawarr}. ## Date/time values in OpenOffice.org are returned as numerical values -## with base 1-1-000 (same as octave). But beware that Excel spreadsheets +## with base 1-1-0000 (same as octave). But beware that Excel spreadsheets ## rewritten by OpenOffice.org into .ods format may have numerical date ## cells with base 01-01-1900 (same as MS-Excel). ## Modified: trunk/octave-forge/main/io/inst/odsfinfo.m =================================================================== --- trunk/octave-forge/main/io/inst/odsfinfo.m 2010-01-03 22:30:17 UTC (rev 6697) +++ trunk/octave-forge/main/io/inst/odsfinfo.m 2010-01-03 22:33:41 UTC (rev 6698) @@ -15,8 +15,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} [@var{filetype}] = odsfinfo (@var{filename}) -## @deftypefnx {Function File} [@var{filetype}, @var{sh_names}] = odsfinfo (@var{filename}) +## @deftypefn {Function File} [@var{filetype}] = odsfinfo (@var{filename} [, @var{reqintf}]) +## @deftypefnx {Function File} [@var{filetype}, @var{sh_names}] = odsfinfo (@var{filename} [, @var{reqintf}]) ## Query an OpenOffice.org spreadsheet file @var{filename} (with .ods ## suffix) for some info about its contents (viz. sheet names). ## @@ -30,10 +30,14 @@ ## to right) in which they occur in the sheet stack. ## ## If you omit return arguments @var{filetype} and @var{sh_names} altogether, -## odsfinfo returns the sheet names + a guess for the number of rows -## containing actual data to the screen. +## odsfinfo returns the sheet names + (in case of the ODF toolkit interfcae) +## a raw guess for the number of rows containing actual data to the screen +## (actually the number of "table-rows" in ODS). ## -## odsfinfo execution can take its time as the entire spreadsheet has to +## By specifying a value of 'jod' or 'otk' for @var{reqintf} the automatic +## selection of the java interface is bypassed and the specified interface +## will be used (if at all present). +#### odsfinfo execution can take its time as the entire spreadsheet has to ## be parsed to get the sheet names. ## ## Examples: @@ -49,20 +53,20 @@ ## list of sheet names) ## @end example ## -## @seealso odsread, ods2oct +## @seealso odsread, odsopen, ods2oct, odsclose ## ## @end deftypefn ## Author: Philip Nienhuis <pr.nienhuis at users.sf.net> ## Created: 2009-12-17 -## Last updated 2009-12-29 +## Last updated 2010-01-03 (added functionality for JOD as well) -function [ filetype, sheetnames ] = odsfinfo (filename) +function [ filetype, sheetnames ] = odsfinfo (filename, reqintf=[]) onscreen = nargout < 1; + + ods = odsopen (filename, 0, reqintf); - ods = odsopen (filename); - filetype = 'OpenOffice.org Calc Document'; # To save execution time, only proceed if sheet names are wanted @@ -95,11 +99,21 @@ endfor elseif (strcmp (ods.xtype, 'JOD')) - # jOpenDocument doesn't support sheet name extraction (yet?) - printf ("No sheet name support implemented in jOpenDocument.\n") + nr_of_sheets = ods.workbook.getSheetCount (); + sheetnames = cell (nr_of_sheets, 1); + for ii=1:nr_of_sheets + tmp1 = char (ods.workbook.getSheet (ii-1)); + ist = index (tmp1, 'table:name=') + 12; + ien = index (tmp1(ist:end), '" table') - 2 + ist; + sheetnames(ii) = tmp1(ist:ien); + if (onscreen) + # Echo sheet names + printf (" %s\n", sheetnames{ii}); + endif + endfor else - error (sprintf ("odsfinfo: unknown OpenOffice.org .ods interface - %s.", xls.xtype)); +# error (sprintf ("odsfinfo: unknown OpenOffice.org .ods interface - %s.", xls.xtype)); endif endif Modified: trunk/octave-forge/main/io/inst/odsopen.m =================================================================== --- trunk/octave-forge/main/io/inst/odsopen.m 2010-01-03 22:30:17 UTC (rev 6697) +++ trunk/octave-forge/main/io/inst/odsopen.m 2010-01-03 22:33:41 UTC (rev 6698) @@ -24,7 +24,7 @@ ## Calling odsopen without specifying a return argument is fairly useless! ## ## To make this function work at all, you need the Java package > 1.2.5 plus -## either ODFtoolkit > 3.5 & xercesImpl, or jOpenDocument installed on your +## either ODFtoolkit > 0.7.5 & xercesImpl, or jOpenDocument installed on your ## computer + proper javaclasspath set. These interfaces are referred to as ## OTK and JOD, resp., and are preferred in that order by default (depending ## on their presence). @@ -58,7 +58,7 @@ ## Created: 2009-12-13 ## Last update: 2009-12-30 -function [ ods ] = odsopen (filename, rw=0, reqinterface = []) +function [ ods ] = odsopen (filename, rw=0, reqinterface=[]) persistent odsinterfaces; persistent chkintf; if (isempty (chkintf)) Modified: trunk/octave-forge/main/io/inst/odsread.m =================================================================== --- trunk/octave-forge/main/io/inst/odsread.m 2010-01-03 22:30:17 UTC (rev 6697) +++ trunk/octave-forge/main/io/inst/odsread.m 2010-01-03 22:33:41 UTC (rev 6698) @@ -56,7 +56,8 @@ ## ## The optional last argument @var{reqintf} can be used to override ## the automatic selection by odsread of one interface out of the -## supported ones: Java/ODFtoolkit or Java/jOpenDocument. +## supported ones: Java/ODFtoolkit ('OTK') or Java/jOpenDocument +## ('JOD'). ## ## Erroneous data and empty cells are set to NaN in @var{numarr} and ## turn up empty in @var{txtarr} and @var{rawarr}. Date/time values This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |