[20843] update manual

Sigurd Nes <[email protected]>
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 20843
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20843
Author:   sigurdne
Date:     2009-11-20 10:27:37 +0000 (Fri, 20 Nov 2009)
Log Message:
-----------
update manual

Modified Paths:
--------------
    people/sigurdne/modules/manual/trunk/inc/class.odt2xhtml.inc.php
    people/sigurdne/modules/manual/trunk/inc/class.uimanual.inc.php
    people/sigurdne/modules/manual/trunk/templates/base/odt2xhtml.xsl

Added Paths:
-----------
    people/sigurdne/modules/manual/trunk/templates/base/sxw2xhtml.xsl

Modified: people/sigurdne/modules/manual/trunk/inc/class.odt2xhtml.inc.php
===================================================================
--- people/sigurdne/modules/manual/trunk/inc/class.odt2xhtml.inc.php	2009-11-20 10:27:33 UTC (rev 20842)
+++ people/sigurdne/modules/manual/trunk/inc/class.odt2xhtml.inc.php	2009-11-20 10:27:37 UTC (rev 20843)
@@ -1,89 +1,614 @@
 <?php
-	/**
-	* phpGroupWare - Manual
+/***
+ * class PHP odt2xhtml
+ * Copyright (C) 2006  Stephane HUC
 	*
-	* @author Piotr Maliński <[email protected]>
-	* @author Sigurd Nes <[email protected]>
-	* @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc. http://www.fsf.org/
-	* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
-	* @internal Development of this application was funded by http://www.bergen.kommune.no/bbb_/ekstern/
-	* @package manual
-	* @subpackage odt2xhtml
- 	* @version $Id$
-	*/
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Contact information:
+ *   Stephane HUC
+ *   <[email protected]>
+ *
+ ***/
 
-	/**
-	 * odt2xhtml converts odt to xhtml
-	 * @package odt2xhtml
-	 */
+/******************************************************************************/
+/***   Dont touch at the rest !                                             ***/
+/******************************************************************************/
 
+class odt2xhtml
+{
+	public $dir=array();
+	public $file=array();
+	
+	private $attribute='';
+	private $body='';
+	private $code='';
+	private $content='';
+	private $debug='';
+	private $ext=array();
+	private $id='';
+	private $meta='';
+	private $pattern='';
+	private $position=array();
+	private $style='';
+	private $title='';
+	private $version=''; /*** php version ***/
 
-	class odt2xhtml
+	/***
+	    publics functions
+	***/
+	
+	public function __construct($file)
 	{
-		public function oo_unzip($file, $path = false)
+		$this->version = substr(VERSION, 0, 1);	// obtain 1rst string php version
+		
+		$this->dir['odf'] = $GLOBALS['phpgw_info']['server']['temp_dir'];	// dir root
+		
+		$this->file['full_path'] = $file;
+		$file = basename($file);
+		$this->file['name'] = substr($file, 0, -4);		// name file without extension
+		$this->file['ext'] = substr($file, -3, 3);		// just extension
+		
+		$this->dir['odf_tmp'] = $this->dir['odf'].'/tmp';	// tmp dir 
+		$this->dir['html'] = $this->dir['odf'].'/html';		// tmp dir html
+		$this->dir['img'] = $this->dir['html'].'/img';		// tmp dir img
+		
+		/*** define dir for attribute img src ***/
+		if(defined('IMG_SRC')) $this->dir['img_src'] = IMG_SRC.'img';
+		else $this->dir['img_src'] = 'img';
+		
+		$this->file['dir_tmp'] = $this->dir['odf_tmp'].'/php'.$this->version.'_'.$this->file['name'].'_'.$this->file['ext'];
+		$this->file['html_tmp'] = $this->file['dir_tmp'].'_tmp.html';	// file html tmp
+		$this->file['xml_tmp'] = $this->file['dir_tmp'].'.xml';	// file xml tmp
+		
+		$this->dir['img_php'] = $this->dir['img'].'/php'.$this->version;
+		$this->dir['img_php_ext'] = $this->dir['img_php'].'/'.$this->file['ext'];
+		$this->dir['img_OOo'] = $this->dir['img_php_ext'].'/'.$this->file['name'];
+		$this->dir['pictures'] = $this->file['dir_tmp'].'/Pictures';
+		
+		$this->debug = 0;
+	}
+	
+	public function __destruct() 
+	{
+	}
+	
+	/*** Converter ODT TO XHTML ***/
+	public function convert2xhtml()
+	{
+		/*** verify if file's extension is really odf format ****/
+		$this->_valid_ext();
+		
+		/*** making all directories ***/
+		$this->_mk_all_dir();
+		
+		/*** unzip odf file ***/
+		$this->_unzip_odf();
+		
+		/*** choose better file xsl ***/
+		$this->_choose_valid_xsl();
+		
+		/***  make new file xml with ODF files xml ***/
+		$this->_make_new_xml_with_odf_files();
+		
+		/*** move file img to directory img ***/
+		$this->_mv_img();
+		
+		/*** Create temporary file html by xslt processor ***/
+		$this->_xslt_convert_odf();
+		
+		/*** Create real file html ***/
+		$this->_create_file_html();		
+
+	}
+	
+	/*** delete directory temporary ***/
+	public function delete_tmp($path='')
+	{	
+	//	ini_set('memory_limit', '24M');
+	//	ini_set('max_execution_time', 0);
+		if(empty($path)) $path = $this->dir['odf_tmp'];
+		
+		chmod($path, 0777);
+		$dir_tmp = opendir($path);
+		
+		/*** tant que la condition est juste en type alors on lit ***/
+		while(false !== ($file_tmp = readdir($dir_tmp)))
 		{
-			if(!function_exists('zip_open'))
+			if($file_tmp != '.' && $file_tmp != '..')
 			{
-				throw new Exception('NO ZIP FUNCTIONS DETECTED. Do you have the PECL ZIP extensions loaded?');
+				$path_tmp = $path.'/'.$file_tmp;
+				
+				if(!empty($path_tmp) && is_file($path_tmp)) 
+				{
+					unlink($path_tmp);
+				}
+				else 
+				{
+					$this->delete_tmp($path_tmp);
+				}
 			}
-			if(!is_file($file))
+		}
+		
+		closedir($dir_tmp);
+		rmdir($path);
+		
+		if(!empty($this->debug)) echo 'Directory '.$path.' is deleted: OK!<br/>';
+		
+	//	ini_set('memory_limit', MEM);
+	//	ini_set('max_execution_time', MAX_TIME);
+	}
+	
+	/*** try to obtain elements when file html is created ***/
+	public function get_elements_html() {
+		$this->subject = file_get_contents($this->dir['html'].'/'.$this->file['name'].'.html');
+	
+		$this->pattern['meta'] = '`<meta (.*?) />`es';
+		$this->pattern['css'] = '`<style type="text/css">(.*?)</style>`es';
+		$this->pattern['body'] = '`<body>(.*?)</body>`es';
+		$this->pattern['title'] = '`<h1 class="(.*?)">(.*?)</h1>`es';
+		
+		foreach($this->pattern as $k => $v) {
+			preg_match_all($v, $this->subject, $this->match); 
+			$this->elements[$k] = $this->match;
+		}
+		
+		return $this->elements;
+	}
+	
+	public function display_elements_html($info,$x) {
+		$this->code='';
+		if($x != '0' && $x != '1') die('You can\'t use other digit, than 0 or 1, in the method display_elements_html() !');
+		
+		if(!empty($this->elements[$info]) && is_array($this->elements[$info])) {
+			foreach($this->elements[$info][$x] as $v) {
+				$this->code .= $v."\n";
+			}
+			echo $this->code;
+		}
+		else die('The searched element <strong>'.$info.'</strong> in the method display_elements_html() is empty or not exists ... try-it with \'css\',\'body\',\'meta\', or \'title\' !');
+	}
+	
+	/***
+	    privates functions
+	***/
+	
+	/*** transform values cm in px ***/
+	function _analyze_attribute($attribute) {
+		
+		if(ereg('cm',$attribute)) {
+			if(ereg(' ',$attribute)) $xploz = explode(' ',$attribute);
+			
+			if(!empty($xploz) && is_array($xploz)) {
+				foreach($xploz as $k => $v) {
+					if(ereg('cm$',$v)) {
+						$v = round(floatval($v)*28.6264);
+						$xploz[$k] = $v.'px';
+					}
+
+					for($i=0;$i<count($xploz);$i++) {
+						if($i==0) $this->attribute = $xploz[$i];
+						else $this->attribute .= ' '.$xploz[$i];
+					}
+				}
+			}
+			else {
+				$this->attribute = round(floatval($attribute)*28.6264);
+				$this->attribute = $this->attribute.'px';
+			}
+			unset($xploz);
+		}
+		else $this->attribute = $attribute;
+
+		$this->attribute = '="'.$this->attribute.'"';
+		
+		return $this->attribute;
+	}
+	
+	/*** choose better file xsl segun file's extension ***/
+	function _choose_valid_xsl() {
+		switch($this->file['ext']) {
+			case 'odt' :
+			case 'ott' :
+				$this->file['xsl'] = PHPGW_SERVER_ROOT . '/manual/templates/base/odt2xhtml.xsl';
+			break;
+			case 'sxw' :
+			case 'stw' :
+				$this->file['xsl'] =PHPGW_SERVER_ROOT . '/manual/templates/base/sxw2xhtml.xsl';
+			break;
+		}
+		
+		if(!empty($this->debug)) { echo 'Choosing valid XSL: ok!<br/>'; }
+	}
+	
+	/*** create ultimate file html ***/
+	function _create_file_html() {
+		/*** modify title in html flux ***/
+		$this->file['tmp'] = $this->_replace_content('title');
+		
+		/*** Create real file html ***/
+		$this->_write_file($this->dir['html'].'/'.$this->file['name'].'.html','w',$this->file['tmp']);
+		
+		if(!empty($this->debug)) { echo 'Creating File HTML: OK!<br/>'; }
+	}
+	
+	/*** make image code html ***/
+	private function _make_image($name) 
+	{
+		$this->code = 'xlink:href="'.$this->dir['img_src'].'/php'.$this->version.'/'.$this->file['ext'].'/'.$this->file['name'].'/'.$name.'"';
+		return $this->code;
+	}
+	
+	/*** make new file xml with ODF files xml ***/
+	private function _make_new_xml_with_odf_files() 
+	{		
+		/*** make file xml ***/
+		$this->content = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
+
+		switch($this->file['ext']) {
+			case 'odt' :
+			case 'ott' :
+				$this->content .= $this->_replace_content('open_element_xml4odt');
+			break;
+			case 'sxw' :
+			case 'stt' :
+				$this->content .= $this->_replace_content('open_element_xml4sxw');
+			break;
+		}
+		
+		$this->_write_file($this->file['dir_tmp'].'.xml','w',$this->content);
+
+		/*** add meta.xml in file xml ***/
+		$this->file['xml'] = $this->file['dir_tmp'].'/meta.xml';
+
+		if(file_exists($this->file['xml']) && is_readable($this->file['xml'])) 
+	{
+			$this->_read_xml($this->file['xml']);
+			
+			/*** modify the content ***/
+			$this->content = str_replace('<?xml version="1.0" encoding="UTF-8"?>','',$this->content);
+			
+			switch($this->file['ext']) {
+				case 'sxw' :
+				case 'stw' :
+					$this->content = str_replace('<!DOCTYPE office:document-meta PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">','',$this->content);
+				break;
+			}
+			
+			/*** build new file xml segun the modified content ***/
+			$this->_write_file($this->file['dir_tmp'].'.xml','a',$this->content);
+			
+			
+			if(!empty($this->debug)) { echo 'Making File XML - Part Meta : ok!<br/>'; }
+		}
+		else die('Problem with file: '.$this->file['xml']);
+		
+		/*** add styles.xml in file xml modified ***/
+		$this->file['xml'] = $this->file['dir_tmp'].'/styles.xml';
+		
+		if(file_exists($this->file['xml']) && is_readable($this->file['xml'])) 
+		{
+			$this->_read_xml($this->file['xml']);
+			
+			/*** modify the content ***/
+			$this->content = str_replace('<?xml version="1.0" encoding="UTF-8"?>','',$this->content);
+			
+			switch($this->file['ext']) {
+				case 'sxw' :
+				case 'stw' :
+					$this->content = str_replace('<!DOCTYPE office:document-styles PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">','',$this->content);
+				break;
+			}
+			
+			# analyze attribute to transform style's value cm in px
+			$this->content = $this->_replace_content('analyze_attribute');
+			
+			if(preg_match_all('/<style:header>(.*)<\/style:header>/Us',$this->content,$this->match)) 
+				$this->header = str_replace('style:header','text:header',$this->match[0][0]);
+			if(preg_match_all('/<style:footer>(.*)<\/style:footer>/Us',$this->content,$this->match))
+				$this->footer = str_replace('style:footer','text:footer',$this->match[0][0]);
+			
+			/*** build new file xml segun the modified content ***/
+			$this->_write_file($this->file['dir_tmp'].'.xml','a',$this->content);
+			
+			
+			if(!empty($this->debug)) { echo 'Making File XML - Part Styles: ok!<br/>'; }
+		}
+		else die('Problem with file: '.$this->file['xml']);
+		
+		/*** add content.xml in file xml modified ***/
+		$this->file['xml'] = $this->file['dir_tmp'].'/content.xml';
+		
+		if(file_exists($this->file['xml']) && is_readable($this->file['xml'])) 
 			{
-				throw new Exception('Can\'t find file: '.$file);
+			$this->_read_xml($this->file['xml']);
+			
+			/*** modify the content ***/
+			$this->content = str_replace('<?xml version="1.0" encoding="UTF-8"?>','',$this->content);
+			
+			switch($this->file['ext']) {
+				case 'odt' :
+				case 'ott' :
+					# add header page
+					if(!empty($this->header))	$this->content = str_replace('<office:text>','<office:text>'.$this->header,$this->content); 
+					# modify src img
+					$this->content = $this->_replace_content('img_odt');
+					# add footer page
+					if(!empty($this->footer))	$this->content = str_replace('</office:text>',$this->footer.'</office:text>',$this->content); 
+				break;
+				case 'sxw' :
+				case 'stw' :
+					$this->content = str_replace('<!DOCTYPE office:document-content PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">','',$this->content);
+					# add header page
+					if(!empty($this->header))	$this->content = str_replace('<office:body>','<office:body>'.$this->header,$this->content); 
+					# modify src img
+					$this->content = $this->_replace_content('img_sxw');
+					# add footer page
+					if(!empty($this->footer))	$this->content = str_replace('</office:body>',$this->footer.'</office:body>',$this->content); 
+				break;
 			}
-			if($zip = zip_open($file))
+
+			# analyze attribute to transform style's value cm in px
+			$this->content = $this->_replace_content('analyze_attribute');
+			# search text in position indice or exposant to transform it correctly
+			$this->_rewrite_position();
+			
+			/*** build new file xml segun the modified content ***/
+			$this->_write_file($this->file['dir_tmp'].'.xml','a',$this->content);
+			
+			if(!empty($this->debug)) { echo 'Making File XML - Part Content: ok!<br/>'; }
+		}
+		else die('Problem with file: '.$this->file['xml']);
+		
+		/*** modify the content ***/
+		$this->content = "\n".'</office:document>'."\n";
+		
+		/*** terminate file xml ***/
+		$this->_write_file($this->file['dir_tmp'].'.xml','a',$this->content);
+		
+		
+		if(!empty($this->debug)) { echo 'Making File XML - Terminated: ok!<br/>'; }
+			}
+
+	private function _mk_all_dir() {
+		umask(0000);
+		
+		/*** making temporary dir ***/
+		if(!file_exists($this->dir['odf_tmp']) && !is_dir($this->dir['odf_tmp'])) {
+			mkdir($this->dir['odf_tmp'], 0777);
+			if(!empty($this->debug)) { echo 'Making Dir TMP '.$this->dir['odf_tmp'].': OK!<br/>'; }
+		}
+		
+		/*** making dir to receive file html ***/
+		if(!file_exists($this->dir['html']) && !is_dir($this->dir['html'])) 
 			{
-				while ($zip_entry = zip_read($zip))
+			mkdir($this->dir['html'], 0777);
+			if(!empty($this->debug)) { echo 'Making Dir HTML: OK!<br/>'; }
+			}
+
+		/*** making directory to receive file img ***/
+		if(!file_exists($this->dir['img']) and !is_dir($this->dir['img']))
+			{
+			mkdir($this->dir['img'], 0777);
+			if(!empty($this->debug)) { echo 'Making Dir IMG '.$this->dir['img'].': OK!<br/>'; }
+		}
+			
+		if(!file_exists($this->dir['img_php']) and !is_dir($this->dir['img_php']))
 				{
-					$filename = zip_entry_name($zip_entry);
-					if(zip_entry_name($zip_entry) == 'content.xml' and zip_entry_open($zip, $zip_entry, "r"))
+			mkdir($this->dir['img_php'], 0777);
+			if(!empty($this->debug)) { echo 'Making Dir '.$this->dir['img_php'].': OK!<br/>'; }
+		}
+			
+		if(!file_exists($this->dir['img_php_ext']) and !is_dir($this->dir['img_php_ext']))
 					{
-						$content = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
-						zip_entry_close($zip_entry);
+			mkdir($this->dir['img_php_ext'], 0777);
+			if(!empty($this->debug)) { echo 'Making Dir '.$this->dir['img_php_ext'].': OK!<br/>'; }
 					}
-					if(ereg('Pictures/', $filename) and !ereg('Object', $filename)  and zip_entry_open($zip, $zip_entry, "r"))
+		
+		if(!file_exists($this->dir['img_OOo']) and !is_dir($this->dir['img_OOo']))
 					{
-						$img[$filename] = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
-						zip_entry_close($zip_entry);
+			mkdir($this->dir['img_OOo'], 0777);
+			if(!empty($this->debug)) { echo 'Making Dir '.$this->dir['img_OOo'].': OK!<br/>'; }
 					}
+		
+		if(!empty($this->debug)) { echo 'All dir are making: OK!<br/>'; }
 				}
-				if(isset($content))
+
+	/*** modify title code html ***/
+	private function _modify_title()
+	{
+		$this->title = "<head>\n\t<title>&quot;".$this->file['name'].'.'.$this->file['ext'].'&quot; :: converted by Odt2Xhtml in PHP5</title>';
+		return $this->title;
+	}
+	
+	/*** make directory image and moving images ***/
+	private function _mv_img()
+	{		
+		/*** move img ***/
+		if(file_exists($this->dir['pictures']) && $this->handle = opendir($this->dir['pictures']))
 				{
-					if(isset($img) && is_array($img))
+			while( false !== $this->file['img'] = readdir($this->handle) )
 					{
-						if(!is_dir($path.'Pictures'))
+				if(is_file($this->dir['pictures'].'/'.$this->file['img']))
 						{
-							mkdir($path.'Pictures');
+					/*** move img at temp directory to img directory ***/
+					if(rename($this->dir['pictures'].'/'.$this->file['img'], $this->dir['img_OOo'].'/'.$this->file['img'])) {
+						chmod($this->dir['img_OOo'].'/'.$this->file['img'], 0644);
+						
+						if(!empty($this->debug)) { echo 'Moving IMG '.$this->file['img'].': ok!<br/>'; }
+					}
+					else die('Image '.$this->file['img'].' can\'t be moved.');
+				}
+			}
+			closedir($this->handle);
+		}
+		//else die('Directory can\'t be opened: '.$this->dir['img']['tmp']);
+	}
+	
+	/*** read file xml ***/
+	private function _read_xml($xml) {
+		$this->handle = fopen($xml, 'r');
+		$this->content = fread($this->handle, filesize($this->file['xml']));
+		fclose($this->handle);
+	}
+	
+	/*** replace content ***/
+	private function _replace_content($info) {
+		switch($info) {
+			case 'analyze_attribute' :
+				$this->exec=1;
+				$this->search = '/="(.*?)"/es';
+				$this->replace = "odt2xhtml::_analyze_attribute('$1')";
+				$this->subject = $this->content;
+			break;
+			case 'img_odt' :
+				$this->exec=1;
+				$this->search = '#xlink:href="Pictures/([.a-zA-Z_0-9]*)"#es';
+				$this->replace = "odt2xhtml::_make_image('$1')";
+				$this->subject = $this->content;
+			break;
+			case 'img_sxw' :
+				$this->exec=1;
+				$this->search = '!xlink:href="\#Pictures/([.a-zA-Z_0-9]*)"!es';
+				$this->replace = "odt2xhtml::_make_image('$1')";
+				$this->subject = $this->content;
+			break;
+			case 'open_element_xml4odt' :
+				$this->buffer = '<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0">';
+			break;
+			case 'open_element_xml4sxw' :
+				$this->buffer = '<office:document xmlns:office="http://openoffice.org/2000/office">';
+			break;
+			case 'title' :
+				$this->exec=1;
+				$this->search = '/<head>/es';
+				$this->replace = "odt2xhtml::_modify_title()";
+				$this->subject = $this->file['tmp'];
+			break;
 						}
-						foreach($img as $key => $val)
+		
+		if(!empty($this->exec)) $this->buffer = preg_replace($this->search,$this->replace,$this->subject);
+		
+		return $this->buffer;
+		
+		unset($this->buffer,$this->exec);
+	}
+	
+	/*** search text in position indice or exposant and transform it ***/
+	private function _rewrite_position() 
 						{
-							file_put_contents($path.$key, $val);
+		# search styles text-position
+		switch($this->file['ext']) {
+			case 'odt' :
+			case 'ott' :
+				if(preg_match_all('`<style:style style:name="T([0-9]+)" style:family="text"><style:text-properties style:text-position="(.*?)"/></style:style>`es',$this->content,$this->match)) {
+					$this->_make_position($this->match);
+				}
+			break;
+			case 'sxw' :
+			case 'stw' :
+				if(preg_match_all('`<style:style style:name="T([0-9]+)" style:family="text"><style:properties style:text-position="(.*?)"/></style:style>`es',$this->content,$this->match)) {
+					$this->_make_position($this->match);
+				}
+			break;
+		}
+		unset($this->match);
+		# search text relative to style text-position
+		if(!empty($this->position) && preg_match_all('`<text:span text:style-name="T([0-9]+)">(.*?)</text:span>`es',$this->content,$this->match)) {
+			
+			foreach($this->match[1] as $k => $v) {
+				if(in_array($v,$this->position['name'])) {
+					foreach($this->position['name'] as $k2 => $v2) {
+						if($v2 == $v) {
+							$this->position['search'][$k2] = '<text:span text:style-name="T'.$this->position['name'][$k2].'">'.$this->match[2][$k].'</text:span>';
+							$this->position['replace'][$k2] = '<text:'.$this->position['string'][$k2].' text:style-name="T'.$this->position['name'][$k2].'">'.$this->match[2][$k].'</text:'.$this->position['string'][$k2].'>';
 						}
 					}
-					return $content;
+						}
+					}
 				}
+		unset($this->match);
+		# replace search text position par replace text position
+		if(!empty($this->position['search']) && is_array($this->position['search'])) {
+			foreach($this->position['search'] as $k => $v) {
+				$this->content = str_replace($v, $this->position['replace'][$k], $this->content);
 			}
 		}
+		unset($this->position);
+	}
 
-		public function oo_convert($xml)
+	/*** Unzip file ODT ***/
+	private function _unzip_odf() 
 		{
-			$xls = new DOMDocument;
-			$xls->load(PHPGW_SERVER_ROOT . '/manual/templates/base/odt2html.xsl');
-		//	$xls->load(PHPGW_SERVER_ROOT . '/manual/templates/base/odt2xhtml.xsl');
-		//	$xls->load('xslt/export/xhtml/ooo2xhtml.xsl');
-		//	$xls->load('template.xsl');
-			$xslt = new XSLTProcessor;
-			$xslt->importStylesheet($xls);
+		$archive = CreateObject('phpgwapi.pclzip', $this->file['full_path']);
 		
-			$x = preg_replace('#<draw:image xlink:href="Pictures/([a-z .A-Z_0-9]*)" (.*?)/>#es', "ODT2XHTML::makeImage('\\1')", $xml);
+		if($archive->extract(PCLZIP_OPT_PATH, $this->file['dir_tmp']) == 0) 
+		{
+			die('Error: '.$archive->errorInfo(true));
+		}
 		
-			$xml = new DOMDocument;
-			$xml->loadXML($x);
-			return $xslt->transformToXML($xml);
+		if(!empty($this->debug)) { echo 'Unzip ok!<br/>'; }
+		
 		}
 
-		public function makeImage($img)
+	/*** Verify if extension is really odt ***/
+	private function _valid_ext() 
 		{
-			return '&lt;img src="Pictures/'.$img.'" border="0" /&gt;';
+		$this->ext['valid'] = array('odt', 'ott', 'stw', 'sxw');
+		
+		if(!in_array($this->file['ext'], $this->ext['valid'])) {
+			die('No valid extension ! The script stop it ! Your extension could be odt, ott or sxw, stw...');
 		}
+		
+		if(!empty($this->debug)) { echo 'Valid extension!<br/>'; }
 	}
-?>
+	
+	/*** write file ***/
+	private function _write_file($filename,$mode,$resource) {
+		$this->handle = fopen($filename,$mode);
+		fwrite($this->handle,$resource);
+		fclose($this->handle);
+	}
+	
+	/*** PHP Convert XML ***/
+	private function _xslt_convert_odf() 
+	{
+		$xls = new DOMDocument();
+		$xls->load($this->file['xsl']);
+
+		$xslt = new XSLTProcessor();
+		$xslt->importStylesheet($xls);
+
+		$xml = new DOMDocument();
+		$xml->load($this->file['xml_tmp']);
+
+		$this->file['tmp'] = html_entity_decode($xslt->transformToXML($xml));
+		if(!empty($this->debug)) { echo 'Convert ODF to Temporary File HTML: ok!<br/>'; }
+	}
+	
+	/***
+		Protected functions
+	***/
+	
+	/*** this function is run by method _rewrite_position() ***/
+	protected function _make_position($match) {
+		if(!empty($match) && is_array($match)) {
+			foreach($match[1] as $k => $v) {
+				$this->position['name'][$k] = $v;
+				$this->position['string'][$k] = substr($match[2][$k], 0, 3);
+			}
+		}
+	}
+}

Modified: people/sigurdne/modules/manual/trunk/inc/class.uimanual.inc.php
===================================================================
--- people/sigurdne/modules/manual/trunk/inc/class.uimanual.inc.php	2009-11-20 10:27:33 UTC (rev 20842)
+++ people/sigurdne/modules/manual/trunk/inc/class.uimanual.inc.php	2009-11-20 10:27:37 UTC (rev 20843)
@@ -11,8 +11,8 @@
 	*/
 
 	/**
-	 * Description
-	 * @package property
+	 * Manual Renderer
+	 * @package manual
 	 */
 
 	class manual_uimanual
@@ -68,16 +68,15 @@
 
 		function help()
 		{
-			$odt2xhtml	= CreateObject('manual.odt2xhtml');
+			$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+			$GLOBALS['phpgw_info']['flags']['no_reset_fonts'] = true;
 			$app = phpgw::get_var('app', 'string', 'GET');
 			$section = phpgw::get_var('section', 'string', 'GET');
 
 			if(!$section)
 			{
-				$referer = parse_url(phpgw::get_var('HTTP_REFERER', 'string', 'SERVER') );
-				parse_str($referer['query']);
-
-				if(isset($menuaction) && $menuaction)
+				$menuaction = phpgw::get_var('referer');
+				if($menuaction)
 				{
 					list($app_from_referer, $class, $method) = explode('.',$menuaction);
 					if ( strpos($class, 'ui') === 0 )
@@ -111,7 +110,13 @@
 
 			if(is_file($odtfile))
 			{
-				echo $odt2xhtml->oo_convert($odt2xhtml->oo_unzip($odtfile));
+				$odt2xhtml	= CreateObject('manual.odt2xhtml',$odtfile);
+				$odt2xhtml->convert2xhtml();
+				$odt2xhtml->get_elements_html();
+				//$odt2xhtml->display_elements_html('css',0); 
+				//$odt2xhtml->display_elements_html('title',0); 
+				$odt2xhtml->display_elements_html('body',0); 
+				$odt2xhtml->delete_tmp();
 			}
 			else
 			{
@@ -128,6 +133,7 @@
 
 		function attrib_help()
 		{
+			$GLOBALS['phpgw_info']['flags']['noframework'] = true;
 			$t =& $GLOBALS['phpgw']->template;
 			$t->set_root(PHPGW_APP_TPL);
 
@@ -138,16 +144,14 @@
 			$location 	= phpgw::get_var('location');
 			$id			= phpgw::get_var('id', 'int');
 
-			$custom 	= createObject('phpgwapi.custom_fields');
-			
-			$attrib_data 	= $custom->get_attrib_single($appname, $location, $id);
+			$attrib_data 	= $GLOBALS['phpgw']->custom_fields->get($appname, $location, $id);
 
 			$function_msg	= lang('Help');
 
-			$t->set_file('help','help.tpl');
-			$t->set_var('title',lang('Help') . ' - "' . $attrib_data['input_text'] . '"');
-			$t->set_var('help_msg',$attrib_data['helpmsg'] );
-			$t->set_var('lang_close',lang('close') );
+			$t->set_file('help', 'help.tpl');
+			$t->set_var('title', lang('Help') . " - \"{$attrib_data['input_text']}\"");
+			$t->set_var('help_msg', $attrib_data['helpmsg'] );
+			$t->set_var('lang_close', lang('close'));
 											
 			$GLOBALS['phpgw']->common->phpgw_header();
 			$t->pfp('out','help');

Modified: people/sigurdne/modules/manual/trunk/templates/base/odt2xhtml.xsl
===================================================================
--- people/sigurdne/modules/manual/trunk/templates/base/odt2xhtml.xsl	2009-11-20 10:27:33 UTC (rev 20842)
+++ people/sigurdne/modules/manual/trunk/templates/base/odt2xhtml.xsl	2009-11-20 10:27:37 UTC (rev 20843)
@@ -1,45 +1,5 @@
-<?xml version="1.0"?>
-<!--
-This file is dual-licensed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
-LGPL:
-    This stylesheet converts OpenDocument text files to XHTML.
-    Copyright (C) 2005-2006 J. David Eisenberg
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-	
-	Author: J. David Eisenberg
-	Contact: [email protected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- Apache 2.0
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-
-
+<?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet version="1.0"
-	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
     xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
     xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
@@ -54,183 +14,351 @@
     xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
     xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
     xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0"
-
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:math="http://www.w3.org/1998/Math/MathML"
     xmlns:xforms="http://www.w3.org/2002/xforms"
-
     xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
     xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
     xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0"
-	
 	xmlns:ooo="http://openoffice.org/2004/office"
 	xmlns:ooow="http://openoffice.org/2004/writer"
 	xmlns:oooc="http://openoffice.org/2004/calc"
-	xmlns:int="http://catcode.com/odf_to_xhtml/internal"
+	xmlns:int="http://opendocumentfellowship.org/internal" 
     xmlns="http://www.w3.org/1999/xhtml"
-	exclude-result-prefixes="office meta config text table draw presentation
-		dr3d chart form script style number anim dc xlink math xforms fo
-		svg smil ooo ooow oooc int #default"
->
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+	exclude-result-prefixes="office meta config text table draw presentation dr3d chart form script style number anim dc xlink math xforms fo svg smil ooo ooow oooc int #default">
 
-<xsl:output
+	<xsl:output 
 	method="xml"
 	indent="yes"
 	omit-xml-declaration="yes"
-	doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
-	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
 	encoding="UTF-8"
-/>
-<xsl:variable name="lineBreak"><xsl:text>
-</xsl:text></xsl:variable>
+	standalone="no"
+	doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
+	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+	/>
+	
+	<xsl:variable name="lineBreak">
+		<xsl:text>
+		</xsl:text>
+	</xsl:variable>
+	
+	<xsl:template match="/office:document">
+		<html xmlns="http://www.w3.org/1999/xhtml">
+			<xsl:attribute name="xml:lang"><xsl:value-of select="substring(office:document-meta/office:meta/dc:language,1,2)"/></xsl:attribute>
+			<xsl:attribute name="lang"><xsl:value-of select="substring(office:document-meta/office:meta/dc:language,1,2)"/></xsl:attribute>
+		<head>
+			<xsl:apply-templates select="office:document-meta"/>
+			<xsl:call-template name="process-all-styles"/>
+		</head>
+		<xsl:apply-templates select="office:document-content"/>
+		</html>
+	</xsl:template>
+	
+	<xsl:template match="office:document-content">
+		<body>
+			<xsl:comment> office:body/office:text </xsl:comment>
+			<xsl:apply-templates select="office:body/office:text"/>
+			<xsl:comment> add-footnote-bodies </xsl:comment>
+			<xsl:call-template name="add-footnote-bodies"/>
+		</body>
+	</xsl:template>	
+	
+<!-- element p -->	
+	<xsl:template match="text:p">
+		<xsl:choose>
+			<xsl:when test="descendant::draw:*">
+				<xsl:apply-templates/>
+				<xsl:if test="count(node())=0"><br/></xsl:if>
+			</xsl:when>
+			
+			<xsl:when test="@text:style-name='Quotations' and node()">
+				<blockquote>
+					<p class="{translate(@text:style-name,'.','_')}">
+						<xsl:apply-templates/>
+					</p>
+				</blockquote>
+			</xsl:when>
+			
+			<xsl:otherwise>
+				<p class="{translate(@text:style-name,'.','_')}">
+					<xsl:apply-templates/>
+					<xsl:if test="count(node())=0"><br/></xsl:if>
+				</p>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+<!-- element span -->	
+	<xsl:template match="text:span">
+	<span class="{translate(@text:style-name,'.','_')}">
+		<xsl:apply-templates/>
+	</span>
+	</xsl:template>
+	
+<!-- element h -->
+	<xsl:template match="text:h">
+	<!-- Heading levels go only to 6 in XHTML -->
+	<xsl:if test="node()">
+		<xsl:variable name="level">
+    		<xsl:choose>
+			<!-- text:outline-level is optional, default is 1 -->
+				<xsl:when test="not(@text:outline-level)">1</xsl:when>
+				<xsl:when test="@text:outline-level &gt; 6">6</xsl:when>
+				<xsl:otherwise>
+					<xsl:value-of select="@text:outline-level"/>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
 
-<xsl:key name="listTypes" match="text:list-style" use="@style:name"/>
+		<xsl:element name="{concat('h', $level)}">
+    		<xsl:attribute name="class">
+				<xsl:value-of select="translate(@text:style-name,'.','_')"/>
+    		</xsl:attribute>
+    		<a name="{generate-id()}"/>
+    		<xsl:apply-templates/>
+		</xsl:element>
+	</xsl:if>
+	</xsl:template>
+	
+	<!-- this elements are not defined by ODF -->
+	<xsl:template match="text:header">
+		<div>
+			<xsl:attribute name="id">
+				<xsl:text>header</xsl:text>
+			</xsl:attribute>
+			<xsl:apply-templates/>
+		</div>
+	</xsl:template>
+	
+	<xsl:template match="text:footer">
+		<div>
+			<xsl:attribute name="id">
+				<xsl:text>footer</xsl:text>
+			</xsl:attribute>
+	<xsl:apply-templates/>
+		</div>
+	</xsl:template>
+	
+	<xsl:template match="text:sub">
+		<sub class="{translate(@text:style-name,'.','_')}"><xsl:apply-templates/></sub>
+	</xsl:template>
+	
+	<xsl:template match="text:sup">
+		<sup class="{translate(@text:style-name,'.','_')}"><xsl:apply-templates/></sup>
+	</xsl:template>
+	<!-- end adding -->
+	
+<!-- preserve tabulation -->
+	<xsl:template match="text:tab">
+		<xsl:text xml:space="preserve"> </xsl:text>
+	</xsl:template>
+	
+<!-- element br -->
+	<xsl:template match="text:line-break">
+	<br/>
+	</xsl:template>
+	
+<!-- preserve spaces -->
+	<xsl:variable name="spaces" xml:space="preserve"/>
+	
+	<xsl:template match="text:s">
+		<xsl:choose>
+			<xsl:when test="@text:c">
+				<xsl:call-template name="insert-spaces">
+					<xsl:with-param name="n" select="@text:c"/>
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:text> </xsl:text>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+<!-- insert spaces -->
+	<xsl:template name="insert-spaces">
+	<xsl:param name="n"/>
+		<xsl:choose>
+			<xsl:when test="$n &lt;= 30">
+				<xsl:value-of select="substring($spaces, 1, $n)"/>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:value-of select="$spaces"/>
+				<xsl:call-template name="insert-spaces">
+					<xsl:with-param name="n">
+						<xsl:value-of select="$n - 30"/>
+					</xsl:with-param>
+				</xsl:call-template>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+<!-- element a -->
+	<xsl:template match="text:a">
+		<a href="{@xlink:href}"><xsl:apply-templates/></a>
+	</xsl:template>
+<!-- preserve bookmark -->	
+	<xsl:template match="text:bookmark-start|text:bookmark">
+		<a name="{@text:name}">
+			<span style="font-size: 0px">
+				<xsl:text> </xsl:text>
+			</span>
+		</a>
+	</xsl:template>
+<!-- preserve footnote -->
+  <xsl:template match="text:note">
+	<xsl:variable name="footnote-id" select="text:note-citation"/>
+	<a href="#footnote-{$footnote-id}">
+		<sup><xsl:value-of select="$footnote-id"/></sup>
+	</a>
+	</xsl:template>
+<!-- preserve note body -->
+	<xsl:template match="text:note-body"/>
+	<xsl:template name="add-footnote-bodies">
+		<xsl:apply-templates select="//text:note" mode="add-footnote-bodies"/>
+	</xsl:template>
+<!-- preserve footnote bodies -->
+	<xsl:template match="text:note" mode="add-footnote-bodies">
+		<xsl:variable name="footnote-id" select="text:note-citation"/>
+			<p><a name="footnote-{$footnote-id}"><sup><xsl:value-of select="$footnote-id"/></sup>:</a></p>
+		<xsl:apply-templates select="text:note-body/*"/>
+	</xsl:template>
 
-<xsl:template match="/office:document-content">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<title>Converted by odt_to_xhtml.xsl</title>
-<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-<xsl:apply-templates select="office:automatic-styles"/>
-</head>
-<body>
-<xsl:apply-templates select="office:body/office:text"/>
-</body>
-</html>
-</xsl:template>
-
-<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
-<!--
-	This section of the transformation handles styles in the
-	content.xml file
--->
-<xsl:template match="office:automatic-styles">
+<!-- procede all styles -->
+	<xsl:template name="process-all-styles">
 	<style type="text/css">
-	<xsl:apply-templates/>
+	/* ODF paragraphs, by default, don't have any line spacing. */
+	p { margin: 0px; padding: 0px; }
+	/* put a default link style in, so we can see links */
+	a[href] { color: blue; text-decoration: underline; }
+	
+	<xsl:apply-templates select="office:document-styles/office:styles"/>
+	<xsl:apply-templates select="office:document-content/office:automatic-styles"/>
+	<xsl:call-template name="toc-styles"/>
 	</style>
-</xsl:template>
+	</xsl:template>
+	
+<!-- procede toc styles -->
+	<xsl:template name="toc-styles">
+		<xsl:apply-templates select="//text:table-of-content" mode="toc-styles"/>
+	</xsl:template>
 
-<xsl:template match="style:style">
+	<xsl:template match="text:table-of-content" mode="toc-styles">
+	<!-- Generate styles for the ToC -->
+		/* ToC styles start */
+		<xsl:apply-templates select="//text:h/@text:outline-level" mode="toc-styles"/>
+		/* ToC styles end */
+	</xsl:template>
+
+	<xsl:template match="text:h/@text:outline-level" mode="toc-styles">
+	<xsl:text>.toc_outline_level_</xsl:text>
+	<xsl:value-of select="."/>
+	<xsl:text> { margin-left: </xsl:text>
+	<xsl:value-of select="round(.*0.5*28.6264)"/> <!-- modified : transform cm in px for 72 dpi -->
+	<xsl:text>px; }&#xa;</xsl:text>
+
+	<xsl:value-of select="$lineBreak"/>
+
+	<xsl:text>.toc_outline_level_</xsl:text>
+	<xsl:value-of select="."/>
+	<xsl:text> a { text-decoration: none } &#xa;</xsl:text>
+
+	<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+
+	<xsl:template match="*" mode="toc-styles"/>
+
+	<xsl:template match="office:document-styles/office:styles">
+		/* Document styles start */
+		<xsl:apply-templates/>
+		/* Document styles end */
+	</xsl:template>
+	
+	<xsl:template match="office:document-content/office:automatic-styles">
+		/* Automatic styles start */
+		<xsl:apply-templates/>
+		/* Automatic styles end */
+	</xsl:template>
+	
+	<xsl:template match="style:default-style">
 	<xsl:choose>
 		<xsl:when test="@style:family='table'">
-			<xsl:call-template name="process-table-style"/>
+       		 	<xsl:text>table</xsl:text>
 		</xsl:when>
-		<xsl:when test="@style:family='table-column'">
-			<xsl:call-template name="process-table-column-style"/>
-		</xsl:when>
 		<xsl:when test="@style:family='table-cell'">
-			<xsl:call-template name="process-table-cell-style"/>
+      		  	<xsl:text>td</xsl:text>
+    		</xsl:when>
+    		<xsl:when test="@style:family='table-row'">
+    		    <xsl:text>tr</xsl:text>
 		</xsl:when>
 		<xsl:when test="@style:family='paragraph'">
-			<xsl:call-template name="process-paragraph-style"/>
+				<xsl:text>p</xsl:text>
 		</xsl:when>
 		<xsl:when test="@style:family='text'">
-			<xsl:call-template name="process-text-style"/>
+    		    <xsl:text>p</xsl:text>
 		</xsl:when>
+    		<xsl:otherwise>
+				<xsl:text>.default_</xsl:text>
+				<xsl:value-of select="translate(@style:family,'.','_')"/>
+			</xsl:otherwise>
 	</xsl:choose>
-</xsl:template>
+		<xsl:text> {</xsl:text><xsl:value-of select="$lineBreak"/>
 
-<xsl:template name="process-table-style">
-	<xsl:if test="style:table-properties">
-		<xsl:value-of select="$lineBreak"/>
-		<xsl:text>.</xsl:text>
-		<xsl:value-of select="translate(@style:name,'.','_')"/>
-		<xsl:text>{width: </xsl:text>
-		<xsl:value-of select="style:table-properties/
-			@style:width"/>
-		<xsl:text>}</xsl:text>
-		<xsl:value-of select="$lineBreak"/>
-	</xsl:if>
-</xsl:template>
-
-<xsl:template name="process-table-column-style">
-	<xsl:if test="style:table-column-properties">
-		<xsl:value-of select="$lineBreak"/>
-		<xsl:text>.</xsl:text>
-		<xsl:value-of select="translate(@style:name,'.','_')"/>
-		<xsl:text>{width: </xsl:text>
-		<xsl:value-of select="style:table-column-properties/
-			@style:column-width"/><xsl:text>;</xsl:text>
-		<xsl:value-of select="$lineBreak"/>
-				<xsl:call-template name="handle-style-properties">
-			<xsl:with-param name="nodeSet"
-				select="style:table-properties"/>
+		<xsl:call-template name="process-styles">
+			<xsl:with-param name="node" select="."/>
 		</xsl:call-template>
-		<xsl:text>}</xsl:text>
-		<xsl:value-of select="$lineBreak"/>
-	</xsl:if>
-</xsl:template>
 
-<xsl:template name="process-table-cell-style">
-	<xsl:if test="style:table-cell-properties">
-		<xsl:value-of select="$lineBreak"/>
+		<xsl:text>}&#xa;</xsl:text>
+	</xsl:template>
+
+	<xsl:template match="style:style">
 		<xsl:text>.</xsl:text>
 		<xsl:value-of select="translate(@style:name,'.','_')"/>
-		<xsl:text>{</xsl:text><xsl:value-of select="$lineBreak"/>
-		<xsl:call-template name="handle-style-properties">
-			<xsl:with-param name="nodeSet"
-				select="style:table-cell-properties"/>
-		</xsl:call-template>
-		<xsl:text>}</xsl:text><xsl:value-of select="$lineBreak"/>
-	</xsl:if>
-</xsl:template>
+		<xsl:text> {</xsl:text><xsl:value-of select="$lineBreak"/>
 
-<xsl:template name="process-paragraph-style">
-	<xsl:if test="style:paragraph-properties">
-		<xsl:value-of select="$lineBreak"/>
-		<xsl:text>.</xsl:text>
-		<xsl:value-of select="translate(@style:name,'.','_')"/>
-		<xsl:text>{</xsl:text><xsl:value-of select="$lineBreak"/>
-		<xsl:call-template name="handle-style-properties">
-			<xsl:with-param name="nodeSet"
-				select="style:paragraph-properties"/>
+		<xsl:call-template name="process-styles">
+			<xsl:with-param name="node" select="."/>
 		</xsl:call-template>
-		<xsl:text>}</xsl:text><xsl:value-of select="$lineBreak"/>
-	</xsl:if>
-</xsl:template>
 
-<xsl:template name="process-text-style">
-	<xsl:if test="style:text-properties">
-		<xsl:value-of select="$lineBreak"/>
-		<xsl:text>.</xsl:text>
-		<xsl:value-of select="translate(@style:name,'.','_')"/>
-		<xsl:text>{</xsl:text><xsl:value-of select="$lineBreak"/>
-		<xsl:call-template name="handle-style-properties">
-			<xsl:with-param name="nodeSet"
-				select="style:text-properties"/>
+		<xsl:text>}&#xa;</xsl:text>
+	</xsl:template>
+
+	<xsl:template name="process-styles">
+		<xsl:param name="node"/>
+		<xsl:if test="$node/@style:parent-style-name">
+			<xsl:variable name="parentStyle" select="$node/@style:parent-style-name"/>
+			<xsl:call-template name="process-styles">
+				<xsl:with-param name="node" select="//style:style[@style:name=$parentStyle]"/>
 		</xsl:call-template>
-		<xsl:text>}</xsl:text><xsl:value-of select="$lineBreak"/>
 	</xsl:if>
-</xsl:template>
 
-<xsl:template name="handle-style-properties">
-	<xsl:param name="nodeSet"/>
-	<xsl:for-each select="$nodeSet/@*">
-		<xsl:variable name="this" select="."/>
-		<xsl:variable name="find" select="document('')/xsl:stylesheet/
-			int:attr-map/int:attr[@name=name($this)]"/>
-		<xsl:if test="$find">
-			<xsl:variable name="action" select="$find/@action"/>
-			<xsl:choose>
-				<xsl:when test="$action='pass-through'">
+		<xsl:apply-templates select="$node/style:paragraph-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:text-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:table-cell-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:table-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:table-column-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:graphic-properties/@*" mode="styleattr"/>
+	</xsl:template>
+
+	<xsl:template match="@fo:border-left|@fo:border-right|@fo:border-top|@fo:border-bottom|@fo:border|@fo:margin-left|@fo:margin-right|@fo:margin-top|@fo:margin-bottom|@fo:margin|@fo:padding-left|@fo:padding-right|@fo:padding-top|@fo:padding-bottom|@fo:padding|@fo:text-align|@fo:text-indent|@fo:font-variant|@fo:font-family|@fo:color|@fo:background-color|@fo:font-size|@svg:font-family|@fo:font-style|@fo:font-weight|@fo:line-height|@style:width" mode="styleattr">
 					<xsl:call-template name="pass-through"/>
-				</xsl:when>
-				<xsl:when test="$action='check-align'">
-					<xsl:call-template name="check-align"/>
-				</xsl:when>
-			</xsl:choose>
-		</xsl:if>
-	</xsl:for-each>
-</xsl:template>
+	</xsl:template>
 
-<xsl:template name="pass-through">
-	<xsl:value-of select="local-name()"/><xsl:text>: </xsl:text>
-	<xsl:value-of select="."/><xsl:text>;</xsl:text>
+	<xsl:template match="@style:font-name" mode="styleattr">
+		<xsl:text>font-family: '</xsl:text>
+		<xsl:value-of select="."/><xsl:text>';</xsl:text>
 	<xsl:value-of select="$lineBreak"/>
-</xsl:template>
+	</xsl:template>
 
-<xsl:template name="check-align">
+	<xsl:template match="@style:text-underline-style|@style:text-underline-type" mode="styleattr">
+<!-- CSS2 only has one type of underline.
+	We can improve this when CSS3 is better supported.
+-->
+		<xsl:if test="not(.='none')">
+			<xsl:text>text-decoration: underline;</xsl:text>
+		</xsl:if>
+	</xsl:template>
+
+	<xsl:template match="@fo:text-align" mode="styleattr">
 	<xsl:value-of select="local-name()"/><xsl:text>: </xsl:text>
 	<xsl:choose>
 		<xsl:when test=".='start'"><xsl:text>left</xsl:text></xsl:when>
@@ -239,9 +367,44 @@
 	</xsl:choose>
 	<xsl:text>;</xsl:text>
 	<xsl:value-of select="$lineBreak"/>
-</xsl:template>
+	</xsl:template>
 
-<xsl:template match="text:list-level-style-bullet">
+	<xsl:template match="@style:horizontal-pos" mode="styleattr">
+		<xsl:choose>
+	<!-- We can't support the others until we figure out pagination. -->
+			<xsl:when test=".='left'">
+   			/* Left alignment */
+   				<xsl:text>margin-left: 0; margin-right: auto;</xsl:text>
+			</xsl:when>
+			<xsl:when test=".='right'">
+   			/* Right alignment */
+   				<xsl:text>margin-left: auto; margin-right: 0;</xsl:text>
+			</xsl:when>
+			<xsl:when test=".='center'">
+   			/* Centered alignment */
+   				<xsl:text>margin: 0 auto;</xsl:text>
+			</xsl:when>
+		</xsl:choose>
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+
+	<xsl:template match="@style:column-width" mode="styleattr">
+		<xsl:text>width: </xsl:text><xsl:value-of select="."/><xsl:text>;</xsl:text>
+	</xsl:template>
+
+	<xsl:template match="@*" mode="styleattr">
+		<!-- don't output anything for attrs we don't understand -->
+	</xsl:template>
+
+	<xsl:template name="pass-through">
+		<xsl:value-of select="local-name()"/><xsl:text>: </xsl:text>
+		<xsl:value-of select="."/>
+		<xsl:text>; </xsl:text>
+		
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+<!-- style li -->
+	<xsl:template match="text:list-level-style-bullet">
 	<xsl:text>.</xsl:text>
 	<xsl:value-of select="../@style:name"/>
 	<xsl:text>_</xsl:text>
@@ -253,12 +416,11 @@
 		<xsl:when test="@text:level mod 3 = 0">square</xsl:when>
 		<xsl:otherwise>decimal</xsl:otherwise>
 	</xsl:choose>
-	<xsl:text>;}</xsl:text>
+		<xsl:text>;}&#xa;</xsl:text>
 	<xsl:value-of select="$lineBreak"/>
-</xsl:template>
-
-
-<xsl:template match="text:list-level-style-number">
+	</xsl:template>
+<!-- style ol -->
+	<xsl:template match="text:list-level-style-number">
 	<xsl:text>.</xsl:text>
 	<xsl:value-of select="../@style:name"/>
 	<xsl:text>_</xsl:text>
@@ -272,115 +434,39 @@
 		<xsl:when test="@style:num-format='a'">lower-alpha</xsl:when>
 		<xsl:otherwise>decimal</xsl:otherwise>
 	</xsl:choose>
-	<xsl:text>;}</xsl:text>
+		<xsl:text>;}&#xa;</xsl:text>
 	<xsl:value-of select="$lineBreak"/>
-</xsl:template>
-<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
-<!--
-	This section of the transformation handles the true content
-	elements in the content.xml file
--->
-
-<!--
-	Yes, paragraphs in ODT really produce a <div> in XHTML,
-	because an ODT paragraph has no extra line spacing.
--->
-<xsl:template match="text:p">
-	<div class="{translate(@text:style-name,'.','_')}">
-		<xsl:apply-templates/>
-		<xsl:if test="count(node())=0"><br /></xsl:if>
-	</div>
-</xsl:template>
-
-<xsl:template match="text:span">
-	<span class="{translate(@text:style-name,'.','_')}">
-		<xsl:apply-templates/>
-	</span>
-</xsl:template>
-
-<xsl:template match="text:h">
-	<!-- Heading levels go only to 6 in XHTML -->
-	<xsl:variable name="level">
-		<xsl:choose>
-			<xsl:when test="@text:outline-level &gt; 6">6</xsl:when>
-			<xsl:otherwise>
-				<xsl:value-of select="@text:outline-level"/>
-			</xsl:otherwise>
-		</xsl:choose>
-	</xsl:variable>
-	<xsl:element name="{concat('h', $level)}">
+	</xsl:template>
+<!-- element table -->
+	<xsl:template match="table:table">
+		<table>
+			<xsl:if test="@table:style-name">
 		<xsl:attribute name="class">
-			<xsl:value-of
-			select="translate(@text:style-name,'.','_')"/>
+					<xsl:value-of select="@table:style-name"/>
 		</xsl:attribute>
-		<xsl:apply-templates/>
-	</xsl:element>
-</xsl:template>
-
-<!--
-	When processing a list, you have to look at the parent style
-	*and* level of nesting
--->
-<xsl:template match="text:list">
-	<xsl:variable name="level" select="count(ancestor::text:list)+1"/>
-	
-	<!-- the list class is the @text:style-name of the outermost
-		<text:list> element -->
-	<xsl:variable name="listClass">
-		<xsl:choose>
-			<xsl:when test="$level=1">
-				<xsl:value-of select="@text:style-name"/>
-			</xsl:when>
-			<xsl:otherwise>
-				<xsl:value-of select="
-					ancestor::text:list[last()]/@text:style-name"/>
-			</xsl:otherwise>
-		</xsl:choose>
-	</xsl:variable>
-	
-	<!-- Now select the <text:list-level-style-foo> element at this
-		level of nesting for this list -->
-	<xsl:variable name="node" select="key('listTypes',
-		$listClass)/*[@text:level='$level']"/>
-
-	<!-- emit appropriate list type -->
-	<xsl:choose>
-		<xsl:when test="local-name($node)='list-level-style-number'">
-			<ol class="{concat($listClass,'_',$level)}">
-				<xsl:apply-templates/>
-			</ol>
-		</xsl:when>
-		<xsl:otherwise>
-			<ul class="{concat($listClass,'_',$level)}">
-				<xsl:apply-templates/>
-			</ul>
-		</xsl:otherwise>
-	</xsl:choose>
-</xsl:template>
-
-<xsl:template match="text:list-item">
-	<li><xsl:apply-templates/></li>
-</xsl:template>
-
-<xsl:template match="table:table">
-	<table class="{@table:style-name}">
+				<caption><xsl:value-of select="@table:style-name"/></caption>
+			</xsl:if>
 		<colgroup>
 			<xsl:apply-templates select="table:table-column"/>
 		</colgroup>
 		<xsl:if test="table:table-header-rows/table:table-row">
 			<thead>
-			<xsl:apply-templates
-				select="table:table-header-rows/table:table-row"/>
+					<xsl:apply-templates select="table:table-header-rows/table:table-row"/>
 				</thead>
 		</xsl:if>
+			<xsl:if test="table:table-footer-rows/table:table-row">
+				<tfoot>
+					<xsl:apply-templates select="table:table-footer-rows/table:table-row"/>
+				</tfoot>
+			</xsl:if>
 		<tbody>
 		<xsl:apply-templates select="table:table-row"/>
 		</tbody>
 	</table>
-</xsl:template>
+	</xsl:template>
 
-<xsl:template match="table:table-column">
-<col>
+	<xsl:template match="table:table-column">
+		<col>
 	<xsl:if test="@table:number-columns-repeated">
 		<xsl:attribute name="span">
 			<xsl:value-of select="@table:number-columns-repeated"/>
@@ -391,16 +477,16 @@
 			<xsl:value-of select="translate(@table:style-name,'.','_')"/>
 		</xsl:attribute>
 	</xsl:if>
-</col>
-</xsl:template>
-
-<xsl:template match="table:table-row">
-<tr>
+		</col>
+	</xsl:template>
+<!-- element tr -->
+	<xsl:template match="table:table-row">
+	<tr>
 	<xsl:apply-templates select="table:table-cell"/>
-</tr>
-</xsl:template>
+	</tr>
+	</xsl:template>
 
-<xsl:template match="table:table-cell">
+	<xsl:template match="table:table-cell">
 	<xsl:variable name="n">
 		<xsl:choose>
 			<xsl:when test="@table:number-columns-repeated != 0">
@@ -412,16 +498,16 @@
 	<xsl:call-template name="process-table-cell">
 		<xsl:with-param name="n" select="$n"/>
 	</xsl:call-template>
-</xsl:template>
+	</xsl:template>
 
-<xsl:template name="process-table-cell">
+<!-- element td -->
+	<xsl:template name="process-table-cell">
 	<xsl:param name="n"/>
 	<xsl:if test="$n != 0">
 		<td>
 		<xsl:if test="@table:style-name">
 			<xsl:attribute name="class">
-				<xsl:value-of select="translate(@table:style-name,
-					'.','_')"/>
+						<xsl:value-of select="translate(@table:style-name,'.','_')"/>
 			</xsl:attribute>
 		</xsl:if>
 		<xsl:if test="@table:number-columns-spanned">
@@ -440,106 +526,309 @@
 			<xsl:with-param name="n" select="$n - 1"/>
 		</xsl:call-template>
 	</xsl:if>
-</xsl:template>
+	</xsl:template>
 
-<xsl:template match="text:tab">
-	<xsl:text xml:space="preserve">	</xsl:text>
-</xsl:template>
+	<xsl:key name="listTypes" match="text:list-style" use="@style:name"/>
+	<xsl:template match="text:list">
+		<xsl:variable name="level" select="count(ancestor::text:list)+1"/>
+		<!-- the list class is the @text:style-name of the outermost <text:list> element -->
+		<xsl:variable name="listClass">
+			<xsl:choose>
+				<xsl:when test="$level=1">
+					<xsl:value-of select="@text:style-name"/>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:value-of select="ancestor::text:list[last()]/@text:style-name"/>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
 
-<xsl:template match="text:line-break">
-	<br />
-</xsl:template>
+	<!-- Now select the <text:list-level-style-foo> element at this level of nesting for this list -->
+		<xsl:variable name="node" select="key('listTypes',$listClass)/*[@text:level='$level']"/>
 
-<xsl:variable name="spaces"
-    xml:space="preserve">                              </xsl:variable>
-
-<xsl:template match="text:s">
-<xsl:choose>
-    <xsl:when test="@text:c">
-        <xsl:call-template name="insert-spaces">
-            <xsl:with-param name="n" select="@text:c"/>
-        </xsl:call-template>
+	<!-- emit appropriate list type -->
+		<xsl:choose>
+		<!-- element ol -->
+			<xsl:when test="local-name($node)='list-level-style-number'">
+				<ol class="{concat($listClass,'_',$level)}">
+					<xsl:apply-templates/>
+				</ol>
     </xsl:when>
+		<!-- element ul -->
     <xsl:otherwise>
-        <xsl:text> </xsl:text>
+				<ul class="{concat($listClass,'_',$level)}">
+					<xsl:apply-templates/>
+				</ul>
     </xsl:otherwise>
-</xsl:choose>
-</xsl:template>
+		</xsl:choose>
+	</xsl:template>
 
-<xsl:template name="insert-spaces">
-<xsl:param name="n"/>
-<xsl:choose>
-    <xsl:when test="$n &lt;= 30">
-        <xsl:value-of select="substring($spaces, 1, $n)"/>
-    </xsl:when>
+<!-- element li -->
+	<xsl:template match="text:list-item">
+		<li><xsl:apply-templates/></li>
+	</xsl:template>
     
+<!-- manage office:document-meta -->
+	<xsl:template match="office:document-meta">
+		<xsl:apply-templates/>
+	</xsl:template>
+	
+<!-- element meta -->
+	<xsl:template match="office:meta">
+		<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"/>
+		<xsl:comment> Metadata starts </xsl:comment>
+		<xsl:apply-templates select="meta:generator"/>
+		<xsl:apply-templates select="dc:title"/>
+		<xsl:apply-templates select="dc:description"/>
+		<xsl:apply-templates select="dc:subject"/>
+		<xsl:apply-templates select="meta:keyword"/>
+		<xsl:apply-templates select="meta:initial-creator"/>
+		<xsl:apply-templates select="dc:creator"/>
+		<xsl:apply-templates select="meta:creation-date"/>
+		<xsl:apply-templates select="dc:date"/>
+		<xsl:apply-templates select="dc:language"/>	
+		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
+		<meta name="DC.Format" scheme="IMT" content="charset=UTF-8" />
+		<meta name="DC.Format" scheme="IMT" content="text/html" />
+		<xsl:comment> Metadata ends </xsl:comment>
+	</xsl:template>
+
+<!-- meta generator -->	
+	<xsl:template match="meta:generator">
+		<meta name="generator" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc title -->
+	<xsl:template match="dc:title">
+		<title><xsl:apply-templates/></title>
+		<meta name="DC.Title" content="{current()}"/>
+	</xsl:template>
+
+<!-- dc description -->
+	<xsl:template match="dc:description">
+		<meta name="Description" content="{current()}"/>
+		<meta name="DC.Description" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc subject -->
+	<xsl:template match="dc:subject">
+	<meta name="DC.Subject" content="{current()}"/>
+	</xsl:template>
+	
+<!-- meta keyword -->
+	<xsl:template match="meta:keyword">
+		<meta name="keywords" content="{current()}"/>
+	</xsl:template>
+
+<!-- meta initial creator -->
+	<xsl:template match="meta:initial-creator">
+		<meta name="author" content="{current()}"/>
+		<meta name="DC.Creator" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc creator -->
+	<xsl:template match="dc:creator">
+		<meta name="DC.Contributor" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc language -->
+	<xsl:template match="dc:language">
+		<meta http-equiv="content-language" content="{current()}"/>
+		<meta name="DC.Language" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc description -->
+	<xsl:template match="dc:description">
+		<meta name="description" content="{current()}"/>
+		<meta name="DC.Description" content="{current()}"/>
+	</xsl:template>
+	
+<!-- meta creation date -->
+	<xsl:template match="meta:creation-date">
+		<meta name="DC.Date.created" content="{current()}"/>
+		<meta name="DC.Date.dateCopyrighted" content="{current()}"/>
+	</xsl:template>
+
+<!-- dc date -->
+	<xsl:template match="dc:date">
+		<meta name="revised" content="{current()}"/>
+		<meta name="DC.Date.modified" content="{current()}"/>
+	</xsl:template>
+
+	<xsl:param name="param_track_changes"/>
+	<xsl:template match="text:tracked-changes">
+		<xsl:comment> Document has track-changes on </xsl:comment>
+	</xsl:template>
+
+	<xsl:template match="text:change">
+	<xsl:if test="$param_track_changes">
+		<xsl:variable name="id" select="@text:change-id"/>
+		<xsl:variable name="change" select="//text:changed-region[@text:id=$id]"/>
+		<xsl:element name="del">
+			<xsl:attribute name="datetime">
+				<xsl:value-of select="$change//dc:date"/>
+			</xsl:attribute>
+			<!--<xsl:apply-templates match="$change/text:deletion/*"/>-->
+		</xsl:element>
+ 	</xsl:if>
+	</xsl:template>
+
+	<xsl:template match="office:change-info"/>
+	<xsl:param name="param_baseuri"/>
+	<xsl:template match="draw:frame">
+		<xsl:choose>
+			<!-- if parent text:h -->
+			<xsl:when test="ancestor::text:h">
+				<xsl:element name="span">
+					<xsl:attribute name="class">
+						<xsl:value-of select="translate(@draw:style-name,'.','_')"/>
+					</xsl:attribute>
+					<xsl:attribute name="style">
+					<!-- This border could be removed, but OOo does default to showing a border. 
+						<xsl:text> border: 1px solid #888;</xsl:text> -->
+						<xsl:if test="@svg:width">width: <xsl:value-of select="substring-before(@svg:width,'px')+2"/>px; </xsl:if>
+						<xsl:if test="@svg:height">height: <xsl:value-of select="substring-before(@svg:height,'px')+2"/>px; </xsl:if>
+					</xsl:attribute>
+					<xsl:choose>
+						<xsl:when test="ancestor::draw:a">
+							<xsl:element name="a">
+								<xsl:attribute name="href">
+									<xsl:value-of select="../@xlink:href"/>
+								</xsl:attribute>
+								<xsl:attribute name="title">
+									<xsl:value-of select="../@office:name"/>
+								</xsl:attribute>
+								<xsl:apply-templates/>
+							</xsl:element>
+						</xsl:when>
+						<xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+					</xsl:choose>
+				</xsl:element>
+			</xsl:when>
+			<!-- if parent is text:p -->
+			<xsl:when test="ancestor::text:p">
+				<xsl:element name="div">
+					<xsl:attribute name="class">
+						<xsl:value-of select="translate(@draw:style-name,'.','_')"/>
+					</xsl:attribute>
+					<xsl:attribute name="style">
+					<!-- This border could be removed, but OOo does default to showing a border. -->
+						<xsl:text>border: 1px solid #888; </xsl:text>
+						<xsl:if test="@svg:width"><!-- div width modified -->
+							<xsl:text>width: </xsl:text>
+							<xsl:choose>
+								<xsl:when test="ancestor::draw:frame">
+									<xsl:value-of select="substring-before(@svg:width,'px')+2"/>
+								</xsl:when>
+								<xsl:when test="ancestor::text:p">
+									<xsl:value-of select="substring-before(@svg:width,'px')+4"/>
+								</xsl:when>
     <xsl:otherwise>
-        <xsl:value-of select="$spaces"/>
-        <xsl:call-template name="insert-spaces">
-            <xsl:with-param name="n">
-                <xsl:value-of select="$n - 30"/>
-            </xsl:with-param>
-        </xsl:call-template>
+									<xsl:value-of select="substring-before(@svg:width,'px')"/>
     </xsl:otherwise>
-</xsl:choose>
-</xsl:template>
+							</xsl:choose>
+							<xsl:text>px; </xsl:text>
+						</xsl:if>
+						<xsl:if test="@svg:height"><!-- div height modified -->
+							<xsl:text>height: </xsl:text>
+							<xsl:choose>
+								<xsl:when test="ancestor::draw:frame">
+									<xsl:value-of select="substring-before(@svg:height,'px')+2"/>
+								</xsl:when>
+								<xsl:when test="ancestor::text:p">
+									<xsl:value-of select="substring-before(@svg:height,'px')+4"/>
+								</xsl:when>
+								<xsl:otherwise>
+									<xsl:value-of select="substring-before(@svg:height,'px')"/>
+								</xsl:otherwise>
+							</xsl:choose>
+							<xsl:text>px; </xsl:text>
+						</xsl:if>
+					</xsl:attribute>
+					<xsl:choose>
+						<xsl:when test="ancestor::draw:a">
+							<xsl:element name="a">
+								<xsl:attribute name="href">
+									<xsl:value-of select="../@xlink:href"/>
+								</xsl:attribute>
+								<xsl:attribute name="title">
+									<xsl:value-of select="../@office:name"/>
+								</xsl:attribute>
+								<xsl:apply-templates/>
+							</xsl:element>
+						</xsl:when>
+						<xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+					</xsl:choose>
+				</xsl:element>
+			</xsl:when>
+		</xsl:choose>
+	</xsl:template>
 
-<xsl:template match="text:a">
-<a href="{@xlink:href}"><xsl:apply-templates/></a>
-</xsl:template>
+	<xsl:template match="draw:frame/draw:image">
+		<xsl:element name="img">
+    	<!-- Default behaviour
+    		<xsl:attribute name="style">
+			width: 100%;
+			height: 100%;
+			<xsl:if test="not(../@text:anchor-type='character')">
+        	display: block;
+			</xsl:if>
+			</xsl:attribute>
+		-->
+			<xsl:if test="not(../@text:anchor-type='character')">
+				<xsl:attribute name="style">display: block;</xsl:attribute>
+	</xsl:if>
 
-<!--
-	<text:bookmark-start /> and <text:bookmark-end /> can
-	be on non-wellformed boundaries. The quickest solution is
-	to create an <a name=""></a> element.
+			<xsl:attribute name="width">
+				<xsl:value-of select="substring-before(../@svg:width,'px')"/>
+			</xsl:attribute>
+			
+			<xsl:attribute name="height">
+				<xsl:value-of select="substring-before(../@svg:height,'px')"/>
+			</xsl:attribute>
+		
+			<xsl:attribute name="alt">
+				<!--<xsl:value-of select="../svg:desc"/>-->
+				<xsl:value-of select="../@draw:name"/>
+			</xsl:attribute>
+			
+			<xsl:attribute name="src">
+				<xsl:value-of select="concat($param_baseuri,@xlink:href)"/>
+				<!--<xsl:value-of select="@xlink:href"/>-->
+			</xsl:attribute>
+			
+			<xsl:if test="../svg:desc">
+				<xsl:attribute name="longdesc">
+					<xsl:value-of select="../svg:desc"/>
+				</xsl:attribute>
+			</xsl:if>		
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="svg:desc"/>
 	
-	If you don't put in any content, it becomes an empty element,
-	which will confuse browsers. While we would love to insert
-	a zero-width non-breaking space (Unicode 0x200b), Internet
-	Explorer doesn't recognize it.  Hence this ugly hack:
--->
-<xsl:template match="text:bookmark-start|text:bookmark">
-<a name="{@text:name}"><span style="font-size: 0px"><xsl:text> </xsl:text></span></a>
-</xsl:template>
+	<xsl:template match="text:table-of-content">
+	<!-- We don't parse the app's ToC but generate our own. -->
+	<div class="toc">
+		<xsl:apply-templates select="text:index-body/text:index-title"/>
+		<xsl:apply-templates select="//text:h" mode="toc"/>
+	</div>
+	</xsl:template>
 
-<!--
-	This template is too dangerous to leave active...
-<xsl:template match="text()">
-	<xsl:if test="normalize-space(.) !=''">
-		<xsl:value-of select="normalize-space(.)"/>
-	</xsl:if>
-</xsl:template>
--->
+	<xsl:template match="text:h" mode="toc">
+	<xsl:element name="p">
+		<xsl:attribute name="class">
+			<xsl:text>toc_outline_level_</xsl:text>
+			<xsl:choose>
+				<xsl:when test="@text:outline-level">
+					<xsl:value-of select="@text:outline-level"/>
+				</xsl:when>
+				<!-- ODF spec says that when unspecified the outline level should be considered to be 1. -->
+				<xsl:otherwise>1</xsl:otherwise>
+			</xsl:choose>
+		</xsl:attribute>
+		<a href="#{generate-id()}"><xsl:value-of select="."/></a>
+		</xsl:element>
+	</xsl:template>
 
-<!--
-	This is a list of fo: attributes to be transferred to the
-	output document. The action tells which template is to be
-	called to process the attribute.
--->
-<int:attr-map>
-	<int:attr name="fo:border-left" action="pass-through"/>
-	<int:attr name="fo:border-right" action="pass-through"/>
-	<int:attr name="fo:border-top" action="pass-through"/>
-	<int:attr name="fo:border-bottom" action="pass-through"/>
-	<int:attr name="fo:border" action="pass-through"/>
-	<int:attr name="fo:margin-left" action="pass-through"/>
-	<int:attr name="fo:margin-right" action="pass-through"/>
-	<int:attr name="fo:margin-top" action="pass-through"/>
-	<int:attr name="fo:margin-bottom" action="pass-through"/>
-	<int:attr name="fo:margin" action="pass-through"/>
-	<int:attr name="fo:padding-left" action="pass-through"/>
-	<int:attr name="fo:padding-right" action="pass-through"/>
-	<int:attr name="fo:padding-top" action="pass-through"/>
-	<int:attr name="fo:padding-bottom" action="pass-through"/>
-	<int:attr name="fo:padding" action="pass-through"/>
-	<int:attr name="fo:text-indent" action="pass-through"/>
-	<int:attr name="fo:font-variant" action="pass-through"/>
-	<int:attr name="fo:font-family" action="pass-through"/>
-	<int:attr name="fo:color" action="pass-through"/>
-	<int:attr name="fo:background-color" action="pass-through"/>
-	<int:attr name="fo:font-style" action="pass-through"/>
-	<int:attr name="fo:font-weight" action="pass-through"/>
-	<int:attr name="fo:line-height" action="pass-through"/>
-	<int:attr name="fo:text-align" action="check-align"/>
-</int:attr-map>
 </xsl:stylesheet>

Added: people/sigurdne/modules/manual/trunk/templates/base/sxw2xhtml.xsl
===================================================================
--- people/sigurdne/modules/manual/trunk/templates/base/sxw2xhtml.xsl	                        (rev 0)
+++ people/sigurdne/modules/manual/trunk/templates/base/sxw2xhtml.xsl	2009-11-20 10:27:37 UTC (rev 20843)
@@ -0,0 +1,844 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" 
+	xmlns:office="http://openoffice.org/2000/office" 
+	xmlns:meta="http://openoffice.org/2000/meta" 
+	xmlns:text="http://openoffice.org/2000/text" 
+	xmlns:table="http://openoffice.org/2000/table" 
+	xmlns:draw="http://openoffice.org/2000/drawing" 
+	xmlns:presentation="http://openoffice.org/2000/presentation" 
+	xmlns:chart="http://openoffice.org/2000/chart" 
+	xmlns:form="http://openoffice.org/2000/form" 
+	xmlns:script="http://openoffice.org/2000/script" 
+	xmlns:style="http://openoffice.org/2000/style" 
+	xmlns:dc="http://purl.org/dc/elements/1.1/" 
+	xmlns:xlink="http://www.w3.org/1999/xlink" 
+	xmlns:math="http://www.w3.org/1998/Math/MathML" 
+	xmlns:xforms="http://www.w3.org/2002/xforms" 
+	xmlns:fo="http://www.w3.org/1999/XSL/Format" 
+	xmlns:svg="http://www.w3.org/2000/svg" 
+	xmlns:smil="http://www.w3.org/TR/REC-smil" 
+	xmlns:ooo="http://openoffice.org/2004/office" 
+	xmlns:ooow="http://openoffice.org/2004/writer" 
+	xmlns:oooc="http://openoffice.org/2004/calc" 
+	xmlns:int="http://opendocumentfellowship.org/internal" 
+	xmlns="http://www.w3.org/1999/xhtml" 
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+	exclude-result-prefixes="office meta text table draw presentation chart form script style dc xlink math xforms fo svg smil ooo ooow oooc int #default">
+	
+	<xsl:output 
+	method="xml" 
+	indent="yes" 
+	omit-xml-declaration="yes" 
+	encoding="UTF-8" 
+	doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
+	doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+	/>
+
+<!--
+100 dpi <=> x*38.37
+72 dpi <=> x*28.6264
+-->
+	
+	<xsl:variable name="lineBreak">
+		<xsl:text>
+		</xsl:text>
+	</xsl:variable>
+	
+	<xsl:template match="/office:document">
+		<html xmlns="http://www.w3.org/1999/xhtml">
+			<xsl:attribute name="xml:lang"><xsl:value-of select="substring(office:document-meta/office:meta/dc:language,1,2)"/></xsl:attribute>
+			<xsl:attribute name="lang"><xsl:value-of select="substring(office:document-meta/office:meta/dc:language,1,2)"/></xsl:attribute>
+		<head>
+			<xsl:apply-templates select="office:document-meta"/>
+			<xsl:call-template name="process-all-styles"/>
+		</head>
+		<xsl:apply-templates select="office:document-content"/>
+		</html>
+	</xsl:template>
+	
+	<xsl:template match="office:document-content">
+		<body>
+			<xsl:comment> office:body </xsl:comment>
+			<xsl:apply-templates select="office:body"/>
+			<xsl:comment> add-footnote-bodies </xsl:comment>
+			<xsl:call-template name="add-footnote-bodies"/>
+		</body>
+	</xsl:template>	
+	
+<!-- element p -->	
+	<xsl:template match="text:p">
+		<xsl:choose>
+			<xsl:when test="descendant::draw:*">
+				<xsl:apply-templates/>
+				<xsl:if test="count(node())=0"><br/></xsl:if>
+			</xsl:when>
+			
+			<xsl:when test="@text:style-name='Quotations' and node()">
+				<blockquote>
+					<p class="{translate(@text:style-name,'.','_')}">
+						<xsl:apply-templates/>
+					</p>
+				</blockquote>
+			</xsl:when>
+			
+			<xsl:otherwise>
+				<p class="{translate(@text:style-name,'.','_')}">
+					<xsl:apply-templates/>
+					<xsl:if test="count(node())=0"><br/></xsl:if>
+				</p>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+<!-- element span -->	
+	<xsl:template match="text:span">
+	<span class="{translate(@text:style-name,'.','_')}">
+		<xsl:apply-templates/>
+	</span>
+	</xsl:template>
+	
+<!-- element h -->
+	<xsl:template match="text:h">
+	<!-- Heading levels go only to 6 in XHTML -->
+	<xsl:if test="node()">
+		<xsl:variable name="level">
+    		<xsl:choose>
+			<!-- text:outline-level is optional, default is 1 -->
+				<xsl:when test="not(@text:outline-level)">1</xsl:when>
+				<xsl:when test="@text:outline-level &gt; 6">6</xsl:when>
+				<xsl:otherwise>
+					<xsl:value-of select="@text:outline-level"/>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+
+		<xsl:element name="{concat('h', $level)}">
+    		<xsl:attribute name="class">
+				<xsl:value-of select="translate(@text:style-name,'.','_')"/>
+    		</xsl:attribute>
+    		<a name="{generate-id()}"/>
+    		<xsl:apply-templates/>
+		</xsl:element>
+	</xsl:if>
+	</xsl:template>
+	
+	<!-- this elements are not defined by ODF -->
+	<xsl:template match="text:header">
+		<div>
+			<xsl:attribute name="id">
+				<xsl:text>header</xsl:text>
+			</xsl:attribute>
+			<xsl:apply-templates/>
+		</div>
+	</xsl:template>
+	
+	<xsl:template match="text:footer">
+		<div>
+			<xsl:attribute name="id">
+				<xsl:text>footer</xsl:text>
+			</xsl:attribute>
+			<xsl:apply-templates/>
+		</div>
+	</xsl:template>
+	
+	<xsl:template match="text:sub">
+		<sub class="{translate(@text:style-name,'.','_')}"><xsl:apply-templates/></sub>
+	</xsl:template>
+	
+	<xsl:template match="text:sup">
+		<sup class="{translate(@text:style-name,'.','_')}"><xsl:apply-templates/></sup>
+	</xsl:template>
+	<!-- end adding -->
+	
+<!-- preserve tabulation -->
+	<xsl:template match="text:tab">
+		<xsl:text xml:space="preserve"> </xsl:text>
+	</xsl:template>
+	
+<!-- element br -->
+	<xsl:template match="text:line-break">
+	<br/>
+	</xsl:template>
+	
+<!-- preserve spaces -->
+	<xsl:variable name="spaces" xml:space="preserve"/>
+	
+	<xsl:template match="text:s">
+		<xsl:choose>
+			<xsl:when test="@text:c">
+				<xsl:call-template name="insert-spaces">
+					<xsl:with-param name="n" select="@text:c"/>
+				</xsl:call-template>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:text> </xsl:text>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+<!-- insert spaces -->
+	<xsl:template name="insert-spaces">
+	<xsl:param name="n"/>
+		<xsl:choose>
+			<xsl:when test="$n &lt;= 30">
+				<xsl:value-of select="substring($spaces, 1, $n)"/>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:value-of select="$spaces"/>
+				<xsl:call-template name="insert-spaces">
+					<xsl:with-param name="n">
+						<xsl:value-of select="$n - 30"/>
+					</xsl:with-param>
+				</xsl:call-template>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+<!-- element a -->
+	<xsl:template match="text:a">
+		<a href="{@xlink:href}"><xsl:apply-templates/></a>
+	</xsl:template>
+<!-- preserve bookmark -->	
+	<xsl:template match="text:bookmark-start|text:bookmark">
+		<a name="{@text:name}">
+			<span style="font-size: 0px">
+				<xsl:text> </xsl:text>
+			</span>
+		</a>
+	</xsl:template>
+<!-- preserve footnote -->
+  <xsl:template match="text:note">
+	<xsl:variable name="footnote-id" select="text:note-citation"/>
+	<a href="#footnote-{$footnote-id}">
+		<sup><xsl:value-of select="$footnote-id"/></sup>
+	</a>
+	</xsl:template>
+<!-- preserve note body -->
+	<xsl:template match="text:note-body"/>
+	<xsl:template name="add-footnote-bodies">
+		<xsl:apply-templates select="//text:note" mode="add-footnote-bodies"/>
+	</xsl:template>
+<!-- preserve footnote bodies -->
+	<xsl:template match="text:note" mode="add-footnote-bodies">
+		<xsl:variable name="footnote-id" select="text:note-citation"/>
+			<p><a name="footnote-{$footnote-id}"><sup><xsl:value-of select="$footnote-id"/></sup>:</a></p>
+		<xsl:apply-templates select="text:note-body/*"/>
+	</xsl:template>
+
+<!-- procede all styles -->
+	<xsl:template name="process-all-styles">
+	<style type="text/css">
+	/* ODF paragraphs, by default, don't have any line spacing. */
+	p { margin: 0px; padding: 0px; }
+	/* put a default link style in, so we can see links */
+	a[href] { color: blue; text-decoration: underline; }
+	
+	<xsl:apply-templates select="office:document-styles/office:styles"/>
+	<xsl:apply-templates select="office:document-content/office:automatic-styles"/>
+	<xsl:call-template name="toc-styles"/>
+	</style>
+	</xsl:template>
+	
+<!-- procede toc styles -->
+	<xsl:template name="toc-styles">
+		<xsl:apply-templates select="//text:table-of-content" mode="toc-styles"/>
+	</xsl:template>
+
+	<xsl:template match="text:table-of-content" mode="toc-styles">
+	<!-- Generate styles for the ToC -->
+		/* ToC styles start */
+		<xsl:apply-templates select="//@text:outline-level" mode="toc-styles"/>
+		/* ToC styles end */
+	</xsl:template>
+
+	<xsl:template match="@text:outline-level" mode="toc-styles">
+	<xsl:text>.toc_outline_level_</xsl:text>
+	<xsl:value-of select="."/>
+	<xsl:text> { margin-left: </xsl:text>
+	<xsl:value-of select="round(current()*0.5*28.6264)"/> <!-- modified : transform cm in px for 72 dpi -->
+	<xsl:text>px; }&#xa;</xsl:text>
+
+	<xsl:value-of select="$lineBreak"/>
+
+	<xsl:text>.toc_outline_level_</xsl:text>
+	<xsl:value-of select="."/>
+	<xsl:text> a { text-decoration: none } &#xa;</xsl:text>
+
+	<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+
+	<xsl:template match="*" mode="toc-styles"/>
+	
+	<xsl:template match="office:document-styles/office:styles">
+		/* Document styles start */
+		<xsl:apply-templates/>
+		/* Document styles end */
+	</xsl:template>
+	
+	<xsl:template match="office:document-content/office:automatic-styles">
+		/* Automatic styles start */
+		<xsl:apply-templates/>
+		/* Automatic styles end */
+	</xsl:template>
+	
+	<xsl:template match="style:default-style">
+		<xsl:choose>
+    		<xsl:when test="@style:family='table'">
+       		 	<xsl:text>table</xsl:text>
+    		</xsl:when>
+    		<xsl:when test="@style:family='table-cell'">
+      		  	<xsl:text>td</xsl:text>
+    		</xsl:when>
+    		<xsl:when test="@style:family='table-row'">
+    		    <xsl:text>tr</xsl:text>
+    		</xsl:when>
+    		<xsl:when test="@style:family='paragraph'">
+				<xsl:text>p</xsl:text>
+    		</xsl:when>
+    		<xsl:when test="@style:family='text'">
+    		    <xsl:text>p</xsl:text>
+    		</xsl:when>
+    		<xsl:otherwise>
+				<xsl:text>.default_</xsl:text>
+				<xsl:value-of select="translate(@style:family,'.','_')"/>
+			</xsl:otherwise>
+		</xsl:choose>
+		<xsl:text> {</xsl:text><xsl:value-of select="$lineBreak"/>
+   
+		<xsl:call-template name="process-styles">
+			<xsl:with-param name="node" select="."/>
+		</xsl:call-template>
+
+		<xsl:text>}&#xa;</xsl:text>
+	</xsl:template>
+
+	<xsl:template match="style:style">
+		<xsl:text>.</xsl:text>
+		<xsl:value-of select="translate(@style:name,'.','_')"/>
+		<xsl:text> {</xsl:text><xsl:value-of select="$lineBreak"/>
+
+		<xsl:call-template name="process-styles">
+			<xsl:with-param name="node" select="."/>
+		</xsl:call-template>
+
+		<xsl:text>}&#xa;</xsl:text>
+	</xsl:template>
+
+	<xsl:template name="process-styles">
+		<xsl:param name="node"/>
+		<xsl:if test="$node/@style:parent-style-name">
+			<xsl:variable name="parentStyle" select="$node/@style:parent-style-name"/>
+			<xsl:call-template name="process-styles">
+				<xsl:with-param name="node" select="//style:style[@style:name=$parentStyle]"/>
+		    </xsl:call-template>
+		</xsl:if>
+
+		<xsl:apply-templates select="$node/style:properties/@*" mode="styleattr"/>
+		<!--<xsl:apply-templates select="$node/style:text-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:table-cell-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:table-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:table-column-properties/@*" mode="styleattr"/>
+		<xsl:apply-templates select="$node/style:graphic-properties/@*" mode="styleattr"/>-->
+	</xsl:template>
+
+	<xsl:template match="@fo:border-left|@fo:border-right|@fo:border-top|@fo:border-bottom|@fo:border|@fo:margin-left|@fo:margin-right|@fo:margin-top|@fo:margin-bottom|@fo:margin|@fo:padding-left|@fo:padding-right|@fo:padding-top|@fo:padding-bottom|@fo:padding|@fo:text-align|@fo:text-indent|@fo:font-variant|@fo:font-family|@fo:color|@fo:background-color|@fo:font-size|@svg:font-family|@fo:font-style|@fo:font-weight|@fo:line-height|@style:width" mode="styleattr">
+		<xsl:call-template name="pass-through"/>
+	</xsl:template>
+
+	<xsl:template match="@style:text-background-color" mode="styleattr">
+		<xsl:text>background-color: </xsl:text>
+		<xsl:value-of select="."/><xsl:text>; </xsl:text>
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+
+	<xsl:template match="@style:font-name" mode="styleattr">
+		<xsl:text>font-family: '</xsl:text>
+		<xsl:value-of select="."/><xsl:text>'; </xsl:text>
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+
+	<xsl:template match="@style:text-underline-style|@style:text-underline-type" mode="styleattr">
+<!-- CSS2 only has one type of underline.
+	We can improve this when CSS3 is better supported.
+-->
+		<xsl:if test="not(.='none')">
+			<xsl:text>text-decoration: underline; </xsl:text>
+		</xsl:if>
+	</xsl:template>
+
+	<xsl:template match="@fo:text-align" mode="styleattr">
+		<xsl:value-of select="local-name()"/><xsl:text>: </xsl:text>
+		<xsl:choose>
+			<xsl:when test=".='start'"><xsl:text>left</xsl:text></xsl:when>
+			<xsl:when test=".='end'"><xsl:text>right</xsl:text></xsl:when>
+			<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
+		</xsl:choose>
+		<xsl:text>; </xsl:text>
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+
+	<xsl:template match="@style:horizontal-pos" mode="styleattr">
+		<xsl:choose>
+	<!-- We can't support the others until we figure out pagination. -->
+			<xsl:when test=".='left'">
+   				/* Left alignment */
+   				<xsl:text>margin-left: 0; margin-right: auto;</xsl:text>
+			</xsl:when>
+			<xsl:when test=".='right'">
+   				/* Right alignment */
+   				<xsl:text>margin-left: auto; margin-right: 0;</xsl:text>
+			</xsl:when>
+			<xsl:when test=".='center'">
+   				/* Centered alignment */
+   				<xsl:text>margin: 0 auto;</xsl:text>
+			</xsl:when>
+		</xsl:choose>
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+
+	<xsl:template match="@style:column-width" mode="styleattr">
+		<xsl:text>width: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+	</xsl:template>
+
+	<xsl:template match="@*" mode="styleattr">
+		<!-- don't output anything for attrs we don't understand -->
+	</xsl:template>
+
+	<xsl:template name="pass-through">
+		<xsl:value-of select="local-name()"/><xsl:text>: </xsl:text>
+		<xsl:value-of select="."/>
+		<xsl:text>; </xsl:text>
+		
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+<!-- style li -->
+	<xsl:template match="text:list-level-style-bullet">
+		<xsl:text>.</xsl:text>
+		<xsl:value-of select="../@style:name"/>
+		<xsl:text>_</xsl:text>
+		<xsl:value-of select="@text:level"/>
+		<xsl:text> { list-style-type: </xsl:text>
+		<xsl:choose>
+			<xsl:when test="@text:level mod 3 = 1">disc</xsl:when>
+			<xsl:when test="@text:level mod 3 = 2">circle</xsl:when>
+			<xsl:when test="@text:level mod 3 = 0">square</xsl:when>
+			<xsl:otherwise>decimal</xsl:otherwise>
+		</xsl:choose>
+		<xsl:text>;}&#xa;</xsl:text>
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+<!-- style ol -->
+	<xsl:template match="text:list-level-style-number">
+		<xsl:text>.</xsl:text>
+		<xsl:value-of select="../@style:name"/>
+		<xsl:text>_</xsl:text>
+		<xsl:value-of select="@text:level"/>
+		<xsl:text> { list-style-type: </xsl:text>
+		<xsl:choose>
+			<xsl:when test="@style:num-format='1'">decimal</xsl:when>
+			<xsl:when test="@style:num-format='I'">upper-roman</xsl:when>
+			<xsl:when test="@style:num-format='i'">lower-roman</xsl:when>
+			<xsl:when test="@style:num-format='A'">upper-alpha</xsl:when>
+			<xsl:when test="@style:num-format='a'">lower-alpha</xsl:when>
+			<xsl:otherwise>decimal</xsl:otherwise>
+		</xsl:choose>
+		<xsl:text>;}&#xa;</xsl:text>
+		<xsl:value-of select="$lineBreak"/>
+	</xsl:template>
+<!-- element table -->
+	<xsl:template match="table:table">
+		<table>
+			<xsl:if test="@table:style-name">
+				<xsl:attribute name="class">
+					<xsl:value-of select="@table:style-name"/>
+				</xsl:attribute>
+				<caption><xsl:value-of select="@table:style-name"/></caption>
+			</xsl:if>
+				<colgroup>
+					<xsl:apply-templates select="table:table-column"/>
+				</colgroup>
+			<xsl:if test="table:table-header-rows/table:table-row">
+				<thead>
+					<xsl:apply-templates select="table:table-header-rows/table:table-row"/>
+				</thead>
+			</xsl:if>
+			<xsl:if test="table:table-footer-rows/table:table-row">
+				<thead>
+					<xsl:apply-templates select="table:table-footer-rows/table:table-row"/>
+				</thead>
+			</xsl:if>
+			<tbody>
+				<xsl:apply-templates select="table:table-row"/>
+			</tbody>
+		</table>
+	</xsl:template>
+	
+	<xsl:template match="table:sub-table">
+		<table>
+			<xsl:if test="@table:style-name">
+				<xsl:attribute name="class">
+					<xsl:value-of select="@table:style-name"/>
+				</xsl:attribute>
+			</xsl:if>
+				<colgroup>
+					<xsl:apply-templates select="table:table-column"/>
+				</colgroup>
+			<xsl:if test="table:table-header-rows/table:table-row">
+				<thead>
+					<xsl:apply-templates select="table:table-header-rows/table:table-row"/>
+				</thead>
+			</xsl:if>
+			<xsl:if test="table:table-footer-rows/table:table-row">
+				<thead>
+					<xsl:apply-templates select="table:table-footer-rows/table:table-row"/>
+				</thead>
+			</xsl:if>
+			<tbody>
+				<xsl:apply-templates select="table:table-row"/>
+			</tbody>
+		</table>
+	</xsl:template>
+	
+	<xsl:template match="table:table-column">
+		<col>
+			<xsl:if test="@table:number-columns-repeated">
+				<xsl:attribute name="span">
+					<xsl:value-of select="@table:number-columns-repeated"/>
+				</xsl:attribute>
+			</xsl:if>
+			<xsl:if test="@table:style-name">
+				<xsl:attribute name="class">
+					<xsl:value-of select="translate(@table:style-name,'.','_')"/>
+				</xsl:attribute>
+			</xsl:if>
+		</col>
+	</xsl:template>
+<!-- element tr -->
+	<xsl:template match="table:table-row">
+	<tr>
+		<xsl:apply-templates select="table:table-cell"/>
+	</tr>
+	</xsl:template>
+
+	<xsl:template match="table:table-cell">
+		<xsl:variable name="n">
+			<xsl:choose>
+				<xsl:when test="@table:number-columns-repeated != 0">
+					<xsl:value-of select="@table:number-columns-repeated"/>
+				</xsl:when>
+				<xsl:otherwise>1</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:call-template name="process-table-cell">
+			<xsl:with-param name="n" select="$n"/>
+		</xsl:call-template>
+	</xsl:template>
+	
+<!-- element td -->
+	<xsl:template name="process-table-cell">
+	<xsl:param name="n"/>
+		<xsl:if test="$n != 0">
+			<td>
+				<xsl:if test="@table:style-name">
+					<xsl:attribute name="class">
+						<xsl:value-of select="translate(@table:style-name,'.','_')"/>
+					</xsl:attribute>
+				</xsl:if>
+				<xsl:if test="@table:number-columns-spanned">
+					<xsl:attribute name="colspan">
+						<xsl:value-of select="@table:number-columns-spanned"/>
+					</xsl:attribute>
+				</xsl:if>
+				<xsl:if test="@table:number-rows-spanned">
+					<xsl:attribute name="rowspan">
+						<xsl:value-of select="@table:number-rows-spanned"/>
+					</xsl:attribute>
+				</xsl:if>
+				<xsl:apply-templates/>
+			</td>
+			<xsl:call-template name="process-table-cell">
+				<xsl:with-param name="n" select="$n - 1"/>
+			</xsl:call-template>
+		</xsl:if>
+	</xsl:template>
+
+	<xsl:key name="listTypes" match="text:list-style" use="@style:name"/>
+	<xsl:template match="text:list">
+		<xsl:variable name="level" select="count(ancestor::text:list)+1"/>
+		<!-- the list class is the @text:style-name of the outermost <text:list> element -->
+		<xsl:variable name="listClass">
+			<xsl:choose>
+				<xsl:when test="$level=1">
+					<xsl:value-of select="@text:style-name"/>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:value-of select="ancestor::text:list[last()]/@text:style-name"/>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+ 
+	<!-- Now select the <text:list-level-style-foo> element at this level of nesting for this list -->
+		<xsl:variable name="node" select="key('listTypes',$listClass)/*[@text:level='$level']"/>
+
+	<!-- emit appropriate list type -->
+		<xsl:choose>
+		<!-- element ol -->
+			<xsl:when test="local-name($node)='list-level-style-number'">
+				<ol class="{concat($listClass,'_',$level)}">
+					<xsl:apply-templates/>
+				</ol>
+			</xsl:when>
+		<!-- element ul -->
+			<xsl:otherwise>
+				<ul class="{concat($listClass,'_',$level)}">
+					<xsl:apply-templates/>
+				</ul>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+<!-- element li -->
+	<xsl:template match="text:list-item">
+		<li><xsl:apply-templates/></li>
+	</xsl:template>
+
+<!-- manage office:document-meta -->
+	<xsl:template match="office:document-meta">
+		<xsl:apply-templates/>
+	</xsl:template>
+	
+<!-- element meta -->
+	<xsl:template match="office:meta">
+		<link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"/>
+		<xsl:comment> Metadata starts </xsl:comment>
+		<xsl:apply-templates select="meta:generator"/>
+		<xsl:apply-templates select="dc:title"/>
+		<xsl:apply-templates select="dc:description"/>
+		<xsl:apply-templates select="dc:subject"/>
+		<xsl:apply-templates select="meta:keyword"/>
+		<xsl:apply-templates select="meta:initial-creator"/>
+		<xsl:apply-templates select="dc:creator"/>
+		<xsl:apply-templates select="meta:creation-date"/>
+		<xsl:apply-templates select="dc:date"/>
+		<xsl:apply-templates select="dc:language"/>	
+		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
+		<meta name="DC.Format" scheme="IMT" content="charset=UTF-8" />
+		<meta name="DC.Format" scheme="IMT" content="text/html" />
+		<xsl:comment> Metadata ends </xsl:comment>
+	</xsl:template>
+
+<!-- meta generator -->	
+	<xsl:template match="meta:generator">
+		<meta name="generator" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc title -->
+	<xsl:template match="dc:title">
+		<title><xsl:apply-templates/></title>
+		<meta name="DC.Title" content="{current()}"/>
+	</xsl:template>
+
+<!-- dc description -->
+	<xsl:template match="dc:description">
+		<meta name="Description" content="{current()}"/>
+		<meta name="DC.Description" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc subject -->
+	<xsl:template match="dc:subject">
+	<meta name="DC.Subject" content="{current()}"/>
+	</xsl:template>
+	
+<!-- meta keyword -->
+	<xsl:template match="meta:keyword">
+		<meta name="keywords" content="{current()}"/>
+	</xsl:template>
+
+<!-- meta initial creator -->
+	<xsl:template match="meta:initial-creator">
+		<meta name="author" content="{current()}"/>
+		<meta name="DC.Creator" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc creator -->
+	<xsl:template match="dc:creator">
+		<meta name="DC.Contributor" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc language -->
+	<xsl:template match="dc:language">
+		<meta http-equiv="content-language" content="{current()}"/>
+		<meta name="DC.Language" content="{current()}"/>
+	</xsl:template>
+	
+<!-- dc description -->
+	<xsl:template match="dc:description">
+		<meta name="description" content="{current()}"/>
+		<meta name="DC.Description" content="{current()}"/>
+	</xsl:template>
+	
+<!-- meta creation date -->
+	<xsl:template match="meta:creation-date">
+		<meta name="DC.Date.created" content="{current()}"/>
+		<meta name="DC.Date.dateCopyrighted" content="{current()}"/>
+	</xsl:template>
+
+<!-- dc date -->
+	<xsl:template match="dc:date">
+		<meta name="revised" content="{current()}"/>
+		<meta name="DC.Date.modified" content="{current()}"/>
+	</xsl:template>
+
+	<xsl:param name="param_track_changes"/>
+	<xsl:template match="text:tracked-changes">
+		<xsl:comment> Document has track-changes on </xsl:comment>
+	</xsl:template>
+
+	<xsl:template match="text:change">
+	<xsl:if test="$param_track_changes">
+		<xsl:variable name="id" select="@text:change-id"/>
+		<xsl:variable name="change" select="//text:changed-region[@text:id=$id]"/>
+		<xsl:element name="del">
+			<xsl:attribute name="datetime">
+				<xsl:value-of select="$change//dc:date"/>
+			</xsl:attribute>
+			<!--<xsl:apply-templates match="$change/text:deletion/*"/>-->
+		</xsl:element>
+ 	</xsl:if>
+	</xsl:template>
+
+	<xsl:template match="office:change-info"/>
+	<xsl:param name="param_baseuri"/>
+	<xsl:template match="draw:a">
+		<xsl:choose>
+			<!-- if parent text:h -->
+			<xsl:when test="ancestor::text:h">
+				<xsl:element name="span">
+					<xsl:if test="draw:image/@draw:style-name">
+						<xsl:attribute name="class">
+							<xsl:value-of select="translate(draw:image/@draw:style-name,'.','_')"/>
+						</xsl:attribute>
+					</xsl:if>
+					<xsl:if test="//svg:desc">
+						<xsl:attribute name="style">
+						<!-- This border could be removed, but OOo does default to showing a border. -->
+							<xsl:text>border: 1px solid #888; </xsl:text> 
+							<xsl:if test="draw:image/@svg:width">width: <xsl:value-of select="substring-before(draw:image/@svg:width,'px')"/>px; </xsl:if>
+							<xsl:if test="draw:image/@svg:height">height: <xsl:value-of select="substring-before(draw:image/@svg:height,'px')"/>px; </xsl:if>
+						</xsl:attribute>						
+					</xsl:if>
+					<xsl:choose>
+						<xsl:when test="../draw:a">
+							<xsl:element name="a">
+								<xsl:attribute name="href">
+									<xsl:value-of select="@xlink:href"/>
+								</xsl:attribute>
+								<xsl:attribute name="title">
+									<xsl:value-of select="@office:name"/>
+								</xsl:attribute>
+								<xsl:apply-templates/>
+							</xsl:element>
+						</xsl:when>
+						<xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+					</xsl:choose>
+				</xsl:element>
+			</xsl:when>
+			<!-- if parent is text p -->
+			<xsl:when test="ancestor::text:p">
+				<xsl:element name="div">
+					<xsl:attribute name="class">
+						<xsl:value-of select="translate(draw:image/@draw:style-name,'.','_')"/>
+					</xsl:attribute>
+					<xsl:attribute name="id">
+						<xsl:text>text-box</xsl:text>
+					</xsl:attribute>
+					<xsl:attribute name="style">
+					<!-- This border could be removed, but OOo does default to showing a border. -->
+						<xsl:text>border: 1px solid #888; </xsl:text>
+						<xsl:if test="draw:image/@svg:width">width: <xsl:value-of select="substring-before(draw:image/@svg:width,'px')"/>px; </xsl:if>
+						<xsl:if test="draw:image/@svg:height">height: <xsl:value-of select="substring-before(draw:image/@svg:height,'px')"/>px; </xsl:if>
+					</xsl:attribute>
+					<xsl:choose>
+						<xsl:when test="../draw:a">
+							<xsl:element name="a">
+								<xsl:attribute name="href">
+									<xsl:value-of select="@xlink:href"/>
+								</xsl:attribute>
+								<xsl:attribute name="title">
+									<xsl:value-of select="@office:name"/>
+								</xsl:attribute>
+								<xsl:apply-templates/>
+							</xsl:element>
+						</xsl:when>
+						<xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+					</xsl:choose>
+				</xsl:element>
+			</xsl:when>
+			<xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+
+	<xsl:template match="draw:image">
+		<xsl:element name="img">
+    	<!-- Default behaviour
+    		<xsl:attribute name="style">
+			width: 100%;
+			height: 100%;
+			<xsl:if test="not(../@text:anchor-type='character')">
+        	display: block;
+			</xsl:if>
+			</xsl:attribute>
+		-->
+			<xsl:if test="not(../@text:anchor-type='character')">
+				<xsl:attribute name="style">display: block; </xsl:attribute>
+			</xsl:if>
+			
+			<xsl:attribute name="width">
+				<xsl:value-of select="substring-before(@svg:width,'px')"/>
+			</xsl:attribute>
+			
+			<xsl:attribute name="height">
+				<xsl:value-of select="substring-before(@svg:height,'px')"/>
+			</xsl:attribute>
+		
+			<xsl:attribute name="alt">
+				<xsl:value-of select="@draw:name"/>
+			</xsl:attribute>
+			
+			<xsl:attribute name="src">
+				<xsl:value-of select="concat($param_baseuri,@xlink:href)"/>
+			</xsl:attribute>
+			
+			<xsl:if test="//svg:desc">
+				<xsl:attribute name="longdesc">
+					<xsl:value-of select="//svg:desc"/>
+				</xsl:attribute>
+			</xsl:if>		
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="svg:desc"/>
+	
+	<xsl:template match="text:table-of-content">
+	<!-- We don't parse the app's ToC but generate our own. -->
+	<div class="toc">
+		<xsl:apply-templates select="text:index-body/text:index-title"/>
+		<xsl:apply-templates select="//text:h" mode="toc"/>
+	</div>
+	</xsl:template>
+
+	<xsl:template match="text:h" mode="toc">
+	<xsl:element name="p">
+		<xsl:attribute name="class">
+			<xsl:text>toc_outline_level_</xsl:text>
+			<xsl:choose>
+				<xsl:when test="@text:outline-level">
+					<xsl:value-of select="@text:outline-level"/>
+				</xsl:when>
+				<!-- ODF spec says that when unspecified the outline level should be considered to be 1. -->
+				<xsl:otherwise>1</xsl:otherwise>
+			</xsl:choose>
+		</xsl:attribute>
+		<a href="#{generate-id()}"><xsl:value-of select="."/></a>
+		</xsl:element>
+	</xsl:template>
+
+</xsl:stylesheet>


Property changes on: people/sigurdne/modules/manual/trunk/templates/base/sxw2xhtml.xsl
___________________________________________________________________
Added: svn:keywords
   + Id Revision
Added: svn:eol-style
   + native
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.