You are here

function socialcalc_parse_cell in Sheetnode 5

Same name and namespace in other branches
  1. 6 socialcalc.inc \socialcalc_parse_cell()
  2. 7.2 socialcalc.inc \socialcalc_parse_cell()
  3. 7 socialcalc.inc \socialcalc_parse_cell()
1 call to socialcalc_parse_cell()
socialcalc_parse_sheet in ./socialcalc.inc

File

./socialcalc.inc, line 302
SocialCalc manipulation functions Translated from socialcalc-3.js and companion files

Code

function socialcalc_parse_cell($parts, $j) {
  $cell = array();
  while ($t = @$parts[$j++]) {
    switch ($t) {
      case "v":
        $cell['datavalue'] = doubleval(socialcalc_decode_value($parts[$j++]));
        $cell['datatype'] = "v";
        $cell['valuetype'] = "n";
        break;
      case "t":
        $cell['datavalue'] = strval(socialcalc_decode_value($parts[$j++]));
        $cell['datatype'] = "t";
        $cell['valuetype'] = "t";
        break;
      case "vt":
        $v = $parts[$j++];
        $cell['valuetype'] = $v;
        $cell['datatype'] = $v[0] == "n" ? "v" : "t";
        $cell['datavalue'] = socialcalc_decode_value($parts[$j++]);
        break;
      case "vtf":
        $cell['valuetype'] = strval($parts[$j++]);
        $cell['datavalue'] = socialcalc_decode_value($parts[$j++]);
        $cell['formula'] = strval(socialcalc_decode_value($parts[$j++]));
        $cell['datatype'] = "f";
        break;
      case "vtc":
        $cell['valuetype'] = strval($parts[$j++]);
        $cell['datavalue'] = socialcalc_decode_value($parts[$j++]);
        $cell['formula'] = strval(socialcalc_decode_value($parts[$j++]));
        $cell['datatype'] = "c";
        break;
      case "e":
        $cell['errors'] = strval(socialcalc_decode_value($parts[$j++]));
        break;
      case "b":
        $cell['bt'] = intval($parts[$j++]);
        $cell['br'] = intval($parts[$j++]);
        $cell['bb'] = intval($parts[$j++]);
        $cell['bl'] = intval($parts[$j++]);
        break;
      case "l":
        $cell['layout'] = intval($parts[$j++]);
        break;
      case "f":
        $cell['font'] = intval($parts[$j++]);
        break;
      case "c":
        $cell['color'] = intval($parts[$j++]);
        break;
      case "bg":
        $cell['bgcolor'] = intval($parts[$j++]);
        break;
      case "cf":
        $cell['cellformat'] = intval($parts[$j++]);
        break;
      case "ntvf":
        $cell['nontextvalueformat'] = intval($parts[$j++]);
        break;
      case "tvf":
        $cell['textvalueformat'] = intval($parts[$j++]);
        break;
      case "colspan":
        $cell['colspan'] = intval($parts[$j++]);
        break;
      case "rowspan":
        $cell['rowspan'] = intval($parts[$j++]);
        break;
      case "cssc":
        $cell['cssc'] = strval($parts[$j++]);
        break;
      case "csss":
        $cell['csss'] = strval(socialcalc_decode_value($parts[$j++]));
        break;
      case "mod":
        $j += 1;
        break;
      case "comment":
        $cell['comment'] = strval(socialcalc_decode_value($parts[$j++]));
        break;
      case "ro":
        $cell['readonly'] = strcmp(strtolower(strval(socialcalc_decode_value($parts[$j++]))), "yes") == 0;
        break;
    }
  }
  return $cell;
}