From: <prn...@us...> - 2011-09-19 16:02:37
|
Revision: 8567 http://octave.svn.sourceforge.net/octave/?rev=8567&view=rev Author: prnienhuis Date: 2011-09-19 16:02:31 +0000 (Mon, 19 Sep 2011) Log Message: ----------- (UNO) try to decipher value type returned by formulas Modified Paths: -------------- trunk/octave-forge/main/io/inst/ods2oct.m trunk/octave-forge/main/io/inst/xls2oct.m Modified: trunk/octave-forge/main/io/inst/ods2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/ods2oct.m 2011-09-19 14:05:34 UTC (rev 8566) +++ trunk/octave-forge/main/io/inst/ods2oct.m 2011-09-19 16:02:31 UTC (rev 8567) @@ -114,7 +114,7 @@ ## 2011-05-06 Experimental UNO support ## 2011-09-18 Set rstatus var here ## -## (Latest update of subfunctions below: 2011-09-18) +## (Latest update of subfunctions below: 2011-09-19) function [ rawarr, ods, rstatus ] = ods2oct (ods, wsh=1, datrange=[], spsh_opts=[]) @@ -789,6 +789,7 @@ ## 2011-09-18 Adapted sh_names type to LO 3.4.1 ## '' Remove default 2 last sheets (LibreOffice 3.4.+) ## '' Remove rstatus var (now set in caller) +## 2011-09-19 Try to decipher if formulas return numeric or string values function [rawarr, ods] = ods2uno2oct (ods, wsh, datrange, spsh_opts) @@ -868,8 +869,12 @@ if (spsh_opts.formulas_as_text) rawarr{ii-trow+2, jj-lcol+2} = XCell.getFormula (); else + # Unfortunately OOo gives no clue as to the type of formula result unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.text.XText'); rawarr{ii-trow+2, jj-lcol+2} = XCell.queryInterface (unotmp).getString (); + tmp = str2double (rawarr{ii-trow+2, jj-lcol+2}); + # If the string happens to contain just a number we'll assume it is numeric + if (~isnan (tmp)); rawarr{ii-trow+2, jj-lcol+2} = tmp; endif endif otherwise # Empty cell Modified: trunk/octave-forge/main/io/inst/xls2oct.m =================================================================== --- trunk/octave-forge/main/io/inst/xls2oct.m 2011-09-19 14:05:34 UTC (rev 8566) +++ trunk/octave-forge/main/io/inst/xls2oct.m 2011-09-19 16:02:31 UTC (rev 8567) @@ -119,7 +119,7 @@ ## 2011-05-18 Experimental UNO support added ## 2011-09-08 Minor code layout ## -## Latest subfunc update: 2011-09-18 +## Latest subfunc update: 2011-09-19 function [ rawarr, xls, rstatus ] = xls2oct (xls, wsh=1, datrange='', spsh_opts=[]) @@ -873,6 +873,7 @@ ## Created: 2011-05-05 ## Updates: ## 2011-09-18 Adapted sh_names type to LO 3.4.1 +## 2011-09-19 Try to decipher if formulas return numeric or string values function [rawarr, xls, rstatus] = xls2uno2oct (xls, wsh, datrange, spsh_opts) @@ -952,8 +953,12 @@ if (spsh_opts.formulas_as_text) rawarr{ii-trow+2, jj-lcol+2} = XCell.getFormula (); else + # Unfortunately OOo gives no clue as to the type of formula result unotmp = java_new ('com.sun.star.uno.Type', 'com.sun.star.text.XText'); rawarr{ii-trow+2, jj-lcol+2} = XCell.queryInterface (unotmp).getString (); + tmp = str2double (rawarr{ii-trow+2, jj-lcol+2}); + # If the string happens to contain just a number we'll assume it is numeric + if (~isnan (tmp)); rawarr{ii-trow+2, jj-lcol+2} = tmp; endif endif otherwise # Empty cell This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |