]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-7996 Add ods export support - row height implemented
authorskodak <skodak>
Fri, 22 Dec 2006 10:37:02 +0000 (10:37 +0000)
committerskodak <skodak>
Fri, 22 Dec 2006 10:37:02 +0000 (10:37 +0000)
lib/odslib.class.php

index e6c87e2c6542a3a11f7c79fd1f52d1f15798632a..2e2dc6d13d19d4ec761142ccdee4db84a29d1e0c 100644 (file)
@@ -249,7 +249,8 @@ class MoodleODSWorksheet {
      * @param integer $level  The optional outline level (0-7)
      */
     function set_row($row, $height, $format = 0, $hidden = false, $level = 0) {
-        //not defined yet
+        $this->rows[$row] = new object();
+        $this->rows[$row]->height = $height;
     }
 
     /* Sets the width (and other settings) of one column
@@ -427,6 +428,7 @@ function get_ods_content(&$worksheets) {
     // find out the size of worksheets and used formats
     $formats = array();
     $formatstyles = '';
+    $rowstyles = '';
     $colstyles = '';
 
     foreach($worksheets as $wsnum=>$ws) {
@@ -443,6 +445,19 @@ function get_ods_content(&$worksheets) {
             }
         }
 
+        foreach($ws->rows as $rnum=>$row) {
+            if ($rnum > $ws->maxr) {
+                $ws->maxr = $rnum;
+            }
+            //define all column styles
+            if (!empty($ws->rows[$rnum])) {
+                $rowstyles .= '
+  <style:style style:name="ws'.$wsnum.'ro'.$rnum.'" style:family="table-row">
+   <style:table-row-properties style:row-height="'.$row->height.'pt"/>
+  </style:style>';
+            }
+        }
+
         foreach($ws->columns as $cnum=>$col) {
             if ($cnum > $ws->maxc) {
                 $ws->maxc = $cnum;
@@ -468,6 +483,7 @@ function get_ods_content(&$worksheets) {
   <style:style style:name="date0" style:family="table-cell"/>';
 
 $buffer .= $formatstyles;
+$buffer .= $rowstyles;
 $buffer .= $colstyles;
 
  $buffer .= '
@@ -492,7 +508,11 @@ $buffer .= $colstyles;
 
         // print all rows
         for($r=0; $r<=$ws->maxr; $r++) {
-            $buffer .= '<table:table-row>'."\n";
+            if (!empty($ws->rows[$r])) {
+                $buffer .= '<table:table-row table:style-name="ws'.$wsnum.'ro'.$r.'">'."\n";
+            } else {
+                $buffer .= '<table:table-row>'."\n";
+            }
             for($c=0; $c<=$ws->maxc; $c++) {
                 if (isset($ws->data[$r][$c])) {
                     if ($ws->data[$r][$c]->type == 'date') {