From: <prn...@us...> - 2012-03-18 13:31:25
|
Revision: 9944 http://octave.svn.sourceforge.net/octave/?rev=9944&view=rev Author: prnienhuis Date: 2012-03-18 13:31:18 +0000 (Sun, 18 Mar 2012) Log Message: ----------- Fixed texinfo header (to be compatible w. get_first_help_sentence.m) Modified Paths: -------------- trunk/octave-forge/main/io/inst/append_save.m trunk/octave-forge/main/io/inst/getusedrange.m trunk/octave-forge/main/io/inst/oct2xls.m trunk/octave-forge/main/io/inst/ods2oct.m trunk/octave-forge/main/io/inst/odsopen.m trunk/octave-forge/main/io/inst/odsread.m trunk/octave-forge/main/io/inst/odswrite.m trunk/octave-forge/main/io/inst/xls2oct.m trunk/octave-forge/main/io/inst/xlswrite.m Modified: trunk/octave-forge/main/io/inst/append_save.m =================================================================== --- trunk/octave-forge/main/io/inst/append_save.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/append_save.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -14,7 +14,7 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## ## append_save M-file function -## + ## Objective: be able to add variables to existing save files. Works for ## all the types of save files that "save" supports. ## Modified: trunk/octave-forge/main/io/inst/getusedrange.m =================================================================== --- trunk/octave-forge/main/io/inst/getusedrange.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/getusedrange.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -18,7 +18,7 @@ ## @deftypefn {Function File} [ @var{toprow#}, @var{bottomrow#}, @var{leftcol#}, @var{rightcol#} ] = getusedrange (@var{spptr}, @var{shindex#}) ## Find occupied data range in worksheet @var{shindex#} in a spreadsheet ## pointed to in struct @var{spptr} (either MS-Excel or -## OpenOffice Calc). +## OpenOffice_org Calc). ## ## @var{shindex#} must be numeric and is 1-based. @var{spptr} can either ## refer to an MS-Excel spreadsheet (spptr returned by xlsopen) or an Modified: trunk/octave-forge/main/io/inst/oct2xls.m =================================================================== --- trunk/octave-forge/main/io/inst/oct2xls.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/oct2xls.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -20,7 +20,7 @@ ## @deftypefnx {Function File} [ @var{xls}, @var{rstatus} ] = oct2xls (@var{arr}, @var{xls}, @var{wsh}, @var{range}) ## @deftypefnx {Function File} [ @var{xls}, @var{rstatus} ] = oct2xls (@var{arr}, @var{xls}, @var{wsh}, @var{range}, @var{options}) ## -## Add data in 1D/2D CELL array @var{arr} into a range specified in +## Add data in 1D/2D CELL array @var{arr} into a cell range specified in ## @var{range} in worksheet @var{wsh} in an Excel spreadsheet file ## pointed to in structure @var{xls}. ## Return argument @var{xls} equals supplied argument @var{xls} and is Modified: trunk/octave-forge/main/io/inst/ods2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/ods2oct.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/ods2oct.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -20,7 +20,7 @@ ## @deftypefnx {Function File} [ @var{rawarr}, @var{ods}, @var{rstatus} ] = ods2oct (@var{ods}, @var{wsh}, @var{range}) ## @deftypefnx {Function File} [ @var{rawarr}, @var{ods}, @var{rstatus} ] = ods2oct (@var{ods}, @var{wsh}, @var{range}, @var{options}) ## -## Read data contained within range @var{range} from worksheet @var{wsh} +## Read data contained within cell range @var{range} from worksheet @var{wsh} ## in an OpenOffice_org Calc spreadsheet file pointed to in struct @var{ods}. ## ## @var{ods} is supposed to have been created earlier by odsopen in the Modified: trunk/octave-forge/main/io/inst/odsopen.m =================================================================== --- trunk/octave-forge/main/io/inst/odsopen.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/odsopen.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -19,7 +19,7 @@ ## @deftypefnx {Function File} @var{ods} = odsopen (@var{filename}, @var{readwrite}) ## @deftypefnx {Function File} @var{ods} = odsopen (@var{filename}, @var{readwrite}, @var{reqintf}) ## Get a pointer to an OpenOffice_org spreadsheet in the form of return -## argument @var{ods}. +## argument (struct) @var{ods}. ## ## Calling odsopen without specifying a return argument is fairly useless! ## Modified: trunk/octave-forge/main/io/inst/odsread.m =================================================================== --- trunk/octave-forge/main/io/inst/odsread.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/odsread.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -20,7 +20,7 @@ ## @deftypefnx {Function File} [@var{numarr}, @var{txtarr}, @var{rawarr}, @var{limits}] = odsread (@var{filename}, @var{wsh}, @var{range}) ## @deftypefnx {Function File} [@var{numarr}, @var{txtarr}, @var{rawarr}, @var{limits}] = odsread (@var{filename}, @var{wsh}, @var{range}, @var{reqintf}) ## -## Read data contained in range @var{range} from worksheet @var{wsh} +## Read data contained from cell range @var{range} in worksheet @var{wsh} ## in OpenOffice_org Calc spreadsheet file @var{filename}. ## ## You need the octave-forge java package (> 1.2.6) and one or both of Modified: trunk/octave-forge/main/io/inst/odswrite.m =================================================================== --- trunk/octave-forge/main/io/inst/odswrite.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/odswrite.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -19,8 +19,8 @@ ## @deftypefnx {Function File} @var{rstatus} = odswrite (@var{filename}, @var{arr}, @var{wsh}) ## @deftypefnx {Function File} @var{rstatus} = odswrite (@var{filename}, @var{arr}, @var{wsh}, @var{range}) ## @deftypefnx {Function File} @var{rstatus} = odswrite (@var{filename}, @var{arr}, @var{wsh}, @var{range}, @var{reqintf}) -## Add data in 1D/2D array @var{arr} to sheet @var{wsh} in -## OpenOffice_org Calc spreadsheet file @var{filename} in range @var{range}. +## Add data in 1D/2D array @var{arr} into sheet @var{wsh} in +## OpenOffice_org Calc spreadsheet file @var{filename} in cell range @var{range}. ## ## @var{rstatus} returns 1 if write succeeded, 0 otherwise. ## Modified: trunk/octave-forge/main/io/inst/xls2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/xls2oct.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/xls2oct.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -20,7 +20,7 @@ ## @deftypefnx {Function File} [ @var{rawarr}, @var{xls}, @var{rstatus} ] = xls2oct (@var{xls}, @var{wsh}, @var{range}) ## @deftypefnx {Function File} [ @var{rawarr}, @var{xls}, @var{rstatus} ] = xls2oct (@var{xls}, @var{wsh}, @var{range}, @var{options}) ## -## Read data contained within range @var{range} from worksheet @var{wsh} +## Read data contained within cell range @var{range} from worksheet @var{wsh} ## in an Excel spreadsheet file pointed to in struct @var{xls}. ## ## @var{xls} is supposed to have been created earlier by xlsopen in the Modified: trunk/octave-forge/main/io/inst/xlswrite.m =================================================================== --- trunk/octave-forge/main/io/inst/xlswrite.m 2012-03-18 12:59:01 UTC (rev 9943) +++ trunk/octave-forge/main/io/inst/xlswrite.m 2012-03-18 13:31:18 UTC (rev 9944) @@ -20,7 +20,7 @@ ## @deftypefnx {Function File} @var{rstatus} = xlswrite (@var{filename}, @var{arr}, @var{wsh}, @var{range}) ## @deftypefnx {Function File} @var{rstatus} = xlswrite (@var{filename}, @var{arr}, @var{wsh}, @var{range}, @var{reqintf}) ## Add data in 1D/2D array @var{arr} to worksheet @var{wsh} in Excel -## spreadsheet file @var{filename} in range @var{range}. +## spreadsheet file @var{filename} in cell range @var{range}. ## ## @var{rstatus} returns 1 if write succeeded, 0 otherwise. ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-03-18 16:09:55
|
Revision: 9949 http://octave.svn.sourceforge.net/octave/?rev=9949&view=rev Author: prnienhuis Date: 2012-03-18 16:09:48 +0000 (Sun, 18 Mar 2012) Log Message: ----------- Texinfo header fixes (get_first_help_sentence compatibility) Modified Paths: -------------- trunk/octave-forge/main/io/inst/io_ods_testscript.m trunk/octave-forge/main/io/inst/io_xls_testscript.m trunk/octave-forge/main/io/inst/object2json.m trunk/octave-forge/main/io/inst/odsfinfo.m Modified: trunk/octave-forge/main/io/inst/io_ods_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_ods_testscript.m 2012-03-18 16:05:16 UTC (rev 9948) +++ trunk/octave-forge/main/io/inst/io_ods_testscript.m 2012-03-18 16:09:48 UTC (rev 9949) @@ -14,7 +14,7 @@ ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. -## Check proper operation of ODS spreadsheet scripts +## (Internal function) Check proper operation of ODS spreadsheet scripts. ## Before running, a character variable 'intf' should be initialized with ## a value of 'otk', 'jod', or 'uno'. Modified: trunk/octave-forge/main/io/inst/io_xls_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-03-18 16:05:16 UTC (rev 9948) +++ trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-03-18 16:09:48 UTC (rev 9949) @@ -14,7 +14,7 @@ ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. -## Check proper operation of XLS spreadsheet scripts. +## (Internal function) Check proper operation of XLS spreadsheet scripts. ## Before running, a character variable 'intf' should be initialized with ## a value of 'com', 'poi', 'jxl', 'oxs', or 'uno'. Modified: trunk/octave-forge/main/io/inst/object2json.m =================================================================== --- trunk/octave-forge/main/io/inst/object2json.m 2012-03-18 16:05:16 UTC (rev 9948) +++ trunk/octave-forge/main/io/inst/object2json.m 2012-03-18 16:09:48 UTC (rev 9949) @@ -23,8 +23,8 @@ function json = object2json (object) % function json = object2json (object) - % This function returns a valid json string that will describe object - % The string will be in a compact form (i.e. no spaces or line breaks) + % Returns a valid json string that will describe object; the string will + % be in a compact form (no spaces or line breaks). % % It will map simple octave values this way: % function handles: string with the name of the function Modified: trunk/octave-forge/main/io/inst/odsfinfo.m =================================================================== --- trunk/octave-forge/main/io/inst/odsfinfo.m 2012-03-18 16:05:16 UTC (rev 9948) +++ trunk/octave-forge/main/io/inst/odsfinfo.m 2012-03-18 16:09:48 UTC (rev 9949) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## @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 +## Query an OpenOffice_org spreadsheet file @var{filename} (with ods ## suffix) for some info about its contents. ## ## If @var{filename} is a recognizable OpenOffice.org spreadsheet file, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-21 00:15:53
|
Revision: 9984 http://octave.svn.sourceforge.net/octave/?rev=9984&view=rev Author: carandraug Date: 2012-03-21 00:15:43 +0000 (Wed, 21 Mar 2012) Log Message: ----------- io: update license to GPLv3+ Modified Paths: -------------- trunk/octave-forge/main/io/inst/append_save.m trunk/octave-forge/main/io/inst/calccelladdress.m trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m trunk/octave-forge/main/io/inst/fexist.m trunk/octave-forge/main/io/inst/getusedrange.m trunk/octave-forge/main/io/inst/io_ods_testscript.m trunk/octave-forge/main/io/inst/io_xls_testscript.m trunk/octave-forge/main/io/inst/object2json.m trunk/octave-forge/main/io/inst/oct2ods.m trunk/octave-forge/main/io/inst/oct2xls.m trunk/octave-forge/main/io/inst/ods2oct.m trunk/octave-forge/main/io/inst/odsclose.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 trunk/octave-forge/main/io/inst/odswrite.m trunk/octave-forge/main/io/inst/parse_sp_range.m trunk/octave-forge/main/io/inst/parsecell.m trunk/octave-forge/main/io/inst/pch2mat.m trunk/octave-forge/main/io/inst/spsh_chkrange.m trunk/octave-forge/main/io/inst/spsh_prstype.m trunk/octave-forge/main/io/inst/xls2oct.m trunk/octave-forge/main/io/inst/xlsclose.m trunk/octave-forge/main/io/inst/xlsfinfo.m trunk/octave-forge/main/io/inst/xlsopen.m trunk/octave-forge/main/io/inst/xlsread.m trunk/octave-forge/main/io/inst/xlswrite.m Modified: trunk/octave-forge/main/io/inst/append_save.m =================================================================== --- trunk/octave-forge/main/io/inst/append_save.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/append_save.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,20 +1,20 @@ -## Copyright (C) 2003 Tomer Altman <ta...@lb...> +## Copyright (C) 2003 Tomer Altman <ta...@lb...> ## -## 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 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 3 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. +## 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 this program; If not, see <http://www.gnu.org/licenses/>. -## -## append_save M-file function +## You should have received a copy of the GNU General Public License along with +## this program; if not, see <http://www.gnu.org/licenses/>. +## append_save M-file function +## ## Objective: be able to add variables to existing save files. Works for ## all the types of save files that "save" supports. ## @@ -163,4 +163,3 @@ filename, " ", var_str; ] ); endfunction - Modified: trunk/octave-forge/main/io/inst/calccelladdress.m =================================================================== --- trunk/octave-forge/main/io/inst/calccelladdress.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/calccelladdress.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ -## Copyright (C) 2009,2010,2011 Philip Nienhuis -## -## 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/>. +## Copyright (C) 2009,2010,2011 Philip Nienhuis <pr....@us...> +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## calccelladdress (R, C) - compute spreadsheet style cell address from ## row & column index (both 1-based). Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -48,21 +48,21 @@ function [ retval ] = chk_spreadsheet_support (path_to_jars, dbug, path_to_ooo) % 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/>. +% +% 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 3 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 +% this program; if not, see <http://www.gnu.org/licenses/>. + % Author: Philip Nienhuis % Created 2010-11-03 for Octave & Matlab % Updates: Modified: trunk/octave-forge/main/io/inst/fexist.m =================================================================== --- trunk/octave-forge/main/io/inst/fexist.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/fexist.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,17 +1,17 @@ -## Copyright (C) 2008 Jaroslav Hajek <hi...@gm...> +## Copyright (C) 2008 Jaroslav Hajek <hi...@gm...> ## -## 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 3 of the License, or -## (at your option) any later version. +## 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 3 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. +## 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 this program; If not, see <http://www.gnu.org/licenses/>. +## You should have received a copy of the GNU General Public License along with +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn{Function File} ex = fexist (file, tspec, aspec) Modified: trunk/octave-forge/main/io/inst/getusedrange.m =================================================================== --- trunk/octave-forge/main/io/inst/getusedrange.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/getusedrange.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ -## Copyright (C) 2010,2011 Philip Nienhuis, <pr....@us...> -## -## 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/>. +## Copyright (C) 2010,2011 Philip Nienhuis <pr....@us...> +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [ @var{toprow#}, @var{bottomrow#}, @var{leftcol#}, @var{rightcol#} ] = getusedrange (@var{spptr}, @var{shindex#}) @@ -97,20 +96,19 @@ ## Copyright (C) 2010,2011 Philip Nienhuis, pr.nienhuis -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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## getusedrange_otk - get used range from ODS spreadsheet using ODF Toolkit @@ -214,20 +212,19 @@ endfunction ## Copyright (C) 2010 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## getusedrange_jod @@ -356,20 +353,19 @@ ## Copyright (C) 2011 Philip Nienhuis -## -## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## getusedrange_uno @@ -437,20 +433,19 @@ ## Copyright (C) 2010 Philip Nienhuis -## -## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## getusedrange_com @@ -488,20 +483,19 @@ ## Copyright (C) 2010 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## getusedrange_poi - get range of occupied data cells from Excel using java/POI @@ -544,20 +538,19 @@ ## Copyright (C) 2010 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## getusedrange_jxl - get occupied data cell range from Excel sheet ## using java/JExcelAPI @@ -599,20 +592,19 @@ ## Copyright (C) 2010 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## getusedrange_oxs Modified: trunk/octave-forge/main/io/inst/io_ods_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_ods_testscript.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/io_ods_testscript.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ ## Copyright (C) 2012 Philip Nienhuis <pr.nienhuis 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## (Internal function) Check proper operation of ODS spreadsheet scripts. ## Before running, a character variable 'intf' should be initialized with Modified: trunk/octave-forge/main/io/inst/io_xls_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ ## Copyright (C) 2012 Philip Nienhuis <pr.nienhuis 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## (Internal function) Check proper operation of XLS spreadsheet scripts. ## Before running, a character variable 'intf' should be initialized with Modified: trunk/octave-forge/main/io/inst/object2json.m =================================================================== --- trunk/octave-forge/main/io/inst/object2json.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/object2json.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,46 @@ %% Copyright (C) 2010 Torre Herrera, Daniel de -%% -%% 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/>. +%% +%% 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 3 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 +%% this program; if not, see <http://www.gnu.org/licenses/>. + +%% Returns a valid json string that will describe object; the string will +%% be in a compact form (no spaces or line breaks). +%% +%% It will map simple octave values this way: +%% function handles: string with the name of the function +%% double (numbers): depends: +%% If it's real it will map to a string representing that number +%% If it's complex it will map to an object with the next properties: +%% real: real part of the number +%% imag: imaginary part of the number +%% char: A string enclosed by double quotes representing that character +%% And will map more complex octave values this other way: +%% struct: an object with properties equal to the struct's field names +%% and value equal to the json counterpart of that field +%% cell: it will be mapped depending on the value of the cell (for +%% example {i} will be mapped to an object with real=0 and imag=1) +%% vectors or cell arrays: it will map them to a corresponding js +%% array (same size) with the values transformed to their json +%% counterpart (Note: that in javascript all arrays are like octave's +%% cells ,i.e. they can store different type and size variables) +%% strings or char vectors: they will be mapped to the same string +%% enclosed by double quotes +%% Other octave values will be mapped to a string enclosed by double +%% quotes with the value that the class() function returns +%% It can handle escape sequences and special chars automatically. +%% If they're valid in JSON it will keep them if not they'll be +%% escaped so they can become valid + %% object2json.m %% Created: 2010-12-06 %% Updates: @@ -21,34 +49,6 @@ %% 2011-09-08 (Philip Nienhuis) layout & style changes cf. Octave coding style function json = object2json (object) - - % Returns a valid json string that will describe object; the string will - % be in a compact form (no spaces or line breaks). - % - % It will map simple octave values this way: - % function handles: string with the name of the function - % double (numbers): depends: - % If it's real it will map to a string representing that number - % If it's complex it will map to an object with the next properties: - % real: real part of the number - % imag: imaginary part of the number - % char: A string enclosed by double quotes representing that character - % And will map more complex octave values this other way: - % struct: an object with properties equal to the struct's field names - % and value equal to the json counterpart of that field - % cell: it will be mapped depending on the value of the cell (for - % example {i} will be mapped to an object with real=0 and imag=1) - % vectors or cell arrays: it will map them to a corresponding js - % array (same size) with the values transformed to their json - % counterpart (Note: that in javascript all arrays are like octave's - % cells ,i.e. they can store different type and size variables) - % strings or char vectors: they will be mapped to the same string - % enclosed by double quotes - % Other octave values will be mapped to a string enclosed by double - % quotes with the value that the class() function returns - % It can handle escape sequences and special chars automatically. - % If they're valid in JSON it will keep them if not they'll be - % escaped so they can become valid s = size (object); if (all (s==1)) Modified: trunk/octave-forge/main/io/inst/oct2ods.m =================================================================== --- trunk/octave-forge/main/io/inst/oct2ods.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/oct2ods.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ ## Copyright (C) 2009,2010,2011,2012 Philip Nienhuis <pr.nienhuis 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [ @var{ods}, @var{rstatus} ] = oct2ods (@var{arr}, @var{ods}) @@ -204,20 +203,19 @@ #============================================================================= ## Copyright (C) 2010,2011 Philip Nienhuis <prn...@us...> -## -## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## oct2jotk2ods ## write data array to an ODS spreadsheet using Java & ODFtoolkit 0.7.5 @@ -646,20 +644,19 @@ #============================================================================= ## Copyright (C) 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## odf3jotk2oct - read ODS spreadsheet data using Java & odftoolkit v 0.8.6. ## You need proper java-for-octave & odfdom.jar 0.8.6 + xercesImpl.jar @@ -844,20 +841,19 @@ #============================================================================= ## Copyright (C) 2009,2010,2011 Philip Nienhuis <pr.nienhuis 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## ods2oct - write data from octave to an ODS spreadsheet using the ## jOpenDocument interface. @@ -1005,20 +1001,19 @@ ## Copyright (C) 2011 Philip Nienhuis <prn...@us...> -## -## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## oct2uno2ods - transfer data to ods or xls file using Java/UNO bridge ## with OpenOffice_org & clones Modified: trunk/octave-forge/main/io/inst/oct2xls.m =================================================================== --- trunk/octave-forge/main/io/inst/oct2xls.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/oct2xls.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ ## Copyright (C) 2009,2010,2011,2012 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [ @var{xls}, @var{rstatus} ] = oct2xls (@var{arr}, @var{xls}) @@ -195,18 +194,18 @@ #=================================================================================== ## Copyright (C) 2009,2010,2011,2012 by Philip Nienhuis <prn...@us...> ## -## 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 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 3 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. +## 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 this program; If not, see <http://www.gnu.org/licenses/>. +## You should have received a copy of the GNU General Public License along with +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [@var{xlso}, @var{status}] = oct2com2xls (@var{obj}, @var{xlsi}) @@ -371,6 +370,7 @@ # Prepare to move new sheet to right of the worksheet stack anyway ws_cnt = xls.workbook.Worksheets.count; # New count needed # Find where Excel has left it. We have to, depends on Excel version :-( + ii = 1; while ((ii < ws_cnt+1) && ~strcmp (sh.Name, xls.workbook.Worksheets(ii).Name) == 1) ++ii; @@ -427,20 +427,19 @@ #==================================================================================== ## Copyright (C) 2009,2010,2011,2012 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [ @var{xlso}, @var{rstatus} ] = oct2jpoi2xls ( @var{arr}, @var{xlsi}) @@ -591,20 +590,19 @@ #==================================================================================== ## Copyright (C) 2009,2010,2011,2012 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [ @var{xlso}, @var{rstatus} ] = oct2jxla2xls ( @var{arr}, @var{xlsi}) @@ -773,20 +771,19 @@ ## Copyright (C) 2011 Philip Nienhuis <prn...@us...> -## -## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [ @var{xlso}, @var{rstatus} ] = oct2oxs2xls ( @var{arr}, @var{xlsi}) @@ -903,20 +900,19 @@ ## Copyright (C) 2011,2012 Philip Nienhuis <prn...@us...> -## -## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## oct2uno2xls Modified: trunk/octave-forge/main/io/inst/ods2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/ods2oct.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/ods2oct.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ ## Copyright (C) 2009,2010,2011,2012 Philip Nienhuis <pr.nienhuis 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [ @var{rawarr}, @var{ods}, @var{rstatus} ] = ods2oct (@var{ods}) @@ -207,20 +206,19 @@ #===================================================================== ## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## odf2jotk2oct - read ODS spreadsheet data using Java & odftoolkit ## You need proper java-for-octave & odfdom.jar + xercesImpl.jar @@ -422,20 +420,19 @@ #=========================================================================== ## Copyright (C) 2010,2011 Philip Nienhuis <prn...@us...> -## -## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## ods3jotk2oct: internal function for reading odf files using odfdom-0.8.6 @@ -590,20 +587,19 @@ #=========================================================================== ## Copyright (C) 2009,2010,2011 Philip Nienhuis <pr.nienhuis 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## ods2oct - get data out of an ODS spreadsheet into octave using jOpenDocument. ## Watch out, no error checks, and spreadsheet formula error results @@ -612,6 +608,7 @@ ## Author: Philip Nienhuis ## Created: 2009-12-13 ## Last updates: + ## 2010-08-12 Added separate stanzas for jOpenDocument v 1.2b3 and up. This version ## allows better cell type parsing and is therefore more reliable ## 2010-10-27 Moved cropping rawarr from empty outer rows & columns to here @@ -778,22 +775,20 @@ endfunction - ## Copyright (C) 2011 Philip Nienhuis <prn...@us...> -## -## 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## ods2uno2oct Modified: trunk/octave-forge/main/io/inst/odsclose.m =================================================================== --- trunk/octave-forge/main/io/inst/odsclose.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/odsclose.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ ## Copyright (C) 2009,2010,2011,2012 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/>. +## +## 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 3 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 +## this program; if not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- ## @deftypefn {Function File} [@var{ods}] = odsclose (@var{ods}) Modified: trunk/octave-forge/main/io/inst/odsfinfo.m =================================================================== --- trunk/octave-forge/main/io/inst/odsfinfo.m 2012-03-21 00:13:56 UTC (rev 9983) +++ trunk/octave-forge/main/io/inst/odsfinfo.m 2012-03-21 00:15:43 UTC (rev 9984) @@ -1,18 +1,17 @@ ## Copyright (C) 2009,2010,2011,2012 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/>. +## +## 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 3 of the License, o... [truncated message content] |
From: <prn...@us...> - 2012-05-22 20:13:19
|
Revision: 10497 http://octave.svn.sourceforge.net/octave/?rev=10497&view=rev Author: prnienhuis Date: 2012-05-22 20:13:13 +0000 (Tue, 22 May 2012) Log Message: ----------- Cast all numeric input data to double in main funcs Modified Paths: -------------- trunk/octave-forge/main/io/inst/oct2ods.m trunk/octave-forge/main/io/inst/oct2xls.m Modified: trunk/octave-forge/main/io/inst/oct2ods.m =================================================================== --- trunk/octave-forge/main/io/inst/oct2ods.m 2012-05-22 15:43:48 UTC (rev 10496) +++ trunk/octave-forge/main/io/inst/oct2ods.m 2012-05-22 20:13:13 UTC (rev 10497) @@ -115,6 +115,7 @@ ## 2012-02-20 Fixed range parameter to be default empty string rather than empty numeral ## 2012-02-27 More range arg fixes ## 2012-03-07 Updated texinfo help text +## 2012-05-22 Cast all numeric data in input array to double ## ## Last update of subfunctions below: 2012-02-26 @@ -136,6 +137,9 @@ error ("oct2ods: input array neither cell nor numeric array"); endif if (ndims (c_arr) > 2), error ("Only 2-dimensional arrays can be written to spreadsheet"); endif + # Cast all numerical values to double as spreadsheets only have double/boolean/text type + idx = cellfun (@isnumeric, obj, "UniformOutput", true); + obj(idx) = cellfun (@double, obj(idx), "UniformOutput", false); # Check ods file pointer struct test1 = ~isfield (ods, "xtype"); Modified: trunk/octave-forge/main/io/inst/oct2xls.m =================================================================== --- trunk/octave-forge/main/io/inst/oct2xls.m 2012-05-22 15:43:48 UTC (rev 10496) +++ trunk/octave-forge/main/io/inst/oct2xls.m 2012-05-22 20:13:13 UTC (rev 10497) @@ -111,13 +111,15 @@ ## 2012-02-20 Fixed range parameter to be default empty string rather than empty numeral ## 2012-02-27 More range param fixes ## 2012-03-07 Updated texinfo help text +## 2012-05-22 Cast all numeric data in input array to double ## Last script file update (incl. subfunctions): 2012-05-21 function [ xls, rstatus ] = oct2xls (obj, xls, wsh=1, crange='', spsh_opts=[]) if (nargin < 2) error ("oct2xls needs a minimum of 2 arguments."); endif - # Make sure input array is a cell array + + # Validate input array, make sure it is a cell array if (isempty (obj)) warning ("Request to write empty matrix - ignored."); rstatus = 1; @@ -131,6 +133,9 @@ error ("oct2xls: input array neither cell nor numeric array"); endif if (ndims (obj) > 2), error ("Only 2-dimensional arrays can be written to spreadsheet"); endif + # Cast all numerical values to double as spreadsheets only have double/boolean/text type + idx = cellfun (@isnumeric, obj, "UniformOutput", true); + obj(idx) = cellfun (@double, obj(idx), "UniformOutput", false); # Check xls file pointer struct test1 = ~isfield (xls, "xtype"); @@ -484,6 +489,7 @@ ## 2012-01-26 Fixed "seealso" help string ## 2012-02-27 Copyright strings updated ## 2012-05-21 "Double" cast added when writing numeric values +## 2012-05-21 "Double" cast moved into main func oct2xls function [ xls, rstatus ] = oct2jpoi2xls (obj, xls, wsh, crange, spsh_opts) @@ -576,7 +582,7 @@ else cell = row.createCell (kk, typearr(ii,jj)); if (isnumeric (obj{ii, jj})) - cell.setCellValue (double (obj{ii, jj})); + cell.setCellValue (obj{ii, jj}); else cell.setCellValue (obj{ii, jj}); endif @@ -654,6 +660,7 @@ ## 2012-01-26 Fixed "seealso" help string ## 2012-02-27 Copyright strings updated ## 2012-05-21 "Double" cast added when writing numeric values +## 2012-05-21 "Double" cast moved into main func oct2xls function [ xls, rstatus ] = oct2jxla2xls (obj, xls, wsh, crange, spsh_opts) @@ -735,7 +742,7 @@ kk = jj + lcol - 2; # JExcelAPI's column count is also 0-based switch typearr(ii, jj) case 1 # Numerical - tmp = java_new ('jxl.write.Number', kk, ll, double (obj{ii, jj})); + tmp = java_new ('jxl.write.Number', kk, ll, obj{ii, jj}); sh.addCell (tmp); case 2 # Boolean tmp = java_new ('jxl.write.Boolean', kk, ll, obj{ii, jj}); @@ -931,6 +938,7 @@ ## 2012-02-26 Bug fix when adding sheets near L.994 (wrong if-else-end construct). ## 2012-02-27 Copyright strings updated ## 2012-05-21 "Double" cast added when writing numeric values +## 2012-05-21 "Double" cast moved into main func oct2xls function [ xls, rstatus ] = oct2uno2xls (c_arr, xls, wsh, crange, spsh_opts) @@ -1038,7 +1046,7 @@ XCell = sh.getCellByPosition (lcol+jj-1, trow+ii-1); switch typearr(ii, jj) case 1 # Float - XCell.setValue (double (c_arr{ii, jj})); + XCell.setValue (c_arr{ii, jj}); case 2 # Logical. Convert to float as OOo has no Boolean type XCell.setValue (double (c_arr{ii, jj})); case 3 # String This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-06-06 21:08:00
|
Revision: 10572 http://octave.svn.sourceforge.net/octave/?rev=10572&view=rev Author: prnienhuis Date: 2012-06-06 21:07:54 +0000 (Wed, 06 Jun 2012) Log Message: ----------- Adapted to implementation of "formulas_as_text" option for COM Modified Paths: -------------- trunk/octave-forge/main/io/inst/io_xls_testscript.m trunk/octave-forge/main/io/inst/xls2oct.m Modified: trunk/octave-forge/main/io/inst/io_xls_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-06-06 17:15:51 UTC (rev 10571) +++ trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-06-06 21:07:54 UTC (rev 10572) @@ -20,6 +20,7 @@ ## Author: Philip Nienhuis ## Created: 2012-02-25 ## Updates: +## 2012-06-06 Adapted to COM implementation for "formulas_as_text" option printf ("\nTesting .xls interface %s ...\n", intf); @@ -93,14 +94,14 @@ endif end_try_catch -## Check if formulas_as_text works (doesn't with COM): +## Check if "formulas_as_text" option works: printf ("\n 8. Repeat reading, now return formulas as text\n"); opts.formulas_as_text = 1; xls = xlsopen ('io-test.xls', 0, intf); raw = xls2oct (xls, shnr, crange, opts); xls = xlsclose (xls); -## 9. Here come the tests, part 2. Fails on COM +## 9. Here come the tests, part 2. printf ("\n 9. Tests part 2 (read back formula):\n"); try Modified: trunk/octave-forge/main/io/inst/xls2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/xls2oct.m 2012-06-06 17:15:51 UTC (rev 10571) +++ trunk/octave-forge/main/io/inst/xls2oct.m 2012-06-06 21:07:54 UTC (rev 10572) @@ -132,8 +132,9 @@ ## 2012-01-26 Fixed "seealso" help string ## 2012-02-25 Fixed missing quotes in struct check L.149-153 ## 2012-02-26 Updated texinfo header help text +## 2012-06-06 Implemented "formulas_as_text" option for COM ## -## Latest subfunc update: 2012-02-25 +## Latest subfunc update: 2012-06-06 function [ rawarr, xls, rstatus ] = xls2oct (xls, wsh=1, datrange='', spsh_opts=[]) @@ -168,9 +169,8 @@ # Select the proper interfaces if (strcmp (xls.xtype, 'COM')) - # Call Excel tru COM server. Excel/COM has no way of returning formulas - # as strings, so arg spsh_opts has no use (yet) - [rawarr, xls, rstatus] = xls2com2oct (xls, wsh, datrange); + # Call Excel tru COM / ActiveX server + [rawarr, xls, rstatus] = xls2com2oct (xls, wsh, datrange, spsh_opts); elseif (strcmp (xls.xtype, 'POI')) # Read xls file tru Java POI [rawarr, xls, rstatus] = xls2jpoi2oct (xls, wsh, datrange, spsh_opts); @@ -237,6 +237,7 @@ ## @deftypefn {Function File} [@var{obj}, @var{rstatus}, @var{xls} ] = xls2com2oct (@var{xls}) ## @deftypefnx {Function File} [@var{obj}, @var{rstatus}, @var{xls} ] = xls2com2oct (@var{xls}, @var{wsh}) ## @deftypefnx {Function File} [@var{obj}, @var{rstatus}, @var{xls} ] = xls2com2oct (@var{xls}, @var{wsh}, @var{range}) +## @deftypefnx {Function File} [@var{obj}, @var{rstatus}, @var{xls} ] = xls2com2oct (@var{xls}, @var{wsh}, @var{range}, @var{spsh_opts}) ## Get cell contents in @var{range} in worksheet @var{wsh} in an Excel ## file pointed to in struct @var{xls} into the cell array @var{obj}. ## @@ -265,8 +266,9 @@ ## 2010-11-12 Moved ptr struct check into main func ## 2010-11-13 Catch empty sheets when no range was specified ## 2012-01-26 Fixed "seealso" help string +## 2012-06-06 Implemented "formulas_as_text option" -function [rawarr, xls, rstatus ] = xls2com2oct (xls, wsh, crange) +function [rawarr, xls, rstatus ] = xls2com2oct (xls, wsh, crange, spsh_opts) rstatus = 0; rawarr = {}; @@ -339,7 +341,11 @@ if (nrows >= 1) # Get object from Excel sheet, starting at cell top_left_cell rr = sh.Range (crange); - rawarr = rr.Value; + if (spsh_opts.formulas_as_text) + rawarr = rr.Formula; + else + rawarr = rr.Value; + endif delete (rr); # Take care of actual singe cell range @@ -405,14 +411,14 @@ ## 2010-07-28 Added option to read formulas as text strings rather than evaluated value ## 2010-08-01 Some bug fixes for formula reading (cvalue rather than scell) ## 2010-10-10 Code cleanup: -getusedrange called; - fixed typo in formula evaluation msg; -## " moved cropping output array to calling function. +## '' moved cropping output array to calling function. ## 2010-11-12 Moved ptr struct check into main func ## 2010-11-13 Catch empty sheets when no range was specified ## 2010-11-14 Fixed sheet # index (was offset by -1) in call to getusedrange() in case ## of text sheet name arg ## 2012-01-26 Fixed "seealso" help string -function [ rawarr, xls, rstatus ] = xls2jpoi2oct (xls, wsh, cellrange=[], spsh_opts) +function [ rawarr, xls, rstatus ] = xls2jpoi2oct (xls, wsh, cellrange, spsh_opts) persistent ctype; if (isempty (ctype)) @@ -584,14 +590,14 @@ ## Added check for proper xls structure ## 2010-07-29 Added check for too latge requested data rectangle ## 2010-10-10 Code cleanup: -getusedrange(); moved cropping result array to -## " calling function +## '' calling function ## 2010-11-12 Moved ptr struct check into main func ## 2010-11-13 Catch empty sheets when no range was specified ## 2011-04-11 (Ron Goldman <ro...@oc...>) Fixed missing months var, wrong arg -## " order in strsplit, wrong isTime condition +## '' order in strsplit, wrong isTime condition ## 2012-01-26 Fixed "seealso" help string -function [ rawarr, xls, rstatus ] = xls2jxla2oct (xls, wsh, cellrange=[], spsh_opts) +function [ rawarr, xls, rstatus ] = xls2jxla2oct (xls, wsh, cellrange, spsh_opts) persistent ctype; persistent months; if (isempty (ctype)) @@ -788,7 +794,7 @@ ## Updates: ## 2012-02-25 Changed ctype into num array rather than cell array -function [ rawarr, xls, rstatus ] = xls2oxs2oct (xls, wsh, cellrange=[], spsh_opts) +function [ rawarr, xls, rstatus ] = xls2oxs2oct (xls, wsh, cellrange, spsh_opts) persistent ctype; if (isempty (ctype)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-06-07 22:10:37
|
Revision: 10589 http://octave.svn.sourceforge.net/octave/?rev=10589&view=rev Author: prnienhuis Date: 2012-06-07 22:10:30 +0000 (Thu, 07 Jun 2012) Log Message: ----------- Replaced tabs by double space Modified Paths: -------------- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m trunk/octave-forge/main/io/inst/xlswrite.m Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-06-07 22:09:56 UTC (rev 10588) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-06-07 22:10:30 UTC (rev 10589) @@ -83,350 +83,351 @@ % 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 % 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 - jcp = []; retval = 0; - if (nargin < 3); path_to_ooo= ''; end %if + jcp = []; retval = 0; + if (nargin < 3); path_to_ooo= ''; end %if if (nargin < 2); dbug = 0; end %if - isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; + isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; if (dbug); fprintf ('\n'); end %if - % interfaces = {'COM', 'POI', 'POI+OOXML', 'JXL', 'OXS', 'OTK', 'JOD', 'UNO'}; % Order = vital + % 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 - 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'); end %if - retval = retval + 1; - catch - % COM not supported - if (dbug), fprintf ('not working.\n\n'); end %if + % 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'); 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 - % 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 - tst1 = version ('-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 + 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 - 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 - % 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) - jver = char (javaMethod ('getProperty', 'java.lang.System', '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 && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if - if (dbug > 1) - % Check JVM virtual memory settings - jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); - jmem = jrt.maxMemory (); + 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 + % 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) + jver = char (javaMethod ('getProperty', 'java.lang.System', '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 && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if + if (dbug > 1) + % Check JVM virtual memory settings + jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); + jmem = jrt.maxMemory (); 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']); - 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 + 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: %s.', lasterr); - end %try_catch + 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 + if (dbug), fprintf ('\nChecking javaclasspath for .jar class libraries needed for spreadsheet I/O...:\n'); 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)); - % 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) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), 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 (jpchk1 >= numel (entries1)), retval = retval + 2; end %if - if (dbug > 1) - if (jpchk1 >= numel (entries1)) - fprintf (' => Apache (POI) OK\n'); - else - fprintf (' => Not all classes (.jar) required for POI in classpath\n'); - end %if - end %if - % Next, check OOXML support + % 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)); + % 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) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), 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 (jpchk1 >= numel (entries1)), retval = retval + 2; end %if + if (dbug > 1) + if (jpchk1 >= numel (entries1)) + fprintf (' => Apache (POI) OK\n'); + 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) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), 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 - % 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'); - else - fprintf (' => Some classes for POI OOXML support missing\n'); - end %if - 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) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), 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 + % 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'); + 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) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), 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 (jpchk >= numel (entries3)), retval = retval + 8; end %if - if (dbug > 1) - if (jpchk >= numel (entries3)) - fprintf (' => Java/JExcelAPI (JXL) OK.\n'); - else - fprintf (' => Not all classes (.jar) required for JXL in classpath\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) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), 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 (jpchk >= numel (entries3)), retval = retval + 8; end %if + if (dbug > 1) + if (jpchk >= numel (entries3)) + fprintf (' => Java/JExcelAPI (JXL) OK.\n'); + 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; 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 (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 >= numel (entries4)), retval = retval + 16; end %if - if (dbug > 1) - if (jpchk >= numel (entries4)) - fprintf (' => Java/OpenXLS (OXS) OK.\n'); - else - fprintf (' => Not all classes (.jar) required for OXS in classpath\n'); - end %if - end %if + % Try Java & OpenXLS + if (dbug > 1), fprintf ('\nOpenXLS (.xls (BIFF8)) <OpenXLS>:\n'); end %if + 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 (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 >= numel (entries4)), retval = retval + 16; end %if + if (dbug > 1) + if (jpchk >= numel (entries4)) + fprintf (' => Java/OpenXLS (OXS) OK.\n'); + 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; 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 (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 (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 = ' '; - try - % New in 0.8.6 - odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest'); - catch - % 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); - else - if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if - retval = retval + 32; - end %if + % Try Java & ODF toolkit + if (dbug > 1), fprintf ('\nODF Toolkit (.ods) <odfdom> <xercesImpl>:\n'); end %if + 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 (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 (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 = ' '; + try + % New in 0.8.6 + odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest'); + catch + % 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); + else + if (dbug > 1), fprintf (' => ODFtoolkit (OTK) OK.\n'); end %if + retval = retval + 32; + end %if elseif (dbug > 1) - fprintf (' => Not all required classes (.jar) in classpath for OTK\n'); - end %if + 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; 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 (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 (jpchk >= numel (entries6)), retval = retval + 64; end %if - if (dbug > 1) - if (jpchk >= numel(entries6)) - fprintf (' => jOpenDocument (JOD) OK.\n'); - else - fprintf (' => Not all required classes (.jar) in classpath for JOD\n'); - end %if - end %if + % Try Java & jOpenDocument + if (dbug > 1), fprintf ('\njOpenDocument (.ods + experimental .sxc readonly) <jOpendocument>:\n'); end %if + 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 (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 (jpchk >= numel (entries6)), retval = retval + 64; end %if + if (dbug > 1) + if (jpchk >= numel(entries6)) + fprintf (' => jOpenDocument (JOD) OK.\n'); + 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 + % 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, 1)); + % If requested, try to add UNO stuff to javaclasspath + 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 - % 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')) - if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if - try - javaaddpath (programdir); - targt = targt - 1; - if (dbug > 2), fprintf ('OK\n'); end %if - catch - 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 - end %if - 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)) - 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 '?asis' '*']); - jj = 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 + % 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')) + if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if + try + javaaddpath (programdir); + targt = targt - 1; + if (dbug > 2), fprintf ('OK\n'); end %if + catch + 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 + end %if + 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)) + 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 '?asis' '*']); + jj = 1; if (numel (basisdirlst) > 0) while (jj <= size (basisdirlst, 1) && jj > 0) basisdir = basisdirlst(jj).name; @@ -441,104 +442,104 @@ else basisdir = path_to_ooo; endif - basisdirentries = {'program', 'classes'}; - tmp = basisdir; jj=1; - while (~isempty (tmp) && jj <= numel (basisdirentries)) - tmp = get_dir_ (tmp, basisdirentries{jj}); - jj = jj + 1; - 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'); - if (isempty (unojardir)) - tmp = uredir; - else - tmp = unojardir; - end %if - 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 filesep file.name]); - targt = targt - 1; - if (dbug > 2), fprintf ('OK\n'); end %if - catch - if (dbug > 2), fprintf ('FAILED\n'); end %if + basisdirentries = {'program', 'classes'}; + tmp = basisdir; jj=1; + while (~isempty (tmp) && jj <= numel (basisdirentries)) + tmp = get_dir_ (tmp, basisdirentries{jj}); + jj = jj + 1; + 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'); + if (isempty (unojardir)) + tmp = uredir; + else + tmp = unojardir; + end %if + 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 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 %if - end %if - end %for - if (~targt); 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'); - end %if - end %f - end %if + end %if + end %if + end %for + if (~targt); 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'); + end %if + end %f + end %if % ----------Rest of Java interfaces---------------------------------- - missing = [missing1 missing2 missing3 missing4 missing5 missing6]; - jars_complete = isempty (find (missing, 1)); - 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 + missing = [missing1 missing2 missing3 missing4 missing5 missing6]; + jars_complete = isempty (find (missing, 1)); + 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 && ~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 - % First combine all entries - targt = sum (missing); - % Search tru list of missing entries - 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'); - else - fprintf ('All interfaces fully supported.now.\n\n'); - end %if - end %f - 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 + % First combine all entries + targt = sum (missing); + % Search tru list of missing entries + 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(1).name); end %if + try + javaaddpath ([path_to_jars filesep file(1).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'); + else + fprintf ('All interfaces fully supported.now.\n\n'); + end %if + end %f + end %if end %function @@ -549,20 +550,20 @@ % 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 - 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 + ret_dir = ''; + % Get list of directory entries + ret_dir_list = dir (base_dir); + % 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)) + 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 Modified: trunk/octave-forge/main/io/inst/xlswrite.m =================================================================== --- trunk/octave-forge/main/io/inst/xlswrite.m 2012-06-07 22:09:56 UTC (rev 10588) +++ trunk/octave-forge/main/io/inst/xlswrite.m 2012-06-07 22:10:30 UTC (rev 10589) @@ -102,76 +102,77 @@ ## 2010-01-12 (Bug fix; added unwind_protect to xlsopen...xlsclose calls) ## 2010-01-15 Fixed typos in texinfo ## 2010-08-18 Added check for existence of xls after call to xlsopen to -## avoid unneeded error message clutter +## avoid unneeded error message clutter ## 2010-10-27 Changed range -> crange to unhide other range functions ## 2011-09-08 Minor code syntax updates ## 2012-01-26 Fixed "seealso" help string +## 2012-06-07 Replaced all tabs by double space function [ rstatus ] = xlswrite (filename, arr, arg3, arg4, arg5) - rstatus = 0; + rstatus = 0; - # Sanity checks - if (nargin < 2) - usage ("Insufficient arguments - see 'help xlswrite'"); - elseif (~ischar (filename)) - error ("First argument must be a filename (incl. suffix)"); - elseif (nargin == 2) - # Assume first worksheet and full worksheet starting at A1 - wsh = 1; - if (strcmp (tolower (filename(end-4:end-1)), 'xls')) - crange = "A1:XFD1048576"; # OOXML has ridiculously large limits - else - crange = "A1:IV65536"; # Regular xls limits - endif - elseif (nargin == 3) - # Find out whether 3rd argument = worksheet or range - if (isnumeric (arg3) || (isempty (findstr (arg3, ':')) && ~isempty (arg3))) - # Apparently a worksheet specified - wsh = arg3; - if (strcmp (tolower (filename(end-4:end-1)), 'xls')) - crange = "A1:XFD1048576"; # OOXML has ridiculously large limits - else - crange = "A1:IV65536"; # Regular xls limits - endif - else - # Range specified - wsh = 1; - crange = arg3; - endif - elseif (nargin >= 4) - wsh = arg3; - crange = arg4; - endif - if (nargin == 5) - reqintf = arg5; - else - reqintf = []; - endif - - # Parse range - [topleft, nrows, ncols, trow, lcol] = parse_sp_range (crange); - - # Check if arr fits in range - [nr, nc] = size (arr); - if ((nr > nrows) || (nc > ncols)) - # Array too big; truncate - nr = min (nrows, nr); - nc = min (ncols, nc); - warning ("xlswrite - array truncated to %d by %d to fit in range %s", ... - nrows, ncols, crange); - endif + # Sanity checks + if (nargin < 2) + usage ("Insufficient arguments - see 'help xlswrite'"); + elseif (~ischar (filename)) + error ("First argument must be a filename (incl. suffix)"); + elseif (nargin == 2) + # Assume first worksheet and full worksheet starting at A1 + wsh = 1; + if (strcmp (tolower (filename(end-4:end-1)), 'xls')) + crange = "A1:XFD1048576"; # OOXML has ridiculously large limits + else + crange = "A1:IV65536"; # Regular xls limits + endif + elseif (nargin == 3) + # Find out whether 3rd argument = worksheet or range + if (isnumeric (arg3) || (isempty (findstr (arg3, ':')) && ~isempty (arg3))) + # Apparently a worksheet specified + wsh = arg3; + if (strcmp (tolower (filename(end-4:end-1)), 'xls')) + crange = "A1:XFD1048576"; # OOXML has ridiculously large limits + else + crange = "A1:IV65536"; # Regular xls limits + endif + else + # Range specified + wsh = 1; + crange = arg3; + endif + elseif (nargin >= 4) + wsh = arg3; + crange = arg4; + endif + if (nargin == 5) + reqintf = arg5; + else + reqintf = []; + endif + + # Parse range + [topleft, nrows, ncols, trow, lcol] = parse_sp_range (crange); + + # Check if arr fits in range + [nr, nc] = size (arr); + if ((nr > nrows) || (nc > ncols)) + # Array too big; truncate + nr = min (nrows, nr); + nc = min (ncols, nc); + warning ("xlswrite - array truncated to %d by %d to fit in range %s", ... + nrows, ncols, crange); + endif - unwind_protect # Needed to be sure Excel can be closed i.c.o. errors + unwind_protect # Needed to be sure Excel can be closed i.c.o. errors xls_ok = 0; xls = xlsopen (filename, 1, reqintf); xls_ok = 1; [xls, rstatus] = oct2xls (arr(1:nr, 1:nc), xls, wsh, topleft); - unwind_protect_cleanup + unwind_protect_cleanup if (xls_ok), xls = xlsclose (xls); endif - end_unwind_protect + end_unwind_protect endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-06-08 15:28:36
|
Revision: 10592 http://octave.svn.sourceforge.net/octave/?rev=10592&view=rev Author: prnienhuis Date: 2012-06-08 15:28:27 +0000 (Fri, 08 Jun 2012) Log Message: ----------- Support for odfdom-0.8.8-incubator; tabs replaced by double space Modified Paths: -------------- trunk/octave-forge/main/io/inst/getusedrange.m trunk/octave-forge/main/io/inst/oct2ods.m trunk/octave-forge/main/io/inst/ods2oct.m trunk/octave-forge/main/io/inst/odsclose.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 trunk/octave-forge/main/io/inst/odswrite.m Modified: trunk/octave-forge/main/io/inst/getusedrange.m =================================================================== --- trunk/octave-forge/main/io/inst/getusedrange.m 2012-06-08 14:11:42 UTC (rev 10591) +++ trunk/octave-forge/main/io/inst/getusedrange.m 2012-06-08 15:28:27 UTC (rev 10592) @@ -66,8 +66,10 @@ ## 2011-06-13 OpenXLS support added ## 2011-09-08 Style & layout updates ## 2012-01-26 Fixed "seealso" help string +## 2012-06-08 Replaced tabs by double space +## '' Added COM and OXS to message about supported interfaces ## -## Last subfunc update: 2012-04-18 (JOD) +## Last subfunc update: 2012-06-08 (OTK) function [ trow, lrow, lcol, rcol ] = getusedrange (spptr, ii) @@ -89,7 +91,7 @@ elseif (strcmp (spptr.xtype, 'OXS')) [ trow, lrow, lcol, rcol ] = getusedrange_oxs (spptr, ii); else - error ('Only OTK, JOD, POI and JXL interface implemented'); + error ("Only OTK, JOD, COM, POI, JXL and OXS interface implemented"); endif endfunction @@ -124,10 +126,11 @@ ## Currently this fix is just commented. ## 2011-06-06 Fixed wrong if clause for finding last filler cells (L.160 & L.176) ## 2011-09-12 Support for odfdom-0.8.7 added (API change for XPATH) +## 2012-06-08 Support for odsfdom-0.8.8-incubator function [ trow, lrow, lcol, rcol ] = getusedrange_otk (ods, ii) - odfcont = ods.workbook; # Local copy just in case + odfcont = ods.workbook; # Local copy just in case if (isfield (ods, 'odfvsn')) if (strcmp (ods.odfvsn, '0.8.6') || strcmp (ods.odfvsn, '0.7.5')) @@ -166,11 +169,11 @@ reprows = 0; endif - # Get leftmost cell column number + # Get leftmost cell column number lcell = row.getFirstChild (); cl_char = char (lcell); - # Swap the following lines into comment to catch a jOpenDocument bug which foobars OTK - # (JOD doesn't set <office:value-type='string'> attribute when writing strings + # Swap the following lines into comment to catch a jOpenDocument bug which foobars OTK + # (JOD doesn't set <office:value-type='string'> attribute when writing strings #if (isempty (findstr ('office:value-type', cl_char)) || isempty (findstr ('<text:', cl_char))) if (isempty (findstr ('office:value-type', cl_char))) lcol = min (lcol, lcell.getTableNumberColumnsRepeatedAttribute () + 1); @@ -232,7 +235,7 @@ ## Created: 2010-05-25 ## Last updates: ## 2010-05-31 Fixed ignoring table-covered-cells; fixed count of sheets comprising just A1:A1 -## '' Added option for wsh being a string argument +## Added option for wsh being a string argument ## 2010-08-12 Little textual adaptations ## 2010-11-13 Catched jOpenDocument bug (1.2bx) where string cells have no office:value-type ## '' attrb set (by JOD). Somehow OTK is more robust as it catches these cells @@ -241,15 +244,15 @@ function [ trow, brow, lcol, rcol ] = getusedrange_jod (ods, wsh) - # This function works by virtue of sheets in JOD actually being a Java string. - # It works outside of the Java memory/heap space which is an added benefit... - # (Read: this is one big dirty hack...... prone to crash Java on BIG spreadsheets) + # This function works by virtue of sheets in JOD actually being a Java string. + # It works outside of the Java memory/heap space which is an added benefit... + # (Read: this is one big dirty hack...... prone to crash Java on BIG spreadsheets) - if (isnumeric (wsh)) - sh = ods.workbook.getSheet (wsh - 1); - else - sh = ods.workbook.getSheet (wsh); - endif + if (isnumeric (wsh)) + sh = char (ods.workbook.getSheet (wsh - 1)); + else + sh = char (ods.workbook.getSheet (wsh)); + endif try # Let's see if we have JOD v. 1.3x. If not, next call fails & we'll fall back to the old hack @@ -266,16 +269,12 @@ brow = trow + nr - 1; rcol = lcol + nc - 1; endif - return catch - # This function works by virtue of sheets in JOD actually being a Java string. - # It works outside of the Java memory/heap space which is an added benefit... - # (Read: this is one big dirty hack...... prone to crash Java on BIG spreadsheets) - + # Fall back to the old hack :-( sh = char (sh); - # Get table-row pointers + # 1. Get table-row pointers id_trow = strfind (sh, '<table:table-row'); id = strfind (sh, '</table:table>') - 1; id_trow = [id_trow id]; @@ -283,96 +282,96 @@ trow = rcol = 0; lcol = 1024; brow = 0; if (~isempty (id)) - # Loop over all table-rows - rowrepcnt = 0; - for irow = 1:length (id_trow)-1 - # Isolate single table-row - tablerow = sh(id_trow(irow):id_trow(irow+1)-1); - # Search table-cells. table-c covers both table-cell & table-covered-cell - id_tcell = strfind (tablerow, '<table:table-c'); - id_tcell = [id_tcell id]; - rowl = length (tablerow); - if (isempty (id_tcell(1:end-1))) - rowend = rowl; - else - rowend = id_tcell(1); - endif - # Add in table-number-rows-repeated attribute values - rowrept = strfind (tablerow(1:rowend), 'number-rows-repeated'); - if (~isempty (rowrept)) - [st, en] = regexp (tablerow(rowrept:min (rowend, rowrept+30)), '\d+'); - rowrepcnt += str2num (tablerow(rowrept+st-1:min (rowend, rowrept+en-1))) - 1; - endif + # 2. Loop over all table-rows + rowrepcnt = 0; + for irow = 1:length (id_trow)-1 + # Isolate single table-row + tablerow = sh(id_trow(irow):id_trow(irow+1)-1); + # Search table-cells. table-c covers both table-cell & table-covered-cell + id_tcell = strfind (tablerow, '<table:table-c'); + id_tcell = [id_tcell id]; + rowl = length (tablerow); + if (isempty (id_tcell(1:end-1))) + rowend = rowl; + else + rowend = id_tcell(1); + endif + # Add in table-number-rows-repeated attribute values + rowrept = strfind (tablerow(1:rowend), 'number-rows-repeated'); + if (~isempty (rowrept)) + [st, en] = regexp (tablerow(rowrept:min (rowend, rowrept+30)), '\d+'); + rowrepcnt += str2num (tablerow(rowrept+st-1:min (rowend, rowrept+en-1))) - 1; + endif - # Search table-cells. table-c is a table-covered-cell that is considered empty - id_tcell = strfind (tablerow, '<table:table-c'); - if (~isempty (id_tcell)) - # OK, this row has a value cell. Now table-covered-cells must be included. - id_tcell2 = strfind (tablerow, '<table:covered-t'); - if (~isempty (id_tcell2)) id_tcell = sort ([id_tcell id_tcell2]); endif - id_tcell = [id_tcell rowl]; - # Search for non-empty cells (i.e., with an office:value-type attribute). But: - # jOpenDocument 1.2b3 has a bug: it often doesn't set this attr for string cells - id_valtcell = strfind (tablerow, 'office:value-type='); - id_textonlycell = strfind (tablerow, '<text:'); - id_valtcell = sort ([id_valtcell id_textonlycell]); - id_valtcell = [id_valtcell rowl]; - if (~isempty (id_valtcell(1:end-1))) - brow = irow + rowrepcnt; - # First set trow if it hadn't already been found - if (~trow) trow = irow; endif - # Search for repeated table-cells - id_reptcell = strfind (tablerow, 'number-columns-repeated'); - id_reptcell = [id_reptcell rowl]; - # Search for leftmost non-empty table-cell. llcol = counter for this table-row - llcol = 1; - while (id_tcell (llcol) < id_valtcell(1) && llcol <= length (id_tcell) - 1) - ++llcol; - endwhile - --llcol; - # Compensate for repeated cells. First count all repeats left of llcol - ii = 1; - repcnt = 0; - if (~isempty (id_reptcell(1:end-1))) - # First try lcol - while (ii <= length (id_reptcell) - 1 && id_reptcell(ii) < id_valtcell(1)) - # Add all repeat counts left of leftmost data tcell minus 1 for each - [st, en] = regexp (tablerow(id_reptcell(ii):id_reptcell(ii)+30), '\d+'); - repcnt += str2num (tablerow(id_reptcell(ii)+st-1:id_reptcell(ii)+en-1)) - 1; - ++ii; - endwhile - # Next, add current repcnt value to llcol and update lcol - lcol = min (lcol, llcol + repcnt); - # Get last value table-cell in table-cell idx - jj = 1; - while (id_tcell (jj) < id_valtcell(length (id_valtcell)-1)) - ++jj; - endwhile + # 3. Search table-cells. table-c is a table-covered-cell that is considered empty + id_tcell = strfind (tablerow, '<table:table-c'); + if (~isempty (id_tcell)) + # OK, this row has a value cell. Now table-covered-cells must be included. + id_tcell2 = strfind (tablerow, '<table:covered-t'); + if (~isempty (id_tcell2)) id_tcell = sort ([id_tcell id_tcell2]); endif + id_tcell = [id_tcell rowl]; + # Search for non-empty cells (i.e., with an office:value-type attribute). But: + # jOpenDocument 1.2b3 has a bug: it often doesn't set this attr for string cells + id_valtcell = strfind (tablerow, 'office:value-type='); + id_textonlycell = strfind (tablerow, '<text:'); + id_valtcell = sort ([id_valtcell id_textonlycell]); + id_valtcell = [id_valtcell rowl]; + if (~isempty (id_valtcell(1:end-1))) + brow = irow + rowrepcnt; + # First set trow if it hadn't already been found + if (~trow) trow = irow; endif + # Search for repeated table-cells + id_reptcell = strfind (tablerow, 'number-columns-repeated'); + id_reptcell = [id_reptcell rowl]; + # Search for leftmost non-empty table-cell. llcol = counter for this table-row + llcol = 1; + while (id_tcell (llcol) < id_valtcell(1) && llcol <= length (id_tcell) - 1) + ++llcol; + endwhile + --llcol; + # Compensate for repeated cells. First count all repeats left of llcol + ii = 1; + repcnt = 0; + if (~isempty (id_reptcell(1:end-1))) + # First try lcol + while (ii <= length (id_reptcell) - 1 && id_reptcell(ii) < id_valtcell(1)) + # Add all repeat counts left of leftmost data tcell minus 1 for each + [st, en] = regexp (tablerow(id_reptcell(ii):id_reptcell(ii)+30), '\d+'); + repcnt += str2num (tablerow(id_reptcell(ii)+st-1:id_reptcell(ii)+en-1)) - 1; + ++ii; + endwhile + # Next, add current repcnt value to llcol and update lcol + lcol = min (lcol, llcol + repcnt); + # Get last value table-cell in table-cell idx + jj = 1; + while (id_tcell (jj) < id_valtcell(length (id_valtcell)-1)) + ++jj; + endwhile - # Get rest of column repeat counts in value table-cell range - while (ii < length (id_reptcell) && id_reptcell(ii) < id_tcell(jj)) - # Add all repeat counts minus 1 for each tcell in value tcell range - [st, en] = regexp (tablerow(id_reptcell(ii):id_reptcell(ii)+30), '\d+'); - repcnt += str2num (tablerow(id_reptcell(ii)+st-1:id_reptcell(ii)+en-1)) - 1; - ++ii; - endwhile - else - # In case left column = A - lcol = min (lcol, llcol); - endif - # Count all table-cells in value table-cell-range - ii = 1; # Indexes cannot be negative - while (ii < length (id_tcell) && id_tcell(ii) < id_valtcell(length (id_valtcell) - 1)) - ++ii; - endwhile - --ii; - rcol = max (rcol, ii + repcnt); - endif - endif - endfor + # Get rest of column repeat counts in value table-cell range + while (ii < length (id_reptcell) && id_reptcell(ii) < id_tcell(jj)) + # Add all repeat counts minus 1 for each tcell in value tcell range + [st, en] = regexp (tablerow(id_reptcell(ii):id_reptcell(ii)+30), '\d+'); + repcnt += str2num (tablerow(id_reptcell(ii)+st-1:id_reptcell(ii)+en-1)) - 1; + ++ii; + endwhile + else + # In case left column = A + lcol = min (lcol, llcol); + endif + # Count all table-cells in value table-cell-range + ii = 1; # Indexes cannot be negative + while (ii < length (id_tcell) && id_tcell(ii) < id_valtcell(length (id_valtcell) - 1)) + ++ii; + endwhile + --ii; + rcol = max (rcol, ii + repcnt); + endif + endif + endfor else - # No data found, empty sheet - lcol = rcol = brow = trow = 0; + # No data found, empty sheet + lcol = rcol = brow = trow = 0; endif end_try_catch @@ -482,30 +481,30 @@ function [ trow, brow, lcol, rcol ] = getusedrange_com (xls, ii) - sh = xls.workbook.Worksheets (ii); - - # Decipher used range. Beware, UsedRange() returns *cached* rectangle of - # all spreadsheet cells containing *anything*, including just formatting - # (i.e., empty cells are included too). ==> This is an approximation only - allcells = sh.UsedRange; - - # Get top left cell as a Range object - toplftcl = allcells.Columns(1).Rows(1); - - # Count number of rows & cols in virtual range from A1 to top left cell - lcol = sh.Range ("A1", toplftcl).columns.Count; - trow = sh.Range ("A1", toplftcl).rows.Count; - - # Add real occupied rows & cols to obtain end row & col - brow = trow + allcells.rows.Count() - 1; - rcol = lcol + allcells.columns.Count() - 1; - - # Check if there are real data - if ((lcol == rcol) && (trow = brow)) - if (isempty (toplftcl.Value)) - trow = brow = lcol = rcol = 0; - endif + sh = xls.workbook.Worksheets (ii); + + # Decipher used range. Beware, UsedRange() returns *cached* rectangle of + # all spreadsheet cells containing *anything*, including just formatting + # (i.e., empty cells are included too). ==> This is an approximation only + allcells = sh.UsedRange; + + # Get top left cell as a Range object + toplftcl = allcells.Columns(1).Rows(1); + + # Count number of rows & cols in virtual range from A1 to top left cell + lcol = sh.Range ("A1", toplftcl).columns.Count; + trow = sh.Range ("A1", toplftcl).rows.Count; + + # Add real occupied rows & cols to obtain end row & col + brow = trow + allcells.rows.Count() - 1; + rcol = lcol + allcells.columns.Count() - 1; + + # Check if there are real data + if ((lcol == rcol) && (trow = brow)) + if (isempty (toplftcl.Value)) + trow = brow = lcol = rcol = 0; endif + endif endfunction @@ -532,35 +531,35 @@ function [ trow, brow, lcol, rcol ] = getusedrange_poi (xls, ii) - persistent cblnk; cblnk = java_get ('org.apache.poi.ss.usermodel.Cell', 'CELL_TYPE_BLANK'); + persistent cblnk; cblnk = java_get ('org.apache.poi.ss.usermodel.Cell', 'CELL_TYPE_BLANK'); - sh = xls.workbook.getSheetAt (ii-1); # Java POI starts counting at 0 + sh = xls.workbook.getSheetAt (ii-1); # Java POI starts counting at 0 - trow = sh.getFirstRowNum (); # 0-based - brow = sh.getLastRowNum (); # 0-based - # Get column range - lcol = 1048577; # OOXML (xlsx) max. + 1 - rcol = 0; - botrow = brow; - for jj=trow:brow - irow = sh.getRow (jj); - if (~isempty (irow)) - scol = (irow.getFirstCellNum).intValue (); - lcol = min (lcol, scol); - ecol = (irow.getLastCellNum).intValue () - 1; - rcol = max (rcol, ecol); - # Keep track of lowermost non-empty row as getLastRowNum() is unreliable - if ~(irow.getCell(scol).getCellType () == cblnk && irow.getCell(ecol).getCellType () == cblnk) - botrow = jj; - endif - endif - endfor - if (lcol > 1048576) - # Empty sheet - trow = 0; brow = 0; lcol = 0; rcol = 0; - else - brow = min (brow, botrow) + 1; ++trow; ++lcol; ++rcol; # 1-based return values + trow = sh.getFirstRowNum (); # 0-based + brow = sh.getLastRowNum (); # 0-based + # Get column range + lcol = 1048577; # OOXML (xlsx) max. + 1 + rcol = 0; + botrow = brow; + for jj=trow:brow + irow = sh.getRow (jj); + if (~isempty (irow)) + scol = (irow.getFirstCellNum).intValue (); + lcol = min (lcol, scol); + ecol = (irow.getLastCellNum).intValue () - 1; + rcol = max (rcol, ecol); + # Keep track of lowermost non-empty row as getLastRowNum() is unreliable + if ~(irow.getCell(scol).getCellType () == cblnk && irow.getCell(ecol).getCellType () == cblnk) + botrow = jj; + endif endif + endfor + if (lcol > 1048576) + # Empty sheet + trow = 0; brow = 0; lcol = 0; rcol = 0; + else + brow = min (brow, botrow) + 1; ++trow; ++lcol; ++rcol; # 1-based return values + endif endfunction @@ -588,33 +587,33 @@ function [ trow, brow, lcol, rcol ] = getusedrange_jxl (xls, wsh) - persistent emptycell = (java_get ('jxl.CellType', 'EMPTY')).toString (); + persistent emptycell = (java_get ('jxl.CellType', 'EMPTY')).toString (); - sh = xls.workbook.getSheet (wsh - 1); # JXL sheet count 0-based + sh = xls.workbook.getSheet (wsh - 1); # JXL sheet count 0-based - brow = sh.getRows (); - rcol = sh.getColumns (); - - if (brow == 0 || rcol == 0) - # Empty sheet - trow = 0; lcol = 0; brow = 0; rcol = 0; - else - trow = brow + 1; - lcol = rcol + 1; - for ii=0:brow-1 # For loop coz we must check ALL rows for leftmost column - emptyrow = 1; - jj = 0; - while (jj < rcol && emptyrow) # While loop => only til first non-empty cell - cell = sh.getCell (jj, ii); - if ~(strcmp (char (cell.getType ()), emptycell)) - lcol = min (lcol, jj + 1); - emptyrow = 0; - endif - ++jj; - endwhile - if ~(emptyrow) trow = min (trow, ii + 1); endif - endfor - endif + brow = sh.getRows (); + rcol = sh.getColumns (); + + if (brow == 0 || rcol == 0) + # Empty sheet + trow = 0; lcol = 0; brow = 0; rcol = 0; + else + trow = brow + 1; + lcol = rcol + 1; + for ii=0:brow-1 # For loop coz we must check ALL rows for leftmost column + emptyrow = 1; + jj = 0; + while (jj < rcol && emptyrow) # While loop => only til first non-empty cell + cell = sh.getCell (jj, ii); + if ~(strcmp (char (cell.getType ()), emptycell)) + lcol = min (lcol, jj + 1); + emptyrow = 0; + endif + ++jj; + endwhile + if ~(emptyrow) trow = min (trow, ii + 1); endif + endfor + endif endfunction @@ -643,18 +642,18 @@ function [ trow, brow, lcol, rcol ] = getusedrange_oxs (xls, wsh) - sh = xls.workbook.getWorkSheet (wsh - 1); - try - # Intriguing: sh.getFirst<> is off by one, sh.getLast<> = OK.... 8-Z - trow = sh.getFirstRow () + 1; - brow = sh.getLastRow (); - lcol = sh.getFirstCol () + 1; - rcol = sh.getLastCol (); - catch - # Might be an empty sheet - trow = brow = lcol = rcol = 0; - end_try_catch - # Check for empty sheet - if ((trow > brow) || (lcol > rcol)), trow = brow = lcol = rcol = 0; endif + sh = xls.workbook.getWorkSheet (wsh - 1); + try + # Intriguing: sh.getFirst<> is off by one, sh.getLast<> = OK.... 8-Z + trow = sh.getFirstRow () + 1; + brow = sh.getLastRow (); + lcol = sh.getFirstCol () + 1; + rcol = sh.getLastCol (); + catch + # Might be an empty sheet + trow = brow = lcol = rcol = 0; + end_try_catch + # Check for empty sheet + if ((trow > brow) || (lcol > rcol)), trow = brow = lcol = rcol = 0; endif endfunction Modified: trunk/octave-forge/main/io/inst/oct2ods.m =================================================================== --- trunk/octave-forge/main/io/inst/oct2ods.m 2012-06-08 14:11:42 UTC (rev 10591) +++ trunk/octave-forge/main/io/inst/oct2ods.m 2012-06-08 15:28:27 UTC (rev 10592) @@ -115,98 +115,96 @@ ## 2012-02-20 Fixed range parameter to be default empty string rather than empty numeral ## 2012-02-27 More range arg fixes ## 2012-03-07 Updated texinfo help text -## 2012-05-22 Cast all numeric data in input array to double +## 2012-06-08 Support for odfdom-incubator-0.8.8 +## '' Tabs replaced by double space ## -## Last update of subfunctions below: 2012-02-26 +## Last update of subfunctions below: 2012-06-08 function [ ods, rstatus ] = oct2ods (c_arr, ods, wsh=1, crange='', spsh_opts=[]) - if (nargin < 2) error ("oct2xls needs a minimum of 2 arguments."); endif + if (nargin < 2) error ("oct2xls needs a minimum of 2 arguments."); endif - # Check if input array is cell - if (isempty (c_arr)) - warning ("Request to write empty matrix - ignored."); - rstatus = 1; - return; - elseif (isnumeric (c_arr)) - c_arr = num2cell (c_arr); - elseif (ischar(c_arr)) - c_arr = {c_arr}; - printf ("(oct2ods: input character array converted to 1x1 cell)\n"); - elseif (~iscell (c_arr)) - error ("oct2ods: input array neither cell nor numeric array"); - endif - if (ndims (c_arr) > 2), error ("Only 2-dimensional arrays can be written to spreadsheet"); endif - # Cast all numerical values to double as spreadsheets only have double/boolean/text type - idx = cellfun (@isnumeric, obj, "UniformOutput", true); - obj(idx) = cellfun (@double, obj(idx), "UniformOutput", false); + # Check if input array is cell + if (isempty (c_arr)) + warning ("Request to write empty matrix - ignored."); + rstatus = 1; + return; + elseif (isnumeric (c_arr)) + c_arr = num2cell (c_arr); + elseif (ischar(c_arr)) + c_arr = {c_arr}; + printf ("(oct2ods: input character array converted to 1x1 cell)\n"); + elseif (~iscell (c_arr)) + error ("oct2ods: input array neither cell nor numeric array"); + endif + if (ndims (c_arr) > 2), error ("Only 2-dimensional arrays can be written to spreadsheet"); endif # Check ods file pointer struct - test1 = ~isfield (ods, "xtype"); - test1 = test1 || ~isfield (ods, "workbook"); - test1 = test1 || isempty (ods.workbook); - test1 = test1 || isempty (ods.app); - if test1 - error ("Arg #2: Invalid ods file pointer struct"); - endif + test1 = ~isfield (ods, "xtype"); + test1 = test1 || ~isfield (ods, "workbook"); + test1 = test1 || isempty (ods.workbook); + test1 = test1 || isempty (ods.app); + if test1 + error ("Arg #2: Invalid ods file pointer struct"); + endif - # Check worksheet ptr - if (~(ischar (wsh) || isnumeric (wsh))), error ("Integer (index) or text (wsh name) expected for arg # 3"); endif + # Check worksheet ptr + if (~(ischar (wsh) || isnumeric (wsh))), error ("Integer (index) or text (wsh name) expected for arg # 3"); endif - # Check range - if (~isempty (crange) && ~ischar (crange)) + # Check range + if (~isempty (crange) && ~ischar (crange)) error ("Character string (range) expected for arg # 4"); elseif (isempty (crange)) crange = ''; endif - # Various options - if (isempty (spsh_opts)) - spsh_opts.formulas_as_text = 0; - # other options to be implemented here - elseif (isstruct (spsh_opts)) - if (~isfield (spsh_opts, 'formulas_as_text')), spsh_opts.formulas_as_text = 0; endif - # other options to be implemented here - else - error ("Structure expected for arg # 5"); - endif - - if (nargout < 1) printf ("Warning: no output spreadsheet file pointer specified.\n"); endif + # Various options + if (isempty (spsh_opts)) + spsh_opts.formulas_as_text = 0; + # other options to be implemented here + elseif (isstruct (spsh_opts)) + if (~isfield (spsh_opts, 'formulas_as_text')), spsh_opts.formulas_as_text = 0; endif + # other options to be implemented here + else + error ("Structure expected for arg # 5"); + endif + + if (nargout < 1) printf ("Warning: no output spreadsheet file pointer specified.\n"); endif - if (strcmp (ods.xtype, 'OTK')) - # Write ods file tru Java & ODF toolkit. - switch ods.odfvsn - case "0.7.5" - [ ods, rstatus ] = oct2jotk2ods (c_arr, ods, wsh, crange, spsh_opts); - case {"0.8.6", "0.8.7"} - [ ods, rstatus ] = oct3jotk2ods (c_arr, ods, wsh, crange, spsh_opts); - otherwise - error ("Unsupported odfdom version"); - endswitch + if (strcmp (ods.xtype, 'OTK')) + # Write ods file tru Java & ODF toolkit. + switch ods.odfvsn + case "0.7.5" + [ ods, rstatus ] = oct2jotk2ods (c_arr, ods, wsh, crange, spsh_opts); + case {"0.8.6", "0.8.7", "0.8.8"} + [ ods, rstatus ] = oct3jotk2ods (c_arr, ods, wsh, crange, spsh_opts); + otherwise + error ("Unsupported odfdom version"); + endswitch - elseif (strcmp (ods.xtype, 'JOD')) - # Write ods file tru Java & jOpenDocument. API still leaves lots to be wished... - [ ods, rstatus ] = oct2jod2ods (c_arr, ods, wsh, crange); + elseif (strcmp (ods.xtype, 'JOD')) + # Write ods file tru Java & jOpenDocument. API still leaves lots to be wished... + [ ods, rstatus ] = oct2jod2ods (c_arr, ods, wsh, crange); - elseif (strcmp (ods.xtype, 'UNO')) - # Write ods file tru Java & UNO bridge (OpenOffice.org & clones) - [ ods, rstatus ] = oct2uno2ods (c_arr, ods, wsh, crange, spsh_opts); + elseif (strcmp (ods.xtype, 'UNO')) + # Write ods file tru Java & UNO bridge (OpenOffice.org & clones) + [ ods, rstatus ] = oct2uno2ods (c_arr, ods, wsh, crange, spsh_opts); -# elseif - # ---- < Other interfaces here > +# elseif + # ---- < Other interfaces here > - else - error (sprintf ("ods2oct: unknown OpenOffice.org .ods interface - %s.", ods.xtype)); - endif + else + error (sprintf ("ods2oct: unknown OpenOffice.org .ods interface - %s.", ods.xtype)); + endif - if (rstatus), ods.limits = []; endif + if (rstatus), ods.limits = []; endif endfunction #============================================================================= -## Copyright (C) 2010,2011 Philip Nienhuis <prn...@us...> +## Copyright (C) 2010,2011,2012 Philip Nienhuis <prn...@us...> ## ## 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 @@ -253,401 +251,401 @@ function [ ods, rstatus ] = oct2jotk2ods (c_arr, ods, wsh, crange, spsh_opts) - persistent ctype; - if (isempty (ctype)) - # Number, Boolean, String, Formula, Empty, Date, Time (last 2 are ignored) - ctype = [1, 2, 3, 4, 5, 6, 7]; - endif + persistent ctype; + if (isempty (ctype)) + # Number, Boolean, String, Formula, Empty, Date, Time (last 2 are ignored) + ctype = [1, 2, 3, 4, 5, 6, 7]; + endif - rstatus = 0; f_errs = 0; + rstatus = 0; f_errs = 0; - # Get some basic spreadsheet data from the pointer using ODFtoolkit - odfcont = ods.workbook; - xpath = ods.app.getXPath (); - offsprdsh = ods.app.getContentRoot(); - autostyles = odfcont.getOrCreateAutomaticStyles(); - officestyles = ods.app.getOrCreateDocumentStyles(); + # Get some basic spreadsheet data from the pointer using ODFtoolkit + odfcont = ods.workbook; + xpath = ods.app.getXPath (); + offsprdsh = ods.app.getContentRoot(); + autostyles = odfcont.getOrCreateAutomaticStyles(); + officestyles = ods.app.getOrCreateDocumentStyles(); - # Create an instance of type NODESET for use in subsequent statements - NODESET = java_get ('javax.xml.xpath.XPathConstants', 'NODESET'); + # Create an instance of type NODESET for use in subsequent statements + NODESET = java_get ('javax.xml.xpath.XPathConstants', 'NODESET'); - # Parse sheets ("tables") from ODS file - sheets = xpath.evaluate ("//table:table", odfcont, NODESET); - nr_of_sheets = sheets.getLength (); - newsh = 0; # Assume existing sheet - if isempty (wsh) wsh = 1; endif - if (~isnumeric (wsh)) # Sheet name specified - # Search in sheet names, match sheet name to sheet number. - # Beware, 0-based index, 1-based count! - ii = 0; - while (++ii <= nr_of_sheets && ischar (wsh)) - # Look in first part of the sheet nodeset - sh_name = sheets.item(ii-1).getTableNameAttribute (); - if (strcmp (sh_name, wsh)) - # Convert local copy of wsh into a number (pointer) - wsh = ii - 1; - endif - endwhile - if (ischar (wsh) && nr_of_sheets < 256) newsh = 1; endif - else # Sheet index specified - if ((ods.changed > 2) || (wsh > nr_of_sheets && wsh < 256)) # Max nr of sheets = 256 - # Create a new sheet - newsh = 1; - elseif (wsh <=nr_of_sheets && wsh > 0) - # Existing sheet. Count = 1-based, index = 0-based - --wsh; sh = sheets.item(wsh); - printf ("Writing to sheet %s\n", sh.getTableNameAttribute()); - else - error ("oct2ods: illegal sheet number."); - endif - endif + # Parse sheets ("tables") from ODS file + sheets = xpath.evaluate ("//table:table", odfcont, NODESET); + nr_of_sheets = sheets.getLength (); + newsh = 0; # Assume existing sheet + if isempty (wsh) wsh = 1; endif + if (~isnumeric (wsh)) # Sheet name specified + # Search in sheet names, match sheet name to sheet number. + # Beware, 0-based index, 1-based count! + ii = 0; + while (++ii <= nr_of_sheets && ischar (wsh)) + # Look in first part of the sheet nodeset + sh_name = sheets.item(ii-1).getTableNameAttribute (); + if (strcmp (sh_name, wsh)) + # Convert local copy of wsh into a number (pointer) + wsh = ii - 1; + endif + endwhile + if (ischar (wsh) && nr_of_sheets < 256) newsh = 1; endif + else # Sheet index specified + if ((ods.changed > 2) || (wsh > nr_of_sheets && wsh < 256)) # Max nr of sheets = 256 + # Create a new sheet + newsh = 1; + elseif (wsh <=nr_of_sheets && wsh > 0) + # Existing sheet. Count = 1-based, index = 0-based + --wsh; sh = sheets.item(wsh); + printf ("Writing to sheet %s\n", sh.getTableNameAttribute()); + else + error ("oct2ods: illegal sheet number."); + endif + endif # Check size of data array & range / capacity of worksheet & prepare vars - [nr, nc] = size (c_arr); - [topleft, nrows, ncols, trow, lcol] = spsh_chkrange (crange, nr, nc, ods.xtype, ods.filename); - --trow; --lcol; # Zero-based row # & col # - if (nrows < nr || ncols < nc) - warning ("Array truncated to fit in range"); - c_arr = c_arr(1:nrows, 1:ncols); - endif - + [nr, nc] = size (c_arr); + [topleft, nrows, ncols, trow, lcol] = spsh_chkrange (crange, nr, nc, ods.xtype, ods.filename); + --trow; --lcol; # Zero-based row # & col # + if (nrows < nr || ncols < nc) + warning ("Array truncated to fit in range"); + c_arr = c_arr(1:nrows, 1:ncols); + endif + # Parse data array, setup typarr and throw out NaNs to speed up writing; - typearr = spsh_prstype (c_arr, nrows, ncols, ctype, spsh_opts, 0); - if ~(spsh_opts.formulas_as_text) - # Find formulas (designated by a string starting with "=" and ending in ")") - fptr = cellfun (@(x) ischar (x) && strncmp (x, "=", 1) && strncmp (x(end:end), ")", 1), c_arr); - typearr(fptr) = ctype(4); # FORMULA - endif + typearr = spsh_prstype (c_arr, nrows, ncols, ctype, spsh_opts, 0); + if ~(spsh_opts.formulas_as_text) + # Find formulas (designated by a string starting with "=" and ending in ")") + fptr = cellfun (@(x) ischar (x) && strncmp (x, "=", 1) && strncmp (x(end:end), ")", 1), c_arr); + typearr(fptr) = ctype(4); # FORMULA + endif # Prepare worksheet for writing. If needed create new sheet - if (newsh) - if (ods.changed > 2) - # New spreadsheet. Prepare to use the default 1x1 first sheet. - sh = sheets.item(0); - else - # Other sheets exist, create a new sheet. First the basics - sh = java_new ('org.odftoolkit.odfdom.doc.table.OdfTable', odfcont); - # Append sheet to spreadsheet ( contentRoot) - offsprdsh.appendChild (sh); - # Rebuild sheets nodes - sheets = xpath.evaluate ("//table:table", odfcont, NODESET); - endif + if (newsh) + if (ods.changed > 2) + # New spreadsheet. Prepare to use the default 1x1 first sheet. + sh = sheets.item(0); + else + # Other sheets exist, create a new sheet. First the basics + sh = java_new ('org.odftoolkit.odfdom.doc.table.OdfTable', odfcont); + # Append sheet to spreadsheet ( contentRoot) + offsprdsh.appendChild (sh); + # Rebuild sheets nodes + sheets = xpath.evaluate ("//table:table", odfcont, NODESET); + endif - # Sheet name - if (isnumeric (wsh)) - # Give sheet a name - str = sprintf ("Sheet%d", wsh); - sh.setTableNameAttribute (str); - else - # Assign name to sheet and change wsh into numeric pointer - sh.setTableNameAttribute (wsh); - wsh = sheets.getLength () - 1; - endif - # Fixup wsh pointer in case of new spreadsheet - if (ods.changed > 2) wsh = 0; endif + # Sheet name + if (isnumeric (wsh)) + # Give sheet a name + str = sprintf ("Sheet%d", wsh); + sh.setTableNameAttribute (str); + else + # Assign name to sheet and change wsh into numeric pointer + sh.setTableNameAttribute (wsh); + wsh = sheets.getLength () - 1; + endif + # Fixup wsh pointer in case of new spreadsheet + if (ods.changed > 2) wsh = 0; endif - # Add table-column entry for style etc - col = sh.addTableColumn (); - col.setTableDefaultCellStyleNameAttribute ("Default"); - col.setTableNumberColumnsRepeatedAttribute (lcol + ncols + 1); - col.setTableStyleNameAttribute ("co1"); + # Add table-column entry for style etc + col = sh.addTableColumn (); + col.setTableDefaultCellStyleNameAttribute ("Default"); + col.setTableNumberColumnsRepeatedAttribute (lcol + ncols + 1); + col.setTableStyleNameAttribute ("co1"); - # Build up the complete row & cell structure to cover the data array. - # This will speed up processing later + # Build up the complete row & cell structure to cover the data array. + # This will speed up processing later - # 1. Build empty table row template - row = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableRow', odfcont); - # Create an empty tablecell & append it to the row - scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); - scell = row.appendCell (scell); - scell.setTableNumberColumnsRepeatedAttribute (1024); - # 2. If needed add empty filler row above the data rows & if needed add repeat count - if (trow > 0) - sh.appendRow (row); - if (trow > 1) row.setTableNumberRowsRepeatedAttribute (trow); endif - endif - # 3. Add data rows; first one serves as a template - drow = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableRow', odfcont); - if (lcol > 0) - scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); - drow.appendCell (scell); - if (lcol > 1) scell.setTableNumberColumnsRepeatedAttribute (lcol); endif - endif - # 4. Add data cell placeholders - scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); - drow.appendCell (scell); - for jj=2:ncols - dcell = scell.cloneNode (1); # Deep copy - drow.appendCell (dcell); - endfor - # 5. Last cell is remaining column counter - rest = max (1024 - lcol - ncols); - if (rest) - dcell = scell.cloneNode (1); # Deep copy - drow.appendCell (dcell); - if (rest > 1) dcell.setTableNumberColumnsRepeatedAttribute (rest); endif - endif - # Only now add drow as otherwise for each cell an empty table-column is - # inserted above the rows (odftoolkit bug?) - sh.appendRow (drow); - if (ods.changed > 2) - # In case of a completely new spreadsheet, delete the first initial 1-cell row - # But check if it *is* a row... - try - sh.removeChild (drow.getPreviousRow ()); - catch - # Nothing. Apparently there was only the just appended row. - end_try_catch - endif - # 6. Row template ready. Copy row template down to cover future array - for ii=2:nrows - nrow = drow.cloneNode (1); # Deep copy - sh.appendRow (nrow); - endfor - ods.changed = min (ods.changed, 2); # Keep 2 for new spshsht, 1 for existing + changed + # 1. Build empty table row template + row = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableRow', odfcont); + # Create an empty tablecell & append it to the row + scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); + scell = row.appendCell (scell); + scell.setTableNumberColumnsRepeatedAttribute (1024); + # 2. If needed add empty filler row above the data rows & if needed add repeat count + if (trow > 0) + sh.appendRow (row); + if (trow > 1) row.setTableNumberRowsRepeatedAttribute (trow); endif + endif + # 3. Add data rows; first one serves as a template + drow = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableRow', odfcont); + if (lcol > 0) + scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); + drow.appendCell (scell); + if (lcol > 1) scell.setTableNumberColumnsRepeatedAttribute (lcol); endif + endif + # 4. Add data cell placeholders + scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); + drow.appendCell (scell); + for jj=2:ncols + dcell = scell.cloneNode (1); # Deep copy + drow.appendCell (dcell); + endfor + # 5. Last cell is remaining column counter + rest = max (1024 - lcol - ncols); + if (rest) + dcell = scell.cloneNode (1); # Deep copy + drow.appendCell (dcell); + if (rest > 1) dcell.setTableNumberColumnsRepeatedAttribute (rest); endif + endif + # Only now add drow as otherwise for each cell an empty table-column is + # inserted above the rows (odftoolkit bug?) + sh.appendRow (drow); + if (ods.changed > 2) + # In case of a completely new spreadsheet, delete the first initial 1-cell row + # But check if it *is* a row... + try + sh.removeChild (drow.getPreviousRow ()); + catch + # Nothing. Apparently there was only the just appended row. + end_try_catch + endif + # 6. Row template ready. Copy row template down to cover future array + for ii=2:nrows + nrow = drow.cloneNode (1); # Deep copy + sh.appendRow (nrow); + endfor + ods.changed = min (ods.changed, 2); # Keep 2 for new spshsht, 1 for existing + changed - else - # Existing sheet. We must be prepared for all situations, incomplete rows, - # number-rows/columns-repeated, merged (spanning) cells, you name it. - # First explore row buildup of existing sheet using an XPath - sh = sheets.item(wsh); # 0 - based - str = sprintf ("//table:table[%d]/table:table-row", wsh + 1); # 1 - based - trows = xpath.evaluate (str, odfcont, NODESET); - nr_of_trows = trows.getLength(); # Nr. of existing table-rows, not data rows! + else + # Existing sheet. We must be prepared for all situations, incomplete rows, + # number-rows/columns-repeated, merged (spanning) cells, you name it. + # First explore row buildup of existing sheet using an XPath + sh = sheets.item(wsh); # 0 - based + str = sprintf ("//table:table[%d]/table:table-row", wsh + 1); # 1 - based + trows = xpath.evaluate (str, odfcont, NODESET); + nr_of_trows = trows.getLength(); # Nr. of existing table-rows, not data rows! - # For the first rows we do some preprocessing here. Similar stuff for cells - # i.e. table-cells (columns) is done in the loops below. - # Make sure the upper data array row doesn't end up in a nr-rows-repeated row + # For the first rows we do some preprocessing here. Similar stuff for cells + # i.e. table-cells (columns) is done in the loops below. + # Make sure the upper data array row doesn't end up in a nr-rows-repeated row - # Provisionally! set start table-row in case "while" & "if" (split) are skipped - drow = trows.item(0); - rowcnt = 0; trowcnt = 0; # Spreadsheet/ table-rows, resp; - while (rowcnt < trow && trowcnt < nr_of_trows) - # Count rows & table-rows UNTIL we reach trow - ++trowcnt; # Nr of table-rows - row = drow; - drow = row.getNextSibling (); - repcnt = row.getTableNumberRowsRepeatedAttribute(); - rowcnt = rowcnt + repcnt; # Nr of spreadsheet rows - endwhile - rsplit = rowcnt - trow; - if (rsplit > 0) - # Apparently a nr-rows-repeated top table-row must be split, as the - # first data row seems to be projected in it (1st while condition above!) - row.removeAttribute ('table:number-rows-repeated'); - row.getCellAt (0).removeAttribute ('table:number-columns-repeated'); - nrow = row.cloneNode (1); - drow = nrow; # Future upper data array row - if (repcnt > 1) - row.setTableNumberRowsRepeatedAttribute (repcnt - rsplit); - else - row.removeAttribute ('table:number-rows-repeated'); - endif - rrow = row.getNextSibling (); - sh.insertBefore (nrow, rrow); - for jj=2:rsplit - nrow = nrow.cloneNode (1); - sh.insertBefore (nrow, rrow); - endfor - elseif (rsplit < 0) - # New data rows to be added below existing data & table(!) rows, i.e. - # beyond lower end of the current sheet. Add filler row and 1st data row - row = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableRow', odfcont); - drow = row.cloneNode (1); # First data row - row.setTableNumberRowsRepeatedAttribute (-rsplit); # Filler row - scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); - dcell = scell.cloneNode (1); - scell.setTableNumberColumnsRepeatedAttribute (COL_CAP); # Filler cell - row.appendCell (scell); - sh.appendRow (row); - drow.appendCell (dcell); - sh.appendRow (drow); - endif - endif + # Provisionally! set start table-row in case "while" & "if" (split) are skipped + drow = trows.item(0); + rowcnt = 0; trowcnt = 0; # Spreadsheet/ table-rows, resp; + while (rowcnt < trow && trowcnt < nr_of_trows) + # Count rows & table-rows UNTIL we reach trow + ++trowcnt; # Nr of table-rows + row = drow; + drow = row.getNextSibling (); + repcnt = row.getTableNumberRowsRepeatedAttribute(); + rowcnt = rowcnt + repcnt; # Nr of spreadsheet rows + endwhile + rsplit = rowcnt - trow; + if (rsplit > 0) + # Apparently a nr-rows-repeated top table-row must be split, as the + # first data row seems to be projected in it (1st while condition above!) + row.removeAttribute ('table:number-rows-repeated'); + row.getCellAt (0).removeAttribute ('table:number-columns-repeated'); + nrow = row.cloneNode (1); + drow = nrow; # Future upper data array row + if (repcnt > 1) + row.setTableNumberRowsRepeatedAttribute (repcnt - rsplit); + else + row.removeAttribute ('table:number-rows-repeated'); + endif + rrow = row.getNextSibling (); + sh.insertBefore (nrow, rrow); + for jj=2:rsplit + nrow = nrow.cloneNode (1); + sh.insertBefore (nrow, rrow); + endfor + elseif (rsplit < 0) + # New data rows to be added below existing data & table(!) rows, i.e. + # beyond lower end of the current sheet. Add filler row and 1st data row + row = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableRow', odfcont); + drow = row.cloneNode (1); # First data row + row.setTableNumberRowsRepeatedAttribute (-rsplit); # Filler row + scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); + dcell = scell.cloneNode (1); + scell.setTableNumberColumnsRepeatedAttribute (COL_CAP); # Filler cell + row.appendCell (scell); + sh.appendRow (row); + drow.appendCell (dcell); + sh.appendRow (drow); + endif + endif # For each row, for each cell, add the data. Expand row/column-repeated nodes - row = drow; # Start row; pointer still exists from above stanzas - for ii=1:nrows - if (~newsh) # Only for existing sheets the next checks should be made - # While processing next data rows, fix table-rows if needed - if (isempty (row) || (row.getLength () < 1)) - # Append an empty row with just one empty cell - row = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableRow', odfcont); - scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); - scell.setTableNumberColumnsRepeatedAttribute (lcol + 1); - row.appendCell (scell); - sh.appendRow (row); - else - # If needed expand nr-rows-repeated - repcnt = row.getTableNumberRowsRepeatedAttribute (); - if (repcnt > 1) - row.removeAttribute ('table:number-rows-repeated'); - # Insert new table-rows above row until our new data space is complete. - # Keep handle of upper new table-row as that's where data are added 1st - drow = row.cloneNode (1); - sh.insertBefore (drow, row); - for kk=1:min (repcnt, nrows-ii) - nrow = row.cloneNode (1); - sh.insertBefore (nrow, row); - endfor - if (repcnt > nrows-ii+1) - row.setTableNumberRowsRepeatedAttribute (repcnt - nrows +ii - 1); - endif - row = drow; - endif - endif + row = drow; # Start row; pointer still exists from above stanzas + for ii=1:nrows + if (~newsh) # Only for existing sheets the next checks should be made + # While processing next data rows, fix table-rows if needed + if (isempty (row) || (row.getLength () < 1)) + # Append an empty row with just one empty cell + row = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableRow', odfcont); + scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); + scell.setTableNumberColumnsRepeatedAttribute (lcol + 1); + row.appendCell (scell); + sh.appendRow (row); + else + # If needed expand nr-rows-repeated + repcnt = row.getTableNumberRowsRepeatedAttribute (); + if (repcnt > 1) + row.removeAttribute ('table:number-rows-repeated'); + # Insert new table-rows above row until our new data space is complete. + # Keep handle of upper new table-row as that's where data are added 1st + drow = row.cloneNode (1); + sh.insertBefore (drow, row); + for kk=1:min (repcnt, nrows-ii) + nrow = row.cloneNode (1); + sh.insertBefore (nrow, row); + endfor + if (repcnt > nrows-ii+1) + row.setTableNumberRowsRepeatedAttribute (repcnt - nrows +ii - 1); + endif + row = drow; + endif + endif - # Check if leftmost cell ends up in nr-cols-repeated cell - colcnt = 0; tcellcnt = 0; rcellcnt = row.getLength(); - dcell = row.getCellAt (0); - while (colcnt < lcol && tcellcnt < rcellcnt) - # Count columns UNTIL we hit lcol - ++tcellcnt; # Nr of table-cells counted - scell = dcell; - dcell = scell.getNextSibling (); - repcnt = scell.getTableNumberColumnsRepeatedAttribute (); - colcnt = colcnt + repcnt; # Nr of spreadsheet cell counted - endwhile - csplit = colcnt - lcol; - if (csplit > 0) - # Apparently a nr-columns-repeated cell must be split - scell.removeAttribute ('table:number-columns-repeated'); - ncell = scell.cloneNode (1); - if (repcnt > 1) - scell.setTableNumberColumnsRepeatedAttribute (repcnt - csplit); - else - scell.removeAttribute ('table:number-columns-repeated'); - endif - rcell = scell.getNextSibling (); - row.insertBefore (ncell, rcell); - for jj=2:csplit - ncell = ncell.cloneNode (1); - row.insertBefore (ncell, rcell); - endfor - elseif (csplit < 0) - # New cells to be added beyond current last cell & table-cell in row - dcell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); - scell = dcell.cloneNode (1); - dcell.setTableNumberColumnsRepeatedAttribute (-csplit); - row.appendCell (dcell); - row.appendCell (scell); - endif - endif + # Check if leftmost cell ends up in nr-cols-repeated cell + colcnt = 0; tcellcnt = 0; rcellcnt = row.getLength(); + dcell = row.getCellAt (0); + while (colcnt < lcol && tcellcnt < rcellcnt) + # Count columns UNTIL we hit lcol + ++tcellcnt; # Nr of table-cells counted + scell = dcell; + dcell = scell.getNextSibling (); + repcnt = scell.getTableNumberColumnsRepeatedAttribute (); + colcnt = colcnt + repcnt; # Nr of spreadsheet cell counted + endwhile + csplit = colcnt - lcol; + if (csplit > 0) + # Apparently a nr-columns-repeated cell must be split + scell.removeAttribute ('table:number-columns-repeated'); + ncell = scell.cloneNode (1); + if (repcnt > 1) + scell.setTableNumberColumnsRepeatedAttribute (repcnt - csplit); + else + scell.removeAttribute ('table:number-columns-repeated'); + endif + rcell = scell.getNextSibling (); + row.insertBefore (ncell, rcell); + for jj=2:csplit + ncell = ncell.cloneNode (1); + row.insertBefore (ncell, rcell); + endfor + elseif (csplit < 0) + # New cells to be added beyond current last cell & table-cell in row + dcell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); + scell = dcell.cloneNode (1); + dcell.setTableNumberColumnsRepeatedAttribute (-csplit); + row.appendCell (dcell); + row.appendCell (scell); + endif + endif - # Write a row of data from data array, column by column - - for jj=1:ncols - scell = row.getCellAt (lcol + jj - 1); - if (~newsh) - if (isempty (scell)) - # Apparently end of row encountered. Add cell - scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); - scell = row.appendCell (scell); - else - # If needed expand nr-cols-repeated - repcnt = scell.getTableNumberColumnsRepeatedAttribute (); - if (repcnt > 1) - scell.removeAttribute ('table:number-columns-repeated'); - for kk=2:repcnt - ncell = scell.cloneNode (1); - row.insertBefore (ncell, scell.getNextSibling ()); - endfor - endif - endif - # Clear text contents - while (scell.hasChildNodes ()) - tmp = scell.getFirstChild (); - scell.removeChild (tmp); - endwhile - scell.removeAttribute ('table:formula'); - endif + # Write a row of data from data array, column by column + + for jj=1:ncols + scell = row.getCellAt (lcol + jj - 1); + if (~newsh) + if (isempty (scell)) + # Apparently end of row encountered. Add cell + scell = java_new ('org.odftoolkit.odfdom.doc.table.OdfTableCell', odfcont); + scell = row.appendCell (scell); + else + # If needed expand nr-cols-repeated + repcnt = scell.getTableNumberColumnsRepeatedAttribute (); + if (repcnt > 1) + scell.removeAttribute ('table:number-columns-repeated'); + for kk=2:repcnt + ncell = scell.cloneNode (1); + row.insertBefore (ncell, scell.getNextSibling ()); + endfor + endif + endif + # Clear text contents + while (scell.hasChildNodes ()) + tmp = scell.getFirstChild (); + scell.removeChild (tmp); + endwhile + scell.removeAttribute ('table:formula'); + endif - # Empty cell count stuff done. At last we can add the data - switch (typearr (ii, jj)) - case 1 # float - scell.setOfficeValueTypeAttribute ('float'); - scell.setOfficeValueAttribute (c_arr{ii, jj}); - case 2 # boolean - # Beware, for unpatched-for-booleans java-1.2.7- we must resort to floats - try - # First try the preferred java-boolean way - scell.setOfficeValueTypeAttribute ('boolean'); - scell.removeAttribute ('office:value'); - if (c_arr{ii, jj}) - scell.setOfficeBooleanValueAttribute (1); - else - scell.setOfficeBooleanValueAttribute (0); - endif - catch - # Unpatched java package. Fall back to transferring a float - scell.setOfficeValueTypeAttribute ('float'); - if (c_arr{ii, jj}) - scell.setOfficeValueAttribute (1); - else - scell.setOfficeValueAttribute (0); - endif - end_try_catch - case 3 # string - scell.setOfficeValueTypeAttribute ('string'); - pe = java_new ('org.odftoolkit.odfdom.doc.text.OdfTextParagraph', odfcont,'', c_arr{ii, jj}); - scell.appendChild (pe); - case 4 # Formula. - # As we don't know the result type, simply remove previous type info. - # Once OOo Calc reads it, it'll add the missing attributes - scell.removeAttribute ('office:value'); - scell.removeAttribute ('office:value-type'); - # Try-catch not strictly needed, there's no formula validator yet - try - scell.setTableFormulaAttribute (c_arr{ii, jj}); - scell.setOfficeValueTypeAttribute ('string'); - pe = java_new ('org.odftoolkit.odfdom.doc.text.OdfTextParagraph', odfcont,'', '#Recalc Formula#'); - scell.appendChild (pe); - catch - ++f_errs; - scell.setOfficeValueTypeAttribute ('string'); - pe = java_new ('org.odftoolkit.odfdom.doc.text.OdfTextParagraph', odfcont,'', c_arr{ii, jj}); - scell.appendChild (pe); - end_try_catch - case {0 5} # Empty. Clear value attributes - if (~newsh) - scell.removeAttribute ('office:value-type'); - scell.removeAttribute ('office:value'); - endif - case 6 # Date (implemented but Octave has no "date" data type - yet?) - scell.setOfficeValueTypeAttribute ('date'); - [hh mo dd hh mi ss] = datevec (c_arr{ii,jj}); - str = sprintf ("%4d-%2d-%2dT%2d:%2d:%2d", yy, mo, dd, hh, mi, ss); - scell.setOfficeDateValueAttribute (str); - case 7 # Time (implemented but Octave has no "time" data type) - scell.setOfficeValueTypeAttribute ('time'); - [hh mo dd hh mi ss] = datevec (c_arr{ii,jj}); - str = sprintf ("PT%2d:%2d:%2d", hh, mi, ss); - scell.setOfficeTimeValuettribute (str); - otherwise - # Nothing - endswitch + # Empty cell count stuff done. At last we can add the data + switch (typearr (ii, jj)) + case 1 # float + scell.setOfficeValueTypeAttribute ('float'); + scell.setOfficeValueAttribute (c_arr{ii, jj}); + case 2 # boolean + # Beware, for unpatched-for-booleans java-1.2.7- we must resort to floats + try + # First try the preferred java-boolean way + scell.setOfficeValueTypeAttribute ('boolean'); + scell.removeAttribute ('office:value'); + if (c_arr{ii, jj}) + scell.setOfficeBooleanValueAttribute (1); + else + scell.setOfficeBooleanValueAttribute (0); + endif + catch + # Unpatched java package. Fall back to transferring a float + scell.setOfficeValueTypeAttribute ('float'); + if (c_arr{ii, jj}) + scell.setOfficeValueAttribute (1); + else + scell.setOfficeValueAttribute (0); + endif + end_try_catch + case 3 # string + scell.setOfficeValueTypeAttribute ('string'); + pe = java_new ('org.odftoolkit.odfdom.doc.text.OdfTextParagraph', odfcont,'', c_arr{ii, jj}); + scell.appendChild (pe); + case 4 # Formula. + # As we don't know the result type, simply remove previous type info. + # Once OOo Calc reads it, it'll add the missing attributes + scell.removeAttribute ('office:value'); + scell.removeAttribute ('office:value-type'); + # Try-catch not strictly needed, there's no formula validator yet + try + scell.setTableFormulaAttribute (c_arr{ii, jj}); + scell.setOfficeValueTypeAttribute ('string'); + pe = java_new ('org.odftoolkit.odfdom.doc.text.OdfTextParagraph', odfcont,'', '#Recalc Formula#'); + scell.appendChild (pe); + catch + ++f_errs; + scell.setOfficeValueTypeAttribute ('string'); + pe = java_new ('org.odftoolkit.odfdom.doc.text.OdfTextParagraph', odfcont,'', c_arr{ii, jj}); + scell.appendChild (pe); + end_try_catch + case {0 5} # Empty. Clear value attributes + if (~newsh) + scell.removeAttribute ('office:value-type'); + scell.removeAttribute ('office:value'); + endif + case 6 # Date (implemented but Octave has no "date" data type - yet?) + scell.setOfficeValueTypeAttribute ('date'); + [hh mo dd hh mi ss] = datevec (c_arr{ii,jj}); + str = sprintf ("%4d-%2d-%2dT%2d:%2d:%2d", yy, mo, dd, hh, mi, ss); + scell.setOfficeDateValueAttribute (str); + case 7 # Time (implemented but Octave has no "time" data type) + scell.setOfficeValueTypeAttribute ('time'); + [hh mo dd hh mi ss] = datevec (c_arr{ii,jj}); + str = sprintf ("PT%2d:%2d:%2d", hh, mi, ss); + scell.setOfficeTimeValuettribute (str); + otherwise + # Nothing + endswitch - scell = scell.getNextSibling (); + scell = scell.getNextSibling (); - endfor + endfor - row = row.getNextSibling (); + row = row.getNextSibling (); - endfor + endfor - if (f_errs) - printf ("%d formula errors encountered - please check input array\n", f_errs); - endif - ods.changed = max (min (ods.changed, 2), changed); # Preserve 2 (new file), 1 (existing) - rstatus = 1; - + if (f_errs) + printf ("%d formula errors encountered - please check input array\n", f_errs); + endif + ods.changed = max (min (ods.changed, 2), changed); # Preserve 2 (new file), 1 (existing) + rstatus = 1; + endfunction #============================================================================= -## Copyright (C) 2010,2011 Philip Nienhuis <prnienhuis _at- users.sf.net> +## Copyright (C) 2010,2011,2012 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 @@ -662,9 +660,9 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -## odf3jotk2oct - read ODS spreadsheet data using Java & odftoolkit v 0.8.6. -## You need proper java-for-octave & odfdom.jar 0.8.6 + xercesImpl.jar -## in your javaclasspath. For reliable writing odfdom-0.8.6 is still +## odf3jotk2oct - read ODS spreadsheet data using Java & odftoolkit v 0.8.6+. +## You need proper java-for-octave & odfdom.jar 0.8.6+ & xercesImpl.jar 2.9.1 +## in your javaclasspath. For reliable writing odfdom-0.8.6+ is still ## experimental :-( v. 0.7.5 has been tested much more ## ## Author: Philip Nenhuis <pr.nienhuis at users.sf.net> @@ -684,167 +682,168 @@ ## 2010-11-12 Improved file change tracking tru ods.changed ## 2010-12-08 Bugfixes (obj -> arg L.715; removed stray arg in call to spsh_prstype L.719) ## 2011-03-23 First try of odfdom 0.8.7 +## 2012-06-08 Support for odfdom-incubator-0.8.8 function [ ods, rstatus ] = oct3jotk2ods (c_arr, ods, wsh, crange, spsh_opts) - persistent ctype; - if (isempty (ctype)) - # Number, Boolean, String, Formula, Empty; Date, Time - last two aren't used - ctype = [1, 2, 3, 4, 5, 6, 7]; - endif + persistent ctype; + if (isempty (ctype)) + # Number, Boolean, String, Formula, Empty; Date, Time - last two aren't used + ctype = [1, 2, 3, 4, 5, 6, 7]; + endif - rstatus = 0; changed = 0; newsh = 0; + rstatus = 0; changed = 0; newsh = 0; - # Get... [truncated message content] |
From: <prn...@us...> - 2012-09-03 19:51:38
|
Revision: 10955 http://octave.svn.sourceforge.net/octave/?rev=10955&view=rev Author: prnienhuis Date: 2012-09-03 19:51:31 +0000 (Mon, 03 Sep 2012) Log Message: ----------- Replaced canonicalize_file_name() calls for *nix systems by make_absolute_filename (bug #36677); 2 rather than 3 slashes for web addresses in UNO sections; code cleanup Modified Paths: -------------- trunk/octave-forge/main/io/inst/odsclose.m trunk/octave-forge/main/io/inst/odsopen.m trunk/octave-forge/main/io/inst/xlsclose.m trunk/octave-forge/main/io/inst/xlsopen.m Modified: trunk/octave-forge/main/io/inst/odsclose.m =================================================================== --- trunk/octave-forge/main/io/inst/odsclose.m 2012-09-02 22:39:41 UTC (rev 10954) +++ trunk/octave-forge/main/io/inst/odsclose.m 2012-09-03 19:51:31 UTC (rev 10955) @@ -65,6 +65,7 @@ ## 2011-09-08 FIXME - closing OOo kills all other OOo invocations (known Java-UNO issue) ## 2012-01-26 Fixed "seealso" help string ## 2012-06-08 tabs replaced by double space +## 2012-09-03 Extended file renaming section to xlsclose equivalent function [ ods ] = odsclose (ods, varargs) @@ -78,17 +79,39 @@ if (strcmp (lower (varargin{ii}), "force")) # Close .ods anyway even if write errors occur force = 1; - elseif (~isempty (strfind (tolower (varargin{ii}), '.ods')) || ... - ~isempty (strfind (tolower (varargin{ii}), '.sxc'))) - # Apparently a file name + elseif (~isempty (strfind (tolower (varargin{ii}), '.'))) + # Apparently a file name. First some checks.... if (ods.changed == 0 || ods.changed > 2) warning ("File %s wasn't changed, new filename ignored.", ods.filename); + elseif (~strcmp (xls.xtype, 'UNO') && isempty (strfind ( lower (filename), '.ods'))) + # UNO will write any file type, all other interfaces only .ods + error ('.ods suffix lacking in filename %s', filename); else - if (strfind (tolower (filename), '.sxc') || strfind (tolower (filename), '.ods')) - ods.filename = filename; - else - error ('No .sxc or .ods filename extension specified'); + # All checks passed + if (strcmp (xls.xtype, 'UNO')) + # For UNO, turn filename into URL + if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http://", filename))... + || ~isempty (strmatch ("ftp://", filename)) || ~isempty (strmatch ("www://", filename))) + # Seems in proper shape for OOo (at first sight) + else + # Transform into URL form + if (ispc) + fname = canonicalize_file_name (strsplit (filename, filesep){end}); + else + fname = make_absolute_filename (strsplit (filename, filesep){end}); + endif + # On Windows, change backslash file separator into forward slash + if (strcmp (filesep, "\\")) + tmp = strsplit (fname, filesep); + flen = numel (tmp); + tmp(2:2:2*flen) = tmp; + tmp(1:2:2*flen) = '/'; + filename = [ 'file://' tmp{:} ]; + endif + endif endif + # Preprocessing / -checking ready. Assign filename arg to file ptr struct + ods.filename = filename; endif endif endfor Modified: trunk/octave-forge/main/io/inst/odsopen.m =================================================================== --- trunk/octave-forge/main/io/inst/odsopen.m 2012-09-02 22:39:41 UTC (rev 10954) +++ trunk/octave-forge/main/io/inst/odsopen.m 2012-09-03 19:51:31 UTC (rev 10955) @@ -93,6 +93,9 @@ ## 2012-02-26 Added ";" to suppress echo of filename f UNO ## 2012-06-06 Made interface checking routine less verbose when same requested interface ## was used consecutively +## 2012-09-03 (in UNO section) replace canonicalize_file_name on non-Windows to +## make_absolute_filename (see bug #36677) +## '' (in UNO section) web adresses need only two consecutive slashes ## ## Latest change on subfunctions below: 2012-06-08 @@ -263,12 +266,18 @@ if (odsinterfaces.UNO && ~odssupport) # First the file name must be transformed into a URL - if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http:///", filename))... - || ~isempty (strmatch ("ftp:///", filename)) || ~isempty (strmatch ("www:///", filename))) + if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http://", filename))... + || ~isempty (strmatch ("ftp://", filename)) || ~isempty (strmatch ("www://", filename))) # Seems in proper shape for OOO (at first sight) else # Transform into URL form - fname = canonicalize_file_name (strsplit (filename, filesep){end}); + ## FIXME make_absolute_filename() doesn't work across drive(-letters) so + ## until it is fixed we'll fall back on canonicalize_file_name() there + if (ispc) + fname = canonicalize_file_name (strsplit (filename, filesep){end}); + else + fname = make_absolute_filename (strsplit (filename, filesep){end}); + endif # On Windows, change backslash file separator into forward slash if (strcmp (filesep, "\\")) tmp = strsplit (fname, filesep); Modified: trunk/octave-forge/main/io/inst/xlsclose.m =================================================================== --- trunk/octave-forge/main/io/inst/xlsclose.m 2012-09-02 22:39:41 UTC (rev 10954) +++ trunk/octave-forge/main/io/inst/xlsclose.m 2012-09-03 19:51:31 UTC (rev 10955) @@ -71,208 +71,216 @@ ## 2011-05-18 Added experimental UNO support, incl. saving newly created files ## 2011-09-08 Bug fix in check for filename input arg ## 2012-01-26 Fixed "seealso" help string +## 2012-09-03 (in UNO section) replace canonicalize_file_name on non-Windows to +## make_absolute_filename (see bug #36677) +## '' (in UNO section) web adresses need only two consecutive slashes function [ xls ] = xlsclose (xls, varargs) - force = 0; + force = 0; - if (nargin > 1) - for ii=2:nargin - if (strcmp (lower (varargin{ii}), "force")) - # Close .ods anyway even if write errors occur - force = 1; - elseif (~isempty (strfind (tolower (varargin{ii}), '.'))) - # Apparently a file name - if (xls.changed == 0 || xls.changed > 2) - printf ("File %s wasn't changed, new filename ignored.", xls.filename); - elseif (strcmp (xls.xtype, 'JXL')) - error ("JXL doesn't support changing filename, new filename ignored."); - elseif ~((strcmp (xls.xtype, 'COM') || strcmp (xls.xtype, 'UNO')) && isempty (strfind ( lower (filename), '.xls'))) - # Excel/ActiveX && OOo (UNO bridge) will write any valid filetype; POI/JXL/OXS need .xls[x] - error ('.xls or .xlsx extension lacking in filename %s', filename); - else - ### For multi-user environments, uncomment below AND relevant stanza in xlsopen - # In case of COM, be sure to first close the open workbook - #if (strcmp (xls.xtype, 'COM')) - # xls.app.Application.DisplayAlerts = 0; - # xls.workbook.close(); - # xls.app.Application.DisplayAlerts = 0; - #endif - if (strcmp (xls.xtype, 'UNO')) - # If needed, turn filename into URL - if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http:///", filename))... - || ~isempty (strmatch ("ftp:///", filename)) || ~isempty (strmatch ("www:///", filename))) - # Seems in proper shape for OOo (at first sight) - else - # Transform into URL form - fname = canonicalize_file_name (strsplit (filename, filesep){end}); - # On Windows, change backslash file separator into forward slash - if (strcmp (filesep, "\\")) - tmp = strsplit (fname, filesep); - flen = numel (tmp); - tmp(2:2:2*flen) = tmp; - tmp(1:2:2*flen) = '/'; - filename = [ 'file://' tmp{:} ]; - endif - endif - endif + if (nargin > 1) + for ii=2:nargin + if (strcmp (lower (varargin{ii}), "force")) + # Close .ods anyway even if write errors occur + force = 1; + elseif (~isempty (strfind (tolower (varargin{ii}), '.'))) + # Apparently a file name. First some checks.... + if (xls.changed == 0 || xls.changed > 2) + warning ("File %s wasn't changed, new filename ignored.", xls.filename); + elseif (strcmp (xls.xtype, 'JXL')) + error ("JXL doesn't support changing filename, new filename ignored."); + elseif ~((strcmp (xls.xtype, 'COM') || strcmp (xls.xtype, 'UNO')) && isempty (strfind ( lower (filename), '.xls'))) + # Excel/ActiveX && OOo (UNO bridge) will write any valid filetype; POI/JXL/OXS need .xls[x] + error ('.xls or .xlsx suffix lacking in filename %s', filename); + else + ### For multi-user environments, uncomment below AND relevant stanza in xlsopen + # In case of COM, be sure to first close the open workbook + #if (strcmp (xls.xtype, 'COM')) + # xls.app.Application.DisplayAlerts = 0; + # xls.workbook.close(); + # xls.app.Application.DisplayAlerts = 0; + #endif + # All checks passed + if (strcmp (xls.xtype, 'UNO')) + # If needed, turn filename into URL + if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http://", filename))... + || ~isempty (strmatch ("ftp://", filename)) || ~isempty (strmatch ("www://", filename))) + # Seems in proper shape for OOo (at first sight) + else + # Transform into URL form + if (ispc) + fname = canonicalize_file_name (strsplit (filename, filesep){end}); + else + fname = make_absolute_filename (strsplit (filename, filesep){end}); + endif + # On Windows, change backslash file separator into forward slash + if (strcmp (filesep, "\\")) + tmp = strsplit (fname, filesep); + flen = numel (tmp); + tmp(2:2:2*flen) = tmp; + tmp(1:2:2*flen) = '/'; + filename = [ 'file://' tmp{:} ]; + endif + endif + endif # Preprocessing / -checking ready. Assign filename arg to file ptr struct - xls.filename = filename; - endif - endif - endfor - endif + xls.filename = filename; + endif + endif + endfor + endif - if (strcmp (xls.xtype, 'COM')) - # If file has been changed, write it out to disk. - # - # Note: COM / VB supports other Excel file formats as FileFormatNum: - # 4 = .wks - Lotus 1-2-3 / Microsoft Works - # 6 = .csv - # -4158 = .txt - # 36 = .prn - # 50 = .xlsb - xlExcel12 (Excel Binary Workbook in 2007 with or without macro's) - # 51 = .xlsx - xlOpenXMLWorkbook (without macro's in 2007) - # 52 = .xlsm - xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007) - # 56 = .xls - xlExcel8 (97-2003 format in Excel 2007) - # (see Excel Help, VB reference, Enumerations, xlFileType) - - # xls.changed = 0: no changes: just close; - # 1: existing file with changes: save, close. - # 2: new file with data added: save, close - # 3: new file, no added added (empty): close & delete on disk + if (strcmp (xls.xtype, 'COM')) + # If file has been changed, write it out to disk. + # + # Note: COM / VB supports other Excel file formats as FileFormatNum: + # 4 = .wks - Lotus 1-2-3 / Microsoft Works + # 6 = .csv + # -4158 = .txt + # 36 = .prn + # 50 = .xlsb - xlExcel12 (Excel Binary Workbook in 2007 with or without macro's) + # 51 = .xlsx - xlOpenXMLWorkbook (without macro's in 2007) + # 52 = .xlsm - xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007) + # 56 = .xls - xlExcel8 (97-2003 format in Excel 2007) + # (see Excel Help, VB reference, Enumerations, xlFileType) + + # xls.changed = 0: no changes: just close; + # 1: existing file with changes: save, close. + # 2: new file with data added: save, close + # 3: new file, no added added (empty): close & delete on disk - xls.app.Application.DisplayAlerts = 0; - try - if (xls.changed > 0 && xls.changed < 3) - if (xls.changed == 2) - # Probably a newly created, or renamed, Excel file - printf ("Saving file %s ...\n", xls.filename); - xls.workbook.SaveAs (canonicalize_file_name (xls.filename)); - elseif (xls.changed == 1) - # Just updated existing Excel file - xls.workbook.Save (); - endif - xls.changed = 0; - xls.workbook.Close (canonicalize_file_name (xls.filename)); - endif - xls.app.Quit (); - delete (xls.workbook); # This statement actually closes the workbook - delete (xls.app); # This statement actually closes down Excel - catch - xls.app.Application.DisplayAlerts = 1; - end_try_catch - - elseif (strcmp (xls.xtype, 'POI')) - if (xls.changed > 0 && xls.changed < 3) - try - xlsout = java_new ("java.io.FileOutputStream", xls.filename); - bufout = java_new ("java.io.BufferedOutputStream", xlsout); - if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif - xls.workbook.write (bufout); - bufout.flush (); - bufout.close (); - xlsout.close (); - xls.changed = 0; - catch -# xlsout.close (); - end_try_catch - endif + xls.app.Application.DisplayAlerts = 0; + try + if (xls.changed > 0 && xls.changed < 3) + if (xls.changed == 2) + # Probably a newly created, or renamed, Excel file + printf ("Saving file %s ...\n", xls.filename); + xls.workbook.SaveAs (canonicalize_file_name (xls.filename)); + elseif (xls.changed == 1) + # Just updated existing Excel file + xls.workbook.Save (); + endif + xls.changed = 0; + xls.workbook.Close (canonicalize_file_name (xls.filename)); + endif + xls.app.Quit (); + delete (xls.workbook); # This statement actually closes the workbook + delete (xls.app); # This statement actually closes down Excel + catch + xls.app.Application.DisplayAlerts = 1; + end_try_catch + + elseif (strcmp (xls.xtype, 'POI')) + if (xls.changed > 0 && xls.changed < 3) + try + xlsout = java_new ("java.io.FileOutputStream", xls.filename); + bufout = java_new ("java.io.BufferedOutputStream", xlsout); + if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif + xls.workbook.write (bufout); + bufout.flush (); + bufout.close (); + xlsout.close (); + xls.changed = 0; + catch +# xlsout.close (); + end_try_catch + endif - elseif (strcmp (xls.xtype, 'JXL')) - if (xls.changed > 0 && xls.changed < 3) - try - if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif - xls.workbook.write (); - xls.workbook.close (); - if (xls.changed == 3) - # Upon entering write mode, JExcelAPI always makes a disk file - # Incomplete new files (no data added) had better be deleted. - xls.workbook.close (); - delete (xls.filename); - endif - xls.changed = 0; - catch - end_try_catch - endif + elseif (strcmp (xls.xtype, 'JXL')) + if (xls.changed > 0 && xls.changed < 3) + try + if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif + xls.workbook.write (); + xls.workbook.close (); + if (xls.changed == 3) + # Upon entering write mode, JExcelAPI always makes a disk file + # Incomplete new files (no data added) had better be deleted. + xls.workbook.close (); + delete (xls.filename); + endif + xls.changed = 0; + catch + end_try_catch + endif - elseif (strcmp (xls.xtype, 'OXS')) - if (xls.changed > 0 && xls.changed < 3) - try - xlsout = java_new ("java.io.FileOutputStream", xls.filename); - bufout = java_new ("java.io.BufferedOutputStream", xlsout); - if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif - xls.workbook.writeBytes (bufout); - xls.workbook.close (); - bufout.flush (); - bufout.close (); - xlsout.close (); - xls.changed = 0; - catch -# xlsout.close (); - end_try_catch - else - xls.workbook.close (); - endif + elseif (strcmp (xls.xtype, 'OXS')) + if (xls.changed > 0 && xls.changed < 3) + try + xlsout = java_new ("java.io.FileOutputStream", xls.filename); + bufout = java_new ("java.io.BufferedOutputStream", xlsout); + if (xls.changed == 2) printf ("Saving file %s...\n", xls.filename); endif + xls.workbook.writeBytes (bufout); + xls.workbook.close (); + bufout.flush (); + bufout.close (); + xlsout.close (); + xls.changed = 0; + catch +# xlsout.close (); + end_try_catch + else + xls.workbook.close (); + endif - elseif (strcmp (xls.xtype, 'UNO')) - # Java & UNO bridge - try - if (xls.changed && xls.changed < 3) - # Workaround: - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XModel'); - xModel = xls.workbook.queryInterface (unotmp); - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.util.XModifiable'); - xModified = xModel.queryInterface (unotmp); - if (xModified.isModified ()) - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XStorable'); # isReadonly() ? - xStore = xls.app.xComp.queryInterface (unotmp); - if (xls.changed == 2) - # Some trickery as Octave Java cannot create non-numeric arrays - lProps = javaArray ('com.sun.star.beans.PropertyValue', 1); - lProp = java_new ('com.sun.star.beans.PropertyValue', "Overwrite", 0, true, []); - lProps(1) = lProp; - # OK, store file - xStore.storeAsURL (xls.filename, lProps); - else - xStore.store (); - endif - endif - endif - xls.changed = -1; # Needed for check on properly shutting down OOo - # Workaround: - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XModel'); - xModel = xls.app.xComp.queryInterface (unotmp); - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.util.XCloseable'); - xClosbl = xModel.queryInterface (unotmp); - xClosbl.close (true); - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XDesktop'); - xDesk = xls.app.aLoader.queryInterface (unotmp); - xDesk.terminate(); - xls.changed = 0; - catch - if (force) - # Force closing OOo - unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XDesktop'); - xDesk = xls.app.aLoader.queryInterface (unotmp); - xDesk.terminate(); - else - warning ("Error closing xls pointer (UNO)"); - endif - return - end_try_catch + elseif (strcmp (xls.xtype, 'UNO')) + # Java & UNO bridge + try + if (xls.changed && xls.changed < 3) + # Workaround: + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XModel'); + xModel = xls.workbook.queryInterface (unotmp); + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.util.XModifiable'); + xModified = xModel.queryInterface (unotmp); + if (xModified.isModified ()) + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XStorable'); # isReadonly() ? + xStore = xls.app.xComp.queryInterface (unotmp); + if (xls.changed == 2) + # Some trickery as Octave Java cannot create non-numeric arrays + lProps = javaArray ('com.sun.star.beans.PropertyValue', 1); + lProp = java_new ('com.sun.star.beans.PropertyValue', "Overwrite", 0, true, []); + lProps(1) = lProp; + # OK, store file + xStore.storeAsURL (xls.filename, lProps); + else + xStore.store (); + endif + endif + endif + xls.changed = -1; # Needed for check on properly shutting down OOo + # Workaround: + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XModel'); + xModel = xls.app.xComp.queryInterface (unotmp); + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.util.XCloseable'); + xClosbl = xModel.queryInterface (unotmp); + xClosbl.close (true); + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XDesktop'); + xDesk = xls.app.aLoader.queryInterface (unotmp); + xDesk.terminate(); + xls.changed = 0; + catch + if (force) + # Force closing OOo + unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.frame.XDesktop'); + xDesk = xls.app.aLoader.queryInterface (unotmp); + xDesk.terminate(); + else + warning ("Error closing xls pointer (UNO)"); + endif + return + end_try_catch -# elseif <other interfaces here> - - endif +# elseif <other interfaces here> + + endif - if (xls.changed && xls.changed < 3) - warning (sprintf ("File %s could not be saved. Read-only or in use elsewhere?\nFile pointer preserved.", xls.filename)); - if (force) - xls = []; - endif - else - xls = []; - endif + if (xls.changed && xls.changed < 3) + warning (sprintf ("File %s could not be saved. Read-only or in use elsewhere?\nFile pointer preserved.", xls.filename)); + if (force) + xls = []; + endif + else + xls = []; + endif endfunction Modified: trunk/octave-forge/main/io/inst/xlsopen.m =================================================================== --- trunk/octave-forge/main/io/inst/xlsopen.m 2012-09-02 22:39:41 UTC (rev 10954) +++ trunk/octave-forge/main/io/inst/xlsopen.m 2012-09-03 19:51:31 UTC (rev 10955) @@ -108,8 +108,11 @@ ## 2012-06-06 Improved interface detection logic. No more messages if same interface is ## requested & used consecutively ## 2012-06-07 Fixed mixed-up lastintf assignments for POI and JXL +## 2012-09-02 (in UNO section) web adresses need only two consecutive slashes +## 2012-09-03 (in UNO section) replace canonicalize_file_name on non-Windows to +## make_absolute_filename (see bug #36677) ## -## Latest subfunction update: 2012-06-06 +## Latest subfunction update: 2012-09-03 function [ xls ] = xlsopen (filename, xwrite=0, reqinterface=[]) @@ -327,12 +330,18 @@ if (xlsinterfaces.UNO && ~xlssupport) # First, the file name must be transformed into a URL - if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http:///", filename))... - || ~isempty (strmatch ("ftp:///", filename)) || ~isempty (strmatch ("www:///", filename))) + if (~isempty (strmatch ("file:///", filename)) || ~isempty (strmatch ("http://", filename))... + || ~isempty (strmatch ("ftp://", filename)) || ~isempty (strmatch ("www://", filename))) # Seems in proper shape for OOo (at first sight) else - # Transform into URL form - fname = canonicalize_file_name (strsplit (filename, filesep){end}); + # Transform into URL form. + ## FIXME make_absolute_filename() doesn't work across drive(-letters) so + ## until it is fixed we'll fall back on canonicalize_file_name() there + if (ispc) + fname = canonicalize_file_name (strsplit (filename, filesep){end}); + else + fname = make_absolute_filename (strsplit (filename, filesep){end}); + endif # On Windows, change backslash file separator into forward slash if (strcmp (filesep, "\\")) tmp = strsplit (fname, filesep); @@ -468,6 +477,7 @@ ## '' Improved logic for finding out what interfaces to check ## '' Fixed bugs with Java interface checking (tmp1 initialization) ## 2012-06-06 Improved & simplified Java check code +## 2012-09-03 Check for matching .jar names & javaclasspath was reversed (oops) function [xlsinterfaces] = getxlsinterfaces (xlsinterfaces) @@ -558,7 +568,7 @@ # under Windows we need the following more subtle, platform-independent approach: for ii=1:length (jcp) for jj=1:length (entries1) - if (isempty (strfind (tolower (jcp{ii}), entries1{jj}))), ++jpchk1; endif + if (~isempty (strfind (tolower (jcp{ii}), entries1{jj}))), ++jpchk1; endif endfor endfor if (jpchk1 > 1) @@ -569,7 +579,7 @@ jpchk2 = 0; entries2 = {"xbean", "poi-ooxml-schemas", "dom4j"}; for ii=1:length (jcp) for jj=1:length (entries2) - if (isempty (strfind (lower (jcp{ii}), entries2{jj}))), ++jpchk2; endif + if (~isempty (strfind (lower (jcp{ii}), entries2{jj}))), ++jpchk2; endif endfor endfor if (jpchk2 > 2), printf (" (& OOXML)"); endif @@ -584,7 +594,7 @@ jpchk = 0; entries = {"jxl"}; for ii=1:length (jcp) for jj=1:length (entries) - if (isempty (strfind (lower (jcp{ii}), entries{jj}))), ++jpchk; endif + if (~isempty (strfind (lower (jcp{ii}), entries{jj}))), ++jpchk; endif endfor endfor if (jpchk > 0) @@ -600,7 +610,7 @@ jpchk = 0; entries = {"openxls"}; for ii=1:length (jcp) for jj=1:length (entries) - if (isempty (strfind (lower (jcp{ii}), entries{jj}))), ++jpchk; endif + if (~isempty (strfind (lower (jcp{ii}), entries{jj}))), ++jpchk; endif endfor endfor if (jpchk > 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-09-04 19:01:23
|
Revision: 10960 http://octave.svn.sourceforge.net/octave/?rev=10960&view=rev Author: prnienhuis Date: 2012-09-04 19:01:14 +0000 (Tue, 04 Sep 2012) Log Message: ----------- Add a small delay to UNO (LibreOffice/OOo) calls to avoid lockup Modified Paths: -------------- trunk/octave-forge/main/io/inst/io_ods_testscript.m trunk/octave-forge/main/io/inst/io_xls_testscript.m Modified: trunk/octave-forge/main/io/inst/io_ods_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_ods_testscript.m 2012-09-04 09:09:48 UTC (rev 10959) +++ trunk/octave-forge/main/io/inst/io_ods_testscript.m 2012-09-04 19:01:14 UTC (rev 10960) @@ -20,10 +20,15 @@ ## Author: Philip Nienhuis ## Created: 2012-02-25 ## Updates: +## 2012-09-04 Add small delay between LibreOffice calls to avoid lock-ups with UNO - printf ("\nTesting .ods interface %s ...\n", intf); +isuno = false; dly = 0.25; +if (strcmp (lower (intf), 'uno')); + isuno = true; +endif + ## 1. Initialize test arrays printf ("\n 1. Initialize arrays.\n"); arr1 = [ 1 2; 3 4.5]; @@ -32,26 +37,26 @@ ## 2. Insert empty sheet printf ("\n 2. Insert first empty sheet.\n"); -odswrite ('io-test.ods', {''}, 'EmptySheet', 'b4', intf); +odswrite ('io-test.ods', {''}, 'EmptySheet', 'b4', intf); if (isuno); sleep (dly); endif ## 3. Add data to test sheet printf ("\n 3. Add data to test sheet.\n"); -odswrite ('io-test.ods', arr1, 'Testsheet', 'c2:d3', intf); -odswrite ('io-test.ods', arr2, 'Testsheet', 'd4:z20', intf); +odswrite ('io-test.ods', arr1, 'Testsheet', 'c2:d3', intf); if (isuno); sleep (dly); endif +odswrite ('io-test.ods', arr2, 'Testsheet', 'd4:z20', intf); if (isuno); sleep (dly); endif ## 4. Insert another sheet printf ("\n 4. Add another sheet with just one number in A1.\n"); -odswrite ('io-test.ods', [1], 'JustOne', 'A1', intf); +odswrite ('io-test.ods', [1], 'JustOne', 'A1', intf); if (isuno); sleep (dly); endif ## 5. Get sheet info & find sheet with data and data range printf ("\n 5. Explore sheet info.\n"); -[~, shts] = odsfinfo ('io-test.ods', intf); +[~, shts] = odsfinfo ('io-test.ods', intf); if (isuno); sleep (dly); endif shnr = strmatch ('Testsheet', shts(:, 1)); # Note case! crange = shts{shnr, 2}; ## 6. Read data back printf ("\n 6. Read data back.\n"); -[num, txt, raw, lims] = odsread ('io-test.ods', shnr, crange, intf); +[num, txt, raw, lims] = odsread ('io-test.ods', shnr, crange, intf); if (isuno); sleep (dly); endif ## 7. Here come the tests, part 1 printf ("\n 7. Tests part 1 (basic I/O):\n"); @@ -92,9 +97,9 @@ ## Check if formulas_as_text works: printf ("\n 8. Repeat reading, now return formulas as text\n"); opts.formulas_as_text = 1; -ods = odsopen ('io-test.ods', 0, intf); -raw = ods2oct (ods, shnr, crange, opts); -ods = odsclose (ods); +ods = odsopen ('io-test.ods', 0, intf); if (isuno); sleep (dly); endif +raw = ods2oct (ods, shnr, crange, opts); if (isuno); sleep (dly); endif +ods = odsclose (ods); if (isuno); sleep (dly); endif clear ods; ## 9. Here come the tests, part 2. Fails on COM Modified: trunk/octave-forge/main/io/inst/io_xls_testscript.m =================================================================== --- trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-09-04 09:09:48 UTC (rev 10959) +++ trunk/octave-forge/main/io/inst/io_xls_testscript.m 2012-09-04 19:01:14 UTC (rev 10960) @@ -21,15 +21,18 @@ ## Created: 2012-02-25 ## Updates: ## 2012-06-06 Adapted to COM implementation for "formulas_as_text" option +## 2012-09-04 Added delay between LibreOffice calls to avoid lockups with UNO printf ("\nTesting .xls interface %s ...\n", intf); -if (strcmp (lower (intf), 'oxs')); +isuno = false; dly = 0.25; +intf2 = intf; +if (strcmp (lower (intf), 'oxs')) printf ("OXS interface has no write support enabled - writing is done with POI.\n"); intf2 = 'com'; -else; - intf2 = intf; +elseif (strcmp (lower (intf), 'uno')); + isuno = true; endif ## 1. Initialize test arrays @@ -40,26 +43,26 @@ ## 2. Insert empty sheet printf ("\n 2. Insert first empty sheet.\n"); -xlswrite ('io-test.xls', {''}, 'EmptySheet', 'b4', intf2); +xlswrite ('io-test.xls', {''}, 'EmptySheet', 'b4', intf2); if (isuno); sleep (dly); endif ## 3. Add data to test sheet printf ("\n 3. Add data to test sheet.\n"); -xlswrite ('io-test.xls', arr1, 'Testsheet', 'c2:d3', intf2); -xlswrite ('io-test.xls', arr2, 'Testsheet', 'd4:z20', intf2); +xlswrite ('io-test.xls', arr1, 'Testsheet', 'c2:d3', intf2); if (isuno); sleep (dly); endif +xlswrite ('io-test.xls', arr2, 'Testsheet', 'd4:z20', intf2); if (isuno); sleep (dly); endif ## 4. Insert another sheet printf ("\n 4. Add another sheet with just one number in A1.\n"); -xlswrite ('io-test.xls', [1], 'JustOne', 'A1', intf2); +xlswrite ('io-test.xls', [1], 'JustOne', 'A1', intf2); if (isuno); sleep (dly); endif ## 5. Get sheet info & find sheet with data and data range printf ("\n 5. Explore sheet info.\n"); -[~, shts] = xlsfinfo ('io-test.xls', intf); +[~, shts] = xlsfinfo ('io-test.xls', intf); if (isuno); sleep (dly); endif shnr = strmatch ('Testsheet', shts(:, 1)); # Note case! crange = shts{shnr, 2}; ## 6. Read data back printf ("\n 6. Read data back.\n"); -[num, txt, raw, lims] = xlsread ('io-test.xls', shnr, crange, intf); +[num, txt, raw, lims] = xlsread ('io-test.xls', shnr, crange, intf); if (isuno); sleep (dly); endif ## 7. Here come the tests, part 1 printf ("\n 7. Tests part 1 (basic I/O):\n"); @@ -97,9 +100,9 @@ ## Check if "formulas_as_text" option works: printf ("\n 8. Repeat reading, now return formulas as text\n"); opts.formulas_as_text = 1; -xls = xlsopen ('io-test.xls', 0, intf); -raw = xls2oct (xls, shnr, crange, opts); -xls = xlsclose (xls); +xls = xlsopen ('io-test.xls', 0, intf); if (isuno); sleep (dly); endif +raw = xls2oct (xls, shnr, crange, opts); if (isuno); sleep (dly); endif +xls = xlsclose (xls); if (isuno); sleep (dly); endif ## 9. Here come the tests, part 2. printf ("\n 9. Tests part 2 (read back formula):\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <prn...@us...> - 2012-09-07 14:13:14
|
Revision: 10972 http://octave.svn.sourceforge.net/octave/?rev=10972&view=rev Author: prnienhuis Date: 2012-09-07 14:13:02 +0000 (Fri, 07 Sep 2012) Log Message: ----------- CRLF to LF Modified Paths: -------------- trunk/octave-forge/main/io/inst/calccelladdress.m trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m trunk/octave-forge/main/io/inst/getusedrange.m trunk/octave-forge/main/io/inst/io_ods_testscript.m trunk/octave-forge/main/io/inst/io_xls_testscript.m trunk/octave-forge/main/io/inst/object2json.m trunk/octave-forge/main/io/inst/oct2ods.m trunk/octave-forge/main/io/inst/oct2xls.m trunk/octave-forge/main/io/inst/ods2oct.m trunk/octave-forge/main/io/inst/odsclose.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 trunk/octave-forge/main/io/inst/odswrite.m trunk/octave-forge/main/io/inst/parse_sp_range.m trunk/octave-forge/main/io/inst/parsecell.m trunk/octave-forge/main/io/inst/pch2mat.m trunk/octave-forge/main/io/inst/spsh_chkrange.m trunk/octave-forge/main/io/inst/spsh_prstype.m trunk/octave-forge/main/io/inst/xls2oct.m trunk/octave-forge/main/io/inst/xlsclose.m trunk/octave-forge/main/io/inst/xlsfinfo.m trunk/octave-forge/main/io/inst/xlswrite.m Modified: trunk/octave-forge/main/io/inst/calccelladdress.m =================================================================== --- trunk/octave-forge/main/io/inst/calccelladdress.m 2012-09-07 14:11:47 UTC (rev 10971) +++ trunk/octave-forge/main/io/inst/calccelladdress.m 2012-09-07 14:13:02 UTC (rev 10972) @@ -1,88 +1,89 @@ -## Copyright (C) 2009,2010,2011 Philip Nienhuis <pr....@us...> -## -## 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 3 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 -## this program; if not, see <http://www.gnu.org/licenses/>. - -## calccelladdress (R, C) - compute spreadsheet style cell address from -## row & column index (both 1-based). -## -## Max column index currently set to 18278 (max ODS: 1024, OOXML: 16384). -## Row limits for ODF and OOXML are 65536 and 1048576, resp. - -## Author: Philip Nienhuis <prnienhuis at users.sf.net> -## Created: 2009-12-12 -## Updates: -## 2009-12-27 Fixed OOXML limits -## 2010-03-17 Simplified argument list, only row + column needed -## 2010-09-27 Made error message more comprehensible -## 2010-10-11 Added check for row range -## 2011-04-21 Added tests -## 2011-04-30 Simplified column name computation -## 2011-12-17 Bugfix for wrong column address if column equals multiple of 26 -## 2011-12-18 Added tests for multiple-of-26 cases - -function [ celladdress ] = calccelladdress (row, column) - - if (nargin < 2) error ("calccelladdress: Two arguments needed") endif - - if (column > 18278 || column < 1) error ("Specified column out of range (1..18278)"); endif - if (row > 1048576 || row < 1), error ('Specified row out of range (1..1048576)'); endif - - str = ''; - while (column > 0.01) - rmd = floor ((column - 1) / 26); - str = [char(column - rmd * 26 + 'A' - 1) str]; - column = rmd; - endwhile - - celladdress = sprintf ("%s%d", str, row); - -endfunction - -%!test -%! a = calccelladdress (1, 1); -%! assert (a, 'A1'); - -%!test -%! a = calccelladdress (378, 28); -%! assert (a, 'AB378'); - -%!test -%! a = calccelladdress (65536, 1024); -%! assert (a, 'AMJ65536'); - -%!test -%! a = calccelladdress (1048576, 16384); -%! assert (a, 'XFD1048576'); - -%!test -%! a = calccelladdress (378, 26); -%! assert (a, 'Z378'); - -%!test -%! a = calccelladdress (378, 702); -%! assert (a, 'ZZ378'); - -%!test -%! a = calccelladdress (378, 701); -%! assert (a, 'ZY378'); - -%!test -%! a = calccelladdress (378, 703); -%! assert (a, 'AAA378'); - -%!test -%! a = calccelladdress (378, 676); -%! assert (a, 'YZ378'); - - +## Copyright (C) 2009,2010,2011 Philip Nienhuis <pr....@us...> + ## + ## 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 3 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 + ## this program; if not, see <http://www.gnu.org/licenses/>. + + ## calccelladdress (R, C) - compute spreadsheet style cell address from + ## row & column index (both 1-based). + ## + ## Max column index currently set to 18278 (max ODS: 1024, OOXML: 16384). + ## Row limits for ODF and OOXML are 65536 and 1048576, resp. + + ## Author: Philip Nienhuis <prnienhuis at users.sf.net> + ## Created: 2009-12-12 + ## Updates: + ## 2009-12-27 Fixed OOXML limits + ## 2010-03-17 Simplified argument list, only row + column needed + ## 2010-09-27 Made error message more comprehensible + ## 2010-10-11 Added check for row range + ## 2011-04-21 Added tests + ## 2011-04-30 Simplified column name computation + ## 2011-12-17 Bugfix for wrong column address if column equals multiple of 26 + ## 2011-12-18 Added tests for multiple-of-26 cases + + function [ celladdress ] = calccelladdress (row, column) + + if (nargin < 2) error ("calccelladdress: Two arguments needed") endif + + if (column > 18278 || column < 1) error ("Specified column out of range (1..18278)"); endif + if (row > 1048576 || row < 1), error ('Specified row out of range (1..1048576)'); endif + + str = ''; + while (column > 0.01) + rmd = floor ((column - 1) / 26); + str = [char(column - rmd * 26 + 'A' - 1) str]; + column = rmd; + endwhile + + celladdress = sprintf ("%s%d", str, row); + + endfunction + + %!test + %! a = calccelladdress (1, 1); + %! assert (a, 'A1'); + + %!test + %! a = calccelladdress (378, 28); + %! assert (a, 'AB378'); + + %!test + %! a = calccelladdress (65536, 1024); + %! assert (a, 'AMJ65536'); + + %!test + %! a = calccelladdress (1048576, 16384); + %! assert (a, 'XFD1048576'); + + %!test + %! a = calccelladdress (378, 26); + %! assert (a, 'Z378'); + + %!test + %! a = calccelladdress (378, 702); + %! assert (a, 'ZZ378'); + + %!test + %! a = calccelladdress (378, 701); + %! assert (a, 'ZY378'); + + %!test + %! a = calccelladdress (378, 703); + %! assert (a, 'AAA378'); + + %!test + %! a = calccelladdress (378, 676); + %! assert (a, 'YZ378'); + + + \ No newline at end of file Modified: trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m =================================================================== --- trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-09-07 14:11:47 UTC (rev 10971) +++ trunk/octave-forge/main/io/inst/chk_spreadsheet_support.m 2012-09-07 14:13:02 UTC (rev 10972) @@ -1,587 +1,588 @@ -% Check Octave / Matlab environment for spreadsheet I/O support. -% -% usage: [ RETVAL ] = chk_spreadsheet_support ( [/PATH/TO/JARS], [,DEBUG_LEVEL] [,PATH_TO_OOO]) -% -% 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. 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): -% - Windows: C:\Program Files\OpenOffice.org -% - *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/.../ridl.jar -% resolve OK -% Returns: -% 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) - -% 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 3 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 -% this program; if not, see <http://www.gnu.org/licenses/>. - - -% Author: Philip Nienhuis -% 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) -% 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() -% 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 -% 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-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 -% 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 - if (nargin < 2); dbug = 0; end %if - isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; - 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 - 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'); 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 - % 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 - tst1 = version ('-java'); - jtst = isempty (strfind (tst1, 'Java')); - end %if - if (jtst) - 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. - if (dbug > 1 && isOctave), 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')); - 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 && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if - if (dbug > 1) - % Check JVM virtual memory settings - jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); - jmem = jrt.maxMemory (); - 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']); - 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 - 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 - - % 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)); - % 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) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), 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 (jpchk1 >= numel (entries1)), retval = retval + 2; end %if - if (dbug > 1) - if (jpchk1 >= numel (entries1)) - fprintf (' => Apache (POI) OK\n'); - 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) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), 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 - % 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'); - 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) - jcplst = strsplit (jcp{ii}, filesep); - jcpentry = jcplst {end}; - if (~isempty (strfind (lower (jcpentry), 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 (jpchk >= numel (entries3)), retval = retval + 8; end %if - if (dbug > 1) - if (jpchk >= numel (entries3)) - fprintf (' => Java/JExcelAPI (JXL) OK.\n'); - 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; 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 (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 >= numel (entries4)), retval = retval + 16; end %if - if (dbug > 1) - if (jpchk >= numel (entries4)) - fprintf (' => Java/OpenXLS (OXS) OK.\n'); - 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; 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 (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 (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 = ' '; - try - % New in 0.8.6 - odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest'); - catch - % 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') - || ~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; - 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; 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 (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 (jpchk >= numel (entries6)), retval = retval + 64; end %if - if (dbug > 1) - if (jpchk >= numel(entries6)) - fprintf (' => jOpenDocument (JOD) OK.\n'); - 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, 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)), 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)) - % Add program dir (= where soffice or soffice.exe or ooffice resides) - programdir = [path_to_ooo filesep entries0{1}]; - if (exist (programdir, 'dir')) - if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if - try - javaaddpath (programdir); - targt = targt - 1; - if (dbug > 2), fprintf ('OK\n'); end %if - catch - if (dbug > 2), fprintf ('FAILED\n'); end %if - end %try_catch - else - 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 - 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)) - 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 '?asis' '*']); - jj = 1; - 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)) - tmp = get_dir_ (tmp, basisdirentries{jj}); - jj = jj + 1; - 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'); - if (isempty (unojardir)) - tmp = uredir; - else - tmp = unojardir; - end %if - 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 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 %if - end %if - end %for - if (~targt); 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'); - end %if - end %f - end %if - -% ----------Rest of Java interfaces---------------------------------- - - missing = [missing1 missing2 missing3 missing4 missing5 missing6]; - jars_complete = isempty (find (missing, 1)); - if (dbug) - if (jars_complete) - fprintf ('All Java-based interfaces (save UNO) fully supported.\n\n'); - else - fprintf ('Some class libs lacking yet...\n\n'); - end %if - 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)), printf ('Path expected for arg # 1\n'); return; end %if - % First combine all entries - targt = sum (missing); - % Search tru list of missing entries - 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(1).name); end %if - try - javaaddpath ([path_to_jars filesep file(1).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'); - else - fprintf ('All Java-based interfaces fully supported.now.\n\n'); - end %if - end %f - 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 - 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 +% Check Octave / Matlab environment for spreadsheet I/O support. + % + % usage: [ RETVAL ] = chk_spreadsheet_support ( [/PATH/TO/JARS], [,DEBUG_LEVEL] [,PATH_TO_OOO]) + % + % 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. 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): + % - Windows: C:\Program Files\OpenOffice.org + % - *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/.../ridl.jar + % resolve OK + % Returns: + % 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) + + % 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 3 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 + % this program; if not, see <http://www.gnu.org/licenses/>. + + + % Author: Philip Nienhuis + % 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) + % 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() + % 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 + % 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-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 + % 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 + if (nargin < 2); dbug = 0; end %if + isOctave = exist ('OCTAVE_VERSION', 'builtin') ~= 0; + 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 + 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'); 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 + % 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 + tst1 = version ('-java'); + jtst = isempty (strfind (tst1, 'Java')); + end %if + if (jtst) + 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. + if (dbug > 1 && isOctave), 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')); + 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 && ~iscell (jcp)); jcp = strsplit (char (jcp), ':'); end %if + if (dbug > 1) + % Check JVM virtual memory settings + jrt = javaMethod ('getRuntime', 'java.lang.Runtime'); + jmem = jrt.maxMemory (); + 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']); + 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 + 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 + + % 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)); + % 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) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), 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 (jpchk1 >= numel (entries1)), retval = retval + 2; end %if + if (dbug > 1) + if (jpchk1 >= numel (entries1)) + fprintf (' => Apache (POI) OK\n'); + 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) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), 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 + % 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'); + 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) + jcplst = strsplit (jcp{ii}, filesep); + jcpentry = jcplst {end}; + if (~isempty (strfind (lower (jcpentry), 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 (jpchk >= numel (entries3)), retval = retval + 8; end %if + if (dbug > 1) + if (jpchk >= numel (entries3)) + fprintf (' => Java/JExcelAPI (JXL) OK.\n'); + 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; 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 (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 >= numel (entries4)), retval = retval + 16; end %if + if (dbug > 1) + if (jpchk >= numel (entries4)) + fprintf (' => Java/OpenXLS (OXS) OK.\n'); + 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; 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 (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 (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 = ' '; + try + % New in 0.8.6 + odfvsn = javaMethod ('getOdfdomVersion', 'org.odftoolkit.odfdom.JarManifest'); + catch + % 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') + || ~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; + 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; 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 (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 (jpchk >= numel (entries6)), retval = retval + 64; end %if + if (dbug > 1) + if (jpchk >= numel(entries6)) + fprintf (' => jOpenDocument (JOD) OK.\n'); + 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, 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)), 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)) + % Add program dir (= where soffice or soffice.exe or ooffice resides) + programdir = [path_to_ooo filesep entries0{1}]; + if (exist (programdir, 'dir')) + if (dbug > 2), fprintf (' Found %s, adding it to javaclasspath ... ', programdir); end %if + try + javaaddpath (programdir); + targt = targt - 1; + if (dbug > 2), fprintf ('OK\n'); end %if + catch + if (dbug > 2), fprintf ('FAILED\n'); end %if + end %try_catch + else + 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 + 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)) + 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 '?asis' '*']); + jj = 1; + 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)) + tmp = get_dir_ (tmp, basisdirentries{jj}); + jj = jj + 1; + 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'); + if (isempty (unojardir)) + tmp = uredir; + else + tmp = unojardir; + end %if + 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 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 %if + end %if + end %for + if (~targt); 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'); + end %if + end %f + end %if + + % ----------Rest of Java interfaces---------------------------------- + + missing = [missing1 missing2 missing3 missing4 missing5 missing6]; + jars_complete = isempty (find (missing, 1)); + if (dbug) + if (jars_complete) + fprintf ('All Java-based interfaces (save UNO) fully supported.\n\n'); + else + fprintf ('Some class libs lacking yet...\n\n'); + end %if + 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)), printf ('Path expected for arg # 1\n'); return; end %if + % First combine all entries + targt = sum (missing); + % Search tru list of missing entries + 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(1).name); end %if + try + javaaddpath ([path_to_jars filesep file(1).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'); + else + fprintf ('All Java-based interfaces fully supported.now.\n\n'); + end %if + end %f + 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 + 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 + \ No newline at end of file Modified: trunk/octave-forge/main/io/inst/getusedrange.m =================================================================== --- trunk/octave-forge/main/io/inst/getusedrange.m 2012-09-07 14:11:47 UTC (rev 10971) +++ trunk/octave-forge/main/io/inst/getusedrange.m 2012-09-07 14:13:02 UTC (rev 10972) @@ -1,659 +1,660 @@ -## Copyright (C) 2010,2011,2012 Philip Nienhuis <pr....@us...> -## -## 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 3 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 -## this program; if not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} [ @var{toprow#}, @var{bottomrow#}, @var{leftcol#}, @var{rightcol#} ] = getusedrange (@var{spptr}, @var{shindex#}) -## Find occupied data range in worksheet @var{shindex#} in a spreadsheet -## pointed to in struct @var{spptr} (either MS-Excel or -## OpenOffice_org Calc). -## -## @var{shindex#} must be numeric and is 1-based. @var{spptr} can either -## refer to an MS-Excel spreadsheet (spptr returned by xlsopen) or an -## OpenOffice.org Calc spreadsheet (spptr returned by odsopen). -## None of these inputs are checked! -## -## Be aware that especially for OpenOffice.org Calc (ODS) spreadsheets -## the results can only be obtained by counting all cells in all rows; -## this can be fairly time-consuming. Reliable ods data size results can -## only be obtained using UNO interface. -## For the ActiveX (COM) interface the underlying Visual Basic call relies -## on cached range values and counts empty cells with only formatting too, -## so COM returns only approximate (but then usually too big) range values. -## -## Examples: -## -## @example -## [trow, brow, lcol, rcol] = getusedrange (ods2, 3); -## (which returns the outermost... [truncated message content] |