diff --git a/lib/odslib.class.php b/lib/odslib.class.php
index 8c7272a85b1..300b9a9d97a 100644
--- a/lib/odslib.class.php
+++ b/lib/odslib.class.php
@@ -25,10 +25,13 @@
// //
///////////////////////////////////////////////////////////////////////////
-// This code uses parts of the Minimalistic creator of OASIS OpenDocument
-// from phpMyAdmin (www.phpmyadmin.net)
-// files: libraries/opendocument.lib.php and libraries/export/ods.php
-// and also parts of the original MoodleExcelWorkbook class.
+/*
+ * The xml used here is derived from output of KSpread 1.6.1
+ *
+ * Known problems:
+ * - missing formatting
+ * - write_date() works fine in OOo, but it does not work in KOffice - it knows only date or time but not both :-(
+ */
class MoodleODSWorkbook {
var $worksheets = array();
@@ -55,7 +58,7 @@ class MoodleODSWorkbook {
* i.e: [bold]=1 for set_bold(1)...Optional!
*/
function &add_format($properties = array()) {
- $format = new MoodleODSFormat($this);
+ $format = new MoodleODSFormat($this, $properties);
return $format;;
}
@@ -120,7 +123,7 @@ class MoodleODSWorksheet {
/* Constructs one Moodle Worksheet.
* @param string $filename The name of the file
*/
- function ODSWorksheet($name) {
+ function MoodleODSWorksheet($name) {
$this->name = $name;
}
@@ -415,19 +418,22 @@ function get_ods_content(&$worksheets) {
/// header
$buffer =
- ''
- . ''
- . 'xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"'
- . ''
- . '';
+'
+
+
+
+
+
+
+
+
+
+';
foreach($worksheets as $ws) {
+
/// worksheet header
- $buffer .= '';
+ $buffer .= ''."\n".' '."\n";
$nr = 0;
$nc = 0;
@@ -443,39 +449,42 @@ function get_ods_content(&$worksheets) {
}
for($r=0; $r<=$nr; $r++) {
- $buffer .= '';
+ $buffer .= ''."\n";
for($c=0; $c<=$nc; $c++) {
if (isset($ws->data[$r][$c])) {
if ($ws->data[$r][$c]->type == 'date') {
- $buffer .= ''
- . '' . htmlspecialchars($ws->data[$r][$c]->value) . ''
- . '';
+ $buffer .= ''
+ . '' . strftime('%Y-%m-%dT%H:%M:%S', $ws->data[$r][$c]->value) . ''
+ . ''."\n";
} else if ($ws->data[$r][$c]->type == 'float') {
$buffer .= ''
. '' . htmlspecialchars($ws->data[$r][$c]->value) . ''
- . '';
+ . ''."\n";
} else if ($ws->data[$r][$c]->type == 'string') {
- $buffer .= ''
+ $buffer .= ''
. '' . htmlspecialchars($ws->data[$r][$c]->value) . ''
- . '';
+ . ''."\n";
} else {
$buffer .= ''
. '!!Error - unknown type!!'
- . '';
+ . ''."\n";
}
} else {
- $buffer .= '';
+ $buffer .= ''."\n";
}
}
- $buffer .= '';
+ $buffer .= ''."\n";
}
/// worksheet footer
- $buffer .= '';
+ $buffer .= ''."\n";
}
/// footer
- $buffer .= '';
+ $buffer .=
+'
+
+';
return $buffer;
}
@@ -485,82 +494,69 @@ function get_ods_mimetype() {
}
function get_ods_meta() {
- global $CFG;
+ global $CFG, $USER;
+
return
- ''
- . ''
- . ''
- . 'Moodle ' . $CFG->version. ''
- . 'Moodle ' . $CFG->version . ''
- . '' . strftime('%Y-%m-%dT%H:%M:%S') . ''
- . ''
- . '';
+'
+
+
+ Moodle '.$CFG->version.'
+ '.fullname($USER, true).'
+ 1
+ '.strftime('%Y-%m-%dT%H:%M:%S').'
+ '.strftime('%Y-%m-%dT%H:%M:%S').'
+ '.fullname($USER, true).'
+
+';
}
function get_ods_styles() {
return
- ''
- . ''
- . 'xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"'
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . '';
+'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ???
+
+
+
+ Page
+ 1
+
+
+
+
+
+';
}
function get_ods_manifest() {
return
- ''
- . ''
- . ''
- . ''
- . ''
- . ''
- . '';
+'
+
+
+
+
+
+';
}
?>
\ No newline at end of file