changeset 12065:269bb2780348 octave-forge

Clean up/pretty returned ODS formulas
author prnienhuis
date Fri, 27 Sep 2013 18:01:08 +0000
parents 07169c2596f2
children acbeb620b385
files main/io/inst/private/__OTK_spsh2oct__.m
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/main/io/inst/private/__OTK_spsh2oct__.m	Fri Sep 27 18:00:28 2013 +0000
+++ b/main/io/inst/private/__OTK_spsh2oct__.m	Fri Sep 27 18:01:08 2013 +0000
@@ -25,8 +25,12 @@
 ##     ''     Remove rstatus var (now set in caller)
 ## 2012-10-12 Renamed & moved into ./private
 ## 2012-10-24 Style fixes
+## 2013-09-11 rstatus return arg added (nowhere used, but all other routines have it)
+##     ''     Returned formulas cleaned up
 
-function [ rawarr, ods ] = __OTK_spsh2oct__ (ods, wsh, crange, spsh_opts)
+function [ rawarr, ods, rstatus ] = __OTK_spsh2oct__ (ods, wsh, crange, spsh_opts)
+
+  rstatus = 0;
 
   ## Get contents and table stuff from the workbook
   odfcont = ods.workbook;  ## Use a local copy just to be sure. octave 
@@ -153,7 +157,12 @@
 ##          endif
 ##          rawarr(ii-trow+1, jj-lcol+1)= cvalue;
           case "formula"
-            rawarr(ii-trow+1, jj-lcol+1) = ocell.getFormula ();
+            form = ocell.getFormula ();
+            ## Pimp ranges in formulas
+            form = regexprep (form(4:end), '\[\.(\w+)\]', '$1');
+            form = regexprep (form, '\[\.(\w+):', '$1:');
+            form = regexprep (form, ':\.(\w+)\]', ':$1');
+            rawarr(ii-trow+1, jj-lcol+1) = form;
           otherwise
             ## Nothing.
         endswitch