qsos-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qsos-commits] qsos/apps/o3s export_oo.php


From: Raphaël Semeteys
Subject: [Qsos-commits] qsos/apps/o3s export_oo.php
Date: Sun, 17 May 2009 22:04:47 +0000

CVSROOT:        /sources/qsos
Module name:    qsos
Changes by:     Raphaël Semeteys <rsemeteys>    09/05/17 22:04:47

Modified files:
        apps/o3s       : export_oo.php 

Log message:
        Multiple evaluation export
        Localization
        Chart generation is dropped for now.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/o3s/export_oo.php?cvsroot=qsos&r1=1.1&r2=1.2

Patches:
Index: export_oo.php
===================================================================
RCS file: /sources/qsos/qsos/apps/o3s/export_oo.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- export_oo.php       2 Feb 2007 07:14:33 -0000       1.1
+++ export_oo.php       17 May 2009 22:04:47 -0000      1.2
@@ -1,6 +1,6 @@
 <?php
 /*
-**  Copyright (C) 2007 Atos Origin 
+**  Copyright (C) 2007-2009 Atos Origin 
 **
 **  Author: Raphael Semeteys <address@hidden>
 **
@@ -27,21 +27,133 @@
 session_start();
 
 include("config.php");
+include("lang.php");
 include("libs/QSOSDocument.php");
 include('libs/pclzip.lib.php');
 
-//XML file to be exported
-$file = $_GET['f'];
+//Ids of XML files to be exported
+$ids = $_REQUEST['id'];
 //Name of the ODS file
-$odsfile = basename($file, ".qsos").".ods";
+$odsfile = "QSOS.ods";
 
 //Global variables
 $numrow;
 $graph_formula_module;
+$output;
+$input;
+$document;
+$table0;
+$table1;
+
+function getTableName($id) {
+  $output = basename($id, ".qsos");
+  //OOo 2.x doesn't accept . in tab names
+  return str_replace(".", "-", $output);
+}
 
-function showtree($output, $input, $tree, $table0, $table1, $depth) {
-       global $numrow;;
-       global $graph_formula_module;
+function createCell($style, $type, $value, $formula=false) {
+  global $output;
+
+  //HACK: & caracter causes an error because of HTML entities
+  $value = str_replace("&", "+", $value);
+
+  $cell = $output->createElement('table:table-cell');
+  if ($style != "") $cell->setAttribute("table:style-name",$style);
+  if (!($formula)) {
+    $cell->setAttribute("office:value-type",$type);
+    $cell->setAttribute("office:value",$value);
+    $text = $output->createElement('text:p',$value);
+    $cell->appendChild($text);
+  } else {
+    $cell->setAttribute("table:formula",$formula);
+  }
+  return $cell;
+}
+
+function getFormula($cells) {
+  $quotient = "";
+  $dividend = "";
+  for ($i=0; $i < count($cells); $i++) {
+    if ($i != 0) {
+      $quotient .= "+";
+      $dividend .= "+";
+    }
+    $quotient .= "[.C".$cells[$i]."]*[.D".$cells[$i]."]";
+    $dividend .= "[.D".$cells[$i]."]";
+  }
+  return "oooc:=IF(($dividend)=0;0;($quotient)/($dividend))";
+}
+
+function createTreeCriteria($tree, $table0, $depth) {
+  global $output;
+  global $input;
+  global $numrow;
+  $children = array();
+
+  $new_depth = $depth + 1;
+  $offset = $new_depth*10;
+  $idF = 0;
+
+  switch ($depth) {
+    case '0':
+      //Section
+      $style_row = 'ro1';
+      $style_title = 'ce2';
+      break;
+    case '1':
+      //Level 1 criterion
+      $style_row = 'ro1';
+      $style_title = 'ce3';
+      break;
+    case '2':
+      //Level 2 criterion
+      $style_row = 'ro1';
+      $style_title = '';
+      break;
+    default:
+      //Level N criterion,  N > 2
+      $style_row = 'ro1';
+      $style_title = 'ce8';
+      break;
+  }
+
+  foreach($tree as $element) {
+    $name = $element->name;
+    $title = $element->title;
+    $subtree = $element->children;
+    $comment = $input->getgeneric($name, "comment");
+
+    $numrow++;
+    array_push($children, $numrow);
+
+    //New row for first sheet (table0, criteria)
+    $row = $output->createElement('table:table-row');
+    $row->setAttribute("table:style-name",$style_row);
+    //Criterion
+    $row->appendChild(createCell($style_title, "string", $title));
+
+    //Desc0, 1 and 2
+    $row->appendChild(createCell($style_title, "string", 
$input->getgeneric($name, "desc0")));
+    $row->appendChild(createCell($style_title, "string", 
$input->getgeneric($name, "desc1")));
+    $row->appendChild(createCell($style_title, "string", 
$input->getgeneric($name, "desc2")));
+    $table0->appendChild($row);
+
+    //Recursivity
+    if ($subtree) {
+      //Subcriteria regrouping
+      $group0 = $output->createElement('table:table-row-group');
+      $return = createTreeCriteria($subtree, $group0, $new_depth);
+      $table0->appendChild($group0);
+    }
+  }
+  return $children;
+}
+
+function createTreeSynthesis($tree, $table0, $depth) {
+  global $output;
+  global $input;
+  global $numrow;
+  global $ids;
        $children = array();
 
        $new_depth = $depth + 1;
@@ -83,9 +195,6 @@
                        break;
        }
 
-       $graph_formula_module1 = '';
-       $graph_formula_module2 = '';
-
        foreach($tree as $element) {
                $name = $element->name;
                $title = $element->title;
@@ -95,526 +204,321 @@
                $numrow++;
                array_push($children, $numrow);
 
-               if ($depth == '0') {
-                       $graph_formula_module1 .= "\$Evaluation.\$A\$$numrow;";
-                       $graph_formula_module2 .= "\$Evaluation.\$C\$$numrow;";
-               }
-
-               //New row for first sheet
                $row = $output->createElement('table:table-row');
                $row->setAttribute("table:style-name",$style_row);
                //Criterion
-               $cell = $output->createElement('table:table-cell');
-               if ($style_title != "") 
$cell->setAttribute("table:style-name",$style_title);
-               $cell->setAttribute("office:value-type","string");
-               $text = $output->createElement('text:p',$title);
-               $cell->appendChild($text);
-               $row->appendChild($cell);
-               //Desc0
-               $cell = $output->createElement('table:table-cell');
-               if ($style_title != "") 
$cell->setAttribute("table:style-name",$style_title);
-               $cell->setAttribute("office:value-type","string");
-               $text = 
$output->createElement('text:p',$input->getgeneric($name, "desc0"));
-               $cell->appendChild($text);
-               $row->appendChild($cell);
-               //Desc1
-               $score = $output->createElement('table:table-cell');
-               if ($style_title != "") 
$score->setAttribute("table:style-name",$style_title);
-               $score->setAttribute("office:value-type","string");
-               $text = 
$output->createElement('text:p',$input->getgeneric($name, "desc1"));
-               $score->appendChild($text);
-               $row->appendChild($score);
-               //Desc2
-               $cell = $output->createElement('table:table-cell');
-               if ($style_title != "") 
$cell->setAttribute("table:style-name",$style_title);
-               $cell->setAttribute("office:value-type","string");
-               $text = 
$output->createElement('text:p',$input->getgeneric($name, "desc2"));
-               $cell->appendChild($text);
-               $row->appendChild($cell);
-
+    $row->appendChild(createCell($style_title, "string", $title));
                $table0->appendChild($row);
+    //Weight
+    $weight = isset($_SESSION[$name])?$_SESSION[$name]:1;
+    $row->appendChild(createCell($style_weight, "float", $weight));
+    //Scores
+    foreach($ids as $id) {
+      $name = getTableName($id);
+      $num = $numrow + 6;
+      $row->appendChild(createCell($style_score, "string", null, 
"oooc:=['$name'.C$num]"));
+      $table0->appendChild($row);
+    }
+
+    //Recursivity
+    if ($subtree) {
+      //Subcriteria regrouping
+      $group0 = $output->createElement('table:table-row-group');
+      $return = createTreeSynthesis($subtree, $group0, $new_depth);
+      $table0->appendChild($group0);
+    }
+  }
+  return $children;
+}
+
+function createTreeEval($tree, $table1, $depth) {
+  global $output;
+  global $input;
+  global $numrow;
+  global $msg;
+  $children = array();
+
+  $new_depth = $depth + 1;
+  $offset = $new_depth*10;
+  $idF = 0;
+
+  switch ($depth) {
+    case '0':
+      //Section
+      $style_row = 'ro1';
+      $style_title = 'ce2';
+      $style_comment = 'ce2';
+      $style_score = 'ce5';
+      $style_weight = 'ce5';
+      break;
+    case '1':
+      //Level 1 criterion
+      $style_row = 'ro1';
+      $style_title = 'ce3';
+      $style_comment = 'ce3';
+      $style_score = 'ce6';
+      $style_weight = 'ce6';
+      break;
+    case '2':
+      //Level 2 criterion
+      $style_row = 'ro1';
+      $style_title = '';
+      $style_comment = '';
+      $style_score = '';
+      $style_weight = '';
+      break;
+    default:
+      //Level N criterion,  N > 2
+      $style_row = 'ro1';
+      $style_title = 'ce8';
+      $style_comment = 'ce8';
+      $style_score = 'ce9';
+      $style_weight = 'ce9';
+      break;
+  }
+
+  foreach($tree as $element) {
+    $name = $element->name;
+    $title = $element->title;
+    $subtree = $element->children;
+    $comment = $input->getgeneric($name, "comment");
 
-               //New row for second sheet
+    $numrow++;
+    array_push($children, $numrow);
+
+    //New row for second sheet (table1, evaluation)
                $row = $output->createElement('table:table-row');
                $row->setAttribute("table:style-name",$style_row);
                //Criterion
-               $cell = $output->createElement('table:table-cell');
-               if ($style_title != "") 
$cell->setAttribute("table:style-name",$style_title);
-               $cell->setAttribute("office:value-type","string");
-               $text = $output->createElement('text:p',$title);
-               $cell->appendChild($text);
-               $row->appendChild($cell);
+    $row->appendChild(createCell($style_title, "string", $title));
                //Comment
-               $cell = $output->createElement('table:table-cell');
-               if ($style_comment != "") 
$cell->setAttribute("table:style-name",$style_comment);
-               $cell->setAttribute("office:value-type","string");
-               $text = $output->createElement('text:p',$comment);
-               $cell->appendChild($text);
-               $row->appendChild($cell);
+    $row->appendChild(createCell($style_comment, "string", $comment));
                //Score
-               $score = $output->createElement('table:table-cell');
-               if ($style_score != "") 
$score->setAttribute("table:style-name",$style_score);
-               $score->setAttribute("office:value-type","float");
-               $score->setAttribute("office:value",$element->score);
-               $text = $output->createElement('text:p',$element->score);
-               $score->appendChild($text);
+    $score = createCell($style_score, "float", $element->score);
                $row->appendChild($score);
                //Weight
-               $cell = $output->createElement('table:table-cell');
-               if ($style_weight != "") 
$cell->setAttribute("table:style-name",$style_weight);
-               $cell->setAttribute("office:value-type","float");
-               $cell->setAttribute("office:value",$_SESSION[$name]);
-               $text = $output->createElement('text:p',$_SESSION[$name]);
-               $cell->appendChild($text);
-               $row->appendChild($cell);
-
+    $num = $numrow - 6;
+    $row->appendChild(createCell($style_weight, "float", null, 
"oooc:=['".$msg['ods_synthesis']."'.B$num]"));
                $table1->appendChild($row);
 
+    //Recursivity
                if ($subtree) {
                        //Subcriteria regrouping
-                       $group0 = 
$output->createElement('table:table-row-group');
                        $group = 
$output->createElement('table:table-row-group');
-                       $return = showtree($output, $input, $subtree, $group0, 
$group, $new_depth);
+      $return = createTreeEval($subtree, $group, $new_depth);
                        //Set score formula
                        
$score->setAttribute("table:formula",getFormula($return));
-                       $table0->appendChild($group0);
                        $table1->appendChild($group);
                }
        }
-
-       if ($depth == 0) {
-               $graph_formula_module = 
$graph_formula_module1.$graph_formula_module2;
-               return $children;
-       } else {
                return $children;
-       }
 }
 
-function getFormula($cells) {
-       $quotient = "";
-       $dividend = "";
-       for ($i=0; $i < count($cells); $i++) {
-               if ($i != 0) {
-                       $quotient .= "+";
-                       $dividend .= "+";
-               }
-               $quotient .= "[.C".$cells[$i]."]*[.D".$cells[$i]."]";
-               $dividend .= "[.D".$cells[$i]."]";
-       }
-       return "oooc:=($quotient)/($dividend)";
+function createColumn($style,$styledefault) {
+  global $output;
+  $column = $output->createElement('table:table-column');
+  $column->setAttribute("table:style-name",$style);
+  $column->setAttribute("table:default-cell-style-name",$styledefault);
+  return $column;
 }
 
-function createODS($file) {
-       global $numrow;
-       global $odsfile;
-       global $graph_formula_module;
-       global $temp;
-       $input = new QSOSDocument("$file");
-       $output = new DOMDocument();
-       
-       //Document element
-       $document = $output->createElement('office:document-content');
-       
$document->setAttribute("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0");
-       
$document->setAttribute("xmlns:style","urn:oasis:names:tc:opendocument:xmlns:style:1.0");
-       
$document->setAttribute("xmlns:text","urn:oasis:names:tc:opendocument:xmlns:text:1.0");
-       
$document->setAttribute("xmlns:table","urn:oasis:names:tc:opendocument:xmlns:table:1.0");
-       
$document->setAttribute("xmlns:draw","urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
-       
$document->setAttribute("xmlns:fo","urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
-       $document->setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink";);
-       $document->setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/";);
-       
$document->setAttribute("xmlns:meta","urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
-       
$document->setAttribute("xmlns:number","urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0");
-       
$document->setAttribute("xmlns:svg","urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
-       
$document->setAttribute("xmlns:chart","urn:oasis:names:tc:opendocument:xmlns:chart:1.0");
-       
$document->setAttribute("xmlns:dr3d","urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0");
-       
$document->setAttribute("xmlns:math","http://www.w3.org/1998/Math/MathML";);
-       
$document->setAttribute("xmlns:form","urn:oasis:names:tc:opendocument:xmlns:form:1.0");
-       
$document->setAttribute("xmlns:script","urn:oasis:names:tc:opendocument:xmlns:script:1.0");
-       
$document->setAttribute("xmlns:ooo","http://openoffice.org/2004/office";);
-       
$document->setAttribute("xmlns:ooow","http://openoffice.org/2004/writer";);
-       $document->setAttribute("xmlns:oooc","http://openoffice.org/2004/calc";);
-       
$document->setAttribute("xmlns:dom","http://www.w3.org/2001/xml-events";);
-       $document->setAttribute("xmlns:xforms","http://www.w3.org/2002/xforms";);
-       $document->setAttribute("xmlns:xsd","http://www.w3.org/2001/XMLSchema";);
-       
$document->setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance";);
-       $document->setAttribute("office:version","1.0");
-       
-       $scripts = $output->createElement('office:scripts');
-       $listeners = $output->createElement('office:event-listeners');
-       $listener = $output->createElement('script:event-listener');
-       $listener->setAttribute("script:language","ooo:script");
-       $listener->setAttribute("script:event-name","dom:load");
-       
$listener->setAttribute("xlink:href","vnd.sun.star.script:Standard.Module1.Graph?language=Basic&location=document");
-       $listeners->appendChild($listener);
-       $scripts->appendChild($listeners);
-       $document->appendChild($scripts);
-       
-       //Font declaration
-       $fontfaces = $output->createElement('office:font-face-decls');
-       
-       $font = $output->createElement('style:font-face');
-       $font->setAttribute("style:name","Lucida Sans Unicode");
-       $font->setAttribute("svg:font-family","'Lucida Sans Unicode'");
-       $font->setAttribute("style:font-pitch","variable");
-       $fontfaces->appendChild($font);
-       
-       $font = $output->createElement('style:font-face');
-       $font->setAttribute("style:name","Tahoma");
-       $font->setAttribute("svg:font-family","Tahoma");
-       $font->setAttribute("style:font-pitch","variable");
-       $fontfaces->appendChild($font);
+function createSimpleRow() {
+  global $output;
+  $row = $output->createElement('table:table-row');
+  $row->setAttribute("table:style-name","ro1");
+  $row->setAttribute("table:number-rows-repeated","2");
+  $cell = $output->createElement('table:table-cell');
+  $cell->setAttribute("table:style-name","Default");
+  $cell->setAttribute("table:number-columns-repeated","4");
+  $row->appendChild($cell);
+  return $row;
+}
        
-       $font = $output->createElement('style:font-face');
-       $font->setAttribute("style:name","Arial");
-       $font->setAttribute("svg:font-family","Arial");
-       $font->setAttribute("style:font-pitch","variable");
-       $fontfaces->appendChild($font);
+function createHeaderRow($title,$value) {
+  global $output;
+  $row = $output->createElement('table:table-row');
+  $row->setAttribute("table:style-name","ro1");
+  $cell = $output->createElement('table:table-cell');
+  $cell->setAttribute("table:style-name","ce2");
+  $cell->setAttribute("office:value-type","string");
+  $text = $output->createElement('text:p',$title);
+  $cell->appendChild($text);
+  $row->appendChild($cell);
+  $cell = $output->createElement('table:table-cell');
+  $cell->setAttribute("table:style-name","ce8");
+  $cell->setAttribute("office:value-type","string");
+  $text = $output->createElement('text:p',$value);
+  $cell->appendChild($text);
+  $row->appendChild($cell);
+  $cell = $output->createElement('table:table-cell');
+  $cell->setAttribute("table:style-name","ce10");
+  $cell->setAttribute("table:number-columns-repeated","2");
+  $row->appendChild($cell);
+  return $row;
+}
        
+function createFont($fontFamily) {
+  global $output;
        $font = $output->createElement('style:font-face');
-       $font->setAttribute("style:name","Arial");
-       $font->setAttribute("svg:font-family","Arial");
-       $font->setAttribute("style:font-family-generic","swiss");
+  $font->setAttribute("style:name",$fontFamily);
+  $font->setAttribute("svg:font-family","'$fontFamily'");
        $font->setAttribute("style:font-pitch","variable");
-       $fontfaces->appendChild($font);
-       
-       $document->appendChild($fontfaces);
-       
-       //Styles
-       $styles = $output->createElement('office:automatic-styles');
-
-       //co0
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","co0");
-       $style->setAttribute("style:family","table-column");
-       $substyle = $output->createElement('style:table-column-properties');
-       $substyle->setAttribute("fo:break-before","auto");
-       $substyle->setAttribute("style:column-width","4.717cm");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-
-       //co1
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","co1");
-       $style->setAttribute("style:family","table-column");
-       $substyle = $output->createElement('style:table-column-properties');
-       $substyle->setAttribute("fo:break-before","auto");
-       $substyle->setAttribute("style:column-width","5.117cm");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //co2
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","co2");
-       $style->setAttribute("style:family","table-column");
-       $substyle = $output->createElement('style:table-column-properties');
-       $substyle->setAttribute("fo:break-before","auto");
-       $substyle->setAttribute("style:column-width","10.931cm");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //co3
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","co3");
-       $style->setAttribute("style:family","table-column");
-       $substyle = $output->createElement('style:table-column-properties');
-       $substyle->setAttribute("fo:break-before","auto");
-       $substyle->setAttribute("style:column-width","1.452cm");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
+  return $font;
+}
        
-       //co4
+function createColumnStyle($name,$width) {
+  global $output;
        $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","co4");
+  $style->setAttribute("style:name",$name);
        $style->setAttribute("style:family","table-column");
        $substyle = $output->createElement('style:table-column-properties');
        $substyle->setAttribute("fo:break-before","auto");
-       $substyle->setAttribute("style:column-width","1.452cm");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //ro1
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ro1");
-       $style->setAttribute("style:family","table-row");
-       $substyle = $output->createElement('style:table-row-properties');
-       $substyle->setAttribute("style:row-height","0.453cm");
-       $substyle->setAttribute("fo:break-before","auto");
-       $substyle->setAttribute("style:use-optimal-row-height","true");
+  $substyle->setAttribute("style:column-width",$width);
        $style->appendChild($substyle);
-       $styles->appendChild($style);
+  return $style;
+}
        
-       //ro2
+function createRowStyle($name,$height) {
+  global $output;
        $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ro2");
+  $style->setAttribute("style:name",$name);
        $style->setAttribute("style:family","table-row");
        $substyle = $output->createElement('style:table-row-properties');
-       $substyle->setAttribute("style:row-height","0.453cm");
+  $substyle->setAttribute("style:row-height",$height);
        $substyle->setAttribute("fo:break-before","auto");
        $substyle->setAttribute("style:use-optimal-row-height","true");
        $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //ta1: basic table
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ta1");
-       $style->setAttribute("style:family","table");
-       $style->setAttribute("style:master-page-name","Default");
-       $substyle = $output->createElement('style:table-properties');
-       $substyle->setAttribute("table:display","true");
-       $substyle->setAttribute("style:writing-mode","lr-tb");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //ce1
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce1");
-       $style->setAttribute("style:family","table-cell");
-       $style->setAttribute("style:parent-style-name","Default");
-       $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("fo:wrap-option","wrap");
-       $substyle->setAttribute("style:vertical-align","middle");
-       $style->appendChild($substyle);
-       $substyle = $output->createElement('style:text-properties');
-       $substyle->setAttribute("fo:color","#ffffff");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //ce2
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce2");
-       $style->setAttribute("style:family","table-cell");
-       $style->setAttribute("style:parent-style-name","Default");
-       $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("fo:background-color","#2323dc");
-       $substyle->setAttribute("fo:wrap-option","wrap");
-       $substyle->setAttribute("style:vertical-align","middle");
-       $style->appendChild($substyle);
-       $substyle = $output->createElement('style:text-properties');
-       $substyle->setAttribute("fo:color","#ffffff");
-       $substyle->setAttribute("fo:font-weight","bold");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //ce3
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce3");
-       $style->setAttribute("style:family","table-cell");
-       $style->setAttribute("style:parent-style-name","Default");
-       $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("fo:wrap-option","wrap");
-       $substyle->setAttribute("style:vertical-align","middle");
-       $substyle->setAttribute("fo:background-color","#99ccff");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //ce4
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce4");
-       $style->setAttribute("style:family","table-cell");
-       $style->setAttribute("style:parent-style-name","Default");
-       $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("fo:wrap-option","wrap");
-       $substyle->setAttribute("style:vertical-align","middle");
-       $substyle->setAttribute("fo:background-color","#ccffff");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
+  return $style;
+}
        
-       //ce5
+function createCellStyle($name, $wrap, $backgroundColor, $textAlignSource, 
$repeatContent, $verticalALign, $textAlign, $marginLeft, $fontColor, 
$fontWeight, $border) {
+  global $output;
        $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce5");
+  $style->setAttribute("style:name",$name);
        $style->setAttribute("style:family","table-cell");
        $style->setAttribute("style:parent-style-name","Default");
-       $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("fo:background-color","#2323dc");
-       $substyle->setAttribute("style:text-align-source","fix");
-       $substyle->setAttribute("style:repeat-content","false");
-       $substyle->setAttribute("style:vertical-align","middle");
-       $style->appendChild($substyle);
-       $substyle = $output->createElement('style:paragraph-properties');
-       $substyle->setAttribute("fo:text-align","center");
-       $substyle->setAttribute("fo:margin-left","0cm");
-       $style->appendChild($substyle);
-       $substyle = $output->createElement('style:text-properties');
-       $substyle->setAttribute("fo:color","#ffffff");
-       $substyle->setAttribute("fo:font-weight","bold");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
        
-       //ce6
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce6");
-       $style->setAttribute("style:family","table-cell");
-       $style->setAttribute("style:parent-style-name","Default");
+  if (isset($wrap) || isset($backgroundColor) || isset($textAlignSource) || 
isset($repeatContent) || isset($verticalALign) || isset($border)) {
        $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("fo:background-color","#99ccff");
-       $substyle->setAttribute("style:text-align-source","fix");
-       $substyle->setAttribute("style:repeat-content","false");
-       $substyle->setAttribute("style:vertical-align","middle");
-       $style->appendChild($substyle);
-       $substyle = $output->createElement('style:paragraph-properties');
-       $substyle->setAttribute("fo:text-align","center");
-       $substyle->setAttribute("fo:margin-left","0cm");
+    if (isset($wrap)) $substyle->setAttribute("fo:wrap-option",$wrap);
+    if (isset($backgroundColor)) 
$substyle->setAttribute("fo:background-color",$backgroundColor);
+    if (isset($border)) $substyle->setAttribute("fo:border","0.002cm solid 
#000000");
+    if (isset($textAlignSource)) 
$substyle->setAttribute("style:text-align-source",$textAlignSource);
+    if (isset($repeatContent)) 
$substyle->setAttribute("style:repeat-content",$repeatContent);
+    if (isset($verticalALign)) 
$substyle->setAttribute("style:vertical-align",$verticalALign);
        $style->appendChild($substyle);
-       $styles->appendChild($style);
+  }
        
-       //ce7
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce7");
-       $style->setAttribute("style:family","table-cell");
-       $style->setAttribute("style:parent-style-name","Default");
-       $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("fo:background-color","#ccffff");
-       $substyle->setAttribute("style:text-align-source","fix");
-       $substyle->setAttribute("style:repeat-content","false");
-       $substyle->setAttribute("style:vertical-align","middle");
-       $style->appendChild($substyle);
+  if (isset($textAlign) || isset($marginLeft)) {
        $substyle = $output->createElement('style:paragraph-properties');
-       $substyle->setAttribute("fo:text-align","center");
-       $substyle->setAttribute("fo:margin-left","0cm");
-       $style->appendChild($substyle);
-       $styles->appendChild($style);
-       
-       //ce8
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce8");
-       $style->setAttribute("style:family","table-cell");
-       $style->setAttribute("style:parent-style-name","Default");
-       $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("style:text-align-source","fix");
-       $substyle->setAttribute("style:repeat-content","false");
-       $substyle->setAttribute("fo:wrap-option","wrap");
-       $substyle->setAttribute("style:vertical-align","middle");
+    if (isset($textAlign)) $substyle->setAttribute("fo:text-align",$textAlign);
+    if (isset($marginLeft)) 
$substyle->setAttribute("fo:margin-left",$marginLeft);
        $style->appendChild($substyle);
-       $styles->appendChild($style);
+  }
        
-       //ce9
-       $style = $output->createElement('style:style');
-       $style->setAttribute("style:name","ce9");
-       $style->setAttribute("style:family","table-cell");
-       $style->setAttribute("style:parent-style-name","Default");
-       $substyle = $output->createElement('style:table-cell-properties');
-       $substyle->setAttribute("style:text-align-source","fix");
-       $substyle->setAttribute("style:repeat-content","false");
-       $substyle->setAttribute("style:vertical-align","middle");
-       $style->appendChild($substyle);
-       $substyle = $output->createElement('style:paragraph-properties');
-       $substyle->setAttribute("fo:text-align","center");
-       $substyle->setAttribute("fo:margin-left","0cm");
+  if (isset($fontColor) || isset($fontWeight)) {
+    $substyle = $output->createElement('style:text-properties');
+    if (isset($fontColor)) $substyle->setAttribute("fo:color",$fontColor);
+    if (isset($fontWeight)) 
$substyle->setAttribute("fo:font-weight",$fontWeight);
        $style->appendChild($substyle);
-       $styles->appendChild($style);
+  }
        
-       $document->appendChild($styles);
+  return $style;
+}
        
-       //Document body
-       $body = $output->createElement('office:body');
-       $spreadsheet = $output->createElement('office:spreadsheet');
+function initSynthesisSheet() {
+  global $output;
+  global $input;
+  global $table0;
+  global $msg;
+  global $ids;
 
-       //First sheet (Criteria)
        $table0 = $output->createElement('table:table');
-       $table0->setAttribute("table:name","Criteria");
+  $table0->setAttribute("table:name",$msg['ods_synthesis']);
        $table0->setAttribute("table:style-name","ta1");
        $table0->setAttribute("table:print","false");
 
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co0");
-       $column->setAttribute("table:default-cell-style-name","ce4");
-       $table0->appendChild($column);
-       
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co0");
-       $column->setAttribute("table:default-cell-style-name","ce4");
-       $table0->appendChild($column);
+  $table0->appendChild(createColumn("co0","ce4"));
+  $table0->appendChild(createColumn("co4","ce7"));
 
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co0");
-       $column->setAttribute("table:default-cell-style-name","ce4");
-       $table0->appendChild($column);
+  foreach($ids as $id) {
+    $table0->appendChild(createColumn("co0","ce7"));
+  }
 
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co0");
-       $column->setAttribute("table:default-cell-style-name","ce4");
-       $table0->appendChild($column);
-
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $row->setAttribute("table:number-rows-repeated","2");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","Default");
-       $cell->setAttribute("table:number-columns-repeated","4");
-       $row->appendChild($cell);
-       $table0->appendChild($row);
+  $table0->appendChild(createSimpleRow());
 
        //Software family
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Software family");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = 
$output->createElement('text:p',$input->getkey("qsosappfamily"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table0->appendChild($row);
+  
$table0->appendChild(createHeaderRow($msg['ods_softwarefamily'],$input->getkey("qsosappfamily")));
 
        //QSOS version
+  
$table0->appendChild(createHeaderRow($msg['ods_qsosversion'],$input->getkey("qsosformat")));
+
+  //Template version
+  
$table0->appendChild(createHeaderRow($msg['ods_templateversion'],$input->getkey("qsosspecificformat")));
+
+  $table0->appendChild(createSimpleRow());
+
+  //Criteria
        $row = $output->createElement('table:table-row');
        $row->setAttribute("table:style-name","ro1");
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce2");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"QSOS version");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$input->getkey("qsosformat"));
+  $text = $output->createElement('text:p',$msg['ods_criterion']);
        $cell->appendChild($text);
        $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table0->appendChild($row);
 
-       //Template version
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
+  //Weight
        $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
+  $cell->setAttribute("table:style-name","ce5");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Template version");
+  $text = $output->createElement('text:p',$msg['ods_weight']);
        $cell->appendChild($text);
        $row->appendChild($cell);
+  
+  //Evaluations
+  foreach($ids as $id) {
+    $name = getTableName($id);
        $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
+    $cell->setAttribute("table:style-name","ce5");
        $cell->setAttribute("office:value-type","string");
-       $text = 
$output->createElement('text:p',$input->getkey("qsosspecificformat"));
+    $text = $output->createElement('text:p',$name);
        $cell->appendChild($text);
        $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table0->appendChild($row);
+  }
 
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $row->setAttribute("table:number-rows-repeated","2");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","Default");
-       $cell->setAttribute("table:number-columns-repeated","4");
-       $row->appendChild($cell);
        $table0->appendChild($row);
+}
+
+function initCriteriaSheet() {
+  global $output;
+  global $input;
+  global $table0;
+  global $msg;
+
+  //First sheet (Criteria)
+  $table0 = $output->createElement('table:table');
+  $table0->setAttribute("table:name",$msg['ods_criteria']);
+  $table0->setAttribute("table:style-name","ta1");
+  $table0->setAttribute("table:print","false");
+
+  $table0->appendChild(createColumn("co0","ce4"));
+  $table0->appendChild(createColumn("co0","ce4"));
+  $table0->appendChild(createColumn("co0","ce4"));
+  $table0->appendChild(createColumn("co0","ce4"));
+
+  $table0->appendChild(createSimpleRow());
+
+  //Software family
+  
$table0->appendChild(createHeaderRow($msg['ods_softwarefamily'],$input->getkey("qsosappfamily")));
+
+  //QSOS version
+  
$table0->appendChild(createHeaderRow($msg['ods_qsosversion'],$input->getkey("qsosformat")));
+
+  //Template version
+  
$table0->appendChild(createHeaderRow($msg['ods_templateversion'],$input->getkey("qsosspecificformat")));
+
+  $table0->appendChild(createSimpleRow());
 
        //Criteria
        $row = $output->createElement('table:table-row');
@@ -622,190 +526,67 @@
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce2");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p','Criterion');
+  $text = $output->createElement('text:p',$msg['ods_criterion']);
        $cell->appendChild($text);
        $row->appendChild($cell);
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce2");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p','Score 0');
+  $text = $output->createElement('text:p',$msg['ods_score0']);
        $cell->appendChild($text);
        $row->appendChild($cell);
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce2");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p','Score 1');
+  $text = $output->createElement('text:p',$msg['ods_score1']);
        $cell->appendChild($text);
        $row->appendChild($cell);
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce2");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p','Score 2');
+  $text = $output->createElement('text:p',$msg['ods_score2']);
        $cell->appendChild($text);
        $row->appendChild($cell);
        $table0->appendChild($row);
+}
+
+function initEvaluationSheet($title) {
+  global $output;
+  global $input;
+  global $table1;
+  global $msg;
 
        //Second sheet (Evaluation)
        $table1 = $output->createElement('table:table');
-       $table1->setAttribute("table:name","Evaluation");
+  $table1->setAttribute("table:name",$title);
        $table1->setAttribute("table:style-name","ta1");
        $table1->setAttribute("table:print","false");
        
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co1");
-       $column->setAttribute("table:default-cell-style-name","ce4");
-       $table1->appendChild($column);
-       
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co2");
-       $column->setAttribute("table:default-cell-style-name","ce4");
-       $table1->appendChild($column);
-       
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co3");
-       $column->setAttribute("table:default-cell-style-name","ce7");
-       $table1->appendChild($column);
-       
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co4");
-       $column->setAttribute("table:default-cell-style-name","ce7");
-       $table1->appendChild($column);
+  $table1->appendChild(createColumn("co1","ce4"));
+  $table1->appendChild(createColumn("co2","ce4"));
+  $table1->appendChild(createColumn("co3","ce7"));
+  $table1->appendChild(createColumn("co4","ce7"));
        
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $row->setAttribute("table:number-rows-repeated","2");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","Default");
-       $cell->setAttribute("table:number-columns-repeated","4");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  $table1->appendChild(createSimpleRow());
 
        //Header
        //Application
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Application");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$input->getkey("appname"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  
$table1->appendChild(createHeaderRow($msg['ods_application'],$input->getkey("appname")));
 
        //Release
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Release");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$input->getkey("release"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  
$table1->appendChild(createHeaderRow($msg['ods_release'],$input->getkey("release")));
 
        //Software family
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Software family");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = 
$output->createElement('text:p',$input->getkey("qsosappfamily"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  
$table1->appendChild(createHeaderRow($msg['ods_softwarefamily'],$input->getkey("qsosappfamily")));
 
        //License
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"License");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$input->getkey("licensedesc"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  
$table1->appendChild(createHeaderRow($msg['ods_license'],$input->getkey("licensedesc")));
 
        //Url
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Website");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$input->getkey("url"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  
$table1->appendChild(createHeaderRow($msg['ods_website'],$input->getkey("url")));
 
        //Description
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Description");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$input->getkey("desc"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  
$table1->appendChild(createHeaderRow($msg['ods_description'],$input->getkey("desc")));
 
        //Authors
        $authors = $input->getauthors();
@@ -816,76 +597,15 @@
                }
                $list .= $authors[$i]->name." (".$authors[$i]->email.")";
        }
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Authors");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$list);
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  $table1->appendChild(createHeaderRow($msg['ods_authors'],$list));
 
        //Creation date
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Creation date");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$input->getkey("creation"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  
$table1->appendChild(createHeaderRow($msg['ods_creationdate'],$input->getkey("creation")));
 
        //Validation date
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce2");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',"Validation date");
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p',$input->getkey("validation"));
-       $cell->appendChild($text);
-       $row->appendChild($cell);
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","ce8");
-       $cell->setAttribute("table:number-columns-repeated","2");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  
$table1->appendChild(createHeaderRow($msg['ods_validationdate'],$input->getkey("validation")));
 
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $row->setAttribute("table:number-rows-repeated","2");
-       $cell = $output->createElement('table:table-cell');
-       $cell->setAttribute("table:style-name","Default");
-       $cell->setAttribute("table:number-columns-repeated","4");
-       $row->appendChild($cell);
-       $table1->appendChild($row);
+  $table1->appendChild(createSimpleRow());
 
        //Criteria
        $row = $output->createElement('table:table-row');
@@ -893,129 +613,170 @@
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce2");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p','Criterion');
+  $text = $output->createElement('text:p',$msg['ods_criterion']);
        $cell->appendChild($text);
        $row->appendChild($cell);
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce2");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p','Comment');
+  $text = $output->createElement('text:p',$msg['ods_comment']);
        $cell->appendChild($text);
        $row->appendChild($cell);
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce5");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p','Score');
+  $text = $output->createElement('text:p',$msg['ods_score']);
        $cell->appendChild($text);
        $row->appendChild($cell);
        $cell = $output->createElement('table:table-cell');
        $cell->setAttribute("table:style-name","ce5");
        $cell->setAttribute("office:value-type","string");
-       $text = $output->createElement('text:p','Weight');
+  $text = $output->createElement('text:p',$msg['ods_weight']);
        $cell->appendChild($text);
        $row->appendChild($cell);
        $table1->appendChild($row);
+}
+
+function initDocument() {
+  global $output;
+
+  //MAIN DOCUMENT ELEMENT
+  $document = $output->createElement('office:document-content');
+  
$document->setAttribute("xmlns:office","urn:oasis:names:tc:opendocument:xmlns:office:1.0");
+  
$document->setAttribute("xmlns:style","urn:oasis:names:tc:opendocument:xmlns:style:1.0");
+  
$document->setAttribute("xmlns:text","urn:oasis:names:tc:opendocument:xmlns:text:1.0");
+  
$document->setAttribute("xmlns:table","urn:oasis:names:tc:opendocument:xmlns:table:1.0");
+  
$document->setAttribute("xmlns:draw","urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
+  
$document->setAttribute("xmlns:fo","urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
+  $document->setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink";);
+  $document->setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/";);
+  
$document->setAttribute("xmlns:meta","urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
+  
$document->setAttribute("xmlns:number","urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0");
+  
$document->setAttribute("xmlns:svg","urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
+  
$document->setAttribute("xmlns:chart","urn:oasis:names:tc:opendocument:xmlns:chart:1.0");
+  
$document->setAttribute("xmlns:dr3d","urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0");
+  $document->setAttribute("xmlns:math","http://www.w3.org/1998/Math/MathML";);
+  
$document->setAttribute("xmlns:form","urn:oasis:names:tc:opendocument:xmlns:form:1.0");
+  
$document->setAttribute("xmlns:script","urn:oasis:names:tc:opendocument:xmlns:script:1.0");
+  $document->setAttribute("xmlns:ooo","http://openoffice.org/2004/office";);
+  $document->setAttribute("xmlns:ooow","http://openoffice.org/2004/writer";);
+  $document->setAttribute("xmlns:oooc","http://openoffice.org/2004/calc";);
+  $document->setAttribute("xmlns:dom","http://www.w3.org/2001/xml-events";);
+  $document->setAttribute("xmlns:xforms","http://www.w3.org/2002/xforms";);
+  $document->setAttribute("xmlns:xsd","http://www.w3.org/2001/XMLSchema";);
+  
$document->setAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance";);
+  $document->setAttribute("office:version","1.0");
        
-       //Init row counter
-       $numrow = 14;
+  //FONT DECLARATIONS
+  $fontfaces = $output->createElement('office:font-face-decls');
+  $fontfaces->appendChild(createFont("Lucida Sans Unicode"));
+  $fontfaces->appendChild(createFont("Tahoma"));
+  $fontfaces->appendChild(createFont("Arial"));
+  $document->appendChild($fontfaces);
        
-       //Init loop
-       showtree($output, $input, $input->getTree(), $table0, $table1, 0);
+  //STYLE DECLARATIONS
+  $styles = $output->createElement('office:automatic-styles');
+  //Column styles
+  $styles->appendChild(createColumnStyle("co0","4.717cm"));
+  $styles->appendChild(createColumnStyle("co1","5.117cm"));
+  $styles->appendChild(createColumnStyle("co2","10.931cm"));
+  $styles->appendChild(createColumnStyle("co3","1.452cm"));
+  $styles->appendChild(createColumnStyle("co4","1.452cm"));
+  //Row styles
+  $styles->appendChild(createRowStyle("ro1","0.453cm"));
+  $styles->appendChild(createRowStyle("ro2","0.453cm"));
+  //ta1: basic table
+  $style = $output->createElement('style:style');
+  $style->setAttribute("style:name","ta1");
+  $style->setAttribute("style:family","table");
+  $style->setAttribute("style:master-page-name","Default");
+  $substyle = $output->createElement('style:table-properties');
+  $substyle->setAttribute("table:display","true");
+  $substyle->setAttribute("style:writing-mode","lr-tb");
+  $style->appendChild($substyle);
+  $styles->appendChild($style);
+  //Cell styles
+  $styles->appendChild(createCellStyle("ce1", "wrap", null, null, null, 
"middle", null, null, "#ffffff", null, null));
+  $styles->appendChild(createCellStyle("ce2", "wrap", "#2323dc", null, null, 
"middle", null, null, "#ffffff", "bold", true));
+  $styles->appendChild(createCellStyle("ce3", "wrap", "#99ccff", null, null, 
"middle", null, null, null, null, true));
+  $styles->appendChild(createCellStyle("ce4","wrap","#ccffff", null, 
null,"middle", null, null, null, null, true));
+  $styles->appendChild(createCellStyle("ce5", null, "#2323dc", "fix", "false", 
"middle", "center", "0cm", "#ffffff", "bold", true));
+  $styles->appendChild(createCellStyle("ce6", null, "#99ccff", "fix", "false", 
"middle", "center", "0cm", null, null, true));
+  $styles->appendChild(createCellStyle("ce7", null, "#ccffff", "fix", "false", 
"middle", "center", "0cm", null, null, true));
+  $styles->appendChild(createCellStyle("ce8", "wrap", null, "fix", "false", 
"middle", null, null, null, null, true));
+  $styles->appendChild(createCellStyle("ce9", null, null, "fix", "false", 
"middle", "center", "0cm", null, null, true));
+  $styles->appendChild(createCellStyle("ce10", "wrap", null, "fix", "false", 
"middle", null, null, null, null, null));
+  $document->appendChild($styles);
        
-       //Third sheet (Graph)
-       $table2 = $output->createElement('table:table');
-       $table2->setAttribute("table:name","Graph");
-       $table2->setAttribute("table:style-name","ta1");
-       $table2->setAttribute("table:print","false");
-
-       $forms = $output->createElement('office:forms');
-       $forms->setAttribute("form:automatic-focus","false");
-       $forms->setAttribute("form:apply-design-mode","false");
-       $table2->appendChild($forms);
+  return $document;
+}
 
-       $column = $output->createElement('table:table-column');
-       $column->setAttribute("table:style-name","co2");
-       $column->setAttribute("table:default-cell-style-name","Default");
-       $table2->appendChild($column);
+function createODS() {
+  global $msg;
+  global $numrow;
+  global $odsfile;
+  global $graph_formula_module;
+  global $temp;
+  global $output;
+  global $input;
+  global $table0;
+  global $table1;
+  global $db_host;
+  global $db_user;
+  global $db_pwd;
+  global $db_db;
+  global $ids;
 
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $row->setAttribute("table:number-rows-repeated","2");
-       $cell = $output->createElement('table:table-cell');
-       $row->appendChild($cell);
-       $table2->appendChild($row);
+  $output = new DOMDocument();
 
-       $row = $output->createElement('table:table-row');
-       $row->setAttribute("table:style-name","ro1");
-       $cell = $output->createElement('table:table-cell');
-       $frame = $output->createElement('draw:frame');
-       $frame->setAttribute("table:end-cell-address","Graph.I32");
-       $frame->setAttribute("table:end-x","0.449cm");
-       $frame->setAttribute("table:end-y","0.104cm");
-       $frame->setAttribute("draw:z-index","0");
-       $frame->setAttribute("svg:width","17.669cm");
-       $frame->setAttribute("svg:height","12.024cm");
-       $frame->setAttribute("svg:x","0.844cm");
-       $frame->setAttribute("svg:y","0.412cm");
-       $object = $output->createElement('draw:object');
-       
$object->setAttribute("draw:notify-on-update-of-ranges","Criteria.A1:Criteria.A1");
-       $object->setAttribute("xlink:href","./Object 1");
-       $object->setAttribute("xlink:type","simple");
-       $object->setAttribute("xlink:show","embed");
-       $object->setAttribute("xlink:actuate","onLoad");
-       $frame->appendChild($object);
-       $image = $output->createElement('draw:image');
-       $image->setAttribute("xlink:href","./ObjectReplacements/Object 1");
-       $image->setAttribute("xlink:type","simple");
-       $image->setAttribute("xlink:show","embed");
-       $image->setAttribute("xlink:actuate","onLoad");
-       $frame->appendChild($image);
-       $cell->appendChild($frame);
-       $row->appendChild($cell);
-       $table2->appendChild($row);
+  //Init document
+  $document = initDocument();
+  $body = $output->createElement('office:body');
+  $spreadsheet = $output->createElement('office:spreadsheet');
+  
+  $IdDB = mysql_connect($db_host ,$db_user, $db_pwd);
+  mysql_select_db($db_db);
+  $query = "SELECT file FROM evaluations WHERE id = \"$ids[0]\"";
+  $IdReq = mysql_query($query, $IdDB);
+  $files = mysql_fetch_row($IdReq);
+  $file = $files[0];
 
+  //Synthesis Sheet
+  $input = new QSOSDocument("$file");
+  initSynthesisSheet();
+  $numrow = 8; //Reinit row counter
+  createTreeSynthesis($input->getTree(), $table0, 0);
+  $spreadsheet->appendChild($table0);
+  
+  //Criteria Sheet
+  initCriteriaSheet();
+  createTreeCriteria($input->getTree(), $table0, 0);
        $spreadsheet->appendChild($table0);
+
+  //Evaluation Sheets
+  foreach($ids as $id) {
+    $query = "SELECT file FROM evaluations WHERE id = \"$id\"";
+    $IdReq = mysql_query($query, $IdDB);
+    $files = mysql_fetch_row($IdReq);
+    $file = $files[0];
+  
+    $input = new QSOSDocument("$file");
+    initEvaluationSheet(getTableName($id));
+    $numrow = 14; //Reinit row counter
+    createTreeEval($input->getTree(), $table1, 0);
        $spreadsheet->appendChild($table1);
-       $spreadsheet->appendChild($table2);
+  }
+  
+  //Finalize Document (in memory)
        $body->appendChild($spreadsheet);
        $document->appendChild($body);
        $output->appendChild($document);
        
+  //Finalize Document (on disk)
        $tempdir = $temp.uniqid();
        mkdir($tempdir, 0755);
        $output->save("$tempdir/content.xml");
 
-       //Macro definition
-       $output = new DOMDocument();
-       $document = $output->createElement('script:module');
-       
$document->setAttribute("xmlns:script","http://openoffice.org/2000/script";);
-       $document->setAttribute("script:name","Module1");
-       $document->setAttribute("script:language","StarBasic");
-
-       $macro = "\n \nSub Main\n \n \nEnd Sub\n \n";
-       $macro .= "sub Graph\n \n";
-       $macro .= "dim document   as object\n";
-       $macro .= "dim dispatcher as object\n \n";      
-       $macro .= "document   = ThisComponent.CurrentController.Frame\n";
-       $macro .= "dispatcher = 
createUnoService(\"com.sun.star.frame.DispatchHelper\")\n \n";
-       $macro .= "dim args2(3) as new com.sun.star.beans.PropertyValue\n";
-       $macro .= "args2(0).Name = \"Name\"\n";
-       $macro .= "args2(0).Value = \"Object 1\"\n";
-       $macro .= "args2(1).Name = \"Range\"\n";
-       //$macro .= "args2(1).Value = 
\"\$Evaluation.\$A\$15;\$Evaluation.\$A\$74;\$Evaluation.\$A\$102;\$Evaluation.\$A\$108;\$Evaluation.\$C\$15;\$Evaluation.\$C\$74;\$Evaluation.\$C\$102;\$Evaluation.\$C\$108\"\n";
-       $macro .= "args2(1).Value = \"$graph_formula_module\"\n";
-       $macro .= "args2(2).Name = \"ColHeaders\"\n";
-       $macro .= "args2(2).Value = false\n";
-       $macro .= "args2(3).Name = \"RowHeaders\"\n";
-       $macro .= "args2(3).Value = true\n \n";
-       $macro .= 
"dispatcher.executeDispatch(document,\".uno:ChangeChartData\", \"\", 0, 
args2())\n \n";
-       $macro .= "end sub";
-
-       $document->appendChild($output->createTextNode($macro));
-       $output->appendChild($document);
-
-       $output->save("$tempdir/Module1.xml");
-       
        copy("template.zip", "ods/$odsfile");
        
        $oofile = new PclZip("ods/$odsfile");
@@ -1023,20 +784,14 @@
        if ($v_list == 0) {
                die("Error 01: ODS generation");
        }
-       $v_list = $oofile->add("$tempdir/Module1.xml", PCLZIP_OPT_REMOVE_PATH, 
$tempdir,
-                          PCLZIP_OPT_ADD_PATH, 'Basic/Standard');
-       if ($v_list == 0) {
-               die("Error 02: ODS generation");
-       }
 }
 
 //Uncomment to manage a cache
 //if (!(file_exists("ods/$odsfile"))) {
-       createODS($file);
+  createODS();
 //}
 
 //Return ODS file to the browser
 header("Location: ods/$odsfile");
 exit;
-
 ?>
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]