You are here

function socialcalc_coord_to_cr in Sheetnode 7

Same name and namespace in other branches
  1. 5 socialcalc.inc \socialcalc_coord_to_cr()
  2. 6 socialcalc.inc \socialcalc_coord_to_cr()
  3. 7.2 socialcalc.inc \socialcalc_coord_to_cr()
7 calls to socialcalc_coord_to_cr()
sheetnode_handler_field_named_range::render in views/sheetnode_handler_field_named_range.inc
Render the field.
sheetnode_handler_field_range::render in views/sheetnode_handler_field_range.inc
Render the field.
sheetnode_plugin_style::render_sheet in views/sheetnode_plugin_style.inc
socialcalc_parse_edit in ./socialcalc.inc
socialcalc_parse_sheet in ./socialcalc.inc

... See full list

File

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

Code

function socialcalc_coord_to_cr($coord) {
  static $coord_to_cr = array();
  if (isset($coord_to_cr[$coord])) {
    return $coord_to_cr[$coord];
  }
  $c = 0;
  $r = 0;
  for ($i = 0; $i < strlen($coord); $i++) {

    // this was faster than using regexes; assumes well-formed
    $ch = ord(substr($coord, $i, 1));
    if ($ch == 36) {
    }
    else {
      if ($ch <= 57) {
        $r = 10 * $r + $ch - 48;
      }
      else {
        if ($ch >= 97) {
          $c = 26 * $c + $ch - 96;
        }
        else {
          if ($ch >= 65) {
            $c = 26 * $c + $ch - 64;
          }
        }
      }
    }
  }
  $coord_to_cr[$coord] = array(
    $c,
    $r,
  );
  return $coord_to_cr[$coord];
}