function OpenDoc_ChartRenameSeries(&$Txt, &$series, $NewName)
 {
     $NewName = htmlspecialchars($NewName);
     $col_name = $series['col_name'];
     $el = clsTbsXmlLoc::FindStartTag($Txt, 'table:table-header-rows', 0);
     $el = clsTbsXmlLoc::FindStartTag($Txt, 'table:table-row', $el->PosEnd);
     for ($i = 1; $i < $col_name; $i++) {
         $el = clsTbsXmlLoc::FindStartTag($Txt, 'table:table-cell', $el->PosEnd);
     }
     $elCell = clsTbsXmlLoc::FindElement($Txt, 'table:table-cell', $el->PosEnd);
     $elP = clsTbsXmlLoc::FindElement($elCell, 'text:p', 0);
     if ($elP === false) {
         $elCell->ReplaceInnerSrc($elCell->InnerSrc . '<text:p>' . $NewName . '</text:p>');
     } else {
         if ($elP->SelfClosing) {
             $elP->ReplaceSrc('<text:p>' . $NewName . '</text:p>');
         } else {
             $elP->ReplaceInnerSrc($NewName);
         }
         $elP->UpdateParent();
     }
 }
 /**
  * Return information and data about all series in the chart.
  */
 function OpenDoc_ChartReadSeries($ChartRef, $Complete)
 {
     $Txt = false;
     $chart = $this->OpenDoc_ChartFind($ChartRef, $Txt, 'ChartReadSeries');
     if ($chart === false) {
         return;
     }
     // Read the data table
     $table = array();
     $rows = clsTbsXmlLoc::FindElement($Txt, 'table:table-rows', 0);
     $pr = 0;
     while ($r = clsTbsXmlLoc::FindElement($rows, 'table:table-row', $pr)) {
         $pr = $r->PosEnd;
         $pc = 0;
         $row = array();
         while ($c = clsTbsXmlLoc::FindElement($r, 'table:table-cell', $pc)) {
             $pc = $c->PosEnd;
             $val = $c->getAttLazy('office:value');
             if ($val == 'NaN') {
                 // Not a Number, happens when the cell is empty
                 $val = false;
                 $txt = '';
             } else {
                 if ($x = clsTbsXmlLoc::FindElement($c, 'text:p', 0)) {
                     $txt = $x->GetInnerSrc();
                 } else {
                     $txt = false;
                 }
             }
             $row[] = array('val' => $val, 'txt' => $txt);
         }
         $table[] = $row;
     }
     // Format series information
     $series = array();
     $cat_idx = $chart['col_cat'] - 1;
     foreach ($chart['series'] as $idx => $info) {
         $cat = array();
         $val = array();
         $col_idx = $info['cols'][0] - 1;
         foreach ($table as $row) {
             $val[] = $row[$col_idx]['val'];
             $cat[] = $row[$cat_idx]['txt'];
         }
         $series[] = array('name' => $info['name'], 'cat' => $cat, 'val' => $val);
     }
     if ($Complete) {
         // Complete information about the chart
         $main_idx = $this->Ext_GetMainIdx();
         return array('file_idx' => $chart['file_idx'], 'file_name' => $chart['file_name'], 'parent_idx' => $main_idx, 'parent_name' => $this->TbsGetFileName($main_idx), 'series' => $series);
     } else {
         // Simple information about data
         $simple = array();
         foreach ($series as $s) {
             $name = $s['name'];
             $simple[$name] = array($s['cat'], $s['val']);
         }
         return $simple;
     }
 }