1#!/bin/bash
2#
3# IMPORTANT: this is like the slowest thing ever. But it works. Usually.
4# Requires an open instance of KSpread, with openformula-test.ods loaded.
5#
6
7KSPREAD=`dcopfind 'kspread*'`
8KSPREAD=`echo $KSPREAD | sed s/DCOPRef\(// | sed s/,\)//`
9for i in `seq 51 514`
10  do
11  CELLREF=`dcop $KSPREAD Document/Map/List1 cell 7 $i`
12  PASS=`dcop $CELLREF value`
13  if test $PASS = 1.000000
14    then
15    CELLREF=`dcop $KSPREAD Document/Map/List1 cell 2 $i`
16    formula=`dcop $CELLREF text`
17    formula=`echo $formula | sed s/\"/\\\\\\\\\"/g`
18
19#nothing if formula contains a cellref ...
20    if test -z "`echo $formula | grep B[1-9]`"
21      then
22      CELLREF=`dcop $KSPREAD Document/Map/List1 cell 3 $i`
23      result=`dcop $CELLREF text`
24#test whether we have a number
25      if test $result = True
26        then
27	VAL="true"
28      else if test $result = False
29        then
30	VAL="false"
31      else if test -z `echo $result | grep -P "^\d+([\.,]\d+)?$"`
32        then
33	VAL="\"${result}\""
34      else
35	result=`echo $result | sed s/,/./`
36        VAL=$result
37      fi;fi;fi
38      echo "CHECK_EVAL(\"=${formula}\", Value($VAL));  // row $i"
39    fi
40  else echo // Not passed for line $i.
41  fi
42done
43
44
45